Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java14
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java103
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java3
3 files changed, 73 insertions, 47 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index b9116e7a4..8744134b1 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -68,8 +68,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "1", null);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertNotNull(task);
- // assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
- // connector.synchronize(task, true, null);
+ assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
BugzillaTask retrievedTask = (BugzillaTask) taskList.getTask(task.getHandleIdentifier());
@@ -151,9 +151,10 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
TasksUiPlugin.getTaskListManager().getTaskList().moveToRoot(task);
assertTrue(task.isDownloaded());
// (The initial local copy from server)
- // assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
- // connector.synchronize(task, true, null);
+ assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
+
// Modify it
String newCommentText = "BugzillaRepositoryClientTest.testSynchronize(): " + (new Date()).toString();
task.getTaskData().setNewComment(newCommentText);
@@ -283,6 +284,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
assertNotNull(task);
assertTrue(task.isDownloaded());
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
assertEquals(bugId, Integer.parseInt(task.getTaskData().getId()));
int numAttached = task.getTaskData().getAttachments().size();
@@ -359,10 +361,12 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
init222();
BugzillaTask task4 = generateLocalTaskAndDownload("4");
assertNotNull(task4.getTaskData());
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(task4, true);
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task4.getSyncState());
assertEquals(4, Integer.parseInt(task4.getTaskData().getId()));
BugzillaTask task5 = generateLocalTaskAndDownload("5");
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(task5, true);
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task5.getSyncState());
assertEquals(5, Integer.parseInt(task5.getTaskData().getId()));
@@ -424,6 +428,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
init222();
BugzillaTask task7 = generateLocalTaskAndDownload("7");
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(task7, true);
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task7.getSyncState());
assertEquals(7, Integer.parseInt(task7.getTaskData().getId()));
@@ -495,6 +500,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
*/
protected void timeTracker(int taskid, boolean enableDeadline) throws Exception {
BugzillaTask bugtask = generateLocalTaskAndDownload("" + taskid);
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(bugtask, true);
assertEquals(taskid, Integer.parseInt(bugtask.getTaskData().getId()));
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, bugtask.getSyncState());
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java
index b85639b73..b6c522038 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositoryTaskSynchronizationTest.java
@@ -36,7 +36,7 @@ import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
public class RepositoryTaskSynchronizationTest extends TestCase {
private static final String DATE_STAMP_3 = "2006-06-21 15:29:42";
-
+
private static final String DATE_STAMP_2 = "2006-06-21 15:29:41";
private static final String DATE_STAMP_1 = "2006-06-21 15:29:40";
@@ -64,7 +64,8 @@ public class RepositoryTaskSynchronizationTest extends TestCase {
AbstractRepositoryTask task = new MockRepositoryTask(HANDLE1);
RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(), connector.getRepositoryType(),
URL1, "1");
- //assertTrue(TasksUiPlugin.getSynchronizationManager().checkHasIncoming(task, taskData));
+ // assertTrue(TasksUiPlugin.getSynchronizationManager().checkHasIncoming(task,
+ // taskData));
task.setLastSyncDateStamp("never");
assertTrue(TasksUiPlugin.getSynchronizationManager().checkHasIncoming(task, taskData));
taskData.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, "2006-06-21 15:29:39");
@@ -76,7 +77,7 @@ public class RepositoryTaskSynchronizationTest extends TestCase {
task.setLastSyncDateStamp(DATE_STAMP_1);
assertFalse(TasksUiPlugin.getSynchronizationManager().checkHasIncoming(task, taskData));
}
-
+
public void testIncomingToIncoming() {
/*
* - Synchronize task with incoming changes - Make another change using
@@ -95,24 +96,28 @@ public class RepositoryTaskSynchronizationTest extends TestCase {
assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
assertEquals(DATE_STAMP_2, task.getTaskData().getLastModified());
// and again...
-
- RepositoryTaskData taskData3 = new RepositoryTaskData(new MockAttributeFactory(), connector.getRepositoryType(), URL1, "1");
- taskData3.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, DATE_STAMP_3);
+
+ RepositoryTaskData taskData3 = new RepositoryTaskData(new MockAttributeFactory(),
+ connector.getRepositoryType(), URL1, "1");
+ taskData3.setAttributeValue(RepositoryTaskAttribute.DATE_MODIFIED, DATE_STAMP_3);
TasksUiPlugin.getSynchronizationManager().updateOfflineState(task, taskData3, false);
- // last modified stamp not updated until user synchronizes (newdata == olddata)
+ // last modified stamp not updated until user synchronizes (newdata ==
+ // olddata)
assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
assertEquals(DATE_STAMP_3, task.getTaskData().getLastModified());
- // Should keep INCOMING state state since new data has same date samp and sych is not forced.
+ // Should keep INCOMING state state since new data has same date samp
+ // and sych is not forced.
TasksUiPlugin.getSynchronizationManager().updateOfflineState(task, taskData3, false);
assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
- assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
+ assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
assertEquals(DATE_STAMP_3, task.getTaskData().getLastModified());
}
public void testIncomingToSynchronized() {
- // When not forced, tasks with incoming state should remain in incoming state if
+ // When not forced, tasks with incoming state should remain in incoming
+ // state if
// if new data has same date stamp as old data.
AbstractRepositoryTask task = primeTaskAndRepository(RepositoryTaskSyncState.INCOMING,
RepositoryTaskSyncState.SYNCHRONIZED);
@@ -120,41 +125,54 @@ public class RepositoryTaskSynchronizationTest extends TestCase {
TasksUiPlugin.getSynchronizationManager().updateOfflineState(task, newData, false);
assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
-
- // Test forced (should move to synced state if new data has same date stamp)
+
+ // Test forced (should move to synced state if new data has same date
+ // stamp)
+ // UPDATE: as of bug#163850 synchronizing doesn't mark read
+ // (synchronized)
task = primeTaskAndRepository(RepositoryTaskSyncState.INCOMING, RepositoryTaskSyncState.SYNCHRONIZED);
assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
TasksUiPlugin.getSynchronizationManager().updateOfflineState(task, newData, true);
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
+ assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
+ // assertEquals(RepositoryTaskSyncState.SYNCHRONIZED,
+ // task.getSyncState());
assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
// Test forced with remote incoming
+ // Update: bug#163850 - synchronize gets new data but doesn't mark as read (synchronized)
task = primeTaskAndRepository(RepositoryTaskSyncState.INCOMING, RepositoryTaskSyncState.INCOMING);
assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
TasksUiPlugin.getSynchronizationManager().updateOfflineState(task, newData, true);
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
- assertEquals(DATE_STAMP_2, task.getLastSyncDateStamp());
-
+ assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
+ //assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
+ //assertEquals(DATE_STAMP_2, task.getLastSyncDateStamp());
+
}
-// public void testIncomingToSynchronizedWithVoidSyncTime() {
-// // IF the last sync time (modified timestamp on task) is null, this can result
-// // in the editor refresh/repoen going into an infinite loops since the task never
-// // gets to a synchronized state if the last mod time isn't set. It is now being set
-// // if found to be null.
-// AbstractRepositoryTask task = primeTaskAndRepository(RepositoryTaskSyncState.INCOMING,
-// RepositoryTaskSyncState.SYNCHRONIZED);
-// assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
-// task.setLastSyncDateStamp(null);
-// TasksUiPlugin.getSynchronizationManager().updateOfflineState(task, newData, false);
-// assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
-// assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
-//
-// TasksUiPlugin.getSynchronizationManager().updateOfflineState(task, newData, false);
-// assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
-// assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
-// }
-
+ // public void testIncomingToSynchronizedWithVoidSyncTime() {
+ // // IF the last sync time (modified timestamp on task) is null, this can
+ // result
+ // // in the editor refresh/repoen going into an infinite loops since the
+ // task never
+ // // gets to a synchronized state if the last mod time isn't set. It is now
+ // being set
+ // // if found to be null.
+ // AbstractRepositoryTask task =
+ // primeTaskAndRepository(RepositoryTaskSyncState.INCOMING,
+ // RepositoryTaskSyncState.SYNCHRONIZED);
+ // assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
+ // task.setLastSyncDateStamp(null);
+ // TasksUiPlugin.getSynchronizationManager().updateOfflineState(task,
+ // newData, false);
+ // assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
+ // assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
+ //
+ // TasksUiPlugin.getSynchronizationManager().updateOfflineState(task,
+ // newData, false);
+ // assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
+ // assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
+ // }
+
/*
* public void testIncomingToConflict() { // invalid }
*/
@@ -277,18 +295,18 @@ public class RepositoryTaskSynchronizationTest extends TestCase {
assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
assertEquals(DATE_STAMP_1, task.getLastSyncDateStamp());
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
+ assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
}
-
+
public void testMarkUnread() {
AbstractRepositoryTask task = primeTaskAndRepository(RepositoryTaskSyncState.SYNCHRONIZED,
RepositoryTaskSyncState.SYNCHRONIZED);
task.setLastSyncDateStamp(null);
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
- TasksUiPlugin.getSynchronizationManager().setTaskRead(task, false);
- assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(task, false);
+ assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
}
-
+
private class TestOfflineTaskHandler implements IOfflineTaskHandler {
private final String DATE_FORMAT_2 = "yyyy-MM-dd HH:mm:ss";
@@ -310,12 +328,13 @@ public class RepositoryTaskSynchronizationTest extends TestCase {
}
public Set<AbstractRepositoryTask> getChangedSinceLastSync(TaskRepository repository,
- Set<AbstractRepositoryTask> tasks, Proxy proxySettings) throws CoreException, UnsupportedEncodingException {
+ Set<AbstractRepositoryTask> tasks, Proxy proxySettings) throws CoreException,
+ UnsupportedEncodingException {
return null;
}
- public RepositoryTaskData downloadTaskData(TaskRepository repository, String taskId,
- Proxy proxySettings) throws CoreException {
+ public RepositoryTaskData downloadTaskData(TaskRepository repository, String taskId, Proxy proxySettings)
+ throws CoreException {
return null;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java
index fadc376f2..931df1243 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java
@@ -342,7 +342,8 @@ public class RepositorySynchronizationManager {
if (!forceSync && checkHasIncoming(repositoryTask, newTaskData)) {
status = RepositoryTaskSyncState.INCOMING;
} else {
- status = RepositoryTaskSyncState.SYNCHRONIZED;
+ // bug#163850 -Make sync retrieve new data but not mark as read
+ //status = RepositoryTaskSyncState.SYNCHRONIZED;
}
break;
case SYNCHRONIZED:

Back to the top