DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("A", new Double(1.0)); data.addValue("B", new Double(2.0)); data.addValue("C", new Double(3.0)); data.addValue("D", null); // check key order assertEquals(data.getKey(0), "A"); assertEquals(data.getKey(1), "B"); assertEquals(data.getKey(2), "C"); assertEquals(data.getKey(3), "D"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(1.0)); assertEquals(data.getValue("B"), new Double(2.0)); assertEquals(data.getValue("C"), new Double(3.0)); assertEquals(data.getValue("D"), null); // check retrieve value by index assertEquals(data.getValue(0), new Double(1.0)); assertEquals(data.getValue(1), new Double(2.0)); assertEquals(data.getValue(2), new Double(3.0)); assertEquals(data.getValue(3), null);
DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("C", new Double(1.0)); data.addValue("B", null); data.addValue("D", new Double(3.0)); data.addValue("A", new Double(2.0)); data.sortByValues(SortOrder.DESCENDING); // check key order assertEquals(data.getKey(0), "D"); assertEquals(data.getKey(1), "A"); assertEquals(data.getKey(2), "C"); assertEquals(data.getKey(3), "B"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(2.0)); assertEquals(data.getValue("B"), null); assertEquals(data.getValue("C"), new Double(1.0)); assertEquals(data.getValue("D"), new Double(3.0)); // check retrieve value by index assertEquals(data.getValue(0), new Double(3.0)); assertEquals(data.getValue(1), new Double(2.0)); assertEquals(data.getValue(2), new Double(1.0)); assertEquals(data.getValue(3), null);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValuesTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValuesTests.java
Method name: void testInsertAndRetrieve() Method name: void testSortByValueDescending()
Number of AST nodes: 17 Number of AST nodes: 18
1
DefaultKeyedValues data = new DefaultKeyedValues();
1
DefaultKeyedValues data = new DefaultKeyedValues();
2
        data.addValue("A", new Double(1.0));
2
        data.addValue("C", new Double(1.0));
3
        data.addValue("B", new Double(2.0));
3
        data.addValue("B", null);
4
        data.addValue("C", new Double(3.0));
4
        data.addValue("D", new Double(3.0));
5
        data.addValue("D", null
5
        data.addValue("A", new Double(2.0));
6
);
6
        data.sortByValues(SortOrder.DESCENDING);
7
        // check key order
7
        // check key order
8
        assertEquals(data.getKey(0), "A");
8
        assertEquals(data.getKey(0), "D");
9
        assertEquals(data.getKey(1), "B");
9
        assertEquals(data.getKey(1), "A");
10
        assertEquals(data.getKey(2), "C");
10
        assertEquals(data.getKey(2), "C");
11
        assertEquals(data.getKey(3), "D");
11
        assertEquals(data.getKey(3), "B");
12
        // check retrieve value by key
12
        // check retrieve value by key
13
        assertEquals(data.getValue("A"), new Double(1.0));
13
        assertEquals(data.getValue("A"), new Double(2.0));
14
        assertEquals(data.getValue("B"), new Double(2.0));
14
        assertEquals(data.getValue("B"), null);
15
        assertEquals(data.getValue("C"), new Double(3.0));
15
        assertEquals(data.getValue("C"), new Double(1.0));
16
        assertEquals(data.getValue("D"), null);
16
        assertEquals(data.getValue("D"), new Double(3.0));
17
        // check retrieve value by index
17
        // check retrieve value by index
18
        assertEquals(data.getValue(0), new Double(1.0));
18
        assertEquals(data.getValue(0), new Double(3.0));
19
        assertEquals(data.getValue(1), new Double(2.0));
19
        assertEquals(data.getValue(1), new Double(2.0));
20
        assertEquals(data.getValue(2), new Double(3.0));
20
        assertEquals(data.getValue(2), new Double(1.0));
21
        assertEquals(data.getValue(3), null);
21
        assertEquals(data.getValue(3), null);
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.0
Clones locationClones are declared in the same class
Number of node comparisons186
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultKeyedValues data = new DefaultKeyedValues();
    1
    DefaultKeyedValues data = new DefaultKeyedValues();
    2
    data.addValue("A", new Double(1.0));
    2
    data.addValue("A", new Double(1.0));
    2
    data.addValue("C", new Double(1.0));
    Differences
    Expression1Expression2Difference
    "A""C"LITERAL_VALUE_MISMATCH
    2
    data.addValue("C", new Double(1.0));
    3
    data.addValue("B", new Double(2.0));
    3
    data.addValue("B", new Double(2.0));
    3
    data.addValue("B", null);
    Differences
    Expression1Expression2Difference
    new Double(2.0)nullTYPE_COMPATIBLE_REPLACEMENT
    3
    data.addValue("B", null);
    4
    data.addValue("C", new Double(3.0));
    4
    data.addValue("C", new Double(3.0));
    4
    data.addValue("D", new Double(3.0));
    Differences
    Expression1Expression2Difference
    "C""D"LITERAL_VALUE_MISMATCH
    4
    data.addValue("D", new Double(3.0));
    5
    data.addValue("D", null);
    5
    data.addValue("D", null);
    5
    data.addValue("A", new Double(2.0));
    Differences
    Expression1Expression2Difference
    "D""A"LITERAL_VALUE_MISMATCH
    nullnew Double(2.0)TYPE_COMPATIBLE_REPLACEMENT
    5
    data.addValue("A", new Double(2.0));
                                                                                          
    6
    data.sortByValues(SortOrder.DESCENDING);
    Preondition Violations
    Unmatched statement data.sortByValues(SortOrder.DESCENDING); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    data.sortByValues(SortOrder.DESCENDING);
    6
    assertEquals(data.getKey(0), "A");
    6
    assertEquals(data.getKey(0), "A");
    7
    assertEquals(data.getKey(0), "D");
    Differences
    Expression1Expression2Difference
    "A""D"LITERAL_VALUE_MISMATCH
    7
    assertEquals(data.getKey(0), "D");
    7
    assertEquals(data.getKey(1), "B");
    7
    assertEquals(data.getKey(1), "B");
    8
    assertEquals(data.getKey(1), "A");
    Differences
    Expression1Expression2Difference
    "B""A"LITERAL_VALUE_MISMATCH
    8
    assertEquals(data.getKey(1), "A");
    8
    assertEquals(data.getKey(2), "C");
    9
    assertEquals(data.getKey(2), "C");
    9
    assertEquals(data.getKey(3), "D");
    9
    assertEquals(data.getKey(3), "D");
    10
    assertEquals(data.getKey(3), "B");
    Differences
    Expression1Expression2Difference
    "D""B"LITERAL_VALUE_MISMATCH
    10
    assertEquals(data.getKey(3), "B");
    10
    assertEquals(data.getValue("A"), new Double(1.0));
    10
    assertEquals(data.getValue("A"), new Double(1.0));
    13
    assertEquals(data.getValue("C"), new Double(1.0));
    Differences
    Expression1Expression2Difference
    "A""C"LITERAL_VALUE_MISMATCH
    13
    assertEquals(data.getValue("C"), new Double(1.0));
    11
    assertEquals(data.getValue("B"), new Double(2.0));
    11
    assertEquals(data.getValue("B"), new Double(2.0));
    11
    assertEquals(data.getValue("A"), new Double(2.0));
    Differences
    Expression1Expression2Difference
    "B""A"LITERAL_VALUE_MISMATCH
    11
    assertEquals(data.getValue("A"), new Double(2.0));
    12
    assertEquals(data.getValue("C"), new Double(3.0));
    12
    assertEquals(data.getValue("C"), new Double(3.0));
    14
    assertEquals(data.getValue("D"), new Double(3.0));
    Differences
    Expression1Expression2Difference
    "C""D"LITERAL_VALUE_MISMATCH
    14
    assertEquals(data.getValue("D"), new Double(3.0));
    13
    assertEquals(data.getValue("D"), null);
    13
    assertEquals(data.getValue("D"), null);
    12
    assertEquals(data.getValue("B"), null);
    Differences
    Expression1Expression2Difference
    "D""B"LITERAL_VALUE_MISMATCH
    12
    assertEquals(data.getValue("B"), null);
    14
    assertEquals(data.getValue(0), new Double(1.0));
    14
    assertEquals(data.getValue(0), new Double(1.0));
    15
    assertEquals(data.getValue(0), new Double(3.0));
    Differences
    Expression1Expression2Difference
    1.03.0LITERAL_VALUE_MISMATCH
    15
    assertEquals(data.getValue(0), new Double(3.0));
    15
    assertEquals(data.getValue(1), new Double(2.0));
    16
    assertEquals(data.getValue(1), new Double(2.0));
    16
    assertEquals(data.getValue(2), new Double(3.0));
    16
    assertEquals(data.getValue(2), new Double(3.0));
    17
    assertEquals(data.getValue(2), new Double(1.0));
    Differences
    Expression1Expression2Difference
    3.01.0LITERAL_VALUE_MISMATCH
    17
    assertEquals(data.getValue(2), new Double(1.0));
    17
    assertEquals(data.getValue(3), null);
    18
    assertEquals(data.getValue(3), null);
    Precondition Violations (1)
    Row Violation
    1Unmatched statement data.sortByValues(SortOrder.DESCENDING); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted