218-2-14

VectorSeries s1 = new VectorSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0); VectorSeries s2 = null; try { s2 = (VectorSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2));
CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = null; try { plot2 = (CombinedDomainXYPlot) plot1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(plot1 != plot2); assertTrue(plot1.getClass() == plot2.getClass()); assertTrue(plot1.equals(plot2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/VectorSeriesTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CombinedDomainXYPlotTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 8 |  | Number of AST nodes: 7

1

    VectorSeries s1 = new VectorSeries("s1");↵

1

    CombinedDomainXYPlot plot1 = createPlot();↵

2

            s1.add(1.0, 0.5, 1.5, 2.0);↵

2

            ↵

3

            VectorSeries s↵

4

    2 = null;↵

3

            CombinedDomainXYPlot plot2 = null;↵

5

            try {↵

4

            try {↵

6

                s2 = (VectorSeries) s1.clone();↵

5

                plot2 = (CombinedDomainXYPlot) plot1.clone();↵

7

            }↵

6

            }↵

8

            catch (CloneNotSupportedException e) {↵

7

            catch (CloneNotSupportedException e) {↵

9

                e.printStackTrace();↵

8

                e.printStackTrace();↵

10

            }↵

9

            }↵

11

            assertTrue(s1 != s2);↵

10

            assertTrue(plot1 != plot2);↵

12

            assertTrue(s1.getClass() == s2.getClass());↵

11

            assertTrue(plot1.getClass() == plot2.getClass());↵

13

            assertTrue(s1.equals(s2));

12

            assertTrue(plot1.equals(plot2));

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 in different classes having the same super class
Number of node comparisons | 34

1. {Non-refactorable}

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

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

   1

       CombinedDomainXYPlot plot1 = createPlot();

   1

       VectorSeries s1 = new VectorSeries("s1");

   2

       CombinedDomainXYPlot plot2 = null;

   2

       s1.add(1.0, 0.5, 1.5, 2.0);

   2 | s1.add(1.0, 0.5, 1.5, 2.0);
   6 | assertTrue(plot1.getClass() == plot2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   add | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   s1.add(1.0,0.5,1.5,2.0) | assertTrue(plot1.getClass() == plot2.getClass()) | ARGUMENT_NUMBER_MISMATCH
   s1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression s1.add(1.0,0.5,1.5,2.0) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(plot1.getClass() == plot2.getClass()) is a void method call, and thus it cannot be parameterized
   Expression s1.add(1.0,0.5,1.5,2.0) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(plot1.getClass() == plot2.getClass()) is a void method call, and thus it cannot be parameterized

   6

       assertTrue(plot1.getClass() == plot2.getClass());

   3

       VectorSeries s2 = null;

   4

       try

   3

       try

   4 | plot2 = (CombinedDomainXYPlot)plot1.clone();

   Preondition Violations
   Unmatched statement plot2=(CombinedDomainXYPlot)plot1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted

   4

       plot2 = (CombinedDomainXYPlot)plot1.clone();

   5

       s2 = (VectorSeries)s1.clone();

   5 | s2 = (VectorSeries)s1.clone();

   Preondition Violations
   Unmatched statement s2=(VectorSeries)s1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted

   6

       assertTrue(s1 != s2);

   7

       assertTrue(s1.getClass() == s2.getClass());

   7 | assertTrue(s1.getClass() == s2.getClass());
   7 | assertTrue(plot1.equals(plot2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1.getClass() == s2.getClass() | plot1.equals(plot2) | TYPE_COMPATIBLE_REPLACEMENT

   7

       assertTrue(plot1.equals(plot2));

   8

       assertTrue(s1.equals(s2));

   8 | assertTrue(s1.equals(s2));
   5 | assertTrue(plot1 != plot2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1.equals(s2) | plot1 != plot2 | TYPE_COMPATIBLE_REPLACEMENT

   5

       assertTrue(plot1 != plot2);

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Expression s1.add(1.0,0.5,1.5,2.0) is a void method call, and thus it cannot be parameterized
   2 | Expression assertTrue(plot1.getClass() == plot2.getClass()) is a void method call, and thus it cannot be parameterized
   3 | Expression s1.add(1.0,0.5,1.5,2.0) is a void method call, and thus it cannot be parameterized
   4 | Expression assertTrue(plot1.getClass() == plot2.getClass()) is a void method call, and thus it cannot be parameterized
   5 | Unmatched statement plot2=(CombinedDomainXYPlot)plot1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
   6 | Unmatched statement s2=(VectorSeries)s1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted