Search in sources :

Example 1 with TaskMapping

use of org.eclipse.mylyn.tasks.core.TaskMapping in project linuxtools by eclipse.

the class TestOSIORestClient method testinitializeTaskData.

@Test
public void testinitializeTaskData() throws Exception {
    final TaskMapping taskMappingInit = new TaskMapping() {

        @Override
        public String getSummary() {
            return "The Summary";
        }

        @Override
        public String getDescription() {
            return "The Description";
        }
    };
    TestData testData = new TestData();
    TestUtils.initSpaces(requestProvider, testData);
    OSIORestClient client = connector.getClient(repository, requestProvider);
    AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
    TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
    TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
    assertTrue(taskDataHandler.initializeTaskData(repository, taskData, null, null));
    TaskAttribute attribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SUMMARY.getKey());
    assertTrue(attribute != null);
    assertEquals(attribute.getValue(), "");
    taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
    assertTrue(taskDataHandler.initializeTaskData(repository, taskData, taskMappingInit, null));
    attribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SUMMARY.getKey());
    assertEquals(attribute.getValue(), "The Summary");
    attribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().DESCRIPTION.getKey());
    assertEquals(attribute.getValue(), "The Description");
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) TaskMapping(org.eclipse.mylyn.tasks.core.TaskMapping) TaskAttributeMapper(org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper) AbstractTaskDataHandler(org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData) Test(org.junit.Test)

Example 2 with TaskMapping

use of org.eclipse.mylyn.tasks.core.TaskMapping in project linuxtools by eclipse.

the class OSIORestHarness method getTaskIdWithSummary.

private String getTaskIdWithSummary(String summary) throws OSIORestException, CoreException {
    String taskID = null;
    String queryUrlString = repository().getRepositoryUrl() + "/bug?" + "short_desc=" + summary;
    RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
    query.setUrl(queryUrlString);
    final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
    TaskDataCollector collector = new TaskDataCollector() {

        @Override
        public void accept(TaskData taskData) {
            changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
        }
    };
    connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
    if (changedTaskData.size() > 0) {
        Set<Integer> ks = changedTaskData.keySet();
        SortedSet<Integer> sks = new TreeSet<Integer>(ks);
        taskID = sks.last().toString();
    } else {
        final TaskMapping taskMappingInit = new TaskMapping() {

            @Override
            public String getSummary() {
                return summary;
            }

            @Override
            public String getDescription() {
                return "The Description";
            }

            @Override
            public String getProduct() {
                return "ManualTest";
            }

            @Override
            public String getComponent() {
                return "ManualC1";
            }

            @Override
            public String getVersion() {
                return "R1";
            }
        };
        taskID = getNewTaksIdFromInitMapping(taskMappingInit, taskInitializationData);
    }
    return taskID;
}
Also used : SingleTaskDataCollector(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SingleTaskDataCollector) TaskDataCollector(org.eclipse.mylyn.tasks.core.data.TaskDataCollector) RepositoryQuery(org.eclipse.mylyn.internal.tasks.core.RepositoryQuery) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ITaskMapping(org.eclipse.mylyn.tasks.core.ITaskMapping) TaskMapping(org.eclipse.mylyn.tasks.core.TaskMapping) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData)

Aggregations

TaskMapping (org.eclipse.mylyn.tasks.core.TaskMapping)2 TaskData (org.eclipse.mylyn.tasks.core.data.TaskData)2 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OSIORestClient (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient)1 SingleTaskDataCollector (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SingleTaskDataCollector)1 TestData (org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData)1 RepositoryQuery (org.eclipse.mylyn.internal.tasks.core.RepositoryQuery)1 ITaskMapping (org.eclipse.mylyn.tasks.core.ITaskMapping)1 AbstractTaskDataHandler (org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler)1 TaskAttribute (org.eclipse.mylyn.tasks.core.data.TaskAttribute)1 TaskAttributeMapper (org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper)1 TaskDataCollector (org.eclipse.mylyn.tasks.core.data.TaskDataCollector)1 Test (org.junit.Test)1