320-3-4

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.sortByKeys(SortOrder.DESCENDING); // check key order assertEquals(data.getKey(0), "D"); assertEquals(data.getKey(1), "C"); assertEquals(data.getKey(2), "B"); assertEquals(data.getKey(3), "A"); // 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(1.0)); assertEquals(data.getValue(2), null); assertEquals(data.getValue(3), new Double(2.0));
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.ASCENDING); // check key order assertEquals(data.getKey(0), "C"); assertEquals(data.getKey(1), "A"); assertEquals(data.getKey(2), "D"); 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(1.0)); assertEquals(data.getValue(1), new Double(2.0)); assertEquals(data.getValue(2), new Double(3.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 testSortByKeyDescending()` |  | Method name: `void testSortByValueAscending()`
Number of AST nodes: 18 |  | Number of AST nodes: 18

1

    DefaultKeyedValues data = new DefaultKeyedValues();↵

1

    DefaultKeyedValues data = new DefaultKeyedValues();↵

2

            data.addValue("C", new Double(1.0));↵

2

            data.addValue("C", new Double(1.0));↵

3

            data.addValue("B", null);↵

3

            data.addValue("B", null);↵

4

            data.addValue("D", new Double(3.0));↵

4

            data.addValue("D", new Double(3.0));↵

5

            data.addValue("A", new Double(2.0));↵

5

            data.addValue("A", new Double(2.0));↵

6

            data.sortByKeys(SortOrder.DESCENDING);↵

6

            data.sortByValues(SortOrder.ASCENDING);↵

7

            // check key order↵

7

            // check key order↵

8

            assertEquals(data.getKey(0), "D");↵

8

            assertEquals(data.getKey(0), "C");↵

9

            assertEquals(data.getKey(1), "C");↵

9

            assertEquals(data.getKey(1), "A");↵

10

            assertEquals(data.getKey(2), "B");↵

10

            assertEquals(data.getKey(2), "D");↵

11

            assertEquals(data.getKey(3), "A");↵

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(2.0));↵

13

            assertEquals(data.getValue("A"), new Double(2.0));↵

14

            assertEquals(data.getValue("B"), null);↵

14

            assertEquals(data.getValue("B"), null);↵

15

            assertEquals(data.getValue("C"), new Double(1.0));↵

15

            assertEquals(data.getValue("C"), new Double(1.0));↵

16

            assertEquals(data.getValue("D"), new Double(3.0));↵

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(3.0));↵

18

            assertEquals(data.getValue(0), new Double(1.0));↵

19

            assertEquals(data.getValue(1), new Double(1.0));↵

19

            assertEquals(data.getValue(1), new Double(2.0));↵

20

            assertEquals(data.getValue(2), null);↵

20

            assertEquals(data.getValue(2), new Double(3.0));↵

21

            assertEquals(data.getValue(3), new Double(2.0));

21

            assertEquals(data.getValue(3), null);

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0
Clones location | Clones are declared in the same class
Number of node comparisons | 180

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 18
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 0.0
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       DefaultKeyedValues data = new DefaultKeyedValues();

   1

       DefaultKeyedValues data = new DefaultKeyedValues();

   2

       data.addValue("C", new Double(1.0));

   2

       data.addValue("C", new Double(1.0));

   3

       data.addValue("B", null);

   3

       data.addValue("B", null);

   4

       data.addValue("D", new Double(3.0));

   4

       data.addValue("D", new Double(3.0));

   5

       data.addValue("A", new Double(2.0));

   5

       data.addValue("A", new Double(2.0));

   6

       data.sortByKeys(SortOrder.DESCENDING);

   6 | data.sortByKeys(SortOrder.DESCENDING);
   6 | data.sortByValues(SortOrder.ASCENDING);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   sortByKeys | sortByValues | METHOD_INVOCATION_NAME_MISMATCH
   DESCENDING | ASCENDING | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression data.sortByKeys(SortOrder.DESCENDING) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.sortByValues(SortOrder.ASCENDING) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.sortByKeys(SortOrder.DESCENDING) is a void method call, and thus it cannot be parameterized
   Expression data.sortByValues(SortOrder.ASCENDING) is a void method call, and thus it cannot be parameterized

   6

       data.sortByValues(SortOrder.ASCENDING);

   7

       assertEquals(data.getKey(0), "D");

   7 | assertEquals(data.getKey(0), "D");
   15 | assertEquals(data.getValue(0), new Double(1.0));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getKey | getValue | METHOD_INVOCATION_NAME_MISMATCH
   java.lang.Comparable | java.lang.Number | VARIABLE_TYPE_MISMATCH

   Preondition Violations
   Expression data.getKey(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getValue(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   Type java.lang.Comparable of variable data.getKey(0) does not match with type java.lang.Number of variable data.getValue(0)
   - Make classes java.lang.Comparable and java.lang.Number extend a common superclass

   15

       assertEquals(data.getValue(0), new Double(1.0));

   8

       assertEquals(data.getKey(1), "C");

   8 | assertEquals(data.getKey(1), "C");
   16 | assertEquals(data.getValue(1), new Double(2.0));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getKey | getValue | METHOD_INVOCATION_NAME_MISMATCH
   java.lang.Comparable | java.lang.Number | VARIABLE_TYPE_MISMATCH

   Preondition Violations
   Expression data.getKey(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getValue(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   Type java.lang.Comparable of variable data.getKey(1) does not match with type java.lang.Number of variable data.getValue(1)
   - Make classes java.lang.Comparable and java.lang.Number extend a common superclass

   16

       assertEquals(data.getValue(1), new Double(2.0));

   9

       assertEquals(data.getKey(2), "B");

   9 | assertEquals(data.getKey(2), "B");
   17 | assertEquals(data.getValue(2), new Double(3.0));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getKey | getValue | METHOD_INVOCATION_NAME_MISMATCH
   java.lang.Comparable | java.lang.Number | VARIABLE_TYPE_MISMATCH

   Preondition Violations
   Expression data.getKey(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getValue(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   Type java.lang.Comparable of variable data.getKey(2) does not match with type java.lang.Number of variable data.getValue(2)
   - Make classes java.lang.Comparable and java.lang.Number extend a common superclass

   17

       assertEquals(data.getValue(2), new Double(3.0));

   10

       assertEquals(data.getKey(3), "A");

   10 | assertEquals(data.getKey(3), "A");
   18 | assertEquals(data.getValue(3), null);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getKey | getValue | METHOD_INVOCATION_NAME_MISMATCH
   java.lang.Comparable | java.lang.Number | VARIABLE_TYPE_MISMATCH

   Preondition Violations
   Expression data.getKey(3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getValue(3) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   Type java.lang.Comparable of variable data.getKey(3) does not match with type java.lang.Number of variable data.getValue(3)
   - Make classes java.lang.Comparable and java.lang.Number extend a common superclass

   18

       assertEquals(data.getValue(3), null);

   11

       assertEquals(data.getValue("A"), new Double(2.0));

   11

       assertEquals(data.getValue("A"), new Double(2.0));

   12

       assertEquals(data.getValue("B"), null);

   12

       assertEquals(data.getValue("B"), null);

   13

       assertEquals(data.getValue("C"), new Double(1.0));

   13

       assertEquals(data.getValue("C"), new Double(1.0));

   14

       assertEquals(data.getValue("D"), new Double(3.0));

   14

       assertEquals(data.getValue("D"), new Double(3.0));

   15

       assertEquals(data.getValue(0), new Double(3.0));

   15 | assertEquals(data.getValue(0), new Double(3.0));
   7 | assertEquals(data.getKey(0), "C");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getValue | getKey | METHOD_INVOCATION_NAME_MISMATCH
   java.lang.Number | java.lang.Comparable | VARIABLE_TYPE_MISMATCH

   Preondition Violations
   Expression data.getValue(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getKey(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   Type java.lang.Number of variable data.getValue(0) does not match with type java.lang.Comparable of variable data.getKey(0)
   - Make classes java.lang.Number and java.lang.Comparable extend a common superclass

   7

       assertEquals(data.getKey(0), "C");

   16

       assertEquals(data.getValue(1), new Double(1.0));

   16 | assertEquals(data.getValue(1), new Double(1.0));
   8 | assertEquals(data.getKey(1), "A");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getValue | getKey | METHOD_INVOCATION_NAME_MISMATCH
   java.lang.Number | java.lang.Comparable | VARIABLE_TYPE_MISMATCH

   Preondition Violations
   Expression data.getValue(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getKey(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   Type java.lang.Number of variable data.getValue(1) does not match with type java.lang.Comparable of variable data.getKey(1)
   - Make classes java.lang.Number and java.lang.Comparable extend a common superclass

   8

       assertEquals(data.getKey(1), "A");

   17

       assertEquals(data.getValue(2), null);

   17 | assertEquals(data.getValue(2), null);
   9 | assertEquals(data.getKey(2), "D");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getValue | getKey | METHOD_INVOCATION_NAME_MISMATCH
   java.lang.Number | java.lang.Comparable | VARIABLE_TYPE_MISMATCH

   Preondition Violations
   Expression data.getValue(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getKey(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   Type java.lang.Number of variable data.getValue(2) does not match with type java.lang.Comparable of variable data.getKey(2)
   - Make classes java.lang.Number and java.lang.Comparable extend a common superclass

   9

       assertEquals(data.getKey(2), "D");

   18

       assertEquals(data.getValue(3), new Double(2.0));

   18 | assertEquals(data.getValue(3), new Double(2.0));
   10 | assertEquals(data.getKey(3), "B");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getValue | getKey | METHOD_INVOCATION_NAME_MISMATCH
   java.lang.Number | java.lang.Comparable | VARIABLE_TYPE_MISMATCH

   Preondition Violations
   Expression data.getValue(3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getKey(3) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   Type java.lang.Number of variable data.getValue(3) does not match with type java.lang.Comparable of variable data.getKey(3)
   - Make classes java.lang.Number and java.lang.Comparable extend a common superclass

   10

       assertEquals(data.getKey(3), "B");

   Precondition Violations (28)
   Row | Violation
   --- | ---
   1 | Expression data.sortByKeys(SortOrder.DESCENDING) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression data.sortByValues(SortOrder.ASCENDING) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression data.sortByKeys(SortOrder.DESCENDING) is a void method call, and thus it cannot be parameterized
   4 | Expression data.sortByValues(SortOrder.ASCENDING) is a void method call, and thus it cannot be parameterized
   5 | Expression data.getKey(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression data.getValue(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Type java.lang.Comparable of variable data.getKey(0) does not match with type java.lang.Number of variable data.getValue(0)
   8 | Expression data.getKey(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   9 | Expression data.getValue(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Type java.lang.Comparable of variable data.getKey(1) does not match with type java.lang.Number of variable data.getValue(1)
   11 | Expression data.getKey(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   12 | Expression data.getValue(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   13 | Type java.lang.Comparable of variable data.getKey(2) does not match with type java.lang.Number of variable data.getValue(2)
   14 | Expression data.getKey(3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   15 | Expression data.getValue(3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   16 | Type java.lang.Comparable of variable data.getKey(3) does not match with type java.lang.Number of variable data.getValue(3)
   17 | Expression data.getValue(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   18 | Expression data.getKey(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   19 | Type java.lang.Number of variable data.getValue(0) does not match with type java.lang.Comparable of variable data.getKey(0)
   20 | Expression data.getValue(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   21 | Expression data.getKey(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   22 | Type java.lang.Number of variable data.getValue(1) does not match with type java.lang.Comparable of variable data.getKey(1)
   23 | Expression data.getValue(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   24 | Expression data.getKey(2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   25 | Type java.lang.Number of variable data.getValue(2) does not match with type java.lang.Comparable of variable data.getKey(2)
   26 | Expression data.getValue(3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   27 | Expression data.getKey(3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   28 | Type java.lang.Number of variable data.getValue(3) does not match with type java.lang.Comparable of variable data.getKey(3)