Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2013-05-31 16:49:27 -0400
committerGerrit Code Review @ Eclipse.org2013-07-28 15:55:11 -0400
commit193f49befd63eff68d49c7ff31b3a3ab3b5bb203 (patch)
tree7ecf0400abb4e1fa28540bb4cdd8fe16f363abc2 /org.eclipse.mylyn.bugzilla.tests/src
parentf858973866ead9bea8e74f5c02c933015acc9275 (diff)
downloadorg.eclipse.mylyn.tasks-193f49befd63eff68d49c7ff31b3a3ab3b5bb203.tar.gz
org.eclipse.mylyn.tasks-193f49befd63eff68d49c7ff31b3a3ab3b5bb203.tar.xz
org.eclipse.mylyn.tasks-193f49befd63eff68d49c7ff31b3a3ab3b5bb203.zip
13458: 409634: cleanup of BugzillaHarness [Ifc8bff4b]
Change-Id: Ifc8bff4b3d5a0acc88233cff00b8f5f687dd15a6 Task-Url: https://git.eclipse.org/r/#/c/13458/
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests/src')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java361
5 files changed, 149 insertions, 232 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
index dd15e88ec..c1b07311d 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
@@ -58,7 +58,6 @@ public abstract class AbstractBugzillaTest extends TestCase {
public AbstractBugzillaTest() {
super();
- harness = new BugzillaHarness(this);
}
@Override
@@ -73,6 +72,7 @@ public abstract class AbstractBugzillaTest extends TestCase {
this.connector = BugzillaFixture.current().connector();
this.repository = BugzillaFixture.current().repository();
TasksUi.getRepositoryManager().addRepository(repository);
+ harness = BugzillaFixture.current().createHarness();
}
@Override
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
index 4e927728f..ebe30b209 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
@@ -51,16 +51,6 @@ import org.eclipse.mylyn.tasks.ui.TasksUi;
*/
public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest {
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
@SuppressWarnings("null")
public void testUpdateAttachmentFlags() throws Exception {
TaskData taskData = BugzillaFixture.current().createTask(PrivilegeLevel.USER, "update of Attachment Flags",
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java
index 572f4c7d6..1f9dd3f78 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java
@@ -26,6 +26,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.mylyn.bugzilla.tests.AbstractBugzillaTest;
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaHarness;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.WebLocation;
import org.eclipse.mylyn.internal.bugzilla.core.AbstractBugzillaOperation;
@@ -304,9 +305,12 @@ public class BugzillaXmlRpcClientTest extends AbstractBugzillaTest {
}
};
+ private BugzillaHarness harness;
+
@Override
public void setUp() throws Exception {
super.setUp();
+ harness = BugzillaFixture.current().createHarness();
WebLocation webLocation = new WebLocation(BugzillaFixture.current().getRepositoryUrl() + "/xmlrpc.cgi");
webLocation.setCredentials(AuthenticationType.REPOSITORY, "tests@mylyn.eclipse.org", "mylyntest");
bugzillaClient = new BugzillaXmlRpcClient(webLocation, client);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
index e4544b8db..77d136958 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
@@ -290,4 +290,8 @@ public class BugzillaFixture extends TestFixture {
return getProperty("desciptorfile");
}
+ public BugzillaHarness createHarness() {
+ return new BugzillaHarness(this);
+ }
+
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java
index e5efca926..db5a8f191 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java
@@ -18,51 +18,105 @@ import static org.junit.Assert.fail;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.bugzilla.tests.AbstractBugzillaTest;
+import org.eclipse.core.runtime.Status;
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.BugzillaTaskDataHandler;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.data.FileTaskAttachmentSource;
-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.RepositoryResponse.ResponseKind;
import org.eclipse.mylyn.tasks.core.TaskMapping;
-import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
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.tasks.core.data.TaskDataCollector;
-import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
public class BugzillaHarness {
- AbstractBugzillaTest abstractBugzillaTest;
+ private final BugzillaFixture fixture;
- public BugzillaHarness(AbstractBugzillaTest abstractBugzillaTest) {
- this.abstractBugzillaTest = abstractBugzillaTest;
+ private TaskRepository repository;
+
+ private BugzillaClient priviledgedClient;
+
+ public BugzillaRepositoryConnector connector() {
+ return fixture.connector();
+ }
+
+ public TaskRepository repository() {
+ if (repository == null) {
+ repository = fixture.singleRepository();
+ }
+ return repository;
+ }
+
+ public ITask getTask(String taskId) throws Exception {
+ TaskRepository repository = repository();
+ TaskData taskData = fixture.connector().getTaskData(repository, taskId, null);
+ ITask task = TasksUi.getRepositoryModel().createTask(repository, taskData.getTaskId());
+ TasksUiPlugin.getTaskDataManager().putUpdatedTaskData(task, taskData, true);
+ return task;
+ }
+
+ private BugzillaClient priviledgedClient() throws Exception {
+ if (priviledgedClient == null) {
+ priviledgedClient = fixture.client();
+ }
+ return priviledgedClient;
+ }
+
+ TaskData createTaskData(ITaskMapping initializationData, ITaskMapping selectionData, IProgressMonitor monitor)
+ throws CoreException {
+ AbstractTaskDataHandler taskDataHandler = connector().getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository());
+ TaskData taskData = new TaskData(mapper, repository().getConnectorKind(), repository().getRepositoryUrl(), ""); //$NON-NLS-1$
+ boolean result = taskDataHandler.initializeTaskData(repository(), taskData, initializationData, monitor);
+ if (!result) {
+ throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
+ "Initialization of task failed. The provided data is insufficient.")); //$NON-NLS-1$
+ }
+ if (selectionData != null) {
+ connector().getTaskMapping(taskData).merge(selectionData);
+ }
+ return taskData;
+ }
+
+ private RepositoryResponse createNewTask(TaskData taskData) throws IOException, CoreException, Exception {
+ return fixture.submitTask(taskData, priviledgedClient());
+ }
+
+ public BugzillaHarness(BugzillaFixture fixture) {
+ this.fixture = fixture;
}
public String taskXmlRpcExists() {
String taskID = null;
- String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ String queryUrlString = repository().getRepositoryUrl() + "/buglist.cgi?"
+ "short_desc=test%20XMLRPC%20getBugData&resolution=---&query_format=advanced"
+ "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
- RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
- "handle-testQueryViaConnector");
+ RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
query.setUrl(queryUrlString);
final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
TaskDataCollector collector = new TaskDataCollector() {
@@ -71,8 +125,7 @@ public class BugzillaHarness {
changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
}
};
- abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
- new NullProgressMonitor());
+ connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
if (changedTaskData.size() > 0) {
Set<Integer> ks = changedTaskData.keySet();
SortedSet<Integer> sks = new TreeSet<Integer>(ks);
@@ -113,31 +166,18 @@ public class BugzillaHarness {
TaskAttribute stateB = null;
TaskAttribute stateC = null;
TaskAttribute stateD = null;
- final TaskData[] taskDataNew = new TaskData[1];
// create Task
- taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
- taskMappingSelect, null);
- ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
- taskDataNew[0].getRepositoryUrl());
-
- ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
- Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
- workingCopy.save(changed, null);
-
- RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
- abstractBugzillaTest.getClient());//connector.getTaskDataHandler().postTaskData(repository, taskDataNew[0], changed,
-
- ((AbstractTask) taskNew).setSubmitting(true);
+ TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
+ RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
String taskId = response.getTaskId();
- ITask task = abstractBugzillaTest.generateLocalTaskAndDownload(taskId);
+ ITask task = getTask(taskId);
assertNotNull(task);
- TaskDataModel model = abstractBugzillaTest.createModel(task);
- TaskData taskData = model.getTaskData();
+ TaskData taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
assertNotNull(taskData);
TaskAttribute attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData);
TaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment);
@@ -156,12 +196,12 @@ public class BugzillaHarness {
attachment.setDescription("Description");
attachment.setName("My Attachment 1");
try {
- abstractBugzillaTest.getClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(),
- attachment, attrAttachment, new NullProgressMonitor());
+ priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment,
+ attrAttachment, new NullProgressMonitor());
} catch (Exception e) {
fail("never reach this!");
}
- taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), abstractBugzillaTest.getClient());
+ taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient());
assertNotNull(taskData);
TaskAttribute attachmentAttribute = taskData.getAttributeMapper()
@@ -195,12 +235,11 @@ public class BugzillaHarness {
stateAttribute1.setValue("?");
TaskAttribute requestee = attachmentFlag1.getAttribute("requestee"); //$NON-NLS-1$
requestee.setValue("guest@mylyn.eclipse.org");
- abstractBugzillaTest.getClient().postUpdateAttachment(attachmentAttribute, "update", null);
+ priviledgedClient().postUpdateAttachment(attachmentAttribute, "update", null);
- task = abstractBugzillaTest.generateLocalTaskAndDownload(taskId);
+ task = getTask(taskId);
assertNotNull(task);
- model = abstractBugzillaTest.createModel(task);
- taskData = model.getTaskData();
+ taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
assertNotNull(taskData);
for (TaskAttribute taskAttribute : taskData.getRoot().getAttributes().values()) {
@@ -262,42 +301,17 @@ public class BugzillaHarness {
cf_bugidValue = createCfBugIdTask();
}
cf_bugid.setValue(cf_bugidValue);
-
- model.attributeChanged(cf_freetext);
- model.attributeChanged(cf_dropdown);
- model.attributeChanged(cf_largetextbox);
- model.attributeChanged(cf_multiselect);
- model.attributeChanged(cf_datetime);
- model.attributeChanged(cf_bugid);
- model.attributeChanged(flagA);
- model.attributeChanged(flagB);
- model.attributeChanged(flagC);
- model.attributeChanged(flagD);
- changed.clear();
- changed.add(flagA);
- changed.add(flagB);
- changed.add(flagC);
- changed.add(flagD);
- changed.add(cf_freetext);
- changed.add(cf_dropdown);
- changed.add(cf_largetextbox);
- changed.add(cf_multiselect);
- changed.add(cf_datetime);
- changed.add(cf_bugid);
-
- workingCopy.save(changed, null);
- response = BugzillaFixture.current().submitTask(taskData, abstractBugzillaTest.getClient());
+ response = fixture.submitTask(taskData, priviledgedClient());
return taskId;
}
public String taskAttachmentAttributesExists() {
String taskID = null;
- String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ String queryUrlString = repository().getRepositoryUrl() + "/buglist.cgi?"
+ "short_desc=test%20Bug%20with%20Attachment&resolution=---&query_format=advanced"
+ "&short_desc_type=casesubstring&component=ManualC2&product=ManualTest";
- RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
- "handle-testQueryViaConnector");
+ RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
query.setUrl(queryUrlString);
final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
TaskDataCollector collector = new TaskDataCollector() {
@@ -306,8 +320,7 @@ public class BugzillaHarness {
changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
}
};
- abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
- new NullProgressMonitor());
+ connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
if (changedTaskData.size() > 0) {
Set<Integer> ks = changedTaskData.keySet();
SortedSet<Integer> sks = new TreeSet<Integer>(ks);
@@ -340,31 +353,18 @@ public class BugzillaHarness {
return "The Description of the test with Attachment Bug";
}
};
- final TaskData[] taskDataNew = new TaskData[1];
// create Task
- taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
- taskMappingSelect, null);
- ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
- taskDataNew[0].getRepositoryUrl());
-
- ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
- Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
- workingCopy.save(changed, null);
-
- RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
- abstractBugzillaTest.getClient());//connector.getTaskDataHandler().postTaskData(repository, taskDataNew[0], changed,
- //new NullProgressMonitor());
- ((AbstractTask) taskNew).setSubmitting(true);
+ TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
+ RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
String taskId = response.getTaskId();
- ITask task = abstractBugzillaTest.generateLocalTaskAndDownload(taskId);
+ ITask task = getTask(taskId);
assertNotNull(task);
- TaskDataModel model = abstractBugzillaTest.createModel(task);
- TaskData taskData = model.getTaskData();
+ TaskData taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
assertNotNull(taskData);
TaskAttribute attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData);
TaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment);
@@ -382,18 +382,17 @@ public class BugzillaHarness {
attachment.setDescription("My Attachment 1");
attachment.setName("My Attachment 1");
try {
- abstractBugzillaTest.getClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(),
- attachment, attrAttachment, new NullProgressMonitor());
+ priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment,
+ attrAttachment, new NullProgressMonitor());
} catch (Exception e) {
fail("never reach this!");
}
- taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), abstractBugzillaTest.getClient());
+ taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient());
assertNotNull(taskData);
- task = abstractBugzillaTest.generateLocalTaskAndDownload(taskId);
+ task = getTask(taskId);
assertNotNull(task);
- model = abstractBugzillaTest.createModel(task);
- taskData = model.getTaskData();
+ taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
assertNotNull(taskData);
attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData);
attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment);
@@ -411,18 +410,17 @@ public class BugzillaHarness {
attachment.setDescription("My Attachment 2");
attachment.setName("My Attachment 2");
try {
- abstractBugzillaTest.getClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(),
- attachment, attrAttachment, new NullProgressMonitor());
+ priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment,
+ attrAttachment, new NullProgressMonitor());
} catch (Exception e) {
fail("never reach this!");
}
- taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), abstractBugzillaTest.getClient());
+ taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient());
assertNotNull(taskData);
- task = abstractBugzillaTest.generateLocalTaskAndDownload(taskId);
+ task = getTask(taskId);
assertNotNull(task);
- model = abstractBugzillaTest.createModel(task);
- taskData = model.getTaskData();
+ taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
assertNotNull(taskData);
attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData);
attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment);
@@ -444,18 +442,17 @@ public class BugzillaHarness {
child.setValue("1");
}
try {
- abstractBugzillaTest.getClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(),
- attachment, attrAttachment, new NullProgressMonitor());
+ priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment,
+ attrAttachment, new NullProgressMonitor());
} catch (Exception e) {
fail("never reach this!");
}
- taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), abstractBugzillaTest.getClient());
+ taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient());
assertNotNull(taskData);
- task = abstractBugzillaTest.generateLocalTaskAndDownload(taskId);
+ task = getTask(taskId);
assertNotNull(task);
- model = abstractBugzillaTest.createModel(task);
- taskData = model.getTaskData();
+ taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
assertNotNull(taskData);
attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData);
attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment);
@@ -477,12 +474,12 @@ public class BugzillaHarness {
child.setValue("1");
}
try {
- abstractBugzillaTest.getClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(),
- attachment, attrAttachment, new NullProgressMonitor());
+ priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment,
+ attrAttachment, new NullProgressMonitor());
} catch (Exception e) {
fail("never reach this!");
}
- taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), abstractBugzillaTest.getClient());
+ taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient());
assertNotNull(taskData);
TaskAttribute attachment1 = taskData.getAttributeMapper()
@@ -492,13 +489,12 @@ public class BugzillaHarness {
TaskAttribute obsolete = attachment1.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
assertNotNull(obsolete);
obsolete.setValue("1"); //$NON-NLS-1$
- ((BugzillaTaskDataHandler) abstractBugzillaTest.getConnector().getTaskDataHandler()).postUpdateAttachment(
- abstractBugzillaTest.getRepository(), attachment1, "update", new NullProgressMonitor()); //$NON-NLS-1$
+ ((BugzillaTaskDataHandler) connector().getTaskDataHandler()).postUpdateAttachment(repository(), attachment1,
+ "update", new NullProgressMonitor()); //$NON-NLS-1$
- task = abstractBugzillaTest.generateLocalTaskAndDownload(taskId);
+ task = getTask(taskId);
assertNotNull(task);
- model = abstractBugzillaTest.createModel(task);
- taskData = model.getTaskData();
+ taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
assertNotNull(taskData);
TaskAttribute attachment2 = taskData.getAttributeMapper()
@@ -508,19 +504,18 @@ public class BugzillaHarness {
obsolete = attachment2.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
assertNotNull(obsolete);
obsolete.setValue("1"); //$NON-NLS-1$
- ((BugzillaTaskDataHandler) abstractBugzillaTest.getConnector().getTaskDataHandler()).postUpdateAttachment(
- abstractBugzillaTest.getRepository(), attachment2, "update", new NullProgressMonitor()); //$NON-NLS-1$
+ ((BugzillaTaskDataHandler) connector().getTaskDataHandler()).postUpdateAttachment(repository(), attachment2,
+ "update", new NullProgressMonitor()); //$NON-NLS-1$
return taskId;
}
public String taskCustomFieldExists() {
String taskID = null;
- String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ String queryUrlString = repository().getRepositoryUrl() + "/buglist.cgi?"
+ "short_desc=test%20Bug%20with%20Custom%20Fields&resolution=---&query_format=advanced"
+ "&short_desc_type=casesubstring&component=ManualC2&product=ManualTest";
- RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
- "handle-testQueryViaConnector");
+ RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
query.setUrl(queryUrlString);
final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
TaskDataCollector collector = new TaskDataCollector() {
@@ -529,8 +524,7 @@ public class BugzillaHarness {
changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
}
};
- abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
- new NullProgressMonitor());
+ connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
if (changedTaskData.size() > 0) {
Set<Integer> ks = changedTaskData.keySet();
SortedSet<Integer> sks = new TreeSet<Integer>(ks);
@@ -563,42 +557,23 @@ public class BugzillaHarness {
return "The Description of the test with Custom Fields Bug";
}
};
- final TaskData[] taskDataNew = new TaskData[1];
// create Task
- taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
- taskMappingSelect, null);
- ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
- taskDataNew[0].getRepositoryUrl());
-
- ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
- Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
- workingCopy.save(changed, null);
-
- RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
- abstractBugzillaTest.getClient());//connector.getTaskDataHandler().postTaskData(repository, taskDataNew[0], changed,
- //new NullProgressMonitor());
- ((AbstractTask) taskNew).setSubmitting(true);
-
+ TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
+ RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
String taskId = response.getTaskId();
- ITask task = abstractBugzillaTest.generateLocalTaskAndDownload(taskId);
+ ITask task = getTask(taskId);
assertNotNull(task);
- TaskDataModel model = abstractBugzillaTest.createModel(task);
- TaskData taskData = model.getTaskData();
+ TaskData taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
assertNotNull(taskData);
TaskMapper mapper = new TaskMapper(taskData);
TaskAttribute cf_multiselect = mapper.getTaskData().getRoot().getAttribute("cf_multiselect");
cf_multiselect.setValue("Green");
- model.attributeChanged(cf_multiselect);
- changed.clear();
- changed.add(cf_multiselect);
-
- workingCopy.save(changed, null);
- response = BugzillaFixture.current().submitTask(taskData, abstractBugzillaTest.getClient());
+ response = fixture.submitTask(taskData, priviledgedClient());
return taskId;
}
@@ -606,11 +581,10 @@ public class BugzillaHarness {
public ArrayList<String> taskMissingHitsExists() {
ArrayList<String> taskIDs = new ArrayList<String>();
- String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ String queryUrlString = repository().getRepositoryUrl() + "/buglist.cgi?"
+ "short_desc=test%20Missing%20Hits&resolution=---&query_format=advanced"
+ "&short_desc_type=casesubstring&component=ManualC2&product=ManualTest";
- RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
- "handle-testQueryViaConnector");
+ RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
query.setUrl(queryUrlString);
final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
TaskDataCollector collector = new TaskDataCollector() {
@@ -619,8 +593,7 @@ public class BugzillaHarness {
changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
}
};
- abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
- new NullProgressMonitor());
+ connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
if (changedTaskData.size() > 0) {
Set<Integer> ks = changedTaskData.keySet();
SortedSet<Integer> sks = new TreeSet<Integer>(ks);
@@ -693,23 +666,10 @@ public class BugzillaHarness {
}
private String createTask(TaskMapping taskMappingInit, TaskMapping taskMappingSelect) throws Exception {
- final TaskData[] taskDataNew = new TaskData[1];
// create Task
- taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
- taskMappingSelect, null);
- ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
- taskDataNew[0].getRepositoryUrl());
-
- ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
- Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
- workingCopy.save(changed, null);
-
- RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
- abstractBugzillaTest.getClient());
-
- ((AbstractTask) taskNew).setSubmitting(true);
-
+ TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
+ RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
String taskId = response.getTaskId();
@@ -719,11 +679,10 @@ public class BugzillaHarness {
public String taskAliasExists() {
String taskID = null;
- String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ String queryUrlString = repository().getRepositoryUrl() + "/buglist.cgi?"
+ "short_desc=test%20Alias%20Bug&resolution=---&query_format=advanced"
+ "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
- RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
- "handle-testQueryViaConnector");
+ RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
query.setUrl(queryUrlString);
final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
TaskDataCollector collector = new TaskDataCollector() {
@@ -732,8 +691,7 @@ public class BugzillaHarness {
changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
}
};
- abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
- new NullProgressMonitor());
+ connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
if (changedTaskData.size() > 0) {
Set<Integer> ks = changedTaskData.keySet();
SortedSet<Integer> sks = new TreeSet<Integer>(ks);
@@ -766,26 +724,13 @@ public class BugzillaHarness {
return "The Description of the Alias Bug";
}
};
- final TaskData[] taskDataNew = new TaskData[1];
-
- // create Task
- taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
- taskMappingSelect, null);
- ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
- taskDataNew[0].getRepositoryUrl());
-
- ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
- Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
- TaskAttribute alias = taskDataNew[0].getRoot().getAttribute("alias");
+ final TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
+ TaskAttribute alias = taskDataNew.getRoot().getAttribute("alias");
if (alias == null) {
- alias = taskDataNew[0].getRoot().createAttribute("alias");
+ alias = taskDataNew.getRoot().createAttribute("alias");
}
alias.setValue("Fritz");
- changed.add(alias);
- workingCopy.save(changed, null);
- RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
- abstractBugzillaTest.getClient());
- ((AbstractTask) taskNew).setSubmitting(true);
+ RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
String taskId = response.getTaskId();
@@ -794,11 +739,10 @@ public class BugzillaHarness {
public String taskAlias2Exists() {
String taskID = null;
- String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ String queryUrlString = repository().getRepositoryUrl() + "/buglist.cgi?"
+ "short_desc=test%20Alias%20Bug2&resolution=---&query_format=advanced"
+ "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
- RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
- "handle-testQueryViaConnector");
+ RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
query.setUrl(queryUrlString);
final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
TaskDataCollector collector = new TaskDataCollector() {
@@ -807,8 +751,7 @@ public class BugzillaHarness {
changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
}
};
- abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
- new NullProgressMonitor());
+ connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
if (changedTaskData.size() > 0) {
Set<Integer> ks = changedTaskData.keySet();
SortedSet<Integer> sks = new TreeSet<Integer>(ks);
@@ -841,20 +784,10 @@ public class BugzillaHarness {
return "The Description of the Alias Bug";
}
};
- final TaskData[] taskDataNew = new TaskData[1];
// create Task
- taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
- taskMappingSelect, null);
- ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
- taskDataNew[0].getRepositoryUrl());
-
- ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
- Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
- workingCopy.save(changed, null);
- RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
- abstractBugzillaTest.getClient());
- ((AbstractTask) taskNew).setSubmitting(true);
+ TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
+ RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
String taskId = response.getTaskId();
@@ -863,11 +796,10 @@ public class BugzillaHarness {
public String taskCfBugIdExists() {
String taskID = null;
- String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ String queryUrlString = repository().getRepositoryUrl() + "/buglist.cgi?"
+ "short_desc=test%20CF%20Bug%20ID%20Bug&resolution=---&query_format=advanced"
+ "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
- RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
- "handle-testQueryViaConnector");
+ RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
query.setUrl(queryUrlString);
final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
TaskDataCollector collector = new TaskDataCollector() {
@@ -876,8 +808,7 @@ public class BugzillaHarness {
changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
}
};
- abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
- new NullProgressMonitor());
+ connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
if (changedTaskData.size() > 0) {
Set<Integer> ks = changedTaskData.keySet();
SortedSet<Integer> sks = new TreeSet<Integer>(ks);
@@ -910,20 +841,8 @@ public class BugzillaHarness {
return "The Description of the CF Bug ID Bug";
}
};
- final TaskData[] taskDataNew = new TaskData[1];
-
- // create Task
- taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
- taskMappingSelect, null);
- ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
- taskDataNew[0].getRepositoryUrl());
-
- ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
- Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
- workingCopy.save(changed, null);
- RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
- abstractBugzillaTest.getClient());
- ((AbstractTask) taskNew).setSubmitting(true);
+ final TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
+ RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
String taskId = response.getTaskId();

Back to the top