use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestPostNewLink in project linuxtools by eclipse.
the class TestOSIORestPostNewLink method testPostNewLink.
@Test
public void testPostNewLink() 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);
OSIORestPostNewLink data = new OSIORestPostNewLink(client.getClient(), "LINKTYPE-0001", "WORKITEM-0001", "WORKITEM-0002", false);
OSIORestPostNewLink.TaskAttributeTypeAdapter adapter = data.new TaskAttributeTypeAdapter();
StringWriter s = new StringWriter();
JsonWriter writer = new JsonWriter(s);
adapter.write(writer, "");
assertEquals("{\"data\":{\"relationships\":{\"link_type\":{\"data\":{\"id\":\"LINKTYPE-0001\",\"type\":\"workitemlinktypes\"}}," + "\"source\":{\"data\":{\"id\":\"WORKITEM-0002\",\"type\":\"workitems\"}},\"target\":{\"data\":{\"id\":\"WORKITEM-0001\",\"type\":\"workitems\"}}}," + "\"type\":\"workitemlinks\"},\"included\":[false,false,false]}", s.toString());
}
Aggregations