StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelGenerator(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));
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));
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_LegendLabelGenerator() Method name: void testCloning_LegendLabelToolTipGenerator()
Number of AST nodes: 11 Number of AST nodes: 11
1
StandardPieSectionLabelGenerator generator 
1
StandardPieSectionLabelGenerator generator 
2
                = new StandardPieSectionLabelGenerator();
2
                = new StandardPieSectionLabelGenerator();
3
        PiePlot p1 = new PiePlot();
3
        PiePlot p1 = new PiePlot();
4
        p1.setLegendLabelGenerator(generator);
4
        p1.setLegendLabelToolTipGenerator(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
        // change the generator and make sure it only affects p1
17
        generator.getNumberFormat().setMinimumFractionDigits(2);
17
        generator.getNumberFormat().setMinimumFractionDigits(2);
18
        assertFalse(p1.equals(p2));
18
        assertFalse(p1.equals(p2));
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.1
Clones locationClones are declared in the same class
Number of node comparisons45
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)45.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator();
    1
    StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator();
    2
    PiePlot p1 = new PiePlot();
    2
    PiePlot p1 = new PiePlot();
    3
    p1.setLegendLabelGenerator(generator);
    3
    p1.setLegendLabelGenerator(generator);
    3
    p1.setLegendLabelToolTipGenerator(generator);
    Differences
    Expression1Expression2Difference
    setLegendLabelGeneratorsetLegendLabelToolTipGeneratorMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression p1.setLegendLabelGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p1.setLegendLabelToolTipGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p1.setLegendLabelGenerator(generator) is a void method call, and thus it cannot be parameterized
    Expression p1.setLegendLabelToolTipGenerator(generator) is a void method call, and thus it cannot be parameterized
    3
    p1.setLegendLabelToolTipGenerator(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);
    10
    generator.getNumberFormat().setMinimumFractionDigits(2);
    11
    assertFalse(p1.equals(p2));
    11
    assertFalse(p1.equals(p2));
    Precondition Violations (4)
    Row Violation
    1Expression p1.setLegendLabelGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression p1.setLegendLabelToolTipGenerator(generator) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression p1.setLegendLabelGenerator(generator) is a void method call, and thus it cannot be parameterized
    4Expression p1.setLegendLabelToolTipGenerator(generator) is a void method call, and thus it cannot be parameterized