ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(Color.gray, m.getPaint()); m.setPaint(Color.blue); assertEquals(Color.blue, m.getPaint()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setPaint(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); }
ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor()); m.setLabelAnchor(RectangleAnchor.TOP); assertEquals(RectangleAnchor.TOP, m.getLabelAnchor()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelAnchor(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/MarkerTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/MarkerTests.java
Method name: void testGetSetPaint() Method name: void testGetSetLabelAnchor()
Number of AST nodes: 10 Number of AST nodes: 10
1
ValueMarker m = new ValueMarker(1.1);
1
ValueMarker m = new ValueMarker(1.1);
2
        m.addChangeListener(this);
2
        m.addChangeListener(this);
3
        this.lastEvent = null;
3
        this.lastEvent = null;
4
        assertEquals(Color.gray, m.getPaint());
4
        assertEquals(
5
        m.setPaint(Color.blue
5
RectangleAnchor.TOP_LEFT, m.getLabelAnchor());
6
);
6
        m.setLabelAnchor(RectangleAnchor.TOP);
7
        assertEquals(Color.blue, m.getPaint());
7
        assertEquals(RectangleAnchor.TOP, m.getLabelAnchor());
8
        assertEquals(m, this.lastEvent.getMarker());
8
        assertEquals(m, this.lastEvent.getMarker());
9
        
9
        
10
        // check null argument...
10
        // check null argument...
11
        try {
11
        try {
12
            m.setPaint(null);
12
            m.setLabelAnchor(null);
13
            fail("Expected an IllegalArgumentException for null.");
13
            fail("Expected an IllegalArgumentException for null.");
14
        }
14
        }
15
        catch (IllegalArgumentException e) {
15
        catch (IllegalArgumentException e) {
16
            assertTrue(true);
16
            assertTrue(true);
17
        }
17
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are declared in the same class
Number of node comparisons37
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)10.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    ValueMarker m = new ValueMarker(1.1);
    1
    ValueMarker m = new ValueMarker(1.1);
    2
    m.addChangeListener(this);
    2
    m.addChangeListener(this);
    3
    this.lastEvent = null;
    3
    this.lastEvent = null;
                                                                                                                              
    4
    assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor());
    Preondition Violations
    Unmatched statement assertEquals(RectangleAnchor.TOP_LEFT,m.getLabelAnchor()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor());
    4
    assertEquals(Color.gray, m.getPaint());
    4
    assertEquals(Color.gray, m.getPaint());
    Preondition Violations
    Unmatched statement assertEquals(Color.gray,m.getPaint()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
                                                                                      
    5
    m.setLabelAnchor(RectangleAnchor.TOP);
    Preondition Violations
    Unmatched statement m.setLabelAnchor(RectangleAnchor.TOP); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    m.setLabelAnchor(RectangleAnchor.TOP);
    5
    m.setPaint(Color.blue);
    5
    m.setPaint(Color.blue);
    Preondition Violations
    Unmatched statement m.setPaint(Color.blue); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                        
                                                                                                                    
    6
    assertEquals(RectangleAnchor.TOP, m.getLabelAnchor());
    Preondition Violations
    Unmatched statement assertEquals(RectangleAnchor.TOP,m.getLabelAnchor()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    assertEquals(RectangleAnchor.TOP, m.getLabelAnchor());
    6
    assertEquals(Color.blue, m.getPaint());
    6
    assertEquals(Color.blue, m.getPaint());
    Preondition Violations
    Unmatched statement assertEquals(Color.blue,m.getPaint()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
    7
    assertEquals(m, this.lastEvent.getMarker());
    7
    assertEquals(m, this.lastEvent.getMarker());
    8
    try
    8
    try
    9
    m.setPaint(null);
    9
    m.setPaint(null);
    9
    m.setLabelAnchor(null);
    Differences
    Expression1Expression2Difference
    setPaintsetLabelAnchorMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression m.setPaint(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression m.setLabelAnchor(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression m.setPaint(null) is a void method call, and thus it cannot be parameterized
    Expression m.setLabelAnchor(null) is a void method call, and thus it cannot be parameterized
    9
    m.setLabelAnchor(null);
    10
    fail("Expected an IllegalArgumentException for null.");
    10
    fail("Expected an IllegalArgumentException for null.");
    Precondition Violations (10)
    Row Violation
    1Unmatched statement assertEquals(RectangleAnchor.TOP_LEFT,m.getLabelAnchor()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement assertEquals(Color.gray,m.getPaint()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement m.setLabelAnchor(RectangleAnchor.TOP); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement m.setPaint(Color.blue); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement assertEquals(RectangleAnchor.TOP,m.getLabelAnchor()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement assertEquals(Color.blue,m.getPaint()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression m.setPaint(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression m.setLabelAnchor(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression m.setPaint(null) is a void method call, and thus it cannot be parameterized
    10Expression m.setLabelAnchor(null) is a void method call, and thus it cannot be parameterized