1087-8-11

TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul"); Quarter q1 = new Quarter(new Date(1017608399999L), zone); Quarter q2 = new Quarter(new Date(1017608400000L), zone); assertEquals(1, q1.getQuarter()); assertEquals(1017608399999L, q1.getLastMillisecond(zone)); assertEquals(2, q2.getQuarter()); assertEquals(1017608400000L, q2.getFirstMillisecond(zone));
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); }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/QuarterTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/WeekTests.java
Method name: `void testDateConstructor2()` |  | Method name: `void testBug1498805()`
Number of AST nodes: 7 |  | Number of AST nodes: 7

1

    try {↵

1

    TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul");↵

2

                TimeZone zone = TimeZone.getTimeZone("GMT");↵

2

            Quarter q1 = new Quarter(new Date(1017608399999L), zone↵

3

                GregorianCalendar gc = new GregorianCalendar(zone);↵

3

    );↵

4

                gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0);↵

4

            Quarter q2 = new Quarter(new Date(1017608400000L), zone);↵

5

                Week w = new Week(gc.getTime(), zone);↵

5

            assertEquals(1, q1.getQuarter());↵

6

                assertEquals(53, w.getWeek());↵

6

            assertEquals(1017608399999L, q1.getLastMillisecond(zone));↵

7

                assertEquals(↵

7

            assertEquals(2, q2.getQuarter());↵

8

            assertEquals(1017608400000L, q2.getFirstMillisecond(zone));

8

    new Year(2004), w.getYear());↵

9

            }↵

10

            finally {↵

11

                Locale.setDefault(saved);↵

12

            }

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.0
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 33

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 4
   Number of unmapped statements in the first code fragment | 3
   Number of unmapped statements in the second code fragment | 2
   Time elapsed for statement mapping (ms) | 0.0
   Clone type | Type 3

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

   1

       TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul");

   1 | TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul");
   4 | TimeZone zone = TimeZone.getTimeZone("GMT");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   "Europe/Istanbul" | "GMT" | LITERAL_VALUE_MISMATCH

   4

       TimeZone zone = TimeZone.getTimeZone("GMT");

   2

       Quarter q1 = new Quarter(new Date(1017608399999L), zone);

   2 | Quarter q1 = new Quarter(new Date(1017608399999L), zone);
   7 | Week w = new Week(gc.getTime(), zone);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Quarter | org.jfree.data.time.Week | SUBCLASS_TYPE_MISMATCH
   q1 | w | VARIABLE_NAME_MISMATCH
   org.jfree.data.time.Quarter | org.jfree.data.time.Week | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.time.Quarter | org.jfree.data.time.Week | SUBCLASS_TYPE_MISMATCH
   new Date(1017608399999L) | gc.getTime() | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression new Quarter(new Date(1017608399999L),zone) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression new Week(gc.getTime(),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

   7

       Week w = new Week(gc.getTime(), zone);

   3

       Quarter q2 = new Quarter(new Date(1017608400000L), zone);

   3 | Quarter q2 = new Quarter(new Date(1017608400000L), zone);

   Preondition Violations
   Unmatched statement Quarter q2=new Quarter(new Date(1017608400000L),zone); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   4

       assertEquals(1, q1.getQuarter());

   5

       assertEquals(1017608399999L, q1.getLastMillisecond(zone));

   6

       assertEquals(2, q2.getQuarter());

   6 | assertEquals(2, q2.getQuarter());
   6 | gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertEquals | set | METHOD_INVOCATION_NAME_MISMATCH
   assertEquals(2,q2.getQuarter()) | gc.set(2005,Calendar.JANUARY,1,12,0,0) | ARGUMENT_NUMBER_MISMATCH
   | gc | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertEquals(2,q2.getQuarter()) is a void method call, and thus it cannot be parameterized
   Expression gc.set(2005,Calendar.JANUARY,1,12,0,0) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(2,q2.getQuarter()) is a void method call, and thus it cannot be parameterized
   Expression gc.set(2005,Calendar.JANUARY,1,12,0,0) is a void method call, and thus it cannot be parameterized

   6

       gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0);

   7

       assertEquals(1017608400000L, q2.getFirstMillisecond(zone));

   7 | assertEquals(1017608400000L, q2.getFirstMillisecond(zone));
   8 | assertEquals(53, w.getWeek());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   1017608400000L | 53 | LITERAL_VALUE_MISMATCH

   8

       assertEquals(53, w.getWeek());

   Precondition Violations (9)
   Row | Violation
   --- | ---
   1 | Expression new Quarter(new Date(1017608399999L),zone) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression new Week(gc.getTime(),zone) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression gc.getTime() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Unmatched statement Quarter q2=new Quarter(new Date(1017608400000L),zone); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   5 | Expression assertEquals(2,q2.getQuarter()) is a void method call, and thus it cannot be parameterized
   6 | Expression gc.set(2005,Calendar.JANUARY,1,12,0,0) is a void method call, and thus it cannot be parameterized
   7 | Expression assertEquals(2,q2.getQuarter()) is a void method call, and thus it cannot be parameterized
   8 | Expression gc.set(2005,Calendar.JANUARY,1,12,0,0) is a void method call, and thus it cannot be parameterized
   9 | Clone fragment #1 returns variables zone, q1 , while Clone fragment #2 returns variables zone, w