462-7-8

boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), null, new Double(-0.5), new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success);
boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), new Double(4.5), null, new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java
Method name: `void testDrawWithNullMaxRegular()` |  | Method name: `void testDrawWithNullMinOutlier()`
Number of AST nodes: 10 |  | Number of AST nodes: 10

1

    boolean success = false;↵

1

    boolean success = false;↵

2

            try {↵

2

            try {↵

3

                DefaultBoxAndWhiskerCategoryDataset dataset↵

3

                DefaultBoxAndWhiskerCategoryDataset dataset↵

4

                        = new DefaultBoxAndWhiskerCategoryDataset();↵

4

                        = new DefaultBoxAndWhiskerCategoryDataset();↵

5

                dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),↵

5

                dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),↵

6

                        new Double(3.0), new Double(4.0), new Double(0.5),↵

6

                        new Double(3.0), new Double(4.0), new Double(0.5),↵

7

                        null, new Double(-0.5), new Double(5.5),↵

7

                        new Double(4.5), null, new Double(5.5),↵

8

                        null), "S1", "C1");↵

8

                        null), "S1", "C1");↵

9

                CategoryPlot plot = new CategoryPlot(dataset,↵

9

                CategoryPlot plot = new CategoryPlot(dataset,↵

10

                        new CategoryAxis("Category"), new NumberAxis("Value"),↵

10

                        new CategoryAxis("Category"), new NumberAxis("Value"),↵

11

                        new BoxAndWhiskerRenderer());↵

11

                        new BoxAndWhiskerRenderer());↵

12

                ChartRenderingInfo info = new ChartRenderingInfo();↵

12

                ChartRenderingInfo info = new ChartRenderingInfo();↵

13

                JFreeChart chart = new JFreeChart(plot);↵

13

                JFreeChart chart = new JFreeChart(plot);↵

14

                /* BufferedImage image = */ chart.createBufferedImage(300, 200,↵

14

                /* BufferedImage image = */ chart.createBufferedImage(300, 200,↵

15

                        info);↵

15

                        info);↵

16

                success = true;↵

16

                success = true;↵

17

            }↵

17

            }↵

18

            catch (Exception e) {↵

18

            catch (Exception e) {↵

19

                success = false;↵

19

                success = false;↵

20

            }↵

20

            }↵

21

            assertTrue(success);

21

            assertTrue(success);

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1
Clones location | Clones are declared in the same class
Number of node comparisons | 68

1. {Refactorable}

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

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

   1

       boolean success = false;

   1

       boolean success = false;

   2

       try

   2

       try

   3

       DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

   3

       DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

   4

       dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), null, new Double(-0.5), new Double(5.5), null), "S1", "C1");

   4 | dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), null, new Double(-0.5), new Double(5.5), null), "S1", "C1");
   4 | dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), new Double(4.5), null, new Double(5.5), null), "S1", "C1");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   null | new Double(4.5) | TYPE_COMPATIBLE_REPLACEMENT
   new Double(-0.5) | null | TYPE_COMPATIBLE_REPLACEMENT

   4

       dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), new Double(4.5), null, new Double(5.5), null), "S1", "C1");

   5

       CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());

   5

       CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());

   6

       ChartRenderingInfo info = new ChartRenderingInfo();

   6

       ChartRenderingInfo info = new ChartRenderingInfo();

   7

       JFreeChart chart = new JFreeChart(plot);

   7

       JFreeChart chart = new JFreeChart(plot);

   8

       chart.createBufferedImage(300, 200, info);

   8

       chart.createBufferedImage(300, 200, info);

   9

       success = true;

   9

       success = true;

   10

       assertTrue(success);

   10

       assertTrue(success);

   Precondition Violations (0)
   Row | Violation
   --- | ---