diff options
author | Tomasz Zarna | 2013-08-23 15:28:44 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-08-23 16:39:08 +0000 |
commit | eca01884c8c6ecbaf2d3104d896cac846f0ef256 (patch) | |
tree | a64eec1fa9fa98ba6a21057bbcee64819efedf4b | |
parent | e7fe0a9a130215f70da651ace0d21640d9a93e25 (diff) | |
download | org.eclipse.mylyn.tasks-eca01884c8c6ecbaf2d3104d896cac846f0ef256.tar.gz org.eclipse.mylyn.tasks-eca01884c8c6ecbaf2d3104d896cac846f0ef256.tar.xz org.eclipse.mylyn.tasks-eca01884c8c6ecbaf2d3104d896cac846f0ef256.zip |
415263: NPE initializing Bugzilla 4.x task data with product absent from
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>
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 000f1c1b7..c06f7bb9b 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 e581fa1c7..23ab85a31 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 000000000..f2404c129 --- /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")); + } +} |