DefaultPieDataset d = new DefaultPieDataset(); d.setValue("A", 1.0); d.setValue("B", 2.0); assertEquals(0, d.getIndex("A")); assertEquals(1, d.getIndex("B")); assertEquals(-1, d.getIndex("XX")); boolean pass = false; try { d.getIndex(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass);
DefaultKeyedValues2D d = new DefaultKeyedValues2D(); boolean pass = false; try { d.getColumnKey(0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); d.addValue(new Double(1.0), "R1", "C1"); d.addValue(new Double(1.0), "R1", "C2"); assertEquals("C1", d.getColumnKey(0)); assertEquals("C2", d.getColumnKey(1));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultPieDatasetTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java
Method name: void testGetIndex() Method name: void testGetColumnKey()
Number of AST nodes: 10 Number of AST nodes: 9
1
DefaultPieDataset d = new DefaultPieDataset();
1
DefaultKeyedValues2D d = new Default
2
        d.setValue("A", 1.0);
3
        d.setValue("B", 2.0);
4
        assertEquals(0, d.getIndex("A"));
5
        assertEquals(1, d.getIndex("B"));
6
        assertEquals(-1, d.getIndex("XX"));
7
        
8
        boolean
2
KeyedValues2D();
3
        boolean pass = false;
4
        try {
5
            d.getColumnKey(0);
6
        }
7
        catch (IndexOutOfBoundsException e) {
9
 pass = false;
8
            pass = true;
10
        try {
9
        }
11
            d.getIndex(null);
10
        
12
        }
13
        catch (IllegalArgumentException e) {
14
    
11
assertTrue(pass);
12
        d.addValue(new Double(1.0), "R1", "C1");
13
        d.addValue(new Double(1.0), "R1", "C2");
15
        pass = true;
14
        ass
16
        }
17
        assertTrue(pass
15
ertEquals("C1", d.getColumnKey(0));
18
);
16
        assertEquals("C2", d.getColumnKey(1));
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)0.2
Clones locationClones are in different classes having the same super class
Number of node comparisons33
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)28.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultPieDataset d = new DefaultPieDataset();
    1
    DefaultPieDataset d = new DefaultPieDataset();
    1
    DefaultKeyedValues2D d = new DefaultKeyedValues2D();
    Differences
    Expression1Expression2Difference
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.DefaultKeyedValues2DSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.DefaultKeyedValues2DSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.DefaultKeyedValues2DSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DefaultPieDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DefaultKeyedValues2D() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DefaultKeyedValues2D d = new DefaultKeyedValues2D();
    2
    d.setValue("A", 1.0);
    2
    d.setValue("A", 1.0);
    6
    d.addValue(new Double(1.0), "R1", "C1");
    Differences
    Expression1Expression2Difference
    setValueaddValueMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.DefaultKeyedValues2DSUBCLASS_TYPE_MISMATCH
    d.setValue("A",1.0)d.addValue(new Double(1.0),"R1","C1")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression d.setValue("A",1.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.addValue(new Double(1.0),"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.setValue("A",1.0) is a void method call, and thus it cannot be parameterized
    Expression d.addValue(new Double(1.0),"R1","C1") is a void method call, and thus it cannot be parameterized
    Expression d cannot be unified with expression d , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    Expression d.setValue("A",1.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.addValue(new Double(1.0),"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.setValue("A",1.0) is a void method call, and thus it cannot be parameterized
    Expression d.addValue(new Double(1.0),"R1","C1") is a void method call, and thus it cannot be parameterized
    6
    d.addValue(new Double(1.0), "R1", "C1");
    3
    d.setValue("B", 2.0);
    3
    d.setValue("B", 2.0);
    7
    d.addValue(new Double(1.0), "R1", "C2");
    Differences
    Expression1Expression2Difference
    setValueaddValueMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.DefaultKeyedValues2DSUBCLASS_TYPE_MISMATCH
    d.setValue("B",2.0)d.addValue(new Double(1.0),"R1","C2")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression d.setValue("B",2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.addValue(new Double(1.0),"R1","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.setValue("B",2.0) is a void method call, and thus it cannot be parameterized
    Expression d.addValue(new Double(1.0),"R1","C2") is a void method call, and thus it cannot be parameterized
    Expression d cannot be unified with expression d , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    Expression d.setValue("B",2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.addValue(new Double(1.0),"R1","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d.setValue("B",2.0) is a void method call, and thus it cannot be parameterized
    Expression d.addValue(new Double(1.0),"R1","C2") is a void method call, and thus it cannot be parameterized
    7
    d.addValue(new Double(1.0), "R1", "C2");
    4
    assertEquals(0, d.getIndex("A"));
    4
    assertEquals(0, d.getIndex("A"));
    Preondition Violations
    Unmatched statement assertEquals(0,d.getIndex("A")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                          
    5
    assertEquals(1, d.getIndex("B"));
    5
    assertEquals(1, d.getIndex("B"));
    Preondition Violations
    Unmatched statement assertEquals(1,d.getIndex("B")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                          
    6
    assertEquals(-1, d.getIndex("XX"));
    6
    assertEquals(-1, d.getIndex("XX"));
    Preondition Violations
    Unmatched statement assertEquals(-1,d.getIndex("XX")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                              
    7
    boolean pass = false;
    2
    boolean pass = false;
    8
    try
    8
    try
    3
    try
    Differences
    Expression1Expression2Difference
    java.lang.IllegalArgumentExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    java.lang.IllegalArgumentExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    3
    try
                                              
    4
    d.getColumnKey(0);
    Preondition Violations
    Unmatched statement d.getColumnKey(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement d.getColumnKey(0); 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
    4
    d.getColumnKey(0);
    9
    d.getIndex(null);
    9
    d.getIndex(null);
    Preondition Violations
    Unmatched statement d.getIndex(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement d.getIndex(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
                                            
    10
    assertTrue(pass);
    5
    assertTrue(pass);
                                                                                    
    8
    assertEquals("C1", d.getColumnKey(0));
    Preondition Violations
    Unmatched statement assertEquals("C1",d.getColumnKey(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    assertEquals("C1", d.getColumnKey(0));
                                                                                    
    9
    assertEquals("C2", d.getColumnKey(1));
    Preondition Violations
    Unmatched statement assertEquals("C2",d.getColumnKey(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    assertEquals("C2", d.getColumnKey(1));
    Precondition Violations (30)
    Row Violation
    1Expression new DefaultPieDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new DefaultKeyedValues2D() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression d.setValue("A",1.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression d.addValue(new Double(1.0),"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression d.setValue("A",1.0) is a void method call, and thus it cannot be parameterized
    6Expression d.addValue(new Double(1.0),"R1","C1") is a void method call, and thus it cannot be parameterized
    7Expression d cannot be unified with expression d , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    8Expression d.setValue("A",1.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression d.addValue(new Double(1.0),"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression d.setValue("A",1.0) is a void method call, and thus it cannot be parameterized
    11Expression d.addValue(new Double(1.0),"R1","C1") is a void method call, and thus it cannot be parameterized
    12Expression d.setValue("B",2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression d.addValue(new Double(1.0),"R1","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression d.setValue("B",2.0) is a void method call, and thus it cannot be parameterized
    15Expression d.addValue(new Double(1.0),"R1","C2") is a void method call, and thus it cannot be parameterized
    16Expression d cannot be unified with expression d , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    17Expression d.setValue("B",2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression d.addValue(new Double(1.0),"R1","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression d.setValue("B",2.0) is a void method call, and thus it cannot be parameterized
    20Expression d.addValue(new Double(1.0),"R1","C2") is a void method call, and thus it cannot be parameterized
    21Unmatched statement assertEquals(0,d.getIndex("A")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement assertEquals(1,d.getIndex("B")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Unmatched statement assertEquals(-1,d.getIndex("XX")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24Unmatched statement d.getColumnKey(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25Unmatched statement d.getColumnKey(0); 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
    26Unmatched statement d.getIndex(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    27Unmatched statement d.getIndex(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
    28Unmatched statement assertEquals("C1",d.getColumnKey(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29Unmatched statement assertEquals("C2",d.getColumnKey(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    30Clone fragment #1 returns variable d with type org.jfree.data.general.DefaultPieDataset , while Clone fragment #2 returns variable d with type org.jfree.data.DefaultKeyedValues2D