summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2013-08-23 11:28:44 (EDT)
committer Gerrit Code Review @ Eclipse.org2013-08-23 12:39:08 (EDT)
commiteca01884c8c6ecbaf2d3104d896cac846f0ef256 (patch)
treea64eec1fa9fa98ba6a21057bbcee64819efedf4b
parente7fe0a9a130215f70da651ace0d21640d9a93e25 (diff)
downloadorg.eclipse.mylyn.tasks-eca01884c8c6ecbaf2d3104d896cac846f0ef256.zip
org.eclipse.mylyn.tasks-eca01884c8c6ecbaf2d3104d896cac846f0ef256.tar.gz
org.eclipse.mylyn.tasks-eca01884c8c6ecbaf2d3104d896cac846f0ef256.tar.bz2
415263: NPE initializing Bugzilla 4.x task data with product absent fromrefs/changes/15/15815/2
local configuration -- tests Change-Id: I75b669a155b7e0f8536c93a3365807061d206fe5 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=415263 Signed-off-by: Tomasz Zarna <tomasz.zarna@tasktop.com>
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/RepositoryConfigurationTest.java52
3 files changed, 57 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
index 000f1c1..c06f7bb 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import org.apache.commons.lang.BooleanUtils;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_REPORT_STATUS;
@@ -1270,8 +1271,8 @@ public class RepositoryConfiguration implements Serializable {
public boolean getUnconfirmedAllowed(String product) {
ProductEntry entry = products.get(product);
- if (entry != null && entry.getUnconfirmedAllowed() != null) {
- return entry.getUnconfirmedAllowed().booleanValue();
+ if (entry != null) {
+ return BooleanUtils.toBoolean(entry.getUnconfirmedAllowed());
} else {
return false;
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java
index e581fa1..23ab85a 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java
@@ -27,6 +27,7 @@ import org.eclipse.mylyn.bugzilla.tests.core.BugzillaRepositoryConnectorConfigur
import org.eclipse.mylyn.bugzilla.tests.core.BugzillaRepositoryConnectorStandaloneTest;
import org.eclipse.mylyn.bugzilla.tests.core.BugzillaTaskCompletionTest;
import org.eclipse.mylyn.bugzilla.tests.core.BugzillaVersionTest;
+import org.eclipse.mylyn.bugzilla.tests.core.RepositoryConfigurationTest;
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion;
@@ -49,6 +50,7 @@ public class AllBugzillaHeadlessStandaloneTests {
suite.addTestSuite(BugzillaDateTimeTests.class);
suite.addTestSuite(BugzillaAttributeMapperTest.class);
suite.addTestSuite(BugzillaAttributeTest.class);
+ suite.addTestSuite(RepositoryConfigurationTest.class);
if (!configuration.isLocalOnly()) {
// network tests
suite.addTestSuite(BugzillaTaskCompletionTest.class);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/RepositoryConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/RepositoryConfigurationTest.java
new file mode 100644
index 0000000..f2404c1
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/RepositoryConfigurationTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
+
+public class RepositoryConfigurationTest extends TestCase {
+
+ private final static String PRODUCT = "product";
+
+ RepositoryConfiguration cfg;
+
+ @Override
+ protected void setUp() throws Exception {
+ cfg = new RepositoryConfiguration();
+ cfg.addProduct(PRODUCT);
+ }
+
+ public void testGetUnconfirmedAllowed_product() throws Exception {
+ assertFalse(cfg.getUnconfirmedAllowed(PRODUCT));
+ }
+
+ public void testGetUnconfirmedAllowed_productFalse() throws Exception {
+ cfg.addUnconfirmedAllowed(PRODUCT, Boolean.FALSE);
+ assertFalse(cfg.getUnconfirmedAllowed(PRODUCT));
+ }
+
+ public void testGetUnconfirmedAllowed_productNull() throws Exception {
+ cfg.addUnconfirmedAllowed(PRODUCT, null);
+ assertFalse(cfg.getUnconfirmedAllowed(PRODUCT));
+ }
+
+ public void testGetUnconfirmedAllowed_productTrue() throws Exception {
+ cfg.addUnconfirmedAllowed(PRODUCT, Boolean.TRUE);
+ assertTrue(cfg.getUnconfirmedAllowed(PRODUCT));
+ }
+
+ public void testGetUnconfirmedAllowed_noProduct() throws Exception {
+ assertFalse(cfg.getUnconfirmedAllowed("no-product"));
+ }
+}