use of org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData in project linuxtools by eclipse.
the class TestOSIORestClient method testinitializeTaskData.
@Test
public void testinitializeTaskData() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
public String getSummary() {
return "The Summary";
}
@Override
public String getDescription() {
return "The Description";
}
};
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(), "");
assertTrue(taskDataHandler.initializeTaskData(repository, taskData, null, null));
TaskAttribute attribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SUMMARY.getKey());
assertTrue(attribute != null);
assertEquals(attribute.getValue(), "");
taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
assertTrue(taskDataHandler.initializeTaskData(repository, taskData, taskMappingInit, null));
attribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SUMMARY.getKey());
assertEquals(attribute.getValue(), "The Summary");
attribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().DESCRIPTION.getKey());
assertEquals(attribute.getValue(), "The Description");
}
use of org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData in project linuxtools by eclipse.
the class TestOSIORestClient method testGetTaskData.
@Test
public void testGetTaskData() throws Exception {
TestData testData = new TestData();
TestUtils.initSpaces(requestProvider, testData);
requestProvider.addGetRequest("/namedspaces/user", testData.spaces);
OSIORestClient client = connector.getClient(repository, requestProvider);
AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
TaskData task1 = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
TaskData task2 = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
initWorkItems(task1, task2);
client.getConfiguration(repository, new NullOperationMonitor());
requestProvider.addGetRequest("/workitems/WORKITEM-0001", task1);
requestProvider.addRelocation("/namedspaces/user/mywork/workitems/1", "/spaces/SPACE-0001/workitem/WORKITEM-0001");
requestProvider.addGetRequest("/workitems/WORKITEM-0002", task2);
requestProvider.addRelocation("/namedspaces/user3/mywork/workitems/1", "/spaces/SPACE-0003/workitem/WORKITEM-0002");
TestTaskDataCollector collector = new TestTaskDataCollector();
Set<String> taskIds = new TreeSet<>();
taskIds.add("user/mywork#1");
taskIds.add("user3/mywork#1");
client.getTaskData(taskIds, repository, collector, new NullOperationMonitor());
List<TaskData> results = collector.getTaskData();
assertTrue(results != null);
assertEquals(2, results.size());
TaskData data = results.get(0);
assertEquals(data, task1);
TaskAttribute comment0 = data.getRoot().getAttribute(TaskAttribute.PREFIX_COMMENT + "0");
assertTrue(comment0 != null);
TaskCommentMapper commentMapper = TaskCommentMapper.createFrom(comment0);
assertEquals(commentMapper.getText(), "This is comment 1");
TaskAttribute comment1 = data.getRoot().getAttribute(TaskAttribute.PREFIX_COMMENT + "1");
assertTrue(comment1 != null);
commentMapper = TaskCommentMapper.createFrom(comment1);
assertEquals(commentMapper.getText(), "This is comment 2");
data = results.get(1);
assertEquals(data, task2);
comment0 = data.getRoot().getAttribute(TaskAttribute.PREFIX_COMMENT + "0");
assertTrue(comment0 != null);
commentMapper = TaskCommentMapper.createFrom(comment0);
assertEquals(commentMapper.getText(), "This is first comment");
}
use of org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData in project linuxtools by eclipse.
the class TestOSIORestClient method testGetSpaceWorkItemsById.
@Test
public void testGetSpaceWorkItemsById() throws Exception {
TestData testData = new TestData();
TestUtils.initSpaces(requestProvider, testData);
requestProvider.addGetRequest("/namedspaces/user", testData.spaces);
OSIORestClient client = connector.getClient(repository, requestProvider);
RepositoryLocation location = client.getClient().getLocation();
location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
OSIORestConfiguration configuration = connector.getRepositoryConfiguration(repository);
configuration.getSpaces();
Map<String, Space> externSpaces = configuration.getExternalSpaces();
assertTrue(externSpaces != null);
assertTrue(externSpaces.isEmpty());
Space s1 = client.getSpaceById("SPACE-0001", repository);
assertTrue(s1 != null);
assertEquals(s1.getName(), "mywork");
assertEquals(s1.getId(), "SPACE-0001");
Space s2 = client.getSpaceById("SPACE-0003", repository);
assertTrue(s2 != null);
assertEquals(s2.getName(), "mywork");
assertEquals(s2.getId(), "SPACE-0003");
externSpaces = configuration.getExternalSpaces();
assertTrue(externSpaces != null);
assertEquals(externSpaces.get("SPACE-0003"), s2);
}
use of org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData in project linuxtools by eclipse.
the class TestOSIORestGetAuthUser method testGetAuthUser.
@Test
public void testGetAuthUser() 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");
OSIORestGetAuthUser data = new OSIORestGetAuthUser(client.getClient());
String bundleLocation = Activator.getContext().getBundle().getLocation();
int index = bundleLocation.indexOf('/');
String fileName = bundleLocation.substring(index) + "/testjson/authuser.data";
FileReader in = new FileReader(fileName);
Identity user = data.testParseFromJson(in);
assertEquals("User.org", user.getCompany());
assertEquals("user@user.org", user.getEmail());
assertEquals("User 1", user.getFullName());
assertEquals("IDENTITY-0001", user.getIdentityID());
assertEquals("https://www.gravatar.com/avatar/user.jpg", user.getImageURL());
assertEquals("USER-0001", user.getUserID());
assertEquals("user", user.getUsername());
assertEquals("IDENTITY-0001", user.getId());
}
use of org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData 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());
}
Aggregations