Search in sources :

Example 1 with NullOperationMonitor

use of org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor in project linuxtools by eclipse.

the class TestOSIORestClient method testValidate.

@Test
public void testValidate() throws Exception {
    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");
    assertNotNull(client.getClient());
    assertTrue(client.validate(new NullOperationMonitor()));
}
Also used : OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) NullOperationMonitor(org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor) Test(org.junit.Test)

Example 2 with NullOperationMonitor

use of org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor 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");
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) AbstractTaskDataHandler(org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) TreeSet(java.util.TreeSet) TaskCommentMapper(org.eclipse.mylyn.tasks.core.data.TaskCommentMapper) TaskAttributeMapper(org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper) NullOperationMonitor(org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor) Test(org.junit.Test)

Example 3 with NullOperationMonitor

use of org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor in project linuxtools by eclipse.

the class TestOSIORestClient method testGetConfiguration.

@Test
public void testGetConfiguration() 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 = client.getConfiguration(repository, new NullOperationMonitor());
    Map<String, Space> spaces = configuration.getSpaces();
    assertEquals(spaces.size(), 2);
    assertTrue(spaces.containsKey("mywork"));
    assertTrue(spaces.containsKey("mywork2"));
}
Also used : Space(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) NullOperationMonitor(org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor) Test(org.junit.Test)

Example 4 with NullOperationMonitor

use of org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor in project linuxtools by eclipse.

the class TestOSIORestClient method testGetSpaceLinkTypes.

@Test
public void testGetSpaceLinkTypes() 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 = client.getConfiguration(repository, new NullOperationMonitor());
    configuration.getSpaces();
    Map<String, String> linktypes = client.getSpaceLinkTypes("SPACE-0001", repository);
    assertTrue(linktypes != null);
    assertTrue(!linktypes.isEmpty());
    assertEquals(linktypes.get("blocks"), "LINKTYPE-0001");
    assertEquals(linktypes.get("is blocked by"), "LINKTYPE-0001");
}
Also used : TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) NullOperationMonitor(org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor) Test(org.junit.Test)

Example 5 with NullOperationMonitor

use of org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor in project linuxtools by eclipse.

the class TestOSIORestClient method testFormSearchURL.

@Test
public void testFormSearchURL() 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 taskData1 = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
    assertTrue(taskDataHandler.initializeTaskData(repository, taskData1, null, null));
    taskData1.getRoot().createAttribute(OSIORestTaskSchema.getDefault().SPACE_ID.getKey()).addValue("SPACE-0001");
    taskData1.getRoot().createAttribute(OSIORestTaskSchema.getDefault().WORKITEM_TYPE.getKey()).addValue("bug");
    TaskData taskData2 = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
    assertTrue(taskDataHandler.initializeTaskData(repository, taskData2, null, null));
    taskData2.getRoot().createAttribute(OSIORestTaskSchema.getDefault().SPACE_ID.getKey()).addValue("SPACE-0002");
    taskData2.getRoot().createAttribute(OSIORestTaskSchema.getDefault().WORKITEM_TYPE.getKey()).addValue("bug");
    List<TaskData> taskList = new ArrayList<>();
    taskList.add(taskData1);
    taskList.add(taskData2);
    String query = "filter[expression]={\"$AND\":[{\"$OR\":[{\"space\":\"SPACE-0001\"},{\"space\":\"SPACE-0002\"}]},{\"$OR\":[{\"workitemtype\":\"WORKITEMTYPE-0001\"}]}]}";
    String transformedQuery = URLQueryEncoder.transform(query);
    requestProvider.addGetRequest("/search?" + transformedQuery, taskList);
    RepositoryLocation location = client.getClient().getLocation();
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
    location.setUrl("https://api.openshift.io/api");
    OSIORestConfiguration configuration = client.getConfiguration(repository, new NullOperationMonitor());
    Map<String, Space> spaces = configuration.getSpaces();
    TestTaskDataCollector collector = new TestTaskDataCollector();
    RepositoryQuery repoQuery = new RepositoryQuery("https://api.openshift.io/api/query?space=mywork&space=mywork2&baseType=bug");
    IStatus status = client.performQuery(repository, repoQuery, collector, new NullOperationMonitor());
    assertTrue(status.isOK());
    List<TaskData> dataList = collector.getTaskData();
    assertTrue(dataList != null);
    assertEquals(dataList.size(), 2);
    assertEquals(dataList.get(0), taskData1);
    assertEquals(dataList.get(1), taskData2);
}
Also used : Space(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space) IStatus(org.eclipse.core.runtime.IStatus) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) ArrayList(java.util.ArrayList) AbstractTaskDataHandler(org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData) IRepositoryQuery(org.eclipse.mylyn.tasks.core.IRepositoryQuery) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) TaskAttributeMapper(org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper) NullOperationMonitor(org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor) Test(org.junit.Test)

Aggregations

OSIORestClient (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient)5 NullOperationMonitor (org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor)5 Test (org.junit.Test)5 TestData (org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData)4 RepositoryLocation (org.eclipse.mylyn.commons.repositories.core.RepositoryLocation)4 OSIORestConfiguration (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration)3 Space (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space)2 AbstractTaskDataHandler (org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler)2 TaskAttributeMapper (org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper)2 TaskData (org.eclipse.mylyn.tasks.core.data.TaskData)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 IStatus (org.eclipse.core.runtime.IStatus)1 IRepositoryQuery (org.eclipse.mylyn.tasks.core.IRepositoryQuery)1 TaskAttribute (org.eclipse.mylyn.tasks.core.data.TaskAttribute)1 TaskCommentMapper (org.eclipse.mylyn.tasks.core.data.TaskCommentMapper)1