247-2-5

OHLCSeries s1 = new OHLCSeries("s1"); s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); OHLCSeries s2 = null; try { s2 = (OHLCSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2));
CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); CategoryLabelEntity e2 = null; try { e2 = (CategoryLabelEntity) e1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2));

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

1

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

1

    CategoryLabelEntity e1 = new CategoryLabelEntity("A", ↵

2

            s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0);↵

2

                    new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); ↵

3

            OHLCSeries s2 = null;↵

3

            CategoryLabelEntity e2 = null;↵

4

            try {↵

4

            try {↵

5

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

5

                e2 = (CategoryLabelEntity) e1.clone();↵

6

            }↵

6

            }↵

7

            catch (CloneNotSupportedException e) {↵

7

            catch (CloneNotSupportedException e) {↵

8

                e.printStackTrace();↵

8

                e.printStackTrace();↵

9

            }↵

9

            }↵

10

            assertTrue(s1 != s2);↵

10

            assertTrue(e1 != e2);↵

11

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

11

            assertTrue(e1.getClass() == e2.getClass());↵

12

            assertTrue(s1.equals(s2));

12

            assertTrue(e1.equals(e2));

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

1. {Non-refactorable}

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

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

   1

       OHLCSeries s1 = new OHLCSeries("s1");

   1 | OHLCSeries s1 = new OHLCSeries("s1");
   1 | CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | e1 | VARIABLE_NAME_MISMATCH
   new OHLCSeries("s1") | new CategoryLabelEntity("A",new Rectangle2D.Double(1.0,2.0,3.0,4.0),"ToolTip","URL") | ARGUMENT_NUMBER_MISMATCH

   1

       CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL");

   2

       s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0);

   3

       OHLCSeries s2 = null;

   3 | OHLCSeries s2 = null;
   2 | CategoryLabelEntity e2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | e2 | VARIABLE_NAME_MISMATCH

   2

       CategoryLabelEntity e2 = null;

   4

       try

   3

       try

   5

       s2 = (OHLCSeries)s1.clone();

   5 | s2 = (OHLCSeries)s1.clone();
   4 | e2 = (CategoryLabelEntity)e1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | e2 | VARIABLE_NAME_MISMATCH
   s1 | e1 | VARIABLE_NAME_MISMATCH

   4

       e2 = (CategoryLabelEntity)e1.clone();

   6

       assertTrue(s1 != s2);

   6 | assertTrue(s1 != s2);
   5 | assertTrue(e1 != e2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | e1 | VARIABLE_NAME_MISMATCH
   s2 | e2 | VARIABLE_NAME_MISMATCH

   5

       assertTrue(e1 != e2);

   7

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

   7 | assertTrue(s1.getClass() == s2.getClass());
   6 | assertTrue(e1.getClass() == e2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | e1 | VARIABLE_NAME_MISMATCH
   s2 | e2 | VARIABLE_NAME_MISMATCH

   6

       assertTrue(e1.getClass() == e2.getClass());

   8

       assertTrue(s1.equals(s2));

   8 | assertTrue(s1.equals(s2));
   7 | assertTrue(e1.equals(e2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | e2 | VARIABLE_NAME_MISMATCH
   s1 | e1 | VARIABLE_NAME_MISMATCH

   7

       assertTrue(e1.equals(e2));

   Precondition Violations (1)
   Row | Violation
   --- | ---
   1 | Clone fragment #1 returns variables s1 , while Clone fragment #2 returns variables