use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetTaskComments in project linuxtools by eclipse.
the class TestOSIORestGetTaskComments method testGetTaskComments.
@Test
public void testGetTaskComments() 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");
OSIORestGetTaskComments data = new OSIORestGetTaskComments(client.getClient(), testData.spaceMap.get("mywork"), taskData);
String bundleLocation = Activator.getContext().getBundle().getLocation();
int index = bundleLocation.indexOf('/');
String fileName = bundleLocation.substring(index) + "/testjson/comments.data";
FileReader in = new FileReader(fileName);
TaskAttribute original = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().ASSIGNEES.getKey());
assertTrue(original == null || original.getValues().isEmpty());
ArrayList<TaskAttribute> attributes = data.testParseFromJson(in);
assertEquals(4, attributes.size());
TaskAttribute attr1 = attributes.get(0);
TaskCommentMapper commentMapper = TaskCommentMapper.createFrom(attr1);
assertEquals("COMMENT-0004", commentMapper.getCommentId());
assertEquals("This is the fourth comment.", commentMapper.getText());
assertEquals(getDate("2017-11-21T20:46:47.383745Z"), commentMapper.getCreationDate());
IRepositoryPerson person = commentMapper.getAuthor();
assertEquals("User", person.getName());
assertEquals("user@user.org", person.getPersonId());
assertEquals(new Integer(4), commentMapper.getNumber());
TaskAttribute attr2 = attributes.get(1);
commentMapper = TaskCommentMapper.createFrom(attr2);
assertEquals("COMMENT-0003", commentMapper.getCommentId());
assertEquals("This is the third comment.", commentMapper.getText());
assertEquals(getDate("2017-10-05T23:01:54.15784Z"), commentMapper.getCreationDate());
IRepositoryPerson person2 = commentMapper.getAuthor();
assertEquals("User", person2.getName());
assertEquals("user@user.org", person2.getPersonId());
assertEquals(new Integer(3), commentMapper.getNumber());
TaskAttribute attr3 = attributes.get(2);
commentMapper = TaskCommentMapper.createFrom(attr3);
assertEquals("COMMENT-0002", commentMapper.getCommentId());
assertEquals("This is the second comment.", commentMapper.getText());
assertEquals(getDate("2017-10-05T21:09:19.673546Z"), commentMapper.getCreationDate());
IRepositoryPerson person3 = commentMapper.getAuthor();
assertEquals("User", person3.getName());
assertEquals("user@user.org", person3.getPersonId());
assertEquals(new Integer(2), commentMapper.getNumber());
TaskAttribute attr4 = attributes.get(3);
commentMapper = TaskCommentMapper.createFrom(attr4);
assertEquals("COMMENT-0001", commentMapper.getCommentId());
assertEquals("Comment on Task 1.", commentMapper.getText());
assertEquals(getDate("2017-08-14T21:40:29.434379Z"), commentMapper.getCreationDate());
IRepositoryPerson person4 = commentMapper.getAuthor();
assertEquals("User", person4.getName());
assertEquals("user@user.org", person4.getPersonId());
assertEquals(new Integer(1), commentMapper.getNumber());
}
Aggregations