Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2016-03-07 15:48:19 -0500
committerFrank Becker2016-03-16 16:48:56 -0400
commitc47e9260be7b93c04ce3b77952dc581f0d74f709 (patch)
treeb0ee4689141e0cd885dc1f7275d58d4dc5119275 /connector-bugzilla-rest
parent44a9886b02c40febb2691712528a925eee025df0 (diff)
downloadorg.eclipse.mylyn.tasks-c47e9260be7b93c04ce3b77952dc581f0d74f709.tar.gz
org.eclipse.mylyn.tasks-c47e9260be7b93c04ce3b77952dc581f0d74f709.tar.xz
org.eclipse.mylyn.tasks-c47e9260be7b93c04ce3b77952dc581f0d74f709.zip
414360: add support for attributes blocks / depends_on to REST API
Change-Id: Ic8d92d5630d4fe079c18124a550e6140f0590703 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=414360
Diffstat (limited to 'connector-bugzilla-rest')
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java326
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java95
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData.txt2
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData1.txt2
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData2.txt2
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData.txt2
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData1.txt2
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData2.txt2
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java10
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java5
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java62
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java16
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java20
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java5
14 files changed, 542 insertions, 9 deletions
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java
index b186b4c03..314c2159e 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java
@@ -495,7 +495,7 @@ public class BugzillaRestClientTest {
@Test
public void testUpdateTaskData() throws Exception {
- String taskId = harness.getTaksId4TestProduct();
+ String taskId = harness.getNewTaksId4TestProduct();
TaskData taskDataGet = harness.getTaskFromServer(taskId);
Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
@@ -553,7 +553,7 @@ public class BugzillaRestClientTest {
@Test
public void testAddComment() throws Exception {
- String taskId = harness.getTaksId4TestProduct();
+ String taskId = harness.getNewTaksId4TestProduct();
TaskData taskDataGet = harness.getTaskFromServer(taskId);
Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
@@ -783,7 +783,7 @@ public class BugzillaRestClientTest {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
public String getSummary() {
- return "The Summary";
+ return "Test CC Attribute";
}
@Override
@@ -831,8 +831,114 @@ public class BugzillaRestClientTest {
}
@Test
+ public void testCreateBlocksAttribute() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+ @Override
+ public String getSummary() {
+ return "Test blocks Attribute";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description";
+ }
+
+ @Override
+ public String getProduct() {
+ return "ManualTest";
+ }
+
+ @Override
+ public String getComponent() {
+ return "ManualC1";
+ }
+
+ @Override
+ public String getVersion() {
+ return "R1";
+ }
+ };
+ String[] taskIdRel = harness.getRelationTasks();
+ AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(actualFixture.repository());
+ TaskData taskData = new TaskData(mapper, actualFixture.repository().getConnectorKind(),
+ actualFixture.repository().getRepositoryUrl(), "");
+ taskDataHandler.initializeTaskData(actualFixture.repository(), taskData, taskMappingInit, null);
+ taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
+ taskData.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
+ .setValue("M2");
+ taskData.getRoot().getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey()).setValue(
+ taskIdRel[0] + ", " + taskIdRel[1]);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskData, null,
+ null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_CREATED));
+ TaskData taskDataUpdate = harness.getTaskFromServer(reposonse.getTaskId());
+ TaskAttribute blocksAttrib = taskDataUpdate.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey());
+ assertEquals(2, blocksAttrib.getValues().size());
+ assertEquals(taskIdRel[0], blocksAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], blocksAttrib.getValues().get(1));
+ }
+
+ @Test
+ public void testCreateDependsOnAttribute() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+ @Override
+ public String getSummary() {
+ return "Test depends_on Attribute";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description";
+ }
+
+ @Override
+ public String getProduct() {
+ return "ManualTest";
+ }
+
+ @Override
+ public String getComponent() {
+ return "ManualC1";
+ }
+
+ @Override
+ public String getVersion() {
+ return "R1";
+ }
+ };
+ String[] taskIdRel = harness.getRelationTasks();
+ AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(actualFixture.repository());
+ TaskData taskData = new TaskData(mapper, actualFixture.repository().getConnectorKind(),
+ actualFixture.repository().getRepositoryUrl(), "");
+ taskDataHandler.initializeTaskData(actualFixture.repository(), taskData, taskMappingInit, null);
+ taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
+ taskData.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
+ .setValue("M2");
+ taskData.getRoot().getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey()).setValue(
+ taskIdRel[0] + ", " + taskIdRel[1]);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskData, null,
+ null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_CREATED));
+ TaskData taskDataUpdate = harness.getTaskFromServer(reposonse.getTaskId());
+ TaskAttribute dependsOnAttrib = taskDataUpdate.getRoot()
+ .getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey());
+ assertEquals(2, dependsOnAttrib.getValues().size());
+ assertEquals(taskIdRel[0], dependsOnAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], dependsOnAttrib.getValues().get(1));
+ }
+
+ @Test
public void testCCAttribute() throws Exception {
- String taskId = harness.getTaksId4TestProduct();
+ String taskId = harness.getNewTaksId4TestProduct();
TaskData taskDataGet = harness.getTaskFromServer(taskId);
Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
@@ -876,4 +982,216 @@ public class BugzillaRestClientTest {
assertEquals(1, ccAttrib.getValues().size());
assertEquals("admin@mylyn.eclipse.org", ccAttrib.getValues().get(0));
}
+
+ @Test
+ public void testBlocksAttributeV1() throws Exception {
+ String taskId = harness.getNewTaksId4TestProduct();
+ String[] taskIdRel = harness.getRelationTasks();
+
+ TaskData taskDataGet = harness.getTaskFromServer(taskId);
+
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(actualFixture.repository());
+ TaskData taskDataOld = new TaskData(mapper, actualFixture.repository().getConnectorKind(),
+ actualFixture.repository().getRepositoryUrl(), "");
+ taskDataHandler.initializeTaskData(actualFixture.repository(), taskDataOld, null, null);
+
+ TaskAttribute attribute = taskDataGet.getRoot()
+ .getAttribute(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey());
+ attribute.setValue(taskIdRel[0] + ", " + taskIdRel[1]);
+ changed.add(taskDataOld.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey()));
+
+ //Act
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
+ changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ TaskData taskDataUpdate = harness.getTaskFromServer(taskId);
+ TaskAttribute blocksAttrib = taskDataUpdate.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey());
+ assertEquals(2, blocksAttrib.getValues().size());
+ assertEquals(taskIdRel[0], blocksAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], blocksAttrib.getValues().get(1));
+ changed.clear();
+ changed.add(taskDataGet.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey()));
+
+ blocksAttrib.setValue(taskIdRel[0] + ", " + taskIdRel[1] + ", " + taskIdRel[2]);
+
+ //Act
+ reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataUpdate, changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ taskDataUpdate = harness.getTaskFromServer(taskId);
+ blocksAttrib = taskDataUpdate.getRoot().getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey());
+ assertEquals(3, blocksAttrib.getValues().size());
+ assertEquals(taskIdRel[0], blocksAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], blocksAttrib.getValues().get(1));
+ assertEquals(taskIdRel[2], blocksAttrib.getValues().get(2));
+ }
+
+ @Test
+ public void testBlocksAttributeV2() throws Exception {
+ String taskId = harness.getNewTaksId4TestProduct();
+ String[] taskIdRel = harness.getRelationTasks();
+
+ TaskData taskDataGet = harness.getTaskFromServer(taskId);
+
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(actualFixture.repository());
+ TaskData taskDataOld = new TaskData(mapper, actualFixture.repository().getConnectorKind(),
+ actualFixture.repository().getRepositoryUrl(), "");
+ taskDataHandler.initializeTaskData(actualFixture.repository(), taskDataOld, null, null);
+
+ TaskAttribute attribute = taskDataGet.getRoot()
+ .getAttribute(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey());
+ attribute.setValue(taskIdRel[0]);
+ attribute.addValue(taskIdRel[1]);
+ changed.add(taskDataOld.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey()));
+
+ //Act
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
+ changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ TaskData taskDataUpdate = harness.getTaskFromServer(taskId);
+ TaskAttribute blocksAttrib = taskDataUpdate.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey());
+ assertEquals(2, blocksAttrib.getValues().size());
+ assertEquals(taskIdRel[0], blocksAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], blocksAttrib.getValues().get(1));
+ changed.clear();
+ changed.add(taskDataGet.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey()));
+
+ blocksAttrib.setValue(taskIdRel[0]);
+ blocksAttrib.addValue(taskIdRel[1]);
+ blocksAttrib.addValue(taskIdRel[2]);
+
+ //Act
+ reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataUpdate, changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ taskDataUpdate = harness.getTaskFromServer(taskId);
+ blocksAttrib = taskDataUpdate.getRoot().getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey());
+ assertEquals(3, blocksAttrib.getValues().size());
+ assertEquals(taskIdRel[0], blocksAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], blocksAttrib.getValues().get(1));
+ assertEquals(taskIdRel[2], blocksAttrib.getValues().get(2));
+ }
+
+ @Test
+ public void testDependsOnAttributeV1() throws Exception {
+ String taskId = harness.getNewTaksId4TestProduct();
+ String[] taskIdRel = harness.getRelationTasks();
+
+ TaskData taskDataGet = harness.getTaskFromServer(taskId);
+
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(actualFixture.repository());
+ TaskData taskDataOld = new TaskData(mapper, actualFixture.repository().getConnectorKind(),
+ actualFixture.repository().getRepositoryUrl(), "");
+ taskDataHandler.initializeTaskData(actualFixture.repository(), taskDataOld, null, null);
+
+ TaskAttribute attribute = taskDataGet.getRoot()
+ .getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey());
+ attribute.setValue(taskIdRel[0] + ", " + taskIdRel[1]);
+ changed.add(taskDataOld.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey()));
+
+ //Act
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
+ changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ TaskData taskDataUpdate = harness.getTaskFromServer(taskId);
+ TaskAttribute dependsOnAttrib = taskDataUpdate.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey());
+ assertEquals(2, dependsOnAttrib.getValues().size());
+ assertEquals(taskIdRel[0], dependsOnAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], dependsOnAttrib.getValues().get(1));
+ changed.clear();
+ changed.add(taskDataGet.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey()));
+
+ dependsOnAttrib.setValue(taskIdRel[0] + ", " + taskIdRel[1] + ", " + taskIdRel[2]);
+
+ //Act
+ reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataUpdate, changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ taskDataUpdate = harness.getTaskFromServer(taskId);
+ dependsOnAttrib = taskDataUpdate.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey());
+ assertEquals(3, dependsOnAttrib.getValues().size());
+ assertEquals(taskIdRel[0], dependsOnAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], dependsOnAttrib.getValues().get(1));
+ assertEquals(taskIdRel[2], dependsOnAttrib.getValues().get(2));
+ }
+
+ @Test
+ public void testDependsOnAttributeV2() throws Exception {
+ String taskId = harness.getNewTaksId4TestProduct();
+ String[] taskIdRel = harness.getRelationTasks();
+
+ TaskData taskDataGet = harness.getTaskFromServer(taskId);
+
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(actualFixture.repository());
+ TaskData taskDataOld = new TaskData(mapper, actualFixture.repository().getConnectorKind(),
+ actualFixture.repository().getRepositoryUrl(), "");
+ taskDataHandler.initializeTaskData(actualFixture.repository(), taskDataOld, null, null);
+
+ TaskAttribute attribute = taskDataGet.getRoot()
+ .getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey());
+ attribute.setValue(taskIdRel[0]);
+ attribute.addValue(taskIdRel[1]);
+ changed.add(taskDataOld.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey()));
+
+ //Act
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
+ changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ TaskData taskDataUpdate = harness.getTaskFromServer(taskId);
+ TaskAttribute dependsOnAttrib = taskDataUpdate.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey());
+ assertEquals(2, dependsOnAttrib.getValues().size());
+ assertEquals(taskIdRel[0], dependsOnAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], dependsOnAttrib.getValues().get(1));
+ changed.clear();
+ changed.add(taskDataGet.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey()));
+
+ dependsOnAttrib.setValue(taskIdRel[0]);
+ dependsOnAttrib.addValue(taskIdRel[1]);
+ dependsOnAttrib.addValue(taskIdRel[2]);
+
+ //Act
+ reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataUpdate, changed, null);
+ assertNotNull(reposonse);
+ assertNotNull(reposonse.getReposonseKind());
+ assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
+ //Assert
+ taskDataUpdate = harness.getTaskFromServer(taskId);
+ dependsOnAttrib = taskDataUpdate.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey());
+ assertEquals(3, dependsOnAttrib.getValues().size());
+ assertEquals(taskIdRel[0], dependsOnAttrib.getValues().get(0));
+ assertEquals(taskIdRel[1], dependsOnAttrib.getValues().get(1));
+ assertEquals(taskIdRel[2], dependsOnAttrib.getValues().get(2));
+ }
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java
index 0c018787b..8057c8cf3 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java
@@ -15,18 +15,26 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConnector;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestCore;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestCreateTaskSchema;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestException;
import org.eclipse.mylyn.internal.bugzilla.rest.core.SingleTaskDataCollector;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.RepositoryResponse.ResponseKind;
@@ -35,6 +43,7 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
public class BugzillaRestHarness {
private final BugzillaRestTestFixture fixture;
@@ -84,7 +93,7 @@ public class BugzillaRestHarness {
return taskDataGet;
}
- public String getTaksId4TestProduct() throws BugzillaRestException, CoreException {
+ public String getNewTaksId4TestProduct() throws BugzillaRestException, CoreException {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
public String getSummary() {
@@ -119,4 +128,88 @@ public class BugzillaRestHarness {
String taskId = submitNewTask(taskData);
return taskId;
}
+
+ public String createTaskWithSummary(final String summary) throws BugzillaRestException, CoreException {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+ @Override
+ public String getSummary() {
+ return summary;
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description";
+ }
+
+ @Override
+ public String getProduct() {
+ return "ManualTest";
+ }
+
+ @Override
+ public String getComponent() {
+ return "ManualC1";
+ }
+
+ @Override
+ public String getVersion() {
+ return "R1";
+ }
+ };
+ TaskData taskData = createTaskData(taskMappingInit, null, null);
+ taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
+ taskData.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
+ .setValue("M1");
+ String taskId = submitNewTask(taskData);
+ return taskId;
+ }
+
+ public String getTaksId4RelationTask1() throws BugzillaRestException, CoreException {
+ return getTaskIdWithSummary("RelationTask1");
+ }
+
+ public String getTaksId4RelationTask2() throws BugzillaRestException, CoreException {
+ return getTaskIdWithSummary("RelationTask2");
+ }
+
+ public String getTaksId4RelationTask3() throws BugzillaRestException, CoreException {
+ return getTaskIdWithSummary("RelationTask3");
+ }
+
+ private String getTaskIdWithSummary(String summary) throws BugzillaRestException, CoreException {
+ String taskID = null;
+ String queryUrlString = repository().getRepositoryUrl() + "/bug?" + "short_desc=" + summary;
+ RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
+ query.setUrl(queryUrlString);
+ final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
+ TaskDataCollector collector = new TaskDataCollector() {
+ @Override
+ public void accept(TaskData taskData) {
+ changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
+ }
+ };
+ connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
+ if (changedTaskData.size() > 0) {
+ Set<Integer> ks = changedTaskData.keySet();
+ SortedSet<Integer> sks = new TreeSet<Integer>(ks);
+ taskID = sks.last().toString();
+ } else {
+ taskID = createTaskWithSummary(summary);
+ }
+ return taskID;
+
+ }
+
+ public String[] getRelationTasks() throws BugzillaRestException, CoreException {
+ List<String> result = new ArrayList<String>(3);
+ result.add(getTaksId4RelationTask1());
+ result.add(getTaksId4RelationTask2());
+ result.add(getTaksId4RelationTask3());
+
+ String[] array = new String[result.size()];
+ array = result.toArray(array);
+ return array;
+ }
+
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData.txt
index 1833e76d0..0cb446e1c 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData.txt
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData.txt
@@ -18,6 +18,8 @@ TaskAttribute[id=root,values=[],options=null,metaData=null]
TaskAttribute[id=target_milestone,values=[],options={---=---, M1=M1, M1.0=M1.0, M2=M2, M2.0=M2.0, M3=M3, M3.0=M3.0},metaData={task.meta.label=Target milestone, task.meta.type=singleSelect, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=true, task.meta.dependson.attribute=task.common.product}]
TaskAttribute[id=task.common.resolution,values=[],options={=, FIXED=FIXED, INVALID=INVALID, WONTFIX=WONTFIX, DUPLICATE=DUPLICATE, WORKSFORME=WORKSFORME},metaData={task.meta.label=Resolution, task.meta.type=singleSelect, task.meta.readOnly=true, task.meta.required=false}]
TaskAttribute[id=task.common.operation,values=[],options=null,metaData={task.meta.label=Operation, task.meta.type=operation, task.meta.readOnly=false, task.meta.required=false}]
+ TaskAttribute[id=depends_on,values=[],options=null,metaData={task.meta.label=Depends on:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
+ TaskAttribute[id=blocks,values=[],options=null,metaData={task.meta.label=Blocks:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
TaskAttribute[id=cf_bugid,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=integer, task.meta.required=false, task.meta.label=bug id custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_datetime,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=dateTime, task.meta.required=false, task.meta.label=date time custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_dropdown,values=[],options={---=---, one=one, three=three, two=two},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=true, task.meta.label=drop down custom field, task.meta.attributeKind=task.common.kind.default}]
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData1.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData1.txt
index 1d246fbbc..de1a57ec3 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData1.txt
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData1.txt
@@ -18,6 +18,8 @@ TaskAttribute[id=root,values=[],options=null,metaData=null]
TaskAttribute[id=target_milestone,values=[],options={---=---, M1=M1, M1.0=M1.0, M2=M2, M2.0=M2.0, M3=M3, M3.0=M3.0},metaData={task.meta.label=Target milestone, task.meta.type=singleSelect, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=true, task.meta.dependson.attribute=task.common.product}]
TaskAttribute[id=task.common.resolution,values=[],options={=, FIXED=FIXED, INVALID=INVALID, WONTFIX=WONTFIX, DUPLICATE=DUPLICATE, WORKSFORME=WORKSFORME},metaData={task.meta.label=Resolution, task.meta.type=singleSelect, task.meta.readOnly=true, task.meta.required=false}]
TaskAttribute[id=task.common.operation,values=[],options=null,metaData={task.meta.label=Operation, task.meta.type=operation, task.meta.readOnly=false, task.meta.required=false}]
+ TaskAttribute[id=depends_on,values=[],options=null,metaData={task.meta.label=Depends on:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
+ TaskAttribute[id=blocks,values=[],options=null,metaData={task.meta.label=Blocks:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
TaskAttribute[id=cf_bugid,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=integer, task.meta.required=false, task.meta.label=bug id custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_datetime,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=dateTime, task.meta.required=false, task.meta.label=date time custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_dropdown,values=[],options={---=---, one=one, three=three, two=two},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=true, task.meta.label=drop down custom field, task.meta.attributeKind=task.common.kind.default}]
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData2.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData2.txt
index 2ab2142ca..b083d231f 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData2.txt
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version1/taskData2.txt
@@ -18,6 +18,8 @@ TaskAttribute[id=root,values=[],options=null,metaData=null]
TaskAttribute[id=target_milestone,values=[---],options={---=---},metaData={task.meta.label=Target milestone, task.meta.type=singleSelect, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=true, task.meta.dependson.attribute=task.common.product}]
TaskAttribute[id=task.common.resolution,values=[],options={=, FIXED=FIXED, INVALID=INVALID, WONTFIX=WONTFIX, DUPLICATE=DUPLICATE, WORKSFORME=WORKSFORME},metaData={task.meta.label=Resolution, task.meta.type=singleSelect, task.meta.readOnly=true, task.meta.required=false}]
TaskAttribute[id=task.common.operation,values=[],options=null,metaData={task.meta.label=Operation, task.meta.type=operation, task.meta.readOnly=false, task.meta.required=false}]
+ TaskAttribute[id=depends_on,values=[],options=null,metaData={task.meta.label=Depends on:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
+ TaskAttribute[id=blocks,values=[],options=null,metaData={task.meta.label=Blocks:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
TaskAttribute[id=cf_bugid,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=integer, task.meta.required=false, task.meta.label=bug id custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_datetime,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=dateTime, task.meta.required=false, task.meta.label=date time custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_dropdown,values=[],options={---=---, one=one, three=three, two=two},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=true, task.meta.label=drop down custom field, task.meta.attributeKind=task.common.kind.default}]
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData.txt
index 1833e76d0..0cb446e1c 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData.txt
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData.txt
@@ -18,6 +18,8 @@ TaskAttribute[id=root,values=[],options=null,metaData=null]
TaskAttribute[id=target_milestone,values=[],options={---=---, M1=M1, M1.0=M1.0, M2=M2, M2.0=M2.0, M3=M3, M3.0=M3.0},metaData={task.meta.label=Target milestone, task.meta.type=singleSelect, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=true, task.meta.dependson.attribute=task.common.product}]
TaskAttribute[id=task.common.resolution,values=[],options={=, FIXED=FIXED, INVALID=INVALID, WONTFIX=WONTFIX, DUPLICATE=DUPLICATE, WORKSFORME=WORKSFORME},metaData={task.meta.label=Resolution, task.meta.type=singleSelect, task.meta.readOnly=true, task.meta.required=false}]
TaskAttribute[id=task.common.operation,values=[],options=null,metaData={task.meta.label=Operation, task.meta.type=operation, task.meta.readOnly=false, task.meta.required=false}]
+ TaskAttribute[id=depends_on,values=[],options=null,metaData={task.meta.label=Depends on:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
+ TaskAttribute[id=blocks,values=[],options=null,metaData={task.meta.label=Blocks:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
TaskAttribute[id=cf_bugid,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=integer, task.meta.required=false, task.meta.label=bug id custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_datetime,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=dateTime, task.meta.required=false, task.meta.label=date time custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_dropdown,values=[],options={---=---, one=one, three=three, two=two},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=true, task.meta.label=drop down custom field, task.meta.attributeKind=task.common.kind.default}]
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData1.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData1.txt
index 1d246fbbc..de1a57ec3 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData1.txt
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData1.txt
@@ -18,6 +18,8 @@ TaskAttribute[id=root,values=[],options=null,metaData=null]
TaskAttribute[id=target_milestone,values=[],options={---=---, M1=M1, M1.0=M1.0, M2=M2, M2.0=M2.0, M3=M3, M3.0=M3.0},metaData={task.meta.label=Target milestone, task.meta.type=singleSelect, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=true, task.meta.dependson.attribute=task.common.product}]
TaskAttribute[id=task.common.resolution,values=[],options={=, FIXED=FIXED, INVALID=INVALID, WONTFIX=WONTFIX, DUPLICATE=DUPLICATE, WORKSFORME=WORKSFORME},metaData={task.meta.label=Resolution, task.meta.type=singleSelect, task.meta.readOnly=true, task.meta.required=false}]
TaskAttribute[id=task.common.operation,values=[],options=null,metaData={task.meta.label=Operation, task.meta.type=operation, task.meta.readOnly=false, task.meta.required=false}]
+ TaskAttribute[id=depends_on,values=[],options=null,metaData={task.meta.label=Depends on:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
+ TaskAttribute[id=blocks,values=[],options=null,metaData={task.meta.label=Blocks:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
TaskAttribute[id=cf_bugid,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=integer, task.meta.required=false, task.meta.label=bug id custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_datetime,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=dateTime, task.meta.required=false, task.meta.label=date time custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_dropdown,values=[],options={---=---, one=one, three=three, two=two},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=true, task.meta.label=drop down custom field, task.meta.attributeKind=task.common.kind.default}]
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData2.txt b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData2.txt
index 2ab2142ca..b083d231f 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData2.txt
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/Version2/taskData2.txt
@@ -18,6 +18,8 @@ TaskAttribute[id=root,values=[],options=null,metaData=null]
TaskAttribute[id=target_milestone,values=[---],options={---=---},metaData={task.meta.label=Target milestone, task.meta.type=singleSelect, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=true, task.meta.dependson.attribute=task.common.product}]
TaskAttribute[id=task.common.resolution,values=[],options={=, FIXED=FIXED, INVALID=INVALID, WONTFIX=WONTFIX, DUPLICATE=DUPLICATE, WORKSFORME=WORKSFORME},metaData={task.meta.label=Resolution, task.meta.type=singleSelect, task.meta.readOnly=true, task.meta.required=false}]
TaskAttribute[id=task.common.operation,values=[],options=null,metaData={task.meta.label=Operation, task.meta.type=operation, task.meta.readOnly=false, task.meta.required=false}]
+ TaskAttribute[id=depends_on,values=[],options=null,metaData={task.meta.label=Depends on:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
+ TaskAttribute[id=blocks,values=[],options=null,metaData={task.meta.label=Blocks:, task.meta.type=taskDepenedency, task.meta.readOnly=false, task.meta.attributeKind=task.common.kind.default, task.meta.required=false}]
TaskAttribute[id=cf_bugid,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=integer, task.meta.required=false, task.meta.label=bug id custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_datetime,values=[],options=null,metaData={task.meta.readOnly=false, task.meta.type=dateTime, task.meta.required=false, task.meta.label=date time custom field, task.meta.attributeKind=task.common.kind.default}]
TaskAttribute[id=cf_dropdown,values=[],options={---=---, one=one, three=three, two=two},metaData={task.meta.readOnly=false, task.meta.type=singleSelect, task.meta.required=true, task.meta.label=drop down custom field, task.meta.attributeKind=task.common.kind.default}]
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
index e4d09a9f8..581429404 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
@@ -160,7 +160,10 @@ public class BugzillaRestConfiguration implements Serializable {
}
}
if (attribute.getValue().isEmpty()) {
- attribute.setValue(getValueFromParameter(key));
+ String newValue = getValueFromParameter(key);
+ if (newValue != null) {
+ attribute.setValue(getValueFromParameter(key));
+ }
}
}
@@ -261,7 +264,12 @@ public class BugzillaRestConfiguration implements Serializable {
resultString = "bug_severity";
} else if (taskAttributeKey.equals("comment")) {
resultString = "longdesc";
+ } else if (taskAttributeKey.equals("blocks")) {
+ resultString = "blocked";
+ } else if (taskAttributeKey.equals("depends_on")) {
+ resultString = "dependson";
} else {
+
resultString = taskAttributeKey;
}
return resultString;
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java
index 00fc243ae..17d84c4d8 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestCreateTaskSchema.java
@@ -94,4 +94,9 @@ public class BugzillaRestCreateTaskSchema extends AbstractTaskSchema {
public final Field RESOLUTION = inheritFrom(parent.RESOLUTION).create();
public final Field OPERATION = createField(TaskAttribute.OPERATION, "Operation", TaskAttribute.TYPE_OPERATION);
+
+ public final Field DEPENDS_ON = createField("depends_on", "Depends on:", TaskAttribute.TYPE_TASK_DEPENDENCY,
+ Flag.ATTRIBUTE);
+
+ public final Field BLOCKS = createField("blocks", "Blocks:", TaskAttribute.TYPE_TASK_DEPENDENCY, Flag.ATTRIBUTE);
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
index b2927a800..6d6b0459e 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
@@ -11,10 +11,14 @@
package org.eclipse.mylyn.internal.bugzilla.rest.core;
+import static com.google.common.collect.Sets.newHashSet;
+
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;
@@ -47,6 +51,32 @@ public class BugzillaRestGsonUtil {
}
}
+ private class RemoveAddIntegerHelper {
+ Set<Integer> add;
+
+ Set<Integer> remove;
+
+ public RemoveAddIntegerHelper(Set<Integer> removeSet, Set<Integer> addSet) {
+ add = new HashSet<Integer>(addSet);
+ remove = new HashSet<Integer>(removeSet);
+ if (remove.contains(null)) {
+ remove.remove(null);
+ }
+ if (add.contains(null)) {
+ add.remove(null);
+ }
+ Set<Integer> intersection = Sets.intersection(addSet, removeSet);
+ remove.removeAll(intersection);
+ add.removeAll(intersection);
+ if (remove.isEmpty()) {
+ remove = null;
+ }
+ if (add.isEmpty()) {
+ add = null;
+ }
+ }
+ }
+
private static Gson gson = new Gson();
public static String convertString2GSonString(String str) {
@@ -77,11 +107,18 @@ public class BugzillaRestGsonUtil {
return instance;
}
- public static void buildArrayFromHash(JsonWriter out, String id, Set<String> setNew) throws IOException {
+ public static void buildArrayFromHash(JsonWriter out, String id, Set<String> setNew, boolean asInteger)
+ throws IOException {
if (!setNew.isEmpty()) {
out.name(id).beginArray();
for (String string : setNew) {
- out.value(string);
+ if (!"".equals(string)) {
+ if (asInteger) {
+ out.value(Integer.parseInt(string));
+ } else {
+ out.value(string);
+ }
+ }
}
out.endArray();
}
@@ -93,4 +130,25 @@ public class BugzillaRestGsonUtil {
out.name(id);
gson.toJson(test, RemoveAddStringHelper.class, out);
}
+
+ private final Function<String, Integer> convert2Integer = new Function<String, Integer>() {
+
+ @Override
+ public Integer apply(String input) {
+ if ("".equals(input)) {
+ return null;
+ }
+ return Integer.parseInt(input);
+ }
+ };
+
+ public void buildAddRemoveIntegerHash(JsonWriter out, String id, Set<String> setOld, Set<String> setNew)
+ throws IOException {
+ RemoveAddIntegerHelper test = new RemoveAddIntegerHelper(
+ newHashSet(Iterables.transform(setOld, convert2Integer)),
+ newHashSet(Iterables.transform(setNew, convert2Integer)));
+ out.name(id);
+ gson.toJson(test, RemoveAddIntegerHelper.class, out);
+ }
+
} \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java
index aaed696b7..8706c8c45 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java
@@ -84,7 +84,19 @@ public class BugzillaRestPostNewTask extends BugzillaRestAuthenticatedPostReques
if (id.equals("cc")) { //$NON-NLS-1$
HashSet<String> setNew = new HashSet<String>(
Arrays.asList(taskAttribute.getValue().split("\\s*,\\s*"))); //$NON-NLS-1$
- BugzillaRestGsonUtil.buildArrayFromHash(out, id, setNew);
+ BugzillaRestGsonUtil.buildArrayFromHash(out, id, setNew, false);
+ continue;
+ }
+ if (id.equals(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey())
+ || id.equals(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey())) {
+ if (taskAttribute.getValues().size() > 1) {
+ HashSet<String> setNew = new HashSet<String>(taskAttribute.getValues());
+ BugzillaRestGsonUtil.buildArrayFromHash(out, id, setNew, true);
+ } else {
+ HashSet<String> setNew = new HashSet<String>(
+ Arrays.asList(taskAttribute.getValue().split("\\s*,\\s*"))); //$NON-NLS-1$
+ BugzillaRestGsonUtil.buildArrayFromHash(out, id, setNew, true);
+ }
continue;
}
@@ -178,6 +190,8 @@ public class BugzillaRestPostNewTask extends BugzillaRestAuthenticatedPostReques
.add(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.add(TaskAttribute.OPERATION)
.add(BugzillaRestCreateTaskSchema.getDefault().CC.getKey())
+ .add(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey())
+ .add(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey())
.build();
@Override
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
index a3e5d1a02..4dbd9a834 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
@@ -76,6 +76,8 @@ public class BugzillaRestPutUpdateTask extends BugzillaRestAuthenticatedPutReque
.add("resolutionInput") //$NON-NLS-1$
.add(BugzillaRestTaskSchema.getDefault().RESOLUTION.getKey())
.add(BugzillaRestTaskSchema.getDefault().DUPE_OF.getKey())
+ .add(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey())
+ .add(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey())
.build();
class TaskAttributeTypeAdapter extends TypeAdapter<OldAttributes> {
@@ -133,6 +135,24 @@ public class BugzillaRestPutUpdateTask extends BugzillaRestAuthenticatedPutReque
out.endObject();
continue;
}
+ if (id.equals(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey())
+ || id.equals(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey())) {
+ Set<String> setOld;
+ if (element.getValues().size() > 1) {
+ setOld = new HashSet<String>(element.getValues());
+ } else {
+ setOld = new HashSet<String>(Arrays.asList(element.getValue().split("\\s*,\\s*")));
+ }
+ Set<String> setNew;
+ if (taskAttribute.getValues().size() > 1) {
+ setNew = new HashSet<String>(taskAttribute.getValues());
+ } else {
+ setNew = new HashSet<String>(Arrays.asList(taskAttribute.getValue().split("\\s*,\\s*")));
+ }
+ BugzillaRestGsonUtil.getDefault().buildAddRemoveIntegerHash(out, id, setOld, setNew);
+ continue;
+ }
+
out.name(id).value(value);
if (id.equals("description")) { //$NON-NLS-1$
TaskAttribute descriptionpri = taskAttribute
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
index b0aefe9b0..a4f644752 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
@@ -136,6 +136,11 @@ public class BugzillaRestTaskSchema extends AbstractTaskSchema {
public final Field DUPE_OF = createField("dupe_of", "Dup", TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID);
+ public final Field DEPENDS_ON = createField("depends_on", "Depends on:", TaskAttribute.TYPE_TASK_DEPENDENCY,
+ Flag.ATTRIBUTE);
+
+ public final Field BLOCKS = createField("blocks", "Blocks:", TaskAttribute.TYPE_TASK_DEPENDENCY, Flag.ATTRIBUTE);
+
@Override
public void initialize(TaskData taskData) {
for (Field field : getFields()) {

Back to the top