From eca01884c8c6ecbaf2d3104d896cac846f0ef256 Mon Sep 17 00:00:00 2001 From: Tomasz Zarna Date: Fri, 23 Aug 2013 17:28:44 +0200 Subject: 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 --- .../tests/AllBugzillaHeadlessStandaloneTests.java | 2 + .../tests/core/RepositoryConfigurationTest.java | 52 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/RepositoryConfigurationTest.java (limited to 'org.eclipse.mylyn.bugzilla.tests') 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")); + } +} -- cgit v1.2.3