Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2013-03-18 19:36:37 +0000
committerGerrit Code Review @ Eclipse.org2013-05-08 07:23:50 +0000
commite83de18edfd3c3538882d1296b7f365cbc3d80ca (patch)
tree45744b8678288e7a590ece18448ab89cc38cf85c /org.eclipse.mylyn.tasks.tests
parentad4f4ec1807af8386b5dbb2f0faf6045b6bec0f9 (diff)
downloadorg.eclipse.mylyn.tasks-e83de18edfd3c3538882d1296b7f365cbc3d80ca.tar.gz
org.eclipse.mylyn.tasks-e83de18edfd3c3538882d1296b7f365cbc3d80ca.tar.xz
org.eclipse.mylyn.tasks-e83de18edfd3c3538882d1296b7f365cbc3d80ca.zip
403094: cannot mark task unread after incoming suppressed
Change-Id: Icb207c30c943992a77a76d9e5e5d9c81b5bf7349 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=403094
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/plugin.xml11
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataManagerTest.java103
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java20
3 files changed, 132 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/plugin.xml b/org.eclipse.mylyn.tasks.tests/plugin.xml
index 669610cf5..166ddab6d 100644
--- a/org.eclipse.mylyn.tasks.tests/plugin.xml
+++ b/org.eclipse.mylyn.tasks.tests/plugin.xml
@@ -88,6 +88,17 @@
</suppressIncoming>
</extension>
<extension
+ point="org.eclipse.mylyn.tasks.core.synchronizationParticipants">
+ <participant
+ class="org.eclipse.mylyn.tasks.tests.support.MockSynchronizationParticipant"
+ id="org.eclipse.mylyn.tasks.tests.participant">
+ </participant>
+ <suppressIncoming
+ attributeId="task.common.version"
+ connectorKind="mock">
+ </suppressIncoming>
+ </extension>
+ <extension
point="org.eclipse.mylyn.tasks.core.taskActivationListeners">
<listener
id="org.eclipse.mylyn.tasks.tests.listenerTest"
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataManagerTest.java
index 594c4401b..e0d18eb10 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataManagerTest.java
@@ -13,12 +13,20 @@ package org.eclipse.mylyn.tasks.tests;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.mylyn.commons.core.DelegatingProgressMonitor;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
/**
* @author Rob Elves
@@ -28,13 +36,24 @@ public class TaskDataManagerTest extends TestCase {
private TaskDataManager taskDataManger;
+ TaskRepository taskRepository;
+
+ private TaskRepositoryManager taskRepositoryManager;
+
@Override
protected void setUp() throws Exception {
taskDataManger = TasksUiPlugin.getTaskDataManager();
+ taskRepository = TaskTestUtil.createMockRepository();
+ taskRepositoryManager = (TaskRepositoryManager) TasksUi.getRepositoryManager();
+ TasksUi.getRepositoryManager().addRepository(taskRepository);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ taskRepositoryManager.clearRepositories();
}
public void testPutUpdatedTaskData() throws Exception {
- TaskRepository taskRepository = TaskTestUtil.createMockRepository();
TaskTask task = TaskTestUtil.createMockTask("1");
task.setSynchronizationState(SynchronizationState.SYNCHRONIZED);
TaskData taskData = TaskTestUtil.createTaskData(taskRepository, "1");
@@ -42,6 +61,88 @@ public class TaskDataManagerTest extends TestCase {
assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
}
+ public void testIncomming() throws Exception {
+ TaskTask task = TaskTestUtil.createMockTask("1");
+ task.setSynchronizationState(SynchronizationState.SYNCHRONIZED);
+ TaskData taskData = TaskTestUtil.createTaskData(taskRepository, "1");
+ TaskAttribute root = taskData.getRoot();
+ root.createAttribute(TaskAttribute.SUMMARY).setValue("my Task");
+ taskDataManger.putUpdatedTaskData(task, taskData, true, null);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ }
+
+ public void testIncommingSupressed() throws Exception {
+ TaskTask task = TaskTestUtil.createMockTask("1");
+ task.setSynchronizationState(SynchronizationState.SYNCHRONIZED);
+ TaskData taskData = TaskTestUtil.createTaskData(taskRepository, "1");
+ TaskAttribute root = taskData.getRoot();
+ TaskAttribute version = root.createAttribute(TaskAttribute.VERSION);
+ version.getMetaData().defaults().setKind("default");
+ version.setValue("V1.0");
+
+ taskDataManger.putUpdatedTaskData(task, taskData, true, null);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ assertEquals("true", task.getAttribute(ITasksCoreConstants.ATTRIBUTE_TASK_SUPPRESS_INCOMING));
+ }
+
+ public void testIncommingSupressedWithSave() throws Exception {
+ TasksUi.getRepositoryManager().addRepository(taskRepository);
+ TaskTask task = TaskTestUtil.createMockTask("1");
+ task.setSynchronizationState(SynchronizationState.SYNCHRONIZED);
+
+ TaskData taskData = TaskTestUtil.createTaskData(taskRepository, "1");
+ taskDataManger.putUpdatedTaskData(task, taskData, true, null);
+ ITaskDataWorkingCopy taskDataState1 = TasksUiPlugin.getTaskDataManager().getWorkingCopy(task);
+ TaskDataModel model = new TaskDataModel(taskRepository, task, taskDataState1);
+ TaskAttribute root = model.getTaskData().getRoot();
+ TaskAttribute version = root.createAttribute(TaskAttribute.VERSION);
+ version.getMetaData().defaults().setKind("default");
+ version.setValue("V1.0");
+
+ model.attributeChanged(version);
+ model.save(new NullProgressMonitor());
+ assertEquals(SynchronizationState.OUTGOING, task.getSynchronizationState());
+ taskDataManger.putSubmittedTaskData(task, taskData, new DelegatingProgressMonitor());
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+ assertNull(task.getAttribute(ITasksCoreConstants.ATTRIBUTE_TASK_SUPPRESS_INCOMING));
+ }
+
+ public void testIncommingSupressedWithRead() throws Exception {
+ TasksUi.getRepositoryManager().addRepository(taskRepository);
+ TaskTask task = TaskTestUtil.createMockTask("1");
+ task.setSynchronizationState(SynchronizationState.SYNCHRONIZED);
+
+ TaskData taskData = TaskTestUtil.createTaskData(taskRepository, "1");
+ taskDataManger.putUpdatedTaskData(task, taskData, true, null);
+ ITaskDataWorkingCopy taskDataState1 = TasksUiPlugin.getTaskDataManager().getWorkingCopy(task);
+ TaskDataModel model = new TaskDataModel(taskRepository, task, taskDataState1);
+ taskData = model.getTaskData();
+ TaskAttribute root = taskData.getRoot();
+ TaskAttribute version = root.createAttribute(TaskAttribute.VERSION);
+ version.getMetaData().defaults().setKind("default");
+ version.setValue("V1.0");
+
+ model.attributeChanged(version);
+ model.save(new NullProgressMonitor());
+ assertEquals(SynchronizationState.OUTGOING, task.getSynchronizationState());
+ taskDataManger.putSubmittedTaskData(task, taskData, new DelegatingProgressMonitor());
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+
+ root = model.getTaskData().getRoot();
+ version = root.createAttribute(TaskAttribute.VERSION);
+ version.getMetaData().defaults().setKind("default");
+ version.setValue("V1.1");
+
+ taskDataManger.putUpdatedTaskData(task, taskData, true, null);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+
+ assertEquals("true", task.getAttribute(ITasksCoreConstants.ATTRIBUTE_TASK_SUPPRESS_INCOMING));
+ TasksUiPlugin.getTaskDataManager().setTaskRead(task, false);
+ assertEquals(SynchronizationState.INCOMING, task.getSynchronizationState());
+ assertEquals("false", task.getAttribute(ITasksCoreConstants.ATTRIBUTE_TASK_SUPPRESS_INCOMING));
+
+ }
+
// public void testHasIncomingDateComparison() {
// final Stack<Date> dates = new Stack<Date>();
// MockTask task = new MockTask(MOCCK_ID);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java
index cfc2b1deb..f37bdfb0e 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java
@@ -21,6 +21,7 @@ import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskMigrationEvent;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
@@ -160,7 +161,16 @@ public class MockRepositoryConnector extends AbstractRepositoryConnector {
@Override
public boolean hasTaskChanged(TaskRepository taskRepository, ITask task, TaskData taskData) {
- return false;
+ boolean result = false;
+ TaskAttribute summery = taskData.getRoot().getAttribute(TaskAttribute.SUMMARY);
+ result = summery != null ? !task.getSummary().equals(summery.getValue()) : false;
+ if (result) {
+ return result;
+ }
+ TaskAttribute version = taskData.getRoot().getAttribute(TaskAttribute.VERSION);
+
+ return version != null ? !version.getValue().equals(task.getAttribute(TaskAttribute.VERSION)) : false;
+
}
@Override
@@ -170,6 +180,14 @@ public class MockRepositoryConnector extends AbstractRepositoryConnector {
@Override
public void updateTaskFromTaskData(TaskRepository taskRepository, ITask task, TaskData taskData) {
+ TaskAttribute summery = taskData.getRoot().getAttribute(TaskAttribute.SUMMARY);
+ if (summery != null) {
+ task.setSummary(summery.getValue());
+ }
+ TaskAttribute version = taskData.getRoot().getAttribute(TaskAttribute.VERSION);
+ if (version != null) {
+ task.setAttribute(TaskAttribute.VERSION, version.getValue());
+ }
}
// @Override

Back to the top