KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeColumn(0); assertEquals(1, data.getColumnCount()); assertEquals("Obj2", data.getObject(1, 0)); // try negative column index boolean pass = false; try { data.removeColumn(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try column index too high pass = false; try { data.removeColumn(data.getColumnCount()); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass);
KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeColumn("C2"); assertEquals(1, data.getColumnCount()); assertEquals("Obj1", data.getObject(0, 0)); // try unknown column key boolean pass = false; try { data.removeColumn("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); // try null column key pass = false; try { data.removeColumn(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java
Method name: void testRemoveColumnByIndex() Method name: void testRemoveColumnByKey()
Number of AST nodes: 14 Number of AST nodes: 14
1
KeyedObjects2D data = new KeyedObjects2D();
1
KeyedObjects2D data = new KeyedObjects2D();
2
        data.setObject("Obj1", "R1", "C1");
2
        data.setObject("Obj1", "R1", "C1");
3
        data.setObject("Obj2", "R2", "C2");
3
        data.setObject("Obj2", "R2", "C2");
4
        data.removeColumn(0);
4
        data.removeColumn("C2");
5
        assertEquals(1, data.getColumnCount());
5
        assertEquals(1, data.getColumnCount());
6
        assertEquals("Obj2", data.getObject(1, 0));
6
        assertEquals("Obj1", data.getObject(0, 0));
7
        
7
        
8
        // try negative column index
8
        // try unknown column key
9
        boolean pass = false;
9
        boolean pass = false;
10
        try {
10
        try {
11
            data.removeColumn(-1);
11
            data.removeColumn("XXX");
12
        }
12
        }
13
        catch (IndexOutOfBoundsException e) {
13
        catch (UnknownKeyException e) {
14
            pass = true;
14
            pass = true;
15
        }
15
        }
16
        assertTrue(pass);
16
        assertTrue(pass);
17
        
17
        
18
        // try column index too high
18
        // try null column key
19
        pass = false;
19
        pass = false;
20
        try {
20
        try {
21
            data.removeColumn(data.getColumnCount());
21
            data.removeColumn(null);
22
        }
22
        }
23
        catch (IndexOutOfBoundsException e) {
23
        catch (IllegalArgumentException e) {
24
            pass = true;
24
            pass = true;
25
        }
25
        }
26
        assertTrue(pass);
26
        assertTrue(pass);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.6
Clones locationClones are declared in the same class
Number of node comparisons57
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)78.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    KeyedObjects2D data = new KeyedObjects2D();
    1
    KeyedObjects2D data = new KeyedObjects2D();
    2
    data.setObject("Obj1", "R1", "C1");
    2
    data.setObject("Obj1", "R1", "C1");
    3
    data.setObject("Obj2", "R2", "C2");
    3
    data.setObject("Obj2", "R2", "C2");
                                                          
    4
    data.removeColumn("C2");
    Preondition Violations
    Unmatched statement data.removeColumn("C2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    data.removeColumn("C2");
    4
    data.removeColumn(0);
    4
    data.removeColumn(0);
    Preondition Violations
    Unmatched statement data.removeColumn(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    5
    assertEquals(1, data.getColumnCount());
    5
    assertEquals(1, data.getColumnCount());
    6
    assertEquals("Obj2", data.getObject(1, 0));
    6
    assertEquals("Obj2", data.getObject(1, 0));
    6
    assertEquals("Obj1", data.getObject(0, 0));
    Differences
    Expression1Expression2Difference
    "Obj2""Obj1"LITERAL_VALUE_MISMATCH
    10LITERAL_VALUE_MISMATCH
    6
    assertEquals("Obj1", data.getObject(0, 0));
    7
    boolean pass = false;
    7
    boolean pass = false;
    8
    try
    8
    try
    8
    try
    Differences
    Expression1Expression2Difference
    java.lang.IndexOutOfBoundsExceptionorg.jfree.data.UnknownKeyExceptionSUBCLASS_TYPE_MISMATCH
    java.lang.IndexOutOfBoundsExceptionorg.jfree.data.UnknownKeyExceptionSUBCLASS_TYPE_MISMATCH
    8
    try
                                                            
    9
    data.removeColumn("XXX");
    Preondition Violations
    Unmatched statement data.removeColumn("XXX"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement data.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
    9
    data.removeColumn("XXX");
    9
    data.removeColumn(-1);
    9
    data.removeColumn(-1);
    Preondition Violations
    Unmatched statement data.removeColumn(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement data.removeColumn(-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
                                                      
    10
    assertTrue(pass);
    10
    assertTrue(pass);
    11
    pass = false;
    11
    pass = false;
    12
    try
    12
    try
    12
    try
    Differences
    Expression1Expression2Difference
    java.lang.IndexOutOfBoundsExceptionjava.lang.IllegalArgumentExceptionSUBCLASS_TYPE_MISMATCH
    java.lang.IndexOutOfBoundsExceptionjava.lang.IllegalArgumentExceptionSUBCLASS_TYPE_MISMATCH
    12
    try
                                                            
    13
    data.removeColumn(null);
    Preondition Violations
    Unmatched statement data.removeColumn(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement data.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
    13
    data.removeColumn(null);
    13
    data.removeColumn(data.getColumnCount());
    13
    data.removeColumn(data.getColumnCount());
    Preondition Violations
    Unmatched statement data.removeColumn(data.getColumnCount()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement data.removeColumn(data.getColumnCount()); 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 (10)
    Row Violation
    1Unmatched statement data.removeColumn("C2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement data.removeColumn(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement data.removeColumn("XXX"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement data.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
    5Unmatched statement data.removeColumn(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement data.removeColumn(-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
    7Unmatched statement data.removeColumn(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement data.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
    9Unmatched statement data.removeColumn(data.getColumnCount()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement data.removeColumn(data.getColumnCount()); 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