110-2-4

DefaultTableXYDataset d1 = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); d1.addSeries(s1); assertEquals("Series 1", d1.getSeries(0).getKey()); boolean pass = false; try { d1.getSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { d1.getSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass);
XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); assertEquals("s1", c.getSeries("s1").getKey()); boolean pass = false; try { c.getSeries("s2"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { c.getSeries(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/DefaultTableXYDatasetTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java
Method name: `void testGetSeries()` |  | Method name: `void testGetSeriesByKey()`
Number of AST nodes: 12 |  | Number of AST nodes: 12

1

    DefaultTableXYDataset d1 = new DefaultTableXYDataset();↵

1

    XYSeriesCollection c = new XYSeriesCollection();↵

2

            XYSeries s1 = new XYSeries("Series 1", true, false);↵

2

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

3

            d1.addSeries(s1);↵

3

            c.addSeries(s1);↵

4

            assertEquals("Series 1", d1.getSeries(0).getKey());↵

4

            assertEquals("s1", c.getSeries("s1").getKey());↵

5

            boolean pass = false;↵

5

            boolean pass = false;↵

6

            try {↵

6

            try {↵

7

                d1.getSeries(-1);↵

7

                c.getSeries("s2");↵

8

            }↵

8

            }↵

9

            catch (IllegalArgumentException e) {↵

9

            catch (UnknownKeyException e) {↵

10

                pass = true;↵

10

                pass = true;↵

11

            }↵

11

            }↵

12

            assertTrue(pass);↵

12

            assertTrue(pass);↵

13

            pass = false;↵

13

            pass = false;↵

14

            try {↵

14

            try {↵

15

                d1.getSeries(1);↵

15

                c.getSeries(null);↵

16

            }↵

16

            }↵

17

            catch (IllegalArgumentException e) {↵

17

            catch (IllegalArgumentException e) {↵

18

                pass = true;↵

18

                pass = true;↵

19

            }↵

19

            }↵

20

            assertTrue(pass);

20

            assertTrue(pass);

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.3
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 33

1. {Non-refactorable}

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

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

   1

       DefaultTableXYDataset d1 = new DefaultTableXYDataset();

   1 | DefaultTableXYDataset d1 = new DefaultTableXYDataset();
   1 | XYSeriesCollection c = new XYSeriesCollection();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1 | c | VARIABLE_NAME_MISMATCH

   1

       XYSeriesCollection c = new XYSeriesCollection();

   2

       XYSeries s1 = new XYSeries("Series 1", true, false);

   2 | XYSeries s1 = new XYSeries("Series 1", true, false);
   2 | XYSeries s1 = new XYSeries("s1");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   new XYSeries("Series 1",true,false) | new XYSeries("s1") | ARGUMENT_NUMBER_MISMATCH

   2

       XYSeries s1 = new XYSeries("s1");

   3

       d1.addSeries(s1);

   3 | d1.addSeries(s1);
   3 | c.addSeries(s1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1 | c | VARIABLE_NAME_MISMATCH

   3

       c.addSeries(s1);

   4

       assertEquals("s1", c.getSeries("s1").getKey());

   4

       assertEquals("Series 1", d1.getSeries(0).getKey());

   5

       boolean pass = false;

   5

       boolean pass = false;

   6

       try

   10

       try

   7

       d1.getSeries(-1);

   11

       c.getSeries(null);

   8

       assertTrue(pass);

   8

       assertTrue(pass);

   9

       pass = false;

   9

       pass = false;

   10

       try

   10 | try
   6 | try

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.IllegalArgumentException | org.jfree.data.UnknownKeyException | SUBCLASS_TYPE_MISMATCH
   java.lang.IllegalArgumentException | org.jfree.data.UnknownKeyException | SUBCLASS_TYPE_MISMATCH

   6

       try

   7

       c.getSeries("s2");

   11

       d1.getSeries(1);

   12

       assertTrue(pass);

   12

       assertTrue(pass);

   Precondition Violations (1)
   Row | Violation
   --- | ---
   1 | Clone fragment #1 returns variable d1 with type org.jfree.data.xy.DefaultTableXYDataset , while Clone fragment #2 returns variable c with type org.jfree.data.xy.XYSeriesCollection