DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R2", "C2"); assertEquals(2, d.getRowCount()); d.removeRow("R2"); assertEquals(1, d.getRowCount()); boolean pass = false; try { d.removeRow("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.removeRow(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass);
KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeRow(0); assertEquals(1, data.getRowCount()); assertEquals("Obj2", data.getObject(0, 1)); // try negative row index boolean pass = false; try { data.removeRow(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try row index too high pass = false; try { data.removeRow(data.getRowCount()); } 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/junit/KeyedObjects2DTests.java
Method name: void testRemoveRow() Method name: void testRemoveRowByIndex()
Number of AST nodes: 14 Number of AST nodes: 14
1
DefaultCategoryDataset d = new DefaultCategoryDataset();
2
        d.addValue(1.0, "R1", "C1");
3
        d.addValue(2.0, "R2", "C2"
1
KeyedObjects2D data = new KeyedObjects2D();
2
        data.setObject("Obj1", "R1", "C1");
3
        data.setObject("Obj2", "R2", "C2");
4
);
4
        data.removeRow(0);
5
        assertEquals(2, d.getRowCount());
5
        assertEquals(1, data.getRowCount());
6
        d.removeRow("R2");
6
        
7
        assertEquals(1, d.getRowCount());
7
assertEquals("Obj2", data.getObject(0, 1));
8
        
9
        // try negative row index
8
        boolean pass = false;
10
        boolean pass = false;
9
        try {
11
        try {
10
            d.removeRow("XXX");
12
            data.removeRow(-1);
11
        }
13
        }
12
        catch (UnknownKeyException e) {
14
        catch (IndexOutOfBoundsException e) {
13
            pass = true;
15
            pass = true;
14
        }
16
        }
15
        assertTrue(pass);
17
        assertTrue(pass);
18
        
19
        // try row index too high
16
        pass = false;
20
        pass = false;
17
        try {
21
        try {
18
            d.removeRow(null);
22
            data.removeRow(data.getRowCount());
19
        }
23
        }
20
        catch (IllegalArgumentException e) {
24
        catch (IndexOutOfBoundsException e) {
21
            pass = true;
25
            pass = true;
22
        }
26
        }
23
        assertTrue(pass);
27
        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)0.7
Clones locationClones are in different classes having the same super class
Number of node comparisons81
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment7
    Number of unmapped statements in the second code fragment7
    Time elapsed for statement mapping (ms)19.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                            
    1
    KeyedObjects2D data = new KeyedObjects2D();
    Preondition Violations
    Unmatched statement KeyedObjects2D data=new KeyedObjects2D(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    KeyedObjects2D data = new KeyedObjects2D();
    1
    DefaultCategoryDataset d = new DefaultCategoryDataset();
    1
    DefaultCategoryDataset d = new DefaultCategoryDataset();
    Preondition Violations
    Unmatched statement DefaultCategoryDataset d=new DefaultCategoryDataset(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                      
                                                                            
    2
    data.setObject("Obj1", "R1", "C1");
    Preondition Violations
    Unmatched statement data.setObject("Obj1","R1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    data.setObject("Obj1", "R1", "C1");
    2
    d.addValue(1.0, "R1", "C1");
    2
    d.addValue(1.0, "R1", "C1");
    Preondition Violations
    Unmatched statement d.addValue(1.0,"R1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                              
                                                                            
    3
    data.setObject("Obj2", "R2", "C2");
    Preondition Violations
    Unmatched statement data.setObject("Obj2","R2","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    data.setObject("Obj2", "R2", "C2");
    3
    d.addValue(2.0, "R2", "C2");
    3
    d.addValue(2.0, "R2", "C2");
    Preondition Violations
    Unmatched statement d.addValue(2.0,"R2","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                              
                                              
    4
    data.removeRow(0);
    Preondition Violations
    Unmatched statement data.removeRow(0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    data.removeRow(0);
    4
    assertEquals(2, d.getRowCount());
                                                                          
    5
    d.removeRow("R2");
    5
    d.removeRow("R2");
    Preondition Violations
    Unmatched statement d.removeRow("R2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                              
    6
    assertEquals(1, d.getRowCount());
    6
    assertEquals(1, d.getRowCount());
    5
    assertEquals(1, data.getRowCount());
    Differences
    Expression1Expression2Difference
    ddataVARIABLE_NAME_MISMATCH
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.KeyedObjects2DVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.category.DefaultCategoryDataset of variable d does not match with type org.jfree.data.KeyedObjects2D of variable data
    • Make classes org.jfree.data.category.DefaultCategoryDataset and org.jfree.data.KeyedObjects2D extend a common superclass
    5
    assertEquals(1, data.getRowCount());
                                                                                            
    6
    assertEquals("Obj2", data.getObject(0, 1));
    7
    boolean pass = false;
    7
    boolean pass = false;
    8
    try
    8
    try
    8
    try
    Differences
    Expression1Expression2Difference
    org.jfree.data.UnknownKeyExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    org.jfree.data.UnknownKeyExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    8
    try
                                                
    9
    data.removeRow(-1);
    Preondition Violations
    Unmatched statement data.removeRow(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement data.removeRow(-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
    9
    data.removeRow(-1);
    9
    d.removeRow("XXX");
    9
    d.removeRow("XXX");
    Preondition Violations
    Unmatched statement d.removeRow("XXX"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement d.removeRow("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);
    10
    assertTrue(pass);
    11
    pass = false;
    11
    pass = false;
    12
    try
    12
    try
    12
    try
    Differences
    Expression1Expression2Difference
    java.lang.IllegalArgumentExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    java.lang.IllegalArgumentExceptionjava.lang.IndexOutOfBoundsExceptionSUBCLASS_TYPE_MISMATCH
    12
    try
                                                                                  
    13
    data.removeRow(data.getRowCount());
    Preondition Violations
    Unmatched statement data.removeRow(data.getRowCount()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement data.removeRow(data.getRowCount()); 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
    13
    data.removeRow(data.getRowCount());
    13
    d.removeRow(null);
    13
    d.removeRow(null);
    Preondition Violations
    Unmatched statement d.removeRow(null); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement d.removeRow(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);
    14
    assertTrue(pass);
    Precondition Violations (17)
    Row Violation
    1Unmatched statement KeyedObjects2D data=new KeyedObjects2D(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement DefaultCategoryDataset d=new DefaultCategoryDataset(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement data.setObject("Obj1","R1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement d.addValue(1.0,"R1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement data.setObject("Obj2","R2","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement d.addValue(2.0,"R2","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement data.removeRow(0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement d.removeRow("R2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9Type org.jfree.data.category.DefaultCategoryDataset of variable d does not match with type org.jfree.data.KeyedObjects2D of variable data
    10Unmatched statement data.removeRow(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement data.removeRow(-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
    12Unmatched statement d.removeRow("XXX"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement d.removeRow("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
    14Unmatched statement data.removeRow(data.getRowCount()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    15Unmatched statement data.removeRow(data.getRowCount()); 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
    16Unmatched statement d.removeRow(null); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    17Unmatched statement d.removeRow(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