diff options
author | Frank Becker | 2012-05-23 18:08:45 +0000 |
---|---|---|
committer | Frank Becker | 2012-05-24 18:48:20 +0000 |
commit | fe4d9a54c723e0334b28a0af6ab68da1907a5bf2 (patch) | |
tree | c8de8659aad00d0c43e3cbf6542b6449386ad6dc | |
parent | 579b730e415b28a00596365d3bd6b759a84f9ef4 (diff) | |
download | org.eclipse.mylyn.tasks-fe4d9a54c723e0334b28a0af6ab68da1907a5bf2.tar.gz org.eclipse.mylyn.tasks-fe4d9a54c723e0334b28a0af6ab68da1907a5bf2.tar.xz org.eclipse.mylyn.tasks-fe4d9a54c723e0334b28a0af6ab68da1907a5bf2.zip |
ASSIGNED - bug 358682: Target Milestone no longer appears when creating
a bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=358682
Change-Id: Id11e04b113a2bc93bf8f86bca412e6a3d545f48e
3 files changed, 46 insertions, 5 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java index 200d3cc70..9762f0bfa 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java @@ -588,8 +588,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler { } TaskRepository taskRepository = taskData.getAttributeMapper().getTaskRepository(); - String useParam = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE); - if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$ + if (BugzillaUtil.getTaskPropertyWithDefaultTrue(taskRepository, IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE)) { optionValues = repositoryConfiguration.getTargetMilestones(productAttribute.getValue()); if (optionValues.size() > 0) { TaskAttribute attributeTargetMilestone = createAttribute(taskData, BugzillaAttribute.TARGET_MILESTONE); @@ -651,8 +650,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler { TaskAttribute attributeAssignedTo = createAttribute(taskData, BugzillaAttribute.ASSIGNED_TO); attributeAssignedTo.setValue(""); //$NON-NLS-1$ - useParam = taskRepository.getProperty(IBugzillaConstants.BUGZILLA_PARAM_USEQACONTACT); - if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$ + if (BugzillaUtil.getTaskPropertyWithDefaultTrue(taskRepository, IBugzillaConstants.BUGZILLA_PARAM_USEQACONTACT)) { TaskAttribute attributeQAContact = createAttribute(taskData, BugzillaAttribute.QA_CONTACT); attributeQAContact.setValue(""); //$NON-NLS-1$ } diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUtil.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUtil.java index bf6073189..b746a68c7 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUtil.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUtil.java @@ -53,4 +53,16 @@ public class BugzillaUtil { } } } + + /** + * Call this method if you did not know if an property exists + * + * @param taskRepository + * @param property + * @return true if the property is undefined or if the property is true + */ + public static boolean getTaskPropertyWithDefaultTrue(TaskRepository taskRepository, String property) { + String useParam = taskRepository.getProperty(property); + return (useParam == null || (useParam != null && useParam.equals("true"))); //$NON-NLS-1$ + } } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java index e976c2dfb..06381dbb3 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java @@ -14,8 +14,11 @@ package org.eclipse.mylyn.bugzilla.tests; import junit.framework.TestCase; import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture; +import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector; +import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; import org.eclipse.mylyn.internal.tasks.core.DefaultTaskMapping; import org.eclipse.mylyn.tasks.core.ITaskMapping; import org.eclipse.mylyn.tasks.core.TaskMapping; @@ -24,7 +27,6 @@ import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler; import org.eclipse.mylyn.tasks.core.data.TaskAttribute; import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper; import org.eclipse.mylyn.tasks.core.data.TaskData; -import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel; /** * @author Frank Becker @@ -36,9 +38,12 @@ public class BugzillaTaskDataHandlerTest extends TestCase { private BugzillaRepositoryConnector connector; + private BugzillaClient client; + @Override public void setUp() throws Exception { repository = BugzillaFixture.current().repository(); + client = BugzillaFixture.current().client(); connector = BugzillaFixture.current().connector(); } @@ -95,4 +100,30 @@ public class BugzillaTaskDataHandlerTest extends TestCase { assertTrue(taskDataHandler.initializeTaskData(repository, taskData, taskMappingSelect, null)); } + public void testPropertyTargetMilestoneUndefined() throws Exception { + AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler(); + repository.removeProperty(IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE); + TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository); + TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), ""); + assertTrue(taskDataHandler.initializeTaskData(repository, taskData, null, null)); + assertNotNull(taskData.getRoot().getAttribute(BugzillaAttribute.TARGET_MILESTONE.getKey())); + } + + public void testPropertyTargetMilestoneTrue() throws Exception { + AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler(); + repository.setProperty(IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE, Boolean.TRUE.toString()); + TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository); + TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), ""); + assertTrue(taskDataHandler.initializeTaskData(repository, taskData, null, null)); + assertNotNull(taskData.getRoot().getAttribute(BugzillaAttribute.TARGET_MILESTONE.getKey())); + } + + public void testPropertyTargetMilestoneFalse() throws Exception { + AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler(); + repository.setProperty(IBugzillaConstants.BUGZILLA_PARAM_USETARGETMILESTONE, Boolean.FALSE.toString()); + TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository); + TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), ""); + assertTrue(taskDataHandler.initializeTaskData(repository, taskData, null, null)); + assertNull(taskData.getRoot().getAttribute(BugzillaAttribute.TARGET_MILESTONE.getKey())); + } } |