229-40-41

CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = null; try { r2 = (CandlestickRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2));
XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); XIntervalDataItem item2 = null; try { item2 = (XIntervalDataItem) item1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(item1 != item2); assertTrue(item1.getClass() == item2.getClass()); assertTrue(item1.equals(item2));

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

1

    CandlestickRenderer r1 = new CandlestickRenderer();↵

2

            CandlestickRenderer r↵

1

    XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0);↵

3

    2 = null;↵

2

            XIntervalDataItem item2 = null;↵

4

            try {↵

3

            try {↵

5

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

4

                item2 = (XIntervalDataItem) item1.clone();↵

6

            }↵

5

            }↵

7

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

8

                e.printStackTrace();↵

7

                e.printStackTrace();↵

9

            }↵

8

            }↵

10

            assertTrue(r1 != r2);↵

9

            assertTrue(item1 != item2);↵

11

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

10

            assertTrue(item1.getClass() == item2.getClass());↵

12

            assertTrue(r1.equals(r2));

11

            assertTrue(item1.equals(item2));

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
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 | 21

1. {Refactorable}

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

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

   1

       CandlestickRenderer r1 = new CandlestickRenderer();

   1 | CandlestickRenderer r1 = new CandlestickRenderer();
   1 | XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | item1 | VARIABLE_NAME_MISMATCH
   new CandlestickRenderer() | new XIntervalDataItem(1.0,2.0,3.0,4.0) | ARGUMENT_NUMBER_MISMATCH

   1

       XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0);

   2

       CandlestickRenderer r2 = null;

   2 | CandlestickRenderer r2 = null;
   2 | XIntervalDataItem item2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | item2 | VARIABLE_NAME_MISMATCH

   2

       XIntervalDataItem item2 = null;

   3

       try

   3

       try

   4

       r2 = (CandlestickRenderer)r1.clone();

   4 | r2 = (CandlestickRenderer)r1.clone();
   4 | item2 = (XIntervalDataItem)item1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | item2 | VARIABLE_NAME_MISMATCH
   r1 | item1 | VARIABLE_NAME_MISMATCH

   4

       item2 = (XIntervalDataItem)item1.clone();

   5

       assertTrue(r1 != r2);

   5 | assertTrue(r1 != r2);
   5 | assertTrue(item1 != item2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | item1 | VARIABLE_NAME_MISMATCH
   r2 | item2 | VARIABLE_NAME_MISMATCH

   5

       assertTrue(item1 != item2);

   6

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

   6 | assertTrue(r1.getClass() == r2.getClass());
   6 | assertTrue(item1.getClass() == item2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | item1 | VARIABLE_NAME_MISMATCH
   r2 | item2 | VARIABLE_NAME_MISMATCH

   6

       assertTrue(item1.getClass() == item2.getClass());

   7

       assertTrue(r1.equals(r2));

   7 | assertTrue(r1.equals(r2));
   7 | assertTrue(item1.equals(item2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | item2 | VARIABLE_NAME_MISMATCH
   r1 | item1 | VARIABLE_NAME_MISMATCH

   7

       assertTrue(item1.equals(item2));

   Precondition Violations (0)
   Row | Violation
   --- | ---