Search in sources :

Example 1 with WorkItem

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem in project linuxtools by eclipse.

the class TestOSIORestGetTaskLinks method testGetTaskLinks.

@Test
public void testGetTaskLinks() throws Exception {
    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(), "");
    OSIORestTaskSchema.getDefault().initialize(taskData);
    OSIORestConfiguration config = client.getConfiguration(repository, new NullOperationMonitor());
    config.setSpaces(testData.spaceMap);
    connector.setConfiguration(config);
    RepositoryLocation location = client.getClient().getLocation();
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
    WorkItem workitem = initWorkItem("1", "WORKITEM-0001", "SPACE-0001", "Task 1");
    WorkItem workitem2 = initWorkItem("2", "WORKITEM-0002", "SPACE-0001", "Task 2");
    WorkItem workitem3 = initWorkItem("3", "WORKITEM-0003", "SPACE-0001", "Task 3");
    requestProvider.addGetRequest("/workitems/WORKITEM-0001", workitem);
    requestProvider.addGetRequest("/workitems/WORKITEM-0002", workitem2);
    requestProvider.addGetRequest("/workitems/WORKITEM-0003", workitem3);
    taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().UUID.getKey()).setValue("WORKITEM-0001");
    OSIORestGetTaskLinks data = new OSIORestGetTaskLinks(client.getClient(), client, testData.spaceMap.get("mywork"), taskData, config);
    String bundleLocation = Activator.getContext().getBundle().getLocation();
    int index = bundleLocation.indexOf('/');
    String fileName = bundleLocation.substring(index) + "/testjson/links.data";
    FileReader in = new FileReader(fileName);
    TaskAttribute original = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().LINKS.getKey());
    assertTrue(original == null || original.getValues().isEmpty());
    TaskAttribute attribute = data.testParseFromJson(in);
    assertEquals(2, attribute.getValues().size());
    List<String> values = attribute.getValues();
    assertEquals("blocks Task 2 [user/mywork#2]", values.get(0));
    assertEquals("is blocked by Task 3 [user/mywork#3]", values.get(1));
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) AbstractTaskDataHandler(org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler) WorkItem(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData) OSIORestGetTaskLinks(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetTaskLinks) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) FileReader(java.io.FileReader) TaskAttributeMapper(org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper) NullOperationMonitor(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor) Test(org.junit.Test)

Example 2 with WorkItem

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem in project linuxtools by eclipse.

the class OSIOTestRestRequestProvider method postNewLink.

@Override
public LinkResponse postNewLink(IOperationMonitor monitor, CommonHttpClient client, String linkid, String sourceid, String targetid, boolean isForward) throws OSIORestException {
    String query = // $NON-NLS-1$
    "/workitems/" + (isForward ? sourceid : targetid) + "/relationships/links";
    LinkResponse response = (LinkResponse) postMap.get(query);
    WorkItem source = (WorkItem) requestMap.get("/workitems/" + sourceid);
    WorkItem target = (WorkItem) requestMap.get("/workitems/" + targetid);
    String sourceNum = (String) source.getNumber();
    String targetNum = (String) target.getNumber();
    requestMap.put(query, response);
    return response;
}
Also used : WorkItem(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem) LinkResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.LinkResponse)

Example 3 with WorkItem

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem in project linuxtools by eclipse.

the class TestOSIORestGetTaskLinks method initWorkItem.

private WorkItem initWorkItem(String number, String id, String spaceId, String title) throws Exception {
    WorkItem workitem = new WorkItem();
    workitem.setNumber(number);
    workitem.setId(id);
    workitem.setSpaceId(spaceId);
    workitem.setTitle(title);
    return workitem;
}
Also used : WorkItem(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem)

Example 4 with WorkItem

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem in project linuxtools by eclipse.

the class TestOSIORestGetWorkItem method testGetWorkItem.

@Test
public void testGetWorkItem() throws Exception {
    TestData testData = new TestData();
    TestUtils.initSpaces(requestProvider, testData);
    OSIORestClient client = connector.getClient(repository, requestProvider);
    OSIORestConfiguration config = client.getConfiguration(repository, new NullOperationMonitor());
    config.setSpaces(testData.spaceMap);
    connector.setConfiguration(config);
    RepositoryLocation location = client.getClient().getLocation();
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
    OSIORestGetWorkItem data = new OSIORestGetWorkItem(client.getClient(), "WORKITEM-0001");
    String bundleLocation = Activator.getContext().getBundle().getLocation();
    int index = bundleLocation.indexOf('/');
    String fileName = bundleLocation.substring(index) + "/testjson/workitem.data";
    FileReader in = new FileReader(fileName);
    WorkItem workitem = data.testParseFromJson(in);
    assertEquals("WORKITEM-0001", workitem.getId());
    assertEquals("00001", workitem.getTitle());
    assertEquals("SPACE-0001", workitem.getSpaceId());
    assertEquals("1", workitem.getNumber());
}
Also used : TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) OSIORestGetWorkItem(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetWorkItem) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) FileReader(java.io.FileReader) OSIORestGetWorkItem(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetWorkItem) WorkItem(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) NullOperationMonitor(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor) Test(org.junit.Test)

Aggregations

WorkItem (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem)4 FileReader (java.io.FileReader)2 NullOperationMonitor (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor)2 OSIORestClient (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient)2 OSIORestConfiguration (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration)2 TestData (org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData)2 RepositoryLocation (org.eclipse.mylyn.commons.repositories.core.RepositoryLocation)2 Test (org.junit.Test)2 OSIORestGetTaskLinks (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetTaskLinks)1 OSIORestGetWorkItem (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetWorkItem)1 LinkResponse (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.LinkResponse)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 TaskData (org.eclipse.mylyn.tasks.core.data.TaskData)1