Search in sources :

Example 21 with RepositoryLocation

use of org.eclipse.mylyn.commons.repositories.core.RepositoryLocation in project linuxtools by eclipse.

the class TestOSIORestPostNewLabel method testPostNewLabel.

@Test
public void testPostNewLabel() 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);
    OSIORestPostNewLabelTask data = new OSIORestPostNewLabelTask(client.getClient(), testData.spaceMap.get("mywork"), "NewLabel");
    OSIORestPostNewLabelTask.TaskAttributeTypeAdapter adapter = data.new TaskAttributeTypeAdapter();
    StringWriter s = new StringWriter();
    JsonWriter writer = new JsonWriter(s);
    adapter.write(writer, "NewLabel");
    assertEquals("{\"data\":{\"attributes\":{\"name\":\"NewLabel\",\"background-color\":\"#f9d67a\",\"border-color\":\"#f39d3c\"},\"type\":\"labels\"},\"included\":[]}", s.getBuffer().toString());
}
Also used : TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) AbstractTaskDataHandler(org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler) JsonWriter(com.google.gson.stream.JsonWriter) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData) OSIORestPostNewLabelTask(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestPostNewLabelTask) StringWriter(java.io.StringWriter) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) TaskAttributeMapper(org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper) NullOperationMonitor(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor) Test(org.junit.Test)

Example 22 with RepositoryLocation

use of org.eclipse.mylyn.commons.repositories.core.RepositoryLocation in project linuxtools by eclipse.

the class OSIORestConnector method getClient.

public OSIORestClient getClient(TaskRepository repository, IOSIORestRequestProvider provider) throws CoreException {
    try {
        RepositoryLocation location = new RepositoryLocation(convertProperties(repository));
        OSIORestClient newClient = new OSIORestClient(location, this, provider);
        clientCache.put(new RepositoryKey(repository), newClient);
        return newClient;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 23 with RepositoryLocation

use of org.eclipse.mylyn.commons.repositories.core.RepositoryLocation in project linuxtools by eclipse.

the class OSIORestConnector method createClient.

private OSIORestClient createClient(TaskRepository repository) {
    RepositoryLocation location = new RepositoryLocation(convertProperties(repository));
    OSIORestClient client = new OSIORestClient(location, this);
    return client;
}
Also used : RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation)

Aggregations

RepositoryLocation (org.eclipse.mylyn.commons.repositories.core.RepositoryLocation)23 OSIORestClient (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient)20 Test (org.junit.Test)20 OSIORestConfiguration (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration)19 TestData (org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData)19 NullOperationMonitor (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor)15 TaskData (org.eclipse.mylyn.tasks.core.data.TaskData)13 AbstractTaskDataHandler (org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler)11 TaskAttributeMapper (org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper)11 FileReader (java.io.FileReader)10 TaskAttribute (org.eclipse.mylyn.tasks.core.data.TaskAttribute)10 JsonWriter (com.google.gson.stream.JsonWriter)5 StringWriter (java.io.StringWriter)5 OSIORestTaskSchema (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestTaskSchema)4 NullOperationMonitor (org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor)4 Identity (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Identity)3 Space (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space)3 LinkedHashSet (java.util.LinkedHashSet)2 WorkItem (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItem)2 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)1