183-1-8

StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelToolTipGenerator(generator); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // change the generator and make sure it only affects p1 generator.getNumberFormat().setMinimumFractionDigits(2); assertFalse(p1.equals(p2));
CustomPieURLGenerator generator = new CustomPieURLGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelURLGenerator(generator); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check that the URL generator has been cloned assertTrue(p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator());

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/PiePlotTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/PiePlotTests.java
Method name: `void testCloning_LegendLabelToolTipGenerator()` |  | Method name: `void testCloning_LegendLabelURLGenerator()`
Number of AST nodes: 11 |  | Number of AST nodes: 10

1

    StandardPieSectionLabelGenerator generator ↵

1

    CustomPieURLGenerator generator ↵

2

                    = new StandardPieSectionLabelGenerator();↵

2

    = new CustomPieURLGenerator();↵

3

            PiePlot p1 = new PiePlot();↵

3

            PiePlot p1 = new PiePlot();↵

4

            p1.setLegendLabelToolTipGenerator(generator);↵

4

            p1.setLegendLabelURLGenerator(generator);↵

5

            PiePlot p2 = null;↵

5

            PiePlot p2 = null;↵

6

            try {↵

6

            try {↵

7

                p2 = (PiePlot) p1.clone();↵

7

                p2 = (PiePlot) p1.clone();↵

8

            }↵

8

            }↵

9

            catch (CloneNotSupportedException e) {↵

9

            catch (CloneNotSupportedException e) {↵

10

                e.printStackTrace();↵

10

                e.printStackTrace();↵

11

            }↵

11

            }↵

12

            assertTrue(p1 != p2);↵

12

            assertTrue(p1 != p2);↵

13

            assertTrue(p1.getClass() == p2.getClass());↵

13

            assertTrue(p1.getClass() == p2.getClass());↵

14

            assertTrue(p1.equals(p2));↵

14

            assertTrue(p1.equals(p2));↵

15

            ↵

15

            ↵

16

            // change the generator and make sure it only affects p1↵

16

            // check that the URL generator has been cloned↵

17

            generator.getNumberFormat().setMinimumFractionDigits(2);↵

17

            ↵

18

            assertFalse(p1.equals(p2↵

18

    assertTrue(p1.getLegendLabelURLGenerator() ↵

19

    ));

19

                    != p2.getLegendLabelURLGenerator());

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 | 52

1. {Non-refactorable}

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

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

   1

       CustomPieURLGenerator generator = new CustomPieURLGenerator();

   1

       StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator();

   2

       PiePlot p1 = new PiePlot();

   2

       PiePlot p1 = new PiePlot();

   3

       p1.setLegendLabelToolTipGenerator(generator);

   3 | p1.setLegendLabelToolTipGenerator(generator);
   3 | p1.setLegendLabelURLGenerator(generator);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setLegendLabelToolTipGenerator | setLegendLabelURLGenerator | METHOD_INVOCATION_NAME_MISMATCH
   org.jfree.chart.labels.StandardPieSectionLabelGenerator | org.jfree.chart.urls.CustomPieURLGenerator | VARIABLE_TYPE_MISMATCH

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

   Type org.jfree.chart.labels.StandardPieSectionLabelGenerator of variable generator does not match with type org.jfree.chart.urls.CustomPieURLGenerator of variable generator
   - Make classes org.jfree.chart.labels.StandardPieSectionLabelGenerator and org.jfree.chart.urls.CustomPieURLGenerator extend a common superclass

   3

       p1.setLegendLabelURLGenerator(generator);

   4

       PiePlot p2 = null;

   4

       PiePlot p2 = null;

   5

       try

   5

       try

   6

       p2 = (PiePlot)p1.clone();

   6

       p2 = (PiePlot)p1.clone();

   7

       assertTrue(p1 != p2);

   7

       assertTrue(p1 != p2);

   8

       assertTrue(p1.getClass() == p2.getClass());

   8

       assertTrue(p1.getClass() == p2.getClass());

   9

       assertTrue(p1.equals(p2));

   9

       assertTrue(p1.equals(p2));

   10

       generator.getNumberFormat().setMinimumFractionDigits(2);

   11

       assertFalse(p1.equals(p2));

   11 | assertFalse(p1.equals(p2));
   10 | assertTrue(p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertFalse | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   p1.equals(p2) | p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator() | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression assertFalse(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertFalse(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator()) is a void method call, and thus it cannot be parameterized
   Expression p1.equals(p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   10

       assertTrue(p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator());

   Precondition Violations (11)
   Row | Violation
   --- | ---
   1 | Expression p1.setLegendLabelToolTipGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression p1.setLegendLabelURLGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression p1.setLegendLabelToolTipGenerator(generator) is a void method call, and thus it cannot be parameterized
   4 | Expression p1.setLegendLabelURLGenerator(generator) is a void method call, and thus it cannot be parameterized
   5 | Type org.jfree.chart.labels.StandardPieSectionLabelGenerator of variable generator does not match with type org.jfree.chart.urls.CustomPieURLGenerator of variable generator
   6 | Expression assertFalse(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression assertTrue(p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   8 | Expression assertFalse(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   9 | Expression assertTrue(p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator()) is a void method call, and thus it cannot be parameterized
   10 | Expression p1.equals(p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   11 | Expression p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted