try { TimeZone zone = TimeZone.getTimeZone("GMT"); GregorianCalendar gc = new GregorianCalendar(zone); gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0); Week w = new Week(gc.getTime(), zone); assertEquals(53, w.getWeek()); assertEquals(new Year(2004), w.getYear()); } finally { Locale.setDefault(saved); }
TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Year y1 = new Year(new Date(1009871999999L), zone); Year y2 = new Year(new Date(1009872000000L), zone); assertEquals(2001, y1.getYear()); assertEquals(1009871999999L, y1.getLastMillisecond(zone)); assertEquals(2002, y2.getYear()); assertEquals(1009872000000L, y2.getFirstMillisecond(zone));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/WeekTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/YearTests.java
Method name: void testBug1498805() Method name: void testDateConstructor2()
Number of AST nodes: 7 Number of AST nodes: 7
1
try {
2
            TimeZone zone = TimeZone.getTimeZone("GMT");
1
TimeZone zone = TimeZone.getTimeZone("
3
            GregorianCalend
2
America/Los_Angeles");
4
ar gc = new GregorianCalendar(zone);
3
        Year y1 = new 
5
            gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0);
4
Year(new Date(1009871999999L), zone);
6
            Week w = new Week(gc.getTime(), zone);
5
        Year y2 = new Year(new Date(1009872000000L), zone);
7
    
8
        assertEquals(53, w.getWeek());
6
        assertEquals(2001, y1.getYear());
9
            assertEquals(new Year(2004), w.getYear());
7
        assertEquals(
10
        }
11
        finally {
12
            Locale.setDefault(saved);
13
        }
8
1009871999999L, y1.getLastMillisecond(zone));
9
        assertEquals(2002, y2.getYear());
10
        assertEquals(1009872000000L, y2.getFirstMillisecond(zone));
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)0.0
Clones locationClones are in different classes having the same super class
Number of node comparisons34
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    4
    TimeZone zone = TimeZone.getTimeZone("GMT");
    4
    TimeZone zone = TimeZone.getTimeZone("GMT");
    1
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Differences
    Expression1Expression2Difference
    "GMT""America/Los_Angeles"LITERAL_VALUE_MISMATCH
    1
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
                                                                                                          
    2
    Year y1 = new Year(new Date(1009871999999L), zone);
    Preondition Violations
    Unmatched statement Year y1=new Year(new Date(1009871999999L),zone); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    Year y1 = new Year(new Date(1009871999999L), zone);
    5
    GregorianCalendar gc = new GregorianCalendar(zone);
    5
    GregorianCalendar gc = new GregorianCalendar(zone);
    Preondition Violations
    Unmatched statement GregorianCalendar gc=new GregorianCalendar(zone); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                            
    6
    gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0);
    6
    gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0);
    Preondition Violations
    Unmatched statement gc.set(2005,Calendar.JANUARY,1,12,0,0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                        
    7
    Week w = new Week(gc.getTime(), zone);
    7
    Week w = new Week(gc.getTime(), zone);
    3
    Year y2 = new Year(new Date(1009872000000L), zone);
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Weekorg.jfree.data.time.YearSUBCLASS_TYPE_MISMATCH
    wy2VARIABLE_NAME_MISMATCH
    org.jfree.data.time.Weekorg.jfree.data.time.YearSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Weekorg.jfree.data.time.YearSUBCLASS_TYPE_MISMATCH
    gc.getTime()new Date(1009872000000L)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new Week(gc.getTime(),zone) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Year(new Date(1009872000000L),zone) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression gc.getTime() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    Year y2 = new Year(new Date(1009872000000L), zone);
                                                                          
    4
    assertEquals(2001, y1.getYear());
                                                                                                                            
    5
    assertEquals(1009871999999L, y1.getLastMillisecond(zone));
    Preondition Violations
    Unmatched statement assertEquals(1009871999999L,y1.getLastMillisecond(zone)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    assertEquals(1009871999999L, y1.getLastMillisecond(zone));
    8
    assertEquals(53, w.getWeek());
    8
    assertEquals(53, w.getWeek());
    6
    assertEquals(2002, y2.getYear());
    Differences
    Expression1Expression2Difference
    532002LITERAL_VALUE_MISMATCH
    getWeekgetYearMETHOD_INVOCATION_NAME_MISMATCH
    wy2VARIABLE_NAME_MISMATCH
    org.jfree.data.time.Weekorg.jfree.data.time.YearSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression w.getWeek() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression y2.getYear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression w cannot be unified with expression y2 , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getWeek() , public int getYear()
    6
    assertEquals(2002, y2.getYear());
                                                                                                                              
    7
    assertEquals(1009872000000L, y2.getFirstMillisecond(zone));
    Preondition Violations
    Unmatched statement assertEquals(1009872000000L,y2.getFirstMillisecond(zone)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    assertEquals(1009872000000L, y2.getFirstMillisecond(zone));
    9
    assertEquals(new Year(2004), w.getYear());
    9
    assertEquals(new Year(2004), w.getYear());
    Preondition Violations
    Unmatched statement assertEquals(new Year(2004),w.getYear()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                            
    Precondition Violations (13)
    Row Violation
    1Unmatched statement Year y1=new Year(new Date(1009871999999L),zone); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement GregorianCalendar gc=new GregorianCalendar(zone); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement gc.set(2005,Calendar.JANUARY,1,12,0,0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Expression new Week(gc.getTime(),zone) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression new Year(new Date(1009872000000L),zone) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression gc.getTime() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Unmatched statement assertEquals(1009871999999L,y1.getLastMillisecond(zone)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression w.getWeek() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression y2.getYear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression w cannot be unified with expression y2 , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getWeek() , public int getYear()
    11Unmatched statement assertEquals(1009872000000L,y2.getFirstMillisecond(zone)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement assertEquals(new Year(2004),w.getYear()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Clone fragment #1 returns variables zone, w , while Clone fragment #2 returns variables zone, y2