312-5-7

KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeColumn(0); assertEquals(1, data.getColumnCount()); assertEquals("Obj2", data.getObject(1, 0)); // try negative column index boolean pass = false; try { data.removeColumn(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try column index too high pass = false; try { data.removeColumn(data.getColumnCount()); } catch (IndexOutOfBoundsException 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 testRemoveColumnByIndex()` |  | 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.removeColumn(0);↵

4

            data.removeColumn("C2");↵

5

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

5

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

6

            assertEquals("Obj2", data.getObject(1, 0));↵

6

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

7

            ↵

7

            ↵

8

            // try negative column index↵

8

            // try unknown column key↵

9

            boolean pass = false;↵

9

            boolean pass = false;↵

10

            try {↵

10

            try {↵

11

                data.removeColumn(-1);↵

11

                data.removeColumn("XXX");↵

12

            }↵

12

            }↵

13

            catch (IndexOutOfBoundsException e) {↵

13

            catch (UnknownKeyException e) {↵

14

                pass = true;↵

14

                pass = true;↵

15

            }↵

15

            }↵

16

            assertTrue(pass);↵

16

            assertTrue(pass);↵

17

            ↵

17

            ↵

18

            // try column index too high↵

18

            // try null column key↵

19

            pass = false;↵

19

            pass = false;↵

20

            try {↵

20

            try {↵

21

                data.removeColumn(data.getColumnCount());↵

21

                data.removeColumn(null);↵

22

            }↵

22

            }↵

23

            catch (IndexOutOfBoundsException 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 | 57

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 12
   Number of unmapped statements in the first code fragment | 2
   Number of unmapped statements in the second code fragment | 2
   Time elapsed for statement mapping (ms) | 36.0
   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.removeColumn(0);

   4 | data.removeColumn(0);
   6 | assertEquals("Obj1", data.getObject(0, 0));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   removeColumn | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   data.removeColumn(0) | assertEquals("Obj1",data.getObject(0,0)) | ARGUMENT_NUMBER_MISMATCH
   data |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression data.removeColumn(0) 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 data.removeColumn(0) 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 data.removeColumn(0) 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 data.removeColumn(0) 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));

   5

       assertEquals(1, data.getColumnCount());

   5

       assertEquals(1, data.getColumnCount());

   6

       assertEquals("Obj2", data.getObject(1, 0));

   6 | assertEquals("Obj2", data.getObject(1, 0));
   4 | data.removeColumn("C2");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertEquals | removeColumn | METHOD_INVOCATION_NAME_MISMATCH
   assertEquals("Obj2",data.getObject(1,0)) | data.removeColumn("C2") | ARGUMENT_NUMBER_MISMATCH
   | data | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertEquals("Obj2",data.getObject(1,0)) 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 assertEquals("Obj2",data.getObject(1,0)) 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
   Expression assertEquals("Obj2",data.getObject(1,0)) 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 assertEquals("Obj2",data.getObject(1,0)) 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");

   7

       boolean pass = false;

   7

       boolean pass = false;

   8

       try

   8 | try
   8 | try

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

   8

       try

   9

       data.removeColumn("XXX");

   9

       data.removeColumn(-1);

   10

       assertTrue(pass);

   10

       assertTrue(pass);

   11

       pass = false;

   11

       pass = false;

   12

       try

   12 | try
   12 | try

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.IndexOutOfBoundsException | java.lang.IllegalArgumentException | SUBCLASS_TYPE_MISMATCH
   java.lang.IndexOutOfBoundsException | java.lang.IllegalArgumentException | SUBCLASS_TYPE_MISMATCH

   12

       try

   13

       data.removeColumn(null);

   13

       data.removeColumn(data.getColumnCount());

   14

       assertTrue(pass);

   14

       assertTrue(pass);

   Precondition Violations (16)
   Row | Violation
   --- | ---
   1 | Expression data.removeColumn(0) 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 data.removeColumn(0) 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 data.removeColumn(0) 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 data.removeColumn(0) 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 assertEquals("Obj2",data.getObject(1,0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Expression data.removeColumn("C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   11 | Expression assertEquals("Obj2",data.getObject(1,0)) is a void method call, and thus it cannot be parameterized
   12 | Expression data.removeColumn("C2") is a void method call, and thus it cannot be parameterized
   13 | Expression assertEquals("Obj2",data.getObject(1,0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   14 | Expression data.removeColumn("C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   15 | Expression assertEquals("Obj2",data.getObject(1,0)) is a void method call, and thus it cannot be parameterized
   16 | Expression data.removeColumn("C2") is a void method call, and thus it cannot be parameterized