KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); assertEquals("Object 1", ko1.getObject(0)); assertNull(ko1.getObject(1)); assertEquals("Object 2", ko1.getObject(2)); // request with a negative index boolean pass = false; try { ko1.getObject(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // request width index == itemCount pass = false; try { ko1.getObject(3); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass);
KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); assertEquals("Key 1", ko1.getKey(0)); assertEquals("Key 2", ko1.getKey(1)); assertEquals("Key 3", ko1.getKey(2)); // request with a negative index boolean pass = false; try { ko1.getKey(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // request width index == itemCount pass = false; try { ko1.getKey(3); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjectsTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjectsTests.java
Method name: void testGetObject() Method name: void testGetKey()
Number of AST nodes: 15 Number of AST nodes: 15
1
KeyedObjects ko1 = new KeyedObjects();
1
KeyedObjects ko1 = new KeyedObjects();
2
        ko1.addObject("Key 1", "Object 1");
2
        ko1.addObject("Key 1", "Object 1");
3
        ko1.addObject("Key 2", null);
3
        ko1.addObject("Key 2", null);
4
        ko1.addObject("Key 3", "Object 2");
4
        ko1.addObject("Key 3", "Object 2");
5
        assertEquals("Object 1", ko1.getObject(0));
5
        assertEquals("Key 1", ko1.getKey(0));
6
        assertNull(ko1.getObject(1));
6
        assertEquals("Key 2", ko1.getKey(1));
7
        assertEquals("Object 2", ko1.getObject(2));
7
        assertEquals("Key 3", ko1.getKey(2));
8
        
8
        
9
        // request with a negative index
9
        // request with a negative index
10
        boolean pass = false;
10
        boolean pass = false;
11
        try {
11
        try {
12
            ko1.getObject(-1);
12
            ko1.getKey(-1);
13
        }
13
        }
14
        catch (IndexOutOfBoundsException e) {
14
        catch (IndexOutOfBoundsException e) {
15
            pass = true;
15
            pass = true;
16
        }
16
        }
17
        assertTrue(pass);
17
        assertTrue(pass);
18
        
18
        
19
        // request width index == itemCount
19
        // request width index == itemCount
20
        pass = false;
20
        pass = false;
21
        try {
21
        try {
22
            ko1.getObject(3);
22
            ko1.getKey(3);
23
        }
23
        }
24
        catch (IndexOutOfBoundsException e) {
24
        catch (IndexOutOfBoundsException e) {
25
            pass = true;
25
            pass = true;
26
        }
26
        }
27
        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.3
Clones locationClones are declared in the same class
Number of node comparisons58
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)29.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    KeyedObjects ko1 = new KeyedObjects();
    1
    KeyedObjects ko1 = new KeyedObjects();
    2
    ko1.addObject("Key 1", "Object 1");
    2
    ko1.addObject("Key 1", "Object 1");
    3
    ko1.addObject("Key 2", null);
    3
    ko1.addObject("Key 2", null);
    4
    ko1.addObject("Key 3", "Object 2");
    4
    ko1.addObject("Key 3", "Object 2");
    5
    assertEquals("Object 1", ko1.getObject(0));
    5
    assertEquals("Object 1", ko1.getObject(0));
    5
    assertEquals("Key 1", ko1.getKey(0));
    Differences
    Expression1Expression2Difference
    "Object 1""Key 1"LITERAL_VALUE_MISMATCH
    getObjectgetKeyMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Objectjava.lang.ComparableVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression ko1.getObject(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.getKey(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.Object of variable ko1.getObject(0) does not match with type java.lang.Comparable of variable ko1.getKey(0)
    • Make classes java.lang.Object and java.lang.Comparable extend a common superclass
    5
    assertEquals("Key 1", ko1.getKey(0));
    6
    assertNull(ko1.getObject(1));
    6
    assertNull(ko1.getObject(1));
    6
    assertEquals("Key 2", ko1.getKey(1));
    Differences
    Expression1Expression2Difference
    assertNullassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    assertNull(ko1.getObject(1))assertEquals("Key 2",ko1.getKey(1))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertNull(ko1.getObject(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals("Key 2",ko1.getKey(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNull(ko1.getObject(1)) is a void method call, and thus it cannot be parameterized
    Expression assertEquals("Key 2",ko1.getKey(1)) is a void method call, and thus it cannot be parameterized
    Expression assertNull(ko1.getObject(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals("Key 2",ko1.getKey(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNull(ko1.getObject(1)) is a void method call, and thus it cannot be parameterized
    Expression assertEquals("Key 2",ko1.getKey(1)) is a void method call, and thus it cannot be parameterized
    6
    assertEquals("Key 2", ko1.getKey(1));
    7
    assertEquals("Object 2", ko1.getObject(2));
    7
    assertEquals("Object 2", ko1.getObject(2));
    7
    assertEquals("Key 3", ko1.getKey(2));
    Differences
    Expression1Expression2Difference
    "Object 2""Key 3"LITERAL_VALUE_MISMATCH
    getObjectgetKeyMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Objectjava.lang.ComparableVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression ko1.getObject(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.getKey(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.Object of variable ko1.getObject(2) does not match with type java.lang.Comparable of variable ko1.getKey(2)
    • Make classes java.lang.Object and java.lang.Comparable extend a common superclass
    7
    assertEquals("Key 3", ko1.getKey(2));
    8
    boolean pass = false;
    8
    boolean pass = false;
    9
    try
    9
    try
                                          
    10
    ko1.getKey(-1);
    Preondition Violations
    Unmatched statement ko1.getKey(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement ko1.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
    10
    ko1.getKey(-1);
    10
    ko1.getObject(-1);
    10
    ko1.getObject(-1);
    Preondition Violations
    Unmatched statement ko1.getObject(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement ko1.getObject(-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
                                                
    11
    assertTrue(pass);
    11
    assertTrue(pass);
    12
    pass = false;
    12
    pass = false;
    13
    try
    13
    try
                                        
    14
    ko1.getKey(3);
    Preondition Violations
    Unmatched statement ko1.getKey(3); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement ko1.getKey(3); 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
    ko1.getKey(3);
    14
    ko1.getObject(3);
    14
    ko1.getObject(3);
    Preondition Violations
    Unmatched statement ko1.getObject(3); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement ko1.getObject(3); 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
                                              
    15
    assertTrue(pass);
    15
    assertTrue(pass);
    Precondition Violations (22)
    Row Violation
    1Expression ko1.getObject(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression ko1.getKey(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Type java.lang.Object of variable ko1.getObject(0) does not match with type java.lang.Comparable of variable ko1.getKey(0)
    4Expression assertNull(ko1.getObject(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression assertEquals("Key 2",ko1.getKey(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression assertNull(ko1.getObject(1)) is a void method call, and thus it cannot be parameterized
    7Expression assertEquals("Key 2",ko1.getKey(1)) is a void method call, and thus it cannot be parameterized
    8Expression assertNull(ko1.getObject(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression assertEquals("Key 2",ko1.getKey(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression assertNull(ko1.getObject(1)) is a void method call, and thus it cannot be parameterized
    11Expression assertEquals("Key 2",ko1.getKey(1)) is a void method call, and thus it cannot be parameterized
    12Expression ko1.getObject(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression ko1.getKey(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Type java.lang.Object of variable ko1.getObject(2) does not match with type java.lang.Comparable of variable ko1.getKey(2)
    15Unmatched statement ko1.getKey(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Unmatched statement ko1.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
    17Unmatched statement ko1.getObject(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Unmatched statement ko1.getObject(-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
    19Unmatched statement ko1.getKey(3); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement ko1.getKey(3); 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
    21Unmatched statement ko1.getObject(3); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement ko1.getObject(3); 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