312-6-7

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);
KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeColumn("C2"); assertEquals(1, data.getColumnCount()); assertEquals("Obj1", data.getObject(0, 0)); // try unknown column key boolean pass = false; try { data.removeColumn("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); // try null column key pass = false; try { data.removeColumn(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/junit/KeyedObjects2DTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java
Method name: `void testRemoveRowByKey()` |  | Method name: `void testRemoveColumnByKey()`
Number of AST nodes: 14 |  | Number of AST nodes: 14

1

    KeyedObjects2D data = new KeyedObjects2D();↵

1

    KeyedObjects2D data = new KeyedObjects2D();↵

2

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

2

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

3

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

3

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

4

            data.removeRow("R2");↵

4

            data.removeColumn("C2");↵

5

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

5

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

6

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

6

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

7

            ↵

7

            ↵

8

            // try unknown row key↵

8

            // try unknown column key↵

9

            boolean pass = false;↵

9

            boolean pass = false;↵

10

            try {↵

10

            try {↵

11

                data.removeRow("XXX");↵

11

                data.removeColumn("XXX");↵

12

            }↵

12

            }↵

13

            catch (UnknownKeyException e) {↵

13

            catch (UnknownKeyException e) {↵

14

                pass = true;↵

14

                pass = true;↵

15

            }↵

15

            }↵

16

            assertTrue(pass);↵

16

            assertTrue(pass);↵

17

            ↵

17

            ↵

18

            // try null row key↵

18

            // try null column key↵

19

            pass = false;↵

19

            pass = false;↵

20

            try {↵

20

            try {↵

21

                data.removeRow(null);↵

21

                data.removeColumn(null);↵

22

            }↵

22

            }↵

23

            catch (IllegalArgumentException e) {↵

23

            catch (IllegalArgumentException e) {↵

24

                pass = true;↵

24

                pass = true;↵

25

            }↵

25

            }↵

26

            assertTrue(pass);

26

            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 declared in the same class
Number of node comparisons | 49

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) | 43.1
   Clone type | Type 2

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

   1

       KeyedObjects2D data = new KeyedObjects2D();

   1

       KeyedObjects2D data = new KeyedObjects2D();

   2

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

   2

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

   3

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

   3

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

   4

       data.removeRow("R2");

   4 | data.removeRow("R2");
   4 | data.removeColumn("C2");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   removeRow | removeColumn | METHOD_INVOCATION_NAME_MISMATCH
   "R2" | "C2" | LITERAL_VALUE_MISMATCH

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

   4

       data.removeColumn("C2");

   5

       assertEquals(1, data.getRowCount());

   5 | assertEquals(1, data.getRowCount());
   5 | assertEquals(1, data.getColumnCount());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getRowCount | getColumnCount | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression data.getRowCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.getColumnCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   5

       assertEquals(1, data.getColumnCount());

   6

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

   6

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

   7

       boolean pass = false;

   7

       boolean pass = false;

   8

       try

   8

       try

   9

       data.removeRow("XXX");

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

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   removeRow | removeColumn | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression data.removeRow("XXX") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.removeColumn("XXX") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.removeRow("XXX") is a void method call, and thus it cannot be parameterized
   Expression data.removeColumn("XXX") is a void method call, and thus it cannot be parameterized

   9

       data.removeColumn("XXX");

   10

       assertTrue(pass);

   10

       assertTrue(pass);

   11

       pass = false;

   11

       pass = false;

   12

       try

   12

       try

   13

       data.removeRow(null);

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

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   removeRow | removeColumn | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression data.removeRow(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.removeColumn(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression data.removeRow(null) is a void method call, and thus it cannot be parameterized
   Expression data.removeColumn(null) is a void method call, and thus it cannot be parameterized

   13

       data.removeColumn(null);

   14

       assertTrue(pass);

   14

       assertTrue(pass);

   Precondition Violations (14)
   Row | Violation
   --- | ---
   1 | Expression data.removeRow("R2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression data.removeColumn("C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression data.removeRow("R2") is a void method call, and thus it cannot be parameterized
   4 | Expression data.removeColumn("C2") is a void method call, and thus it cannot be parameterized
   5 | Expression data.getRowCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression data.getColumnCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression data.removeRow("XXX") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   8 | Expression data.removeColumn("XXX") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   9 | Expression data.removeRow("XXX") is a void method call, and thus it cannot be parameterized
   10 | Expression data.removeColumn("XXX") is a void method call, and thus it cannot be parameterized
   11 | Expression data.removeRow(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   12 | Expression data.removeColumn(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   13 | Expression data.removeRow(null) is a void method call, and thus it cannot be parameterized
   14 | Expression data.removeColumn(null) is a void method call, and thus it cannot be parameterized