use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetTaskData in project linuxtools by eclipse.
the class TestOSIORestGetTaskData method testGetTaskData.
@Test
public void testGetTaskData() 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");
OSIORestGetTaskData data = new OSIORestGetTaskData(client.getClient(), connector, "/workitems/QUERY", repository);
String bundleLocation = Activator.getContext().getBundle().getLocation();
int index = bundleLocation.indexOf('/');
String fileName = bundleLocation.substring(index) + "/testjson/workitems.data";
FileReader in = new FileReader(fileName);
List<TaskData> taskDataList = data.testParseFromJson(in);
assertEquals(2, taskDataList.size());
TaskData taskData = taskDataList.get(0);
TaskAttribute root = taskData.getRoot();
OSIORestTaskSchema schema = OSIORestTaskSchema.getDefault();
TaskAttribute space = root.getAttribute(schema.SPACE.getKey());
assertEquals("mywork", space.getValue());
TaskAttribute spaceid = root.getAttribute(schema.SPACE_ID.getKey());
assertEquals("SPACE-0001", spaceid.getValue());
TaskAttribute uuid = root.getAttribute(schema.UUID.getKey());
assertEquals("WORKITEM-0001", uuid.getValue());
TaskAttribute labelsLink = root.getAttribute(schema.LABELS_LINK.getKey());
assertEquals("https://openshift.io/api/workitems/WORKITEM-0001/labels", labelsLink.getValue());
TaskAttribute creatorId = root.getAttribute(schema.CREATOR_ID.getKey());
assertEquals("USER-0001", creatorId.getValue());
TaskAttribute taskUrl = root.getAttribute(schema.TASK_URL.getKey());
assertEquals("https://openshift.io/api/workitems/WORKITEM-0001", taskUrl.getValue());
TaskAttribute assigneeIds = root.getAttribute(schema.ASSIGNEE_IDS.getKey());
assertEquals("USER-0001", assigneeIds.getValue());
TaskAttribute id = root.getAttribute(schema.ID.getKey());
assertEquals("user/mywork#1", id.getValue());
TaskAttribute status = root.getAttribute(schema.STATUS.getKey());
assertEquals("resolved", status.getValue());
TaskAttribute title = root.getAttribute(schema.SUMMARY.getKey());
assertEquals("00001", title.getValue());
TaskAttribute description = root.getAttribute(schema.DESCRIPTION.getKey());
assertEquals("Test bug", description.getValue());
TaskAttribute version = root.getAttribute(schema.VERSION.getKey());
assertEquals("11", version.getValue());
TaskAttribute order = root.getAttribute(schema.ORDER.getKey());
assertEquals("1000", order.getValue());
TaskAttribute created_at = root.getAttribute(schema.DATE_CREATION.getKey());
assertEquals(getDate("2017-08-14T21:37:15.863435Z"), created_at.getValue());
TaskAttribute updated_at = root.getAttribute(schema.DATE_MODIFICATION.getKey());
assertEquals(getDate("2017-09-15T15:54:43.08915Z"), updated_at.getValue());
taskData = taskDataList.get(1);
root = taskData.getRoot();
space = root.getAttribute(schema.SPACE.getKey());
assertEquals("mywork", space.getValue());
spaceid = root.getAttribute(schema.SPACE_ID.getKey());
assertEquals("SPACE-0001", spaceid.getValue());
uuid = root.getAttribute(schema.UUID.getKey());
assertEquals("WORKITEM-0002", uuid.getValue());
labelsLink = root.getAttribute(schema.LABELS_LINK.getKey());
assertEquals("https://openshift.io/api/workitems/WORKITEM-0002/labels", labelsLink.getValue());
creatorId = root.getAttribute(schema.CREATOR_ID.getKey());
assertEquals("USER-0001", creatorId.getValue());
taskUrl = root.getAttribute(schema.TASK_URL.getKey());
assertEquals("https://openshift.io/api/workitems/WORKITEM-0002", taskUrl.getValue());
assigneeIds = root.getAttribute(schema.ASSIGNEE_IDS.getKey());
assertEquals("USER-0001", assigneeIds.getValue());
id = root.getAttribute(schema.ID.getKey());
assertEquals("user/mywork#2", id.getValue());
status = root.getAttribute(schema.STATUS.getKey());
assertEquals("open", status.getValue());
title = root.getAttribute(schema.SUMMARY.getKey());
assertEquals("00002", title.getValue());
description = root.getAttribute(schema.DESCRIPTION.getKey());
assertEquals("Test feature", description.getValue());
version = root.getAttribute(schema.VERSION.getKey());
assertEquals("22", version.getValue());
order = root.getAttribute(schema.ORDER.getKey());
assertEquals("2000", order.getValue());
created_at = root.getAttribute(schema.DATE_CREATION.getKey());
assertEquals(getDate("2017-08-15T21:37:15.863435Z"), created_at.getValue());
updated_at = root.getAttribute(schema.DATE_MODIFICATION.getKey());
assertEquals(getDate("2017-09-16T15:54:43.08915Z"), updated_at.getValue());
}
Aggregations