Search in sources :

Example 1 with OSIORestGetTaskLabels

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetTaskLabels in project linuxtools by eclipse.

the class TestOSIORestGetTaskLabels method testGetTaskLabels.

@Test
public void testGetTaskLabels() 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");
    OSIORestGetTaskLabels data = new OSIORestGetTaskLabels(client.getClient(), testData.spaceMap.get("mywork"), taskData);
    String bundleLocation = Activator.getContext().getBundle().getLocation();
    int index = bundleLocation.indexOf('/');
    String fileName = bundleLocation.substring(index) + "/testjson/labels.data";
    FileReader in = new FileReader(fileName);
    TaskAttribute original = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().LABELS.getKey());
    assertTrue(original == null || original.getValues().isEmpty());
    TaskAttribute attribute = data.testParseFromJson(in);
    assertEquals(2, attribute.getValues().size());
    List<String> values = attribute.getValues();
    assertEquals("Label1", values.get(0));
    assertEquals("Label2", values.get(1));
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestGetTaskLabels(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetTaskLabels) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) AbstractTaskDataHandler(org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) FileReader(java.io.FileReader) TaskAttributeMapper(org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper) NullOperationMonitor(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor) Test(org.junit.Test)

Aggregations

FileReader (java.io.FileReader)1 NullOperationMonitor (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor)1 OSIORestClient (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient)1 OSIORestConfiguration (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration)1 OSIORestGetTaskLabels (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetTaskLabels)1 TestData (org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData)1 RepositoryLocation (org.eclipse.mylyn.commons.repositories.core.RepositoryLocation)1 AbstractTaskDataHandler (org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler)1 TaskAttribute (org.eclipse.mylyn.tasks.core.data.TaskAttribute)1 TaskAttributeMapper (org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper)1 TaskData (org.eclipse.mylyn.tasks.core.data.TaskData)1 Test (org.junit.Test)1