Month month = null; // test 1... try { month = Month.parseMonth("1990-01"); } catch (TimePeriodFormatException e) { month = new Month(1, 1900); } assertEquals(1, month.getMonth()); assertEquals(1990, month.getYear().getYear()); // test 2... try { month = Month.parseMonth("02-1991"); } catch (TimePeriodFormatException e) { month = new Month(1, 1900); } assertEquals(2, month.getMonth()); assertEquals(1991, month.getYear().getYear()); // test 3... try { month = Month.parseMonth("March 1993"); } catch (TimePeriodFormatException e) { month = new Month(1, 1900); } assertEquals(3, month.getMonth()); assertEquals(1993, month.getYear().getYear());
Quarter quarter = null; // test 1... try { quarter = Quarter.parseQuarter("Q1-2000"); } catch (TimePeriodFormatException e) { quarter = new Quarter(1, 1900); } assertEquals(1, quarter.getQuarter()); assertEquals(2000, quarter.getYear().getYear()); // test 2... try { quarter = Quarter.parseQuarter("2001-Q2"); } catch (TimePeriodFormatException e) { quarter = new Quarter(1, 1900); } assertEquals(2, quarter.getQuarter()); assertEquals(2001, quarter.getYear().getYear()); // test 3... try { quarter = Quarter.parseQuarter("Q3, 2002"); } catch (TimePeriodFormatException e) { quarter = new Quarter(1, 1900); } assertEquals(3, quarter.getQuarter()); assertEquals(2002, quarter.getYear().getYear());
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/MonthTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/QuarterTests.java
Method name: void testParseMonth() Method name: void testParseQuarter()
Number of AST nodes: 13 Number of AST nodes: 13
1
Month month = null;
1
Quarter quarter = null;
2
        // test 1...
2
        // test 1...
3
        try {
3
        try {
4
            month = Month.parseMonth("1990-01");
4
            quarter = Quarter.parseQuarter("Q1-2000");
5
        }
5
        }
6
        catch (TimePeriodFormatException e) {
6
        catch (TimePeriodFormatException e) {
7
            month = new Month(1, 1900);
7
            quarter = new Quarter(1, 1900);
8
        }
8
        }
9
        assertEquals(1, month.getMonth());
9
        assertEquals(1, quarter.getQuarter());
10
        assertEquals(1990, month.getYear().getYear());
10
        assertEquals(2000, quarter.getYear().getYear());
11
        // test 2...
11
        // test 2...
12
        try {
12
        try {
13
            month = Month.parseMonth("02-1991");
13
            quarter = Quarter.parseQuarter("2001-Q2");
14
        }
14
        }
15
        catch (TimePeriodFormatException e) {
15
        catch (TimePeriodFormatException e) {
16
            month = new Month(1, 1900);
16
            quarter = new Quarter(1, 1900);
17
        }
17
        }
18
        assertEquals(2, month.getMonth());
18
        assertEquals(2, quarter.getQuarter());
19
        assertEquals(1991, month.getYear().getYear());
19
        assertEquals(2001, quarter.getYear().getYear());
20
        // test 3...
20
        // test 3...
21
        try {
21
        try {
22
            month = Month.parseMonth("March 1993");
22
            quarter = Quarter.parseQuarter("Q3, 2002");
23
        }
23
        }
24
        catch (TimePeriodFormatException e) {
24
        catch (TimePeriodFormatException e) {
25
            month = new Month(1, 1900);
25
            quarter = new Quarter(1, 1900);
26
        }
26
        }
27
        assertEquals(3, month.getMonth());
27
        assertEquals(3, quarter.getQuarter());
28
        assertEquals(1993, month.getYear().getYear());
28
        assertEquals(2002, quarter.getYear().getYear());
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)2.6
Clones locationClones are in different classes having the same super class
Number of node comparisons76
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)32.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Month month = null;
    1
    Month month = null;
    1
    Quarter quarter = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    1
    Quarter quarter = null;
    2
    try
    2
    try
    2
    try
    Differences
    Expression1Expression2Difference
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new Month(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Quarter(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    try
    3
    month = Month.parseMonth("1990-01");
    3
    month = Month.parseMonth("1990-01");
    3
    quarter = Quarter.parseQuarter("Q1-2000");
    Differences
    Expression1Expression2Difference
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    "1990-01""Q1-2000"LITERAL_VALUE_MISMATCH
    parseMonthparseQuarterMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    Expression Month.parseMonth("1990-01") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression Quarter.parseQuarter("Q1-2000") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression Month cannot be unified with expression Quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    3
    quarter = Quarter.parseQuarter("Q1-2000");
    4
    assertEquals(1, month.getMonth());
    4
    assertEquals(1, month.getMonth());
    4
    assertEquals(1, quarter.getQuarter());
    Differences
    Expression1Expression2Difference
    getMonthgetQuarterMETHOD_INVOCATION_NAME_MISMATCH
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month.getMonth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression quarter.getQuarter() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getMonth() , public int getQuarter()
    4
    assertEquals(1, quarter.getQuarter());
    5
    assertEquals(1990, month.getYear().getYear());
    5
    assertEquals(1990, month.getYear().getYear());
    5
    assertEquals(2000, quarter.getYear().getYear());
    Differences
    Expression1Expression2Difference
    19902000LITERAL_VALUE_MISMATCH
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public org.jfree.data.time.Year getYear()
    5
    assertEquals(2000, quarter.getYear().getYear());
    6
    try
    6
    try
    6
    try
    Differences
    Expression1Expression2Difference
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new Month(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Quarter(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    try
    7
    month = Month.parseMonth("02-1991");
    7
    month = Month.parseMonth("02-1991");
    7
    quarter = Quarter.parseQuarter("2001-Q2");
    Differences
    Expression1Expression2Difference
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    "02-1991""2001-Q2"LITERAL_VALUE_MISMATCH
    parseMonthparseQuarterMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    Expression Month.parseMonth("02-1991") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression Quarter.parseQuarter("2001-Q2") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression Month cannot be unified with expression Quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    7
    quarter = Quarter.parseQuarter("2001-Q2");
    8
    assertEquals(2, month.getMonth());
    8
    assertEquals(2, month.getMonth());
    8
    assertEquals(2, quarter.getQuarter());
    Differences
    Expression1Expression2Difference
    getMonthgetQuarterMETHOD_INVOCATION_NAME_MISMATCH
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month.getMonth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression quarter.getQuarter() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getMonth() , public int getQuarter()
    8
    assertEquals(2, quarter.getQuarter());
    9
    assertEquals(1991, month.getYear().getYear());
    9
    assertEquals(1991, month.getYear().getYear());
    9
    assertEquals(2001, quarter.getYear().getYear());
    Differences
    Expression1Expression2Difference
    19912001LITERAL_VALUE_MISMATCH
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public org.jfree.data.time.Year getYear()
    9
    assertEquals(2001, quarter.getYear().getYear());
    10
    try
    10
    try
    10
    try
    Differences
    Expression1Expression2Difference
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new Month(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Quarter(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    try
    11
    month = Month.parseMonth("March 1993");
    11
    month = Month.parseMonth("March 1993");
    11
    quarter = Quarter.parseQuarter("Q3, 2002");
    Differences
    Expression1Expression2Difference
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    "March 1993""Q3, 2002"LITERAL_VALUE_MISMATCH
    parseMonthparseQuarterMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    Expression Month.parseMonth("March 1993") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression Quarter.parseQuarter("Q3, 2002") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression Month cannot be unified with expression Quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    11
    quarter = Quarter.parseQuarter("Q3, 2002");
    12
    assertEquals(3, month.getMonth());
    12
    assertEquals(3, month.getMonth());
    12
    assertEquals(3, quarter.getQuarter());
    Differences
    Expression1Expression2Difference
    getMonthgetQuarterMETHOD_INVOCATION_NAME_MISMATCH
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month.getMonth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression quarter.getQuarter() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getMonth() , public int getQuarter()
    12
    assertEquals(3, quarter.getQuarter());
    13
    assertEquals(1993, month.getYear().getYear());
    13
    assertEquals(1993, month.getYear().getYear());
    13
    assertEquals(2002, quarter.getYear().getYear());
    Differences
    Expression1Expression2Difference
    19932002LITERAL_VALUE_MISMATCH
    monthquarterVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.QuarterSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public org.jfree.data.time.Year getYear()
    13
    assertEquals(2002, quarter.getYear().getYear());
    Precondition Violations (30)
    Row Violation
    1Expression new Month(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new Quarter(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    4Expression Month.parseMonth("1990-01") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    5Expression Quarter.parseQuarter("Q1-2000") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    6Expression Month cannot be unified with expression Quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    7Expression month.getMonth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression quarter.getQuarter() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getMonth() , public int getQuarter()
    10Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public org.jfree.data.time.Year getYear()
    11Expression new Month(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression new Quarter(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    14Expression Month.parseMonth("02-1991") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    15Expression Quarter.parseQuarter("2001-Q2") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    16Expression Month cannot be unified with expression Quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    17Expression month.getMonth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression quarter.getQuarter() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getMonth() , public int getQuarter()
    20Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public org.jfree.data.time.Year getYear()
    21Expression new Month(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression new Quarter(1,1900) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    24Expression Month.parseMonth("March 1993") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    25Expression Quarter.parseQuarter("Q3, 2002") is a method call throwing exception(s) that should be caught by a try block that will be extracted
    26Expression Month cannot be unified with expression Quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public static org.jfree.data.time.Month parseMonth(java.lang.String) , public static org.jfree.data.time.Quarter parseQuarter(java.lang.String)
    27Expression month.getMonth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression quarter.getQuarter() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getMonth() , public int getQuarter()
    30Expression month cannot be unified with expression quarter , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public org.jfree.data.time.Year getYear()