312-2-6

DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R2", "C2"); assertEquals(2, d.getRowCount()); d.removeRow("R2"); assertEquals(1, d.getRowCount()); boolean pass = false; try { d.removeRow("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.removeRow(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass);
KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeRow("R2"); assertEquals(1, data.getRowCount()); assertEquals("Obj1", data.getObject(0, 0)); // try unknown row key boolean pass = false; try { data.removeRow("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); // try null row key pass = false; try { data.removeRow(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/category/junit/DefaultCategoryDatasetTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java
Method name: `void testRemoveRow()` |  | Method name: `void testRemoveRowByKey()`
Number of AST nodes: 14 |  | Number of AST nodes: 14

1

    DefaultCategoryDataset d = new DefaultCategoryDataset();↵

2

            d.addValue(1.0↵

1

    KeyedObjects2D data = new KeyedObjects2D();↵

3

    , "R1", "C1");↵

2

            data.setObject("Obj1", "R1", "C1");↵

4

            d.addValue(2.0, "R2", "C2");↵

3

            data.setObject("Obj2", "R2", "C2");↵

4

            data.removeRow("R2");↵

5

            assertEquals(2, d.getRowCount());↵

5

            assertEquals(1, data.getRowCount());↵

6

            d.removeRow("R2");↵

6

            ↵

7

            assertEquals(1, d.getRowCount());↵

7

    assertEquals("Obj1", data.getObject(0, 0));↵

8

            ↵

9

            // try unknown row key↵

8

            boolean pass = false;↵

10

            boolean pass = false;↵

9

            try {↵

11

            try {↵

10

                d.removeRow("XXX");↵

12

                data.removeRow("XXX");↵

11

            }↵

13

            }↵

12

            catch (UnknownKeyException e) {↵

14

            catch (UnknownKeyException e) {↵

13

                pass = true;↵

15

                pass = true;↵

14

            }↵

16

            }↵

15

            assertTrue(pass);↵

17

            assertTrue(pass);↵

18

            ↵

19

            // try null row key↵

16

            pass = false;↵

20

            pass = false;↵

17

            try {↵

21

            try {↵

18

                d.removeRow(null);↵

22

                data.removeRow(null);↵

19

            }↵

23

            }↵

20

            catch (IllegalArgumentException e) {↵

24

            catch (IllegalArgumentException e) {↵

21

                pass = true;↵

25

                pass = true;↵

22

            }↵

26

            }↵

23

            assertTrue(pass);

27

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

1. {Non-refactorable}

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

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

   1

       DefaultCategoryDataset d = new DefaultCategoryDataset();

   1 | DefaultCategoryDataset d = new DefaultCategoryDataset();
   1 | KeyedObjects2D data = new KeyedObjects2D();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d | data | VARIABLE_NAME_MISMATCH

   1

       KeyedObjects2D data = new KeyedObjects2D();

   2

       d.addValue(1.0, "R1", "C1");

   2 | d.addValue(1.0, "R1", "C1");
   6 | assertEquals("Obj1", data.getObject(0, 0));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   addValue | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   d.addValue(1.0,"R1","C1") | assertEquals("Obj1",data.getObject(0,0)) | ARGUMENT_NUMBER_MISMATCH
   d |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression d.addValue(1.0,"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals("Obj1",data.getObject(0,0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d.addValue(1.0,"R1","C1") is a void method call, and thus it cannot be parameterized
   Expression assertEquals("Obj1",data.getObject(0,0)) is a void method call, and thus it cannot be parameterized
   Expression d.addValue(1.0,"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals("Obj1",data.getObject(0,0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d.addValue(1.0,"R1","C1") is a void method call, and thus it cannot be parameterized
   Expression assertEquals("Obj1",data.getObject(0,0)) is a void method call, and thus it cannot be parameterized

   6

       assertEquals("Obj1", data.getObject(0, 0));

   3

       d.addValue(2.0, "R2", "C2");

   3 | d.addValue(2.0, "R2", "C2");
   5 | assertEquals(1, data.getRowCount());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   addValue | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   d.addValue(2.0,"R2","C2") | assertEquals(1,data.getRowCount()) | ARGUMENT_NUMBER_MISMATCH
   d |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression d.addValue(2.0,"R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(1,data.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d.addValue(2.0,"R2","C2") is a void method call, and thus it cannot be parameterized
   Expression assertEquals(1,data.getRowCount()) is a void method call, and thus it cannot be parameterized
   Expression d.addValue(2.0,"R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(1,data.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d.addValue(2.0,"R2","C2") is a void method call, and thus it cannot be parameterized
   Expression assertEquals(1,data.getRowCount()) is a void method call, and thus it cannot be parameterized

   5

       assertEquals(1, data.getRowCount());

   4

       assertEquals(2, d.getRowCount());

   4 | assertEquals(2, d.getRowCount());
   3 | data.setObject("Obj2", "R2", "C2");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertEquals | setObject | METHOD_INVOCATION_NAME_MISMATCH
   assertEquals(2,d.getRowCount()) | data.setObject("Obj2","R2","C2") | ARGUMENT_NUMBER_MISMATCH
   | data | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertEquals(2,d.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.setObject("Obj2","R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(2,d.getRowCount()) is a void method call, and thus it cannot be parameterized
   Expression data.setObject("Obj2","R2","C2") is a void method call, and thus it cannot be parameterized
   Expression assertEquals(2,d.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.setObject("Obj2","R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(2,d.getRowCount()) is a void method call, and thus it cannot be parameterized
   Expression data.setObject("Obj2","R2","C2") is a void method call, and thus it cannot be parameterized

   3

       data.setObject("Obj2", "R2", "C2");

   5

       d.removeRow("R2");

   5 | d.removeRow("R2");
   4 | data.removeRow("R2");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d | data | VARIABLE_NAME_MISMATCH

   4

       data.removeRow("R2");

   6

       assertEquals(1, d.getRowCount());

   6 | assertEquals(1, d.getRowCount());
   2 | data.setObject("Obj1", "R1", "C1");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertEquals | setObject | METHOD_INVOCATION_NAME_MISMATCH
   assertEquals(1,d.getRowCount()) | data.setObject("Obj1","R1","C1") | ARGUMENT_NUMBER_MISMATCH
   | data | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertEquals(1,d.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.setObject("Obj1","R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(1,d.getRowCount()) is a void method call, and thus it cannot be parameterized
   Expression data.setObject("Obj1","R1","C1") is a void method call, and thus it cannot be parameterized
   Expression assertEquals(1,d.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.setObject("Obj1","R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(1,d.getRowCount()) is a void method call, and thus it cannot be parameterized
   Expression data.setObject("Obj1","R1","C1") is a void method call, and thus it cannot be parameterized

   2

       data.setObject("Obj1", "R1", "C1");

   7

       boolean pass = false;

   7

       boolean pass = false;

   8

       try

   8

       try

   9

       d.removeRow("XXX");

   9 | d.removeRow("XXX");
   9 | data.removeRow("XXX");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d | data | VARIABLE_NAME_MISMATCH

   9

       data.removeRow("XXX");

   10

       assertTrue(pass);

   10

       assertTrue(pass);

   11

       pass = false;

   11

       pass = false;

   12

       try

   12

       try

   13

       d.removeRow(null);

   13 | d.removeRow(null);
   13 | data.removeRow(null);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d | data | VARIABLE_NAME_MISMATCH

   13

       data.removeRow(null);

   14

       assertTrue(pass);

   14

       assertTrue(pass);

   Precondition Violations (32)
   Row | Violation
   --- | ---
   1 | Expression d.addValue(1.0,"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression assertEquals("Obj1",data.getObject(0,0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression d.addValue(1.0,"R1","C1") is a void method call, and thus it cannot be parameterized
   4 | Expression assertEquals("Obj1",data.getObject(0,0)) is a void method call, and thus it cannot be parameterized
   5 | Expression d.addValue(1.0,"R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression assertEquals("Obj1",data.getObject(0,0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression d.addValue(1.0,"R1","C1") is a void method call, and thus it cannot be parameterized
   8 | Expression assertEquals("Obj1",data.getObject(0,0)) is a void method call, and thus it cannot be parameterized
   9 | Expression d.addValue(2.0,"R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Expression assertEquals(1,data.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   11 | Expression d.addValue(2.0,"R2","C2") is a void method call, and thus it cannot be parameterized
   12 | Expression assertEquals(1,data.getRowCount()) is a void method call, and thus it cannot be parameterized
   13 | Expression d.addValue(2.0,"R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   14 | Expression assertEquals(1,data.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   15 | Expression d.addValue(2.0,"R2","C2") is a void method call, and thus it cannot be parameterized
   16 | Expression assertEquals(1,data.getRowCount()) is a void method call, and thus it cannot be parameterized
   17 | Expression assertEquals(2,d.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   18 | Expression data.setObject("Obj2","R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   19 | Expression assertEquals(2,d.getRowCount()) is a void method call, and thus it cannot be parameterized
   20 | Expression data.setObject("Obj2","R2","C2") is a void method call, and thus it cannot be parameterized
   21 | Expression assertEquals(2,d.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   22 | Expression data.setObject("Obj2","R2","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   23 | Expression assertEquals(2,d.getRowCount()) is a void method call, and thus it cannot be parameterized
   24 | Expression data.setObject("Obj2","R2","C2") is a void method call, and thus it cannot be parameterized
   25 | Expression assertEquals(1,d.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   26 | Expression data.setObject("Obj1","R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   27 | Expression assertEquals(1,d.getRowCount()) is a void method call, and thus it cannot be parameterized
   28 | Expression data.setObject("Obj1","R1","C1") is a void method call, and thus it cannot be parameterized
   29 | Expression assertEquals(1,d.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   30 | Expression data.setObject("Obj1","R1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   31 | Expression assertEquals(1,d.getRowCount()) is a void method call, and thus it cannot be parameterized
   32 | Expression data.setObject("Obj1","R1","C1") is a void method call, and thus it cannot be parameterized