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));
}
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;
}
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;
}
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());
}
Aggregations