|
Lines 23-31
Link Here
|
| 23 |
import org.eclipse.mylyn.commons.net.AuthenticationType; |
23 |
import org.eclipse.mylyn.commons.net.AuthenticationType; |
| 24 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; |
24 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; |
| 25 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector; |
25 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector; |
|
|
26 |
import org.eclipse.mylyn.internal.tasks.core.AbstractTask; |
| 26 |
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; |
27 |
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; |
|
|
28 |
import org.eclipse.mylyn.internal.tasks.core.TaskTask; |
| 27 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
29 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 28 |
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler; |
30 |
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler; |
|
|
31 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
| 29 |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
32 |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
| 30 |
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; |
33 |
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; |
| 31 |
|
34 |
|
|
Lines 52-57
Link Here
|
| 52 |
handler = connector.getTaskDataHandler(); |
55 |
handler = connector.getTaskDataHandler(); |
| 53 |
} |
56 |
} |
| 54 |
|
57 |
|
|
|
58 |
public void testHasChanged() { |
| 59 |
AbstractTask task = new TaskTask(repository.getConnectorKind(), repository.getRepositoryUrl(), "1"); |
| 60 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12"); |
| 61 |
TaskData data = new TaskData(connector.getTaskDataHandler().getAttributeMapper(repository), |
| 62 |
repository.getConnectorKind(), repository.getRepositoryUrl(), "1"); |
| 63 |
TaskAttribute attribute = data.getRoot().createAttribute(BugzillaAttribute.DELTA_TS.getKey()); |
| 64 |
|
| 65 |
// Testing State 1 |
| 66 |
|
| 67 |
// Offline no timezone, repository no timezone, same time |
| 68 |
attribute.setValue("2008-02-02 12:01:12"); |
| 69 |
assertFalse(connector.hasTaskChanged(repository, task, data)); |
| 70 |
|
| 71 |
// Offline no timezone, repository no timezone, different date |
| 72 |
attribute.setValue("2008-02-03 12:01:12"); |
| 73 |
assertTrue(connector.hasTaskChanged(repository, task, data)); |
| 74 |
|
| 75 |
// Offline no timezone, repository no timezone, different time |
| 76 |
attribute.setValue("2008-02-02 12:03:12"); |
| 77 |
assertTrue(connector.hasTaskChanged(repository, task, data)); |
| 78 |
|
| 79 |
// Offline no timezone, repository no timezone, different (older) time |
| 80 |
attribute.setValue("2008-02-02 12:03:00"); |
| 81 |
assertTrue(connector.hasTaskChanged(repository, task, data)); |
| 82 |
|
| 83 |
// Testing Fuzzy States 2 & 3 |
| 84 |
|
| 85 |
// Offline have timezone, repository no timezone, same time |
| 86 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12 -0700"); |
| 87 |
attribute.setValue("2008-02-02 12:01:12"); |
| 88 |
assertFalse(connector.hasTaskChanged(repository, task, data)); |
| 89 |
|
| 90 |
// Offline have timezone, repository no timezone, different time |
| 91 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12 -0700"); |
| 92 |
attribute.setValue("2008-02-02 12:01:13"); |
| 93 |
assertTrue(connector.hasTaskChanged(repository, task, data)); |
| 94 |
|
| 95 |
// Offline no timezone, repository has timezone |
| 96 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12"); |
| 97 |
attribute.setValue("2008-02-02 12:01:12 -0700"); |
| 98 |
assertFalse(connector.hasTaskChanged(repository, task, data)); |
| 99 |
|
| 100 |
// Offline no timezone, repository has timezone and different time (fuzzy check doesn't pass) |
| 101 |
attribute.setValue("2008-02-02 12:01:13 -0700"); |
| 102 |
assertTrue(connector.hasTaskChanged(repository, task, data)); |
| 103 |
|
| 104 |
// Test backwards in time |
| 105 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12"); |
| 106 |
attribute.setValue("2008-02-02 12:01:03 -0700"); |
| 107 |
assertTrue(connector.hasTaskChanged(repository, task, data)); |
| 108 |
|
| 109 |
// Testing State 4 |
| 110 |
|
| 111 |
// Same world time, reported wrt different time zones |
| 112 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 00:00:00 PDT"); |
| 113 |
attribute.setValue("2009-09-04 03:00:00 EDT"); |
| 114 |
assertFalse(connector.hasTaskChanged(repository, task, data)); |
| 115 |
|
| 116 |
// Different times, same time zone |
| 117 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 12:00:00 PDT"); |
| 118 |
attribute.setValue("2009-09-04 12:00:01 PDT"); |
| 119 |
assertTrue(connector.hasTaskChanged(repository, task, data)); |
| 120 |
|
| 121 |
// Same times, bogus format (string compare) |
| 122 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 12:00:::01 PDT"); |
| 123 |
attribute.setValue("2009-09-04 12:00:::01 PDT"); |
| 124 |
assertFalse(connector.hasTaskChanged(repository, task, data)); |
| 125 |
|
| 126 |
// Same times, bogus format (string compare) |
| 127 |
task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04X12:00:::01 PDT"); |
| 128 |
attribute.setValue("2009-09-04 12:00:::01 PDT"); |
| 129 |
assertTrue(connector.hasTaskChanged(repository, task, data)); |
| 130 |
|
| 131 |
} |
| 132 |
|
| 55 |
/** |
133 |
/** |
| 56 |
* This is the first test so that the repository credentials are correctly set for the other tests |
134 |
* This is the first test so that the repository credentials are correctly set for the other tests |
| 57 |
*/ |
135 |
*/ |