DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R2", "C2"); assertEquals(2, d.getColumnCount()); d.removeColumn("C2"); assertEquals(1, d.getColumnCount()); boolean pass = false; try { d.removeColumn("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.removeColumn(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass);
DefaultPieDataset d = new DefaultPieDataset(); d.setValue("A", 1.0); d.setValue("B", 2.0); assertEquals("A", d.getKey(0)); assertEquals("B", d.getKey(1)); boolean pass = false; try { d.getKey(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); pass = false; try { d.getKey(2); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultPieDatasetTests.java
Method name: void testRemoveColumn() Method name: void testGetKey()
Number of AST nodes: 14 Number of AST nodes: 13
1
DefaultCategoryDataset d = new DefaultCategoryDataset();
1
DefaultPieDataset d = new DefaultPieDataset();
2
        d.addValue(1.0, "R1", "C1");
2
        d.setValue("A", 1.0);
3
        d.addValue(2.0, "R2", "C2");
3
        d.setValue("B", 2.0);
4
        assertEquals(2, d.getColumnCount());
4
        assertEquals("A", d.get
5
        d.removeColumn("C2");
5
Key(0));
6
        assertEquals(1, d.getColumnCount());
6
        assertEquals("B", d.get
7
Key(1));
8
        
7
        boolean pass = false;
9
        boolean pass = false;
8
        try {
10
        try {
9
            d.removeColumn("XXX");
11
            d.getKey(-1);
10
        }
12
        }
11
        catch (UnknownKeyException e) {
13
        catch (IndexOutOfBoundsException e) {
12
            pass = true;
14
            pass = true;
13
        }
15
        }
14
        assertTrue(pass);
16
        assertTrue(pass);
17
        
15
        pass = false;
18
        pass = false;
16
        try {
19
        try {
17
            d.removeColumn(null);
20
            d.getKey(2);
18
        }
21
        }
19
        catch (IllegalArgumentException e) {
22
        catch (IndexOutOfBoundsException e) {
20
            pass = true;
23
            pass = true;
21
        }
24
        }
22
        assertTrue(pass);
25
        assertTrue(pass);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)1.0
Clones locationClones are in different classes having the same super class
Number of node comparisons49
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)48.5
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultCategoryDataset d = new DefaultCategoryDataset();
    1
    DefaultCategoryDataset d = new DefaultCategoryDataset();
    1
    DefaultPieDataset d = new DefaultPieDataset();
    Differences
    Expression1Expression2Difference
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.general.DefaultPieDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.general.DefaultPieDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.general.DefaultPieDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DefaultCategoryDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DefaultPieDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DefaultPieDataset d = new DefaultPieDataset();
    2
    d.addValue(1.0, "R1", "C1");
    2
    d.addValue(1.0, "R1", "C1");
    2
    d.setValue("A", 1.0);
    Differences
    Expression1Expression2Difference
    addValuesetValueMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.general.DefaultPieDatasetSUBCLASS_TYPE_MISMATCH
    d.addValue(1.0,"R1","C1")d.setValue("A",1.0)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression d.addValue(1.0,"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.setValue("A",1.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.addValue(1.0,"R1","C1") is a void method call, and thus it cannot be parameterized
    Expression d.setValue("A",1.0) is a void method call, and thus it cannot be parameterized
    Expression d cannot be unified with expression d , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void addValue(double, Comparable#RAW, Comparable#RAW) , public void setValue(Comparable#RAW, double)
    Expression d.addValue(1.0,"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.setValue("A",1.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.addValue(1.0,"R1","C1") is a void method call, and thus it cannot be parameterized
    Expression d.setValue("A",1.0) is a void method call, and thus it cannot be parameterized
    2
    d.setValue("A", 1.0);
    3
    d.addValue(2.0, "R2", "C2");
    3
    d.addValue(2.0, "R2", "C2");
    3
    d.setValue("B", 2.0);
    Differences
    Expression1Expression2Difference
    addValuesetValueMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.general.DefaultPieDatasetSUBCLASS_TYPE_MISMATCH
    d.addValue(2.0,"R2","C2")d.setValue("B",2.0)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression d.addValue(2.0,"R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.setValue("B",2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.addValue(2.0,"R2","C2") is a void method call, and thus it cannot be parameterized
    Expression d.setValue("B",2.0) is a void method call, and thus it cannot be parameterized
    Expression d cannot be unified with expression d , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void addValue(double, Comparable#RAW, Comparable#RAW) , public void setValue(Comparable#RAW, double)
    Expression d.addValue(2.0,"R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.setValue("B",2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.addValue(2.0,"R2","C2") is a void method call, and thus it cannot be parameterized
    Expression d.setValue("B",2.0) is a void method call, and thus it cannot be parameterized
    3
    d.setValue("B", 2.0);
                                                                      
    4
    assertEquals("A", d.getKey(0));
    Preondition Violations
    Unmatched statement assertEquals("A",d.getKey(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    assertEquals("A", d.getKey(0));
    4
    assertEquals(2, d.getColumnCount());
    4
    assertEquals(2, d.getColumnCount());
    Preondition Violations
    Unmatched statement assertEquals(2,d.getColumnCount()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
                                                                      
    5
    assertEquals("B", d.getKey(1));
    Preondition Violations
    Unmatched statement assertEquals("B",d.getKey(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    assertEquals("B", d.getKey(1));
    5
    d.removeColumn("C2");
    5
    d.removeColumn("C2");
    Preondition Violations
    Unmatched statement d.removeColumn("C2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    6
    assertEquals(1, d.getColumnCount());
    6
    assertEquals(1, d.getColumnCount());
    Preondition Violations
    Unmatched statement assertEquals(1,d.getColumnCount()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    7
    boolean pass = false;
    6
    boolean pass = false;
    8
    try
    8
    try
    7
    try
    Differences
    Expression1Expression2Difference
    org.jfree.data.UnknownKeyExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    org.jfree.data.UnknownKeyExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    7
    try
                                    
    8
    d.getKey(-1);
    Preondition Violations
    Unmatched statement d.getKey(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement d.getKey(-1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    8
    d.getKey(-1);
    9
    d.removeColumn("XXX");
    9
    d.removeColumn("XXX");
    Preondition Violations
    Unmatched statement d.removeColumn("XXX"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement d.removeColumn("XXX"); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                      
    10
    assertTrue(pass);
    9
    assertTrue(pass);
    11
    pass = false;
    10
    pass = false;
    12
    try
    12
    try
    11
    try
    Differences
    Expression1Expression2Difference
    java.lang.IllegalArgumentExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    java.lang.IllegalArgumentExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    11
    try
                                    
    12
    d.getKey(2);
    Preondition Violations
    Unmatched statement d.getKey(2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement d.getKey(2); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    12
    d.getKey(2);
    13
    d.removeColumn(null);
    13
    d.removeColumn(null);
    Preondition Violations
    Unmatched statement d.removeColumn(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement d.removeColumn(null); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                      
    14
    assertTrue(pass);
    13
    assertTrue(pass);
    Precondition Violations (34)
    Row Violation
    1Expression new DefaultCategoryDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new DefaultPieDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression d.addValue(1.0,"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression d.setValue("A",1.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression d.addValue(1.0,"R1","C1") is a void method call, and thus it cannot be parameterized
    6Expression d.setValue("A",1.0) is a void method call, and thus it cannot be parameterized
    7Expression d cannot be unified with expression d , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void addValue(double, Comparable#RAW, Comparable#RAW) , public void setValue(Comparable#RAW, double)
    8Expression d.addValue(1.0,"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression d.setValue("A",1.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression d.addValue(1.0,"R1","C1") is a void method call, and thus it cannot be parameterized
    11Expression d.setValue("A",1.0) is a void method call, and thus it cannot be parameterized
    12Expression d.addValue(2.0,"R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression d.setValue("B",2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression d.addValue(2.0,"R2","C2") is a void method call, and thus it cannot be parameterized
    15Expression d.setValue("B",2.0) is a void method call, and thus it cannot be parameterized
    16Expression d cannot be unified with expression d , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void addValue(double, Comparable#RAW, Comparable#RAW) , public void setValue(Comparable#RAW, double)
    17Expression d.addValue(2.0,"R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression d.setValue("B",2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression d.addValue(2.0,"R2","C2") is a void method call, and thus it cannot be parameterized
    20Expression d.setValue("B",2.0) is a void method call, and thus it cannot be parameterized
    21Unmatched statement assertEquals("A",d.getKey(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement assertEquals(2,d.getColumnCount()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Unmatched statement assertEquals("B",d.getKey(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24Unmatched statement d.removeColumn("C2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25Unmatched statement assertEquals(1,d.getColumnCount()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    26Unmatched statement d.getKey(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    27Unmatched statement d.getKey(-1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    28Unmatched statement d.removeColumn("XXX"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29Unmatched statement d.removeColumn("XXX"); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    30Unmatched statement d.getKey(2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    31Unmatched statement d.getKey(2); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    32Unmatched statement d.removeColumn(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    33Unmatched statement d.removeColumn(null); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    34Clone fragment #1 returns variable d with type org.jfree.data.category.DefaultCategoryDataset , while Clone fragment #2 returns variable d with type org.jfree.data.general.DefaultPieDataset