183-4-6

StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}"); BarRenderer r1 = new BarRenderer(); r1.setLegendItemURLGenerator(generator); BarRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemURLGenerator() != r2.getLegendItemURLGenerator());
StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}"); BarRenderer r1 = new BarRenderer(); r1.setLegendItemLabelGenerator(generator); BarRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator());

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/AbstractCategoryItemRendererTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/AbstractCategoryItemRendererTests.java
Method name: `void testCloning_LegendItemURLGenerator()` |  | Method name: `void testCloning_LegendItemLabelGenerator()`
Number of AST nodes: 10 |  | Number of AST nodes: 10

1

    StandardCategorySeriesLabelGenerator generator ↵

1

    StandardCategorySeriesLabelGenerator generator ↵

2

                    = new StandardCategorySeriesLabelGenerator("Series {0}");↵

2

                    = new StandardCategorySeriesLabelGenerator("Series {0}");↵

3

            BarRenderer r1 = new BarRenderer();↵

3

            BarRenderer r1 = new BarRenderer();↵

4

            r1.setLegendItemURLGenerator(generator);↵

4

            r1.setLegendItemLabelGenerator(generator);↵

5

            BarRenderer r2 = null;↵

5

            BarRenderer r2 = null;↵

6

            try {↵

6

            try {↵

7

                r2 = (BarRenderer) r1.clone();↵

7

                r2 = (BarRenderer) r1.clone();↵

8

            }↵

8

            }↵

9

            catch (CloneNotSupportedException e) {↵

9

            catch (CloneNotSupportedException e) {↵

10

                e.printStackTrace();↵

10

                e.printStackTrace();↵

11

            }↵

11

            }↵

12

            assertTrue(r1 != r2);↵

12

            assertTrue(r1 != r2);↵

13

            assertTrue(r1.getClass() == r2.getClass());↵

13

            assertTrue(r1.getClass() == r2.getClass());↵

14

            assertTrue(r1.equals(r2));↵

14

            assertTrue(r1.equals(r2));↵

15

            ↵

15

            ↵

16

            // check that the generator has been cloned↵

16

            // check that the generator has been cloned↵

17

            assertTrue(r1.getLegendItemURLGenerator() ↵

17

            assertTrue(r1.getLegendItemLabelGenerator() ↵

18

                    != r2.getLegendItemURLGenerator());

18

                    != r2.getLegendItemLabelGenerator());

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.1
Clones location | Clones are declared in the same class
Number of node comparisons | 36

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 10
   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) | 2.3
   Clone type | Type 2

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

   1

       StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}");

   1

       StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}");

   2

       BarRenderer r1 = new BarRenderer();

   2

       BarRenderer r1 = new BarRenderer();

   3

       r1.setLegendItemURLGenerator(generator);

   3 | r1.setLegendItemURLGenerator(generator);
   3 | r1.setLegendItemLabelGenerator(generator);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setLegendItemURLGenerator | setLegendItemLabelGenerator | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression r1.setLegendItemURLGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression r1.setLegendItemLabelGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression r1.setLegendItemURLGenerator(generator) is a void method call, and thus it cannot be parameterized
   Expression r1.setLegendItemLabelGenerator(generator) is a void method call, and thus it cannot be parameterized

   3

       r1.setLegendItemLabelGenerator(generator);

   4

       BarRenderer r2 = null;

   4

       BarRenderer r2 = null;

   5

       try

   5

       try

   6

       r2 = (BarRenderer)r1.clone();

   6

       r2 = (BarRenderer)r1.clone();

   7

       assertTrue(r1 != r2);

   7

       assertTrue(r1 != r2);

   8

       assertTrue(r1.getClass() == r2.getClass());

   8

       assertTrue(r1.getClass() == r2.getClass());

   9

       assertTrue(r1.equals(r2));

   9

       assertTrue(r1.equals(r2));

   10

       assertTrue(r1.getLegendItemURLGenerator() != r2.getLegendItemURLGenerator());

   10 | assertTrue(r1.getLegendItemURLGenerator() != r2.getLegendItemURLGenerator());
   10 | assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getLegendItemURLGenerator | getLegendItemLabelGenerator | METHOD_INVOCATION_NAME_MISMATCH
   getLegendItemURLGenerator | getLegendItemLabelGenerator | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression r1.getLegendItemURLGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression r1.getLegendItemLabelGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression r2.getLegendItemURLGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression r2.getLegendItemLabelGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   10

       assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator());

   Precondition Violations (8)
   Row | Violation
   --- | ---
   1 | Expression r1.setLegendItemURLGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression r1.setLegendItemLabelGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression r1.setLegendItemURLGenerator(generator) is a void method call, and thus it cannot be parameterized
   4 | Expression r1.setLegendItemLabelGenerator(generator) is a void method call, and thus it cannot be parameterized
   5 | Expression r1.getLegendItemURLGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression r1.getLegendItemLabelGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression r2.getLegendItemURLGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   8 | Expression r2.getLegendItemLabelGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted