1017-1-2

AbstractXYItemRenderer renderer = new StandardXYItemRenderer(); // check the bounds of a simple dataset XYDataset dataset = createDataset1(); Range r = renderer.findDomainBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); // check that a null dataset returns null bounds assertTrue(renderer.findDomainBounds(null) == null);
CategoryDataset d = createCategoryDataset1(); KeyToGroupMap map = new KeyToGroupMap("G0"); map.mapKeyToGroup("R2", "G1"); Range r = DatasetUtilities.findStackedRangeBounds(d, map); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(9.0, r.getUpperBound(), EPSILON);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/AbstractXYItemRendererTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java
Method name: `void testFindDomainBounds()` |  | Method name: `void testStackedRangeWithMap()`
Number of AST nodes: 6 |  | Number of AST nodes: 6

1

    AbstractXYItemRenderer renderer = new StandardXYItemRenderer();↵

2

            ↵

3

            // check the bounds of a simple dataset↵

4

            XYDataset dataset = createDataset1();↵

5

            Range r = renderer.findDomain↵

1

    CategoryDataset d = createCategoryDataset1();↵

2

            KeyToGroupMap map = new KeyToGroupMap("G0");↵

3

            map.mapKeyToGroup("R2", "G1");↵

6

    Bounds(dataset);↵

4

            Range r = DatasetUtilities.findStackedRangeBounds(d, map);↵

7

            assertEquals(1.0, r.getLowerBound(), EPSILON);↵

5

            assertEquals(0.0, r.getLowerBound(), EPSILON);↵

8

            assertEquals(3.0, r.getUpperBound(), EPSILON);↵

6

            assertEquals(9.0, r.getUpperBound(), EPSILON);

9

            ↵

10

            // check that a null dataset returns null bounds↵

11

            assertTrue(renderer.findDomainBounds(null) == 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 in different classes having the same super class
Number of node comparisons | 36

1. {Non-refactorable}

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

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

   1

       CategoryDataset d = createCategoryDataset1();

   1

       AbstractXYItemRenderer renderer = new StandardXYItemRenderer();

   2

       KeyToGroupMap map = new KeyToGroupMap("G0");

   2

       XYDataset dataset = createDataset1();

   3

       Range r = renderer.findDomainBounds(dataset);

   4 | Range r = DatasetUtilities.findStackedRangeBounds(d, map);

   Preondition Violations
   Unmatched statement Range r=DatasetUtilities.findStackedRangeBounds(d,map); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   4

       Range r = DatasetUtilities.findStackedRangeBounds(d, map);

   4

       assertEquals(1.0, r.getLowerBound(), EPSILON);

   4 | assertEquals(1.0, r.getLowerBound(), EPSILON);
   5 | assertEquals(0.0, r.getLowerBound(), EPSILON);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   1.0 | 0.0 | LITERAL_VALUE_MISMATCH

   5

       assertEquals(0.0, r.getLowerBound(), EPSILON);

   5

       assertEquals(3.0, r.getUpperBound(), EPSILON);

   5 | assertEquals(3.0, r.getUpperBound(), EPSILON);
   6 | assertEquals(9.0, r.getUpperBound(), EPSILON);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   3.0 | 9.0 | LITERAL_VALUE_MISMATCH

   6

       assertEquals(9.0, r.getUpperBound(), EPSILON);

   6

       assertTrue(renderer.findDomainBounds(null) == null);

   6 | assertTrue(renderer.findDomainBounds(null) == null);
   3 | map.mapKeyToGroup("R2", "G1");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | mapKeyToGroup | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(renderer.findDomainBounds(null) == null) | map.mapKeyToGroup("R2","G1") | ARGUMENT_NUMBER_MISMATCH
   | map | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertTrue(renderer.findDomainBounds(null) == null) is a void method call, and thus it cannot be parameterized
   Expression map.mapKeyToGroup("R2","G1") is a void method call, and thus it cannot be parameterized
   Expression assertTrue(renderer.findDomainBounds(null) == null) is a void method call, and thus it cannot be parameterized
   Expression map.mapKeyToGroup("R2","G1") is a void method call, and thus it cannot be parameterized

   3

       map.mapKeyToGroup("R2", "G1");

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | Unmatched statement Range r=DatasetUtilities.findStackedRangeBounds(d,map); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Expression assertTrue(renderer.findDomainBounds(null) == null) is a void method call, and thus it cannot be parameterized
   3 | Expression map.mapKeyToGroup("R2","G1") is a void method call, and thus it cannot be parameterized
   4 | Expression assertTrue(renderer.findDomainBounds(null) == null) is a void method call, and thus it cannot be parameterized
   5 | Expression map.mapKeyToGroup("R2","G1") is a void method call, and thus it cannot be parameterized