Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java5
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/TaskAttributeTest.java85
3 files changed, 91 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
index 5a01c9d38..a923d6573 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
@@ -573,6 +573,8 @@ public final class TaskAttribute {
}
public void setValues(List<String> values) {
+ Assert.isNotNull(values);
+ Assert.isTrue(!values.contains(null));
this.values.clear();
this.values.addAll(values);
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
index 04c48f1ce..ea22db338 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2012 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
@@ -24,6 +24,7 @@ import org.eclipse.mylyn.tasks.tests.core.TaskListUnmatchedContainerTest;
import org.eclipse.mylyn.tasks.tests.core.TaskRepositoryLocationTest;
import org.eclipse.mylyn.tasks.tests.core.TaskRepositoryTest;
import org.eclipse.mylyn.tasks.tests.data.TaskAttributeMapperTest;
+import org.eclipse.mylyn.tasks.tests.data.TaskAttributeTest;
import org.eclipse.mylyn.tasks.tests.data.TaskDataExternalizerTest;
import org.eclipse.mylyn.tasks.tests.data.Xml11InputStreamTest;
import org.eclipse.mylyn.tasks.tests.ui.AbstractRepositoryConnectorUiTest;
@@ -46,6 +47,7 @@ import org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest;
* @author Mik Kersten
* @author Shawn Minto
* @author Steffen Pingel
+ * @author Benjamin Muskalla
*/
public class AllTasksTests {
@@ -132,6 +134,7 @@ public class AllTasksTests {
suite.addTestSuite(RepositoryClientManagerTest.class);
suite.addTestSuite(AbstractRepositoryConnectorUiTest.class);
suite.addTestSuite(SynchronizeTasksJobTest.class);
+ suite.addTestSuite(TaskAttributeTest.class);
return suite;
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/TaskAttributeTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/TaskAttributeTest.java
new file mode 100644
index 000000000..b9a3a0a2e
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/TaskAttributeTest.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.tasks.tests.data;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+
+/**
+ * @author Benjamin Muskalla
+ */
+public class TaskAttributeTest extends TestCase {
+
+ private TaskAttribute attribute;
+
+ @Override
+ protected void setUp() throws Exception {
+ TaskRepository taskRepository = new TaskRepository("kind", "repository");
+ TaskAttributeMapper mapper = new TaskAttributeMapper(taskRepository);
+ TaskData data = new TaskData(mapper, "kind", "repository", "id");
+ attribute = new TaskAttribute(data.getRoot(), "test");
+ }
+
+ public void testRegularValue() throws Exception {
+ attribute.setValue("foo");
+ assertEquals("foo", attribute.getValue());
+ }
+
+ public void testRegularValues() throws Exception {
+ attribute.setValues(Collections.singletonList("foo"));
+ assertEquals("foo", attribute.getValue());
+ }
+
+ public void testNullValue() throws Exception {
+ try {
+ attribute.setValue(null);
+ fail("Should refuse null");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testNullAsValues() throws Exception {
+ try {
+ attribute.setValues(null);
+ fail("Should refuse null");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testNullAsList() throws Exception {
+ try {
+ attribute.setValues(Collections.<String> singletonList(null));
+ fail("Should refuse null");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testNullInsideValuesList() throws Exception {
+ try {
+ attribute.setValues(Arrays.asList("foo", null, "bar"));
+ fail("Should refuse null");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+}

Back to the top