Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2008-11-10 17:49:20 +0000
committerrelves2008-11-10 17:49:20 +0000
commit15a481550d004807b24305ca7b06f6808bdadda3 (patch)
treed16509526ff1b7fc15dd1c708d6afacf64a2e2b4 /org.eclipse.mylyn.bugzilla.tests
parenta1b21103248da282b71619b1d7eb5d598a00cabb (diff)
downloadorg.eclipse.mylyn.tasks-15a481550d004807b24305ca7b06f6808bdadda3.tar.gz
org.eclipse.mylyn.tasks-15a481550d004807b24305ca7b06f6808bdadda3.tar.xz
org.eclipse.mylyn.tasks-15a481550d004807b24305ca7b06f6808bdadda3.zip
ASSIGNED - bug 254697: [patch] unit test custom attribute support
https://bugs.eclipse.org/bugs/show_bug.cgi?id=254697
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java1
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java139
2 files changed, 140 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java
index ba9f068fb..4c5a25122 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java
@@ -42,6 +42,7 @@ public class AllBugzillaTests {
suite.addTestSuite(BugzillaProductParserTest.class);
suite.addTestSuite(BugzillaSearchDialogTest.class);
suite.addTestSuite(BugzillaTaskHistoryTest.class);
+ suite.addTestSuite(BugzillaRepository32Test.class);
// $JUnit-END$
return suite;
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java
new file mode 100644
index 000000000..995084341
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskMapper;
+
+public class BugzillaRepository32Test extends AbstractBugzillaTest {
+
+ public void testCustomAttributes() throws Exception {
+ init32();
+ String taskNumber = "1";
+ ITask task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ TaskData taskData = TasksUiPlugin.getTaskDataManager().getTaskData(task);
+ assertNotNull(taskData);
+ TaskMapper mapper = new TaskMapper(taskData);
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+ assertEquals(taskNumber, taskData.getTaskId());
+
+ SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ assertEquals(format1.parse("2008-10-04 15:01"), mapper.getCreationDate());
+
+ AuthenticationCredentials credentials = repository.getCredentials(AuthenticationType.REPOSITORY);
+ assertNotNull("credentials are null", credentials);
+ assertNotNull("Repositor User not set", credentials.getUserName());
+ assertNotNull("no password for Repository", credentials.getPassword());
+
+ TaskAttribute colorAttribute = mapper.getTaskData().getRoot().getAttribute("cf_colors");
+ assertNotNull("TaskAttribute Color did not exists", colorAttribute);
+ List<String> theColors = colorAttribute.getValues();
+ assertNotNull(theColors);
+ assertFalse("no colors set", theColors.isEmpty());
+
+ boolean red = false;
+ boolean green = false;
+ boolean yellow = false;
+ boolean blue = false;
+
+ for (Object element : theColors) {
+ String string = (String) element;
+
+ if (!red && string.compareTo("Red") == 0) {
+ red = true;
+ } else if (!green && string.compareTo("Green") == 0) {
+ green = true;
+ } else if (!yellow && string.compareTo("Yellow") == 0) {
+ yellow = true;
+ } else if (!blue && string.compareTo("Blue") == 0) {
+ blue = true;
+ }
+ }
+ changeCollorAndSubmit(task, taskData, colorAttribute, red, green, yellow, blue);
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+ TasksUiInternal.synchronizeTask(connector, task, true, null);
+ TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
+ assertNotNull(task);
+ taskData = TasksUiPlugin.getTaskDataManager().getTaskData(task);
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+
+ colorAttribute = mapper.getTaskData().getRoot().getAttribute("cf_colors");
+ assertNotNull("TaskAttribute Color did not exists", colorAttribute);
+ theColors = colorAttribute.getValues();
+ assertNotNull(theColors);
+ assertFalse("no colors set", theColors.isEmpty());
+ boolean red_new = false;
+ boolean green_new = false;
+ boolean yellow_new = false;
+ boolean blue_new = false;
+
+ for (Object element : theColors) {
+ String string = (String) element;
+
+ if (!red_new && string.compareTo("Red") == 0) {
+ red_new = true;
+ } else if (!green_new && string.compareTo("Green") == 0) {
+ green_new = true;
+ } else if (!yellow_new && string.compareTo("Yellow") == 0) {
+ yellow_new = true;
+ } else if (!blue_new && string.compareTo("Blue") == 0) {
+ blue_new = true;
+ }
+ }
+ assertTrue("wrong change",
+ (!red && green && !yellow && !blue && red_new && green_new && !yellow_new && !blue_new)
+ || (red && green && !yellow && !blue && !red_new && green_new && !yellow_new && !blue_new));
+ changeCollorAndSubmit(task, taskData, colorAttribute, red_new, green_new, yellow_new, blue_new);
+ assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
+
+ }
+
+ private void changeCollorAndSubmit(ITask task, TaskData taskData, TaskAttribute colorAttribute, boolean red,
+ boolean green, boolean yellow, boolean blue) throws CoreException {
+ if (!red && green && !yellow && !blue) {
+ List<String> newValue = new ArrayList<String>(2);
+ newValue.add("Red");
+ newValue.add("Green");
+ colorAttribute.setValues(newValue);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ changed.add(colorAttribute);
+ // Submit changes
+ submit(task, taskData, changed);
+ } else if (red && green && !yellow && !blue) {
+ List<String> newValue = new ArrayList<String>(2);
+ newValue.add("Green");
+ colorAttribute.setValues(newValue);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ changed.add(colorAttribute);
+ // Submit changes
+ submit(task, taskData, changed);
+ }
+
+ }
+}

Back to the top