use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestTaskSchema in project linuxtools by eclipse.
the class TestOSIORestClient method initWorkItems.
@SuppressWarnings("deprecation")
private void initWorkItems(TaskData task1, TaskData task2) throws Exception {
OSIORestClient client = connector.getClient(repository, requestProvider);
AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
TaskData taskData = task1;
OSIORestTaskSchema.getDefault().initialize(taskData);
taskDataHandler.initializeTaskData(repository, taskData, null, null);
OSIORestTaskSchema schema = OSIORestTaskSchema.getDefault();
TaskAttribute root = taskData.getRoot();
root.createAttribute(schema.UUID.getKey()).addValue("WORKITEM-0001");
root.createAttribute(schema.SPACE.getKey()).addValue("mywork");
root.createAttribute(schema.SPACE_ID.getKey()).addValue("SPACE-0001");
root.createAttribute(schema.AREA.getKey()).addValue("otherarea");
root.createAttribute(schema.ITERATION.getKey()).addValue("mywork");
root.createAttribute(schema.DESCRIPTION.getKey()).addValue("This is Bug 1");
root.createAttribute(schema.NUMBER.getKey()).addValue("1");
root.createAttribute(schema.ORDER.getKey()).addValue("1000");
root.createAttribute(schema.STATUS.getKey()).addValue("in progress");
root.createAttribute(schema.SUMMARY.getKey()).addValue("Bug 0001");
root.createAttribute(schema.TASK_URL.getKey()).addValue("https://api.openshift.io/api/workitems/WORKITEM-0001");
root.createAttribute(schema.WORKITEM_TYPE.getKey()).addValue("bug");
root.createAttribute(schema.ID.getKey()).addValue("user/mywork#1");
root.createAttribute(schema.ASSIGNEE_IDS.getKey()).addValue("USER-0001");
root.createAttribute(schema.CREATOR_ID.getKey()).addValue("USER-0001");
TaskAttribute attribute = taskData.getRoot().createAttribute(TaskAttribute.PREFIX_COMMENT + "0");
TaskAttribute numComments = taskData.getRoot().createAttribute(OSIORestTaskSchema.getDefault().COMMENT_COUNT.getKey());
numComments.setValue("1");
TaskCommentMapper taskComment = TaskCommentMapper.createFrom(attribute);
taskComment.setCommentId("COMMENT-0001");
taskComment.setNumber(1);
taskComment.setUrl("https://api.openshift.io/api/workitems/comments/COMMENT-0001");
// $NON-NLS-1$
String email = "user@user.org";
// $NON-NLS-1$
String fullName = "User 1";
IRepositoryPerson author = taskData.getAttributeMapper().getTaskRepository().createPerson(// $NON-NLS-1$
email);
author.setName(fullName);
taskComment.setAuthor(author);
taskComment.setIsPrivate(null);
taskComment.setCreationDate(new Date(2017, 01, 01));
taskComment.setText("This is comment 1");
taskComment.applyTo(attribute);
TaskAttribute attribute2 = taskData.getRoot().createAttribute(TaskAttribute.PREFIX_COMMENT + "1");
taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().COMMENT_COUNT.getKey());
numComments.setValue("2");
taskComment = TaskCommentMapper.createFrom(attribute2);
taskComment.setCommentId("COMMENT-0002");
taskComment.setNumber(2);
taskComment.setUrl("https://api.openshift.io/api/workitems/comments/COMMENT-0002");
// $NON-NLS-1$
email = "user2@user.org";
// $NON-NLS-1$
fullName = "User 2";
author = taskData.getAttributeMapper().getTaskRepository().createPerson(// $NON-NLS-1$
email);
author.setName(fullName);
taskComment.setAuthor(author);
taskComment.setIsPrivate(null);
taskComment.setCreationDate(new Date(2017, 01, 02));
taskComment.setText("This is comment 2");
taskComment.applyTo(attribute2);
List<TaskAttribute> comments = new ArrayList<>();
comments.add(attribute);
comments.add(attribute2);
requestProvider.addGetRequest("/workitems/WORKITEM-0001/comments", comments);
TaskAttribute attribute5 = taskData.getRoot().createAttribute(OSIORestTaskSchema.getDefault().LABELS.getKey());
attribute5.addValue("LabelA");
attribute5.addValue("LabelB");
requestProvider.addGetRequest("/workitems/WORKITEM-0001/labels", attribute5);
TaskAttribute attribute6 = taskData.getRoot().createAttribute(OSIORestTaskSchema.getDefault().LINKS.getKey());
attribute6.addValue("blocks Bug 3 [user/mywork#3]");
requestProvider.addGetRequest("/workitems/WORKITEM-0001/relationships/links", attribute6);
TaskAttribute creator = taskData.getRoot().createAttribute(OSIORestTaskSchema.getDefault().CREATOR.getKey());
TaskAttributeMetaData creatorMeta = creator.getMetaData();
creator.setValue("User 1");
creatorMeta.putValue("email", "user@user.org");
creatorMeta.putValue("username", "user");
creatorMeta.putValue("id", "USER-0001");
requestProvider.addGetRequest("/users/USER-0001", creator);
TaskData taskData2 = task2;
OSIORestTaskSchema.getDefault().initialize(taskData2);
taskDataHandler.initializeTaskData(repository, taskData2, null, null);
root = taskData2.getRoot();
root.createAttribute(schema.UUID.getKey()).addValue("WORKITEM-0002");
root.createAttribute(schema.SPACE.getKey()).addValue("mywork");
root.createAttribute(schema.SPACE_ID.getKey()).addValue("SPACE-0003");
root.createAttribute(schema.AREA.getKey()).addValue("mywork");
root.createAttribute(schema.ITERATION.getKey()).addValue("mywork");
root.createAttribute(schema.DESCRIPTION.getKey()).addValue("This is Feature 1");
root.createAttribute(schema.NUMBER.getKey()).addValue("1");
root.createAttribute(schema.ORDER.getKey()).addValue("1010");
root.createAttribute(schema.STATUS.getKey()).addValue("open");
root.createAttribute(schema.SUMMARY.getKey()).addValue("Feature 0001");
root.createAttribute(schema.TASK_URL.getKey()).addValue("https://api.openshift.io/api/workitems/WORKITEM-0002");
root.createAttribute(schema.WORKITEM_TYPE.getKey()).addValue("bug");
root.createAttribute(schema.ID.getKey()).addValue("user3/mywork#1");
root.createAttribute(schema.ASSIGNEE_IDS.getKey()).addValue("USER-0001");
root.createAttribute(schema.CREATOR_ID.getKey()).addValue("USER-0003");
TaskAttribute attribute3 = taskData.getRoot().createAttribute(TaskAttribute.PREFIX_COMMENT + "0");
TaskAttribute numComments3 = taskData.getRoot().createAttribute(OSIORestTaskSchema.getDefault().COMMENT_COUNT.getKey());
numComments.setValue("1");
taskComment = TaskCommentMapper.createFrom(attribute);
taskComment.setCommentId("COMMENT-0003");
taskComment.setNumber(1);
taskComment.setUrl("https://api.openshift.io/api/workitems/comments/COMMENT-0003");
// $NON-NLS-1$
String email3 = "user@user.org";
// $NON-NLS-1$
String fullName3 = "User 1";
IRepositoryPerson author3 = taskData.getAttributeMapper().getTaskRepository().createPerson(// $NON-NLS-1$
email3);
author3.setName(fullName3);
taskComment.setAuthor(author3);
taskComment.setIsPrivate(null);
taskComment.setCreationDate(new Date(2017, 01, 01));
taskComment.setText("This is first comment");
taskComment.applyTo(attribute3);
List<TaskAttribute> comments2 = new ArrayList<>();
comments2.add(attribute3);
requestProvider.addGetRequest("/workitems/WORKITEM-0002/comments", comments2);
TaskAttribute attribute4 = taskData.getRoot().createAttribute(OSIORestTaskSchema.getDefault().LABELS.getKey());
attribute4.addValue("Label1");
attribute4.addValue("Label2");
requestProvider.addGetRequest("/workitems/WORKITEM-0002/labels", attribute4);
TaskAttribute attribute7 = taskData.getRoot().createAttribute(OSIORestTaskSchema.getDefault().LINKS.getKey());
attribute7.clearValues();
requestProvider.addGetRequest("/workitems/WORKITEM-0002/relationships/links", attribute7);
TaskAttribute creator2 = taskData.getRoot().createAttribute(OSIORestTaskSchema.getDefault().CREATOR.getKey());
TaskAttributeMetaData creatorMeta2 = creator.getMetaData();
creator2.setValue("User 3");
creatorMeta2.putValue("email", "user3@user.org");
creatorMeta2.putValue("username", "user3");
creatorMeta2.putValue("id", "USER-0003");
requestProvider.addGetRequest("/users/USER-0003", creator2);
}
use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestTaskSchema in project linuxtools by eclipse.
the class TestOSIORestGetSingleTask method testGetSingleTask.
@Test
public void testGetSingleTask() 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");
OSIORestGetSingleTaskData data = new OSIORestGetSingleTaskData(client.getClient(), connector, "/workitems/WORKITEM-0001", repository);
String bundleLocation = Activator.getContext().getBundle().getLocation();
int index = bundleLocation.indexOf('/');
String fileName = bundleLocation.substring(index) + "/testjson/workitem.data";
FileReader in = new FileReader(fileName);
TaskData taskData = data.testParseFromJson(in);
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());
}
use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestTaskSchema 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());
}
use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestTaskSchema in project linuxtools by eclipse.
the class TestOSIORestPatchUpdateTask method testPatchUpdateTask.
@Test
public void testPatchUpdateTask() 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");
AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
OSIORestTaskSchema.getDefault().initialize(taskData);
Set<TaskAttribute> attributes = new LinkedHashSet<>();
TaskAttribute newComment = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().NEW_COMMENT.getKey());
newComment.setValue("This is a test comment");
attributes.add(newComment);
OSIORestTaskSchema taskSchema = OSIORestTaskSchema.getDefault();
TaskAttribute root = taskData.getRoot();
TaskAttribute description = root.getAttribute(taskSchema.DESCRIPTION.getKey());
description.setValue("This is a test bug");
TaskAttribute operation = root.createAttribute(TaskAttribute.OPERATION);
operation.setValue("in progress");
TaskAttribute status = root.getAttribute(taskSchema.STATUS.getKey());
status.setValue("open");
TaskAttribute uuid = root.getAttribute(taskSchema.UUID.getKey());
uuid.setValue("WORKITEM-0001");
TaskAttribute summary = root.getAttribute(taskSchema.SUMMARY.getKey());
summary.setValue("Bug0001");
TaskAttribute version = root.getAttribute(taskSchema.VERSION.getKey());
version.setValue("11");
TaskAttribute area = root.getAttribute(taskSchema.AREA.getKey());
area.setValue("mywork");
TaskAttribute iteration = root.getAttribute(taskSchema.ITERATION.getKey());
iteration.setValue("mywork");
TaskAttribute labels = root.getAttribute(taskSchema.LABELS.getKey());
labels.addValue("label1");
labels.addValue("label3");
TaskAttribute addLabels = root.getAttribute(taskSchema.ADD_LABEL.getKey());
addLabels.addValue("label2");
TaskAttribute removeLabels = root.getAttribute(taskSchema.REMOVE_LABEL.getKey());
removeLabels.addValue("label3");
TaskAttribute assignees = root.getAttribute(taskSchema.ASSIGNEES.getKey());
assignees.addValue("user3");
TaskAttribute addAssignees = root.getAttribute(taskSchema.ADD_ASSIGNEE.getKey());
addAssignees.addValue("user");
TaskAttribute removeAssignees = root.getAttribute(taskSchema.REMOVE_ASSIGNEE.getKey());
removeAssignees.addValue("user3");
OSIORestPatchUpdateTask data = new OSIORestPatchUpdateTask(client.getClient(), taskData, attributes, testData.spaceMap.get("mywork"));
OSIORestPatchUpdateTask.TaskAttributeTypeAdapter adapter = data.new TaskAttributeTypeAdapter(location);
OSIORestPatchUpdateTask.OldAttributes oldAttributes = data.new OldAttributes(attributes);
StringWriter s = new StringWriter();
JsonWriter writer = new JsonWriter(s);
adapter.write(writer, oldAttributes);
assertEquals("{\"data\":{\"attributes\":{\"system.description\":\"This is a test bug\",\"system.state\":\"in progress\",\"system.title\":\"Bug0001\",\"version\":\"11\"}," + "\"id\":\"WORKITEM-0001\",\"relationships\":{\"space\":{\"data\":{\"id\":\"SPACE-0001\",\"type\":\"spaces\"}},\"area\":{\"data\":{\"id\":\"AREA-0001\",\"type\":\"areas\"}}," + "\"iteration\":{\"data\":{\"id\":\"ITERATION-0001\",\"type\":\"iterations\"}},\"assignees\":{\"data\":[{\"id\":\"USER-0001\",\"type\":\"users\"}]}," + "\"labels\":{\"data\":[{\"id\":\"LABEL-0001\",\"type\":\"labels\"},{\"id\":\"LABEL-0002\",\"type\":\"labels\"}]}},\"type\":\"workitems\"},\"included\":[true]}", s.getBuffer().toString());
StringWriter s2 = new StringWriter();
JsonWriter writer2 = new JsonWriter(s2);
root.removeAttribute(TaskAttribute.OPERATION);
adapter.write(writer2, oldAttributes);
assertEquals("{\"data\":{\"attributes\":{\"system.description\":\"This is a test bug\",\"system.state\":\"open\",\"system.title\":\"Bug0001\",\"version\":\"11\"}," + "\"id\":\"WORKITEM-0001\",\"relationships\":{\"space\":{\"data\":{\"id\":\"SPACE-0001\",\"type\":\"spaces\"}},\"area\":{\"data\":{\"id\":\"AREA-0001\",\"type\":\"areas\"}}," + "\"iteration\":{\"data\":{\"id\":\"ITERATION-0001\",\"type\":\"iterations\"}},\"assignees\":{\"data\":[{\"id\":\"USER-0001\",\"type\":\"users\"}]}," + "\"labels\":{\"data\":[{\"id\":\"LABEL-0001\",\"type\":\"labels\"},{\"id\":\"LABEL-0002\",\"type\":\"labels\"}]}},\"type\":\"workitems\"},\"included\":[true]}", s2.getBuffer().toString());
}
use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestTaskSchema in project linuxtools by eclipse.
the class TestOSIORestPostNewTask method testPostNewTask.
@Test
public void testPostNewTask() 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");
AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
OSIORestTaskSchema.getDefault().initialize(taskData);
TaskAttribute root = taskData.getRoot();
OSIORestTaskSchema taskSchema = OSIORestTaskSchema.getDefault();
TaskAttribute summary = root.getAttribute(taskSchema.SUMMARY.getKey());
summary.setValue("Bug0001");
TaskAttribute description = root.getAttribute(taskSchema.DESCRIPTION.getKey());
description.setValue("This is a bug");
TaskAttribute workitemtype = root.getAttribute(taskSchema.WORKITEM_TYPE.getKey());
workitemtype.setValue("bug");
OSIORestPostNewTask data = new OSIORestPostNewTask(client.getClient(), taskData, testData.spaceMap.get("mywork"), connector, repository);
OSIORestPostNewTask.TaskAttributeTypeAdapter adapter = data.new TaskAttributeTypeAdapter(location);
StringWriter s = new StringWriter();
JsonWriter writer = new JsonWriter(s);
adapter.write(writer, taskData);
assertEquals("{\"data\":{\"attributes\":{\"system.state\":\"new\",\"system.title\":\"Bug0001\",\"version\":\"1\",\"system.description\":\"This is a bug\"},\"relationships\":{\"baseType\":{\"data\":{\"id\":\"WORKITEMTYPE-0001\",\"type\":\"workitemtypes\"}},\"space\":{\"data\":{\"id\":\"SPACE-0001\",\"type\":\"spaces\"}}},\"type\":\"workitems\"},\"included\":[true]}", s.toString());
}
Aggregations