Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2015-03-08 18:50:15 +0000
committerFrank Becker2015-03-25 17:03:46 +0000
commit2d3f9f7183a6c05e40447ebf97a7c671a766d75d (patch)
tree611f50be9751c4b585448cb2b4b13a1d3fd468fa
parentb81427cddc51e98026915a626a97e5e41b82270d (diff)
downloadorg.eclipse.mylyn.tasks-2d3f9f7183a6c05e40447ebf97a7c671a766d75d.tar.gz
org.eclipse.mylyn.tasks-2d3f9f7183a6c05e40447ebf97a7c671a766d75d.tar.xz
org.eclipse.mylyn.tasks-2d3f9f7183a6c05e40447ebf97a7c671a766d75d.zip
414360: add BugzillaRestHarness
Change-Id: I503a3453c9ab157febae30565643060e075d8fda Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=414360
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java57
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestTestFixture.java12
2 files changed, 69 insertions, 0 deletions
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java
new file mode 100644
index 000000000..604fd3dcf
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestHarness.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Frank Becker 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:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.rest.test.support;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConnector;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestCore;
+import org.eclipse.mylyn.tasks.core.ITaskMapping;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+
+public class BugzillaRestHarness {
+ private final BugzillaRestTestFixture fixture;
+
+ public BugzillaRestHarness(BugzillaRestTestFixture fixture) {
+ this.fixture = fixture;
+ }
+
+ private BugzillaRestConnector connector() {
+ return fixture.connector();
+ }
+
+ private TaskRepository repository() {
+ return fixture.repository();
+ }
+
+ public 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, BugzillaRestCore.ID_PLUGIN,
+ "Initialization of task failed. The provided data is insufficient.")); //$NON-NLS-1$
+ }
+ if (selectionData != null) {
+ connector().getTaskMapping(taskData).merge(selectionData);
+ }
+ return taskData;
+ }
+
+}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestTestFixture.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestTestFixture.java
index fa6bc2598..1d34c8330 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestTestFixture.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/test/support/BugzillaRestTestFixture.java
@@ -18,6 +18,7 @@ import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel;
import org.eclipse.mylyn.commons.sdk.util.FixtureConfiguration;
import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
+import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConnector;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestCore;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -27,6 +28,8 @@ public class BugzillaRestTestFixture extends AbstractTestFixture {
protected TaskRepository repository;
+ private final BugzillaRestConnector connector = new BugzillaRestConnector();
+
@Override
protected AbstractTestFixture getDefault() {
return TestConfiguration.getDefault().discoverDefault(BugzillaRestTestFixture.class, "bugzillaREST");
@@ -53,7 +56,16 @@ public class BugzillaRestTestFixture extends AbstractTestFixture {
return repository;
}
+ public BugzillaRestConnector connector() {
+ return connector;
+ }
+
public String getTestDataFolder() {
return "testdata/" + getProperty("testdataVersion");
}
+
+ public BugzillaRestHarness createHarness() {
+ return new BugzillaRestHarness(this);
+ }
+
}

Back to the top