Search in sources :

Example 6 with OctaneTaskAbridged

use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.

the class TaskingServiceE2ETests method taskingE2ETest.

@Test
public void taskingE2ETest() {
    OctaneTaskAbridged task;
    // push task 1 - status
    String statusTaskId = UUID.randomUUID().toString();
    task = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(statusTaskId).setServiceId(inId).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/status");
    tasks.add(task);
    // push task 2 - jobs list
    String jobsTaskId = UUID.randomUUID().toString();
    task = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(jobsTaskId).setServiceId(inId).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/jobs");
    tasks.add(task);
    // wait for at least 2 tasks to arrive in results map
    GeneralTestUtils.waitAtMostFor(10000, () -> {
        if (results.size() < 3) {
            return null;
        } else {
            return true;
        }
    });
    // verify status task cycle
    Assert.assertTrue(results.containsKey(statusTaskId));
    OctaneResultAbridged statusResult = results.get(statusTaskId);
    Assert.assertNotNull(statusResult);
    Assert.assertEquals(inId, statusResult.getServiceId());
    Assert.assertEquals(HttpStatus.SC_OK, statusResult.getStatus());
    // verify jobs task cycle
    Assert.assertTrue(results.containsKey(jobsTaskId));
    OctaneResultAbridged jobsResult = results.get(jobsTaskId);
    Assert.assertNotNull(jobsResult);
    Assert.assertEquals(inId, jobsResult.getServiceId());
    Assert.assertEquals(HttpStatus.SC_OK, jobsResult.getStatus());
}
Also used : OctaneResultAbridged(com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged) OctaneTaskAbridged(com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged) Test(org.junit.Test)

Example 7 with OctaneTaskAbridged

use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.

the class TaskingServiceTests method testNonExistingAPI.

@Test
public void testNonExistingAPI() {
    TasksProcessor tasksProcessor = client.getTasksProcessor();
    Assert.assertNotNull(tasksProcessor);
    OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(UUID.randomUUID().toString()).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/some/non/existing/url");
    OctaneResultAbridged resultAbridged = tasksProcessor.execute(taskAbridged);
    Assert.assertNotNull(resultAbridged);
    Assert.assertEquals(HttpStatus.SC_NOT_FOUND, resultAbridged.getStatus());
    Assert.assertNotNull(resultAbridged.getHeaders());
    Assert.assertTrue(resultAbridged.getHeaders().isEmpty());
    Assert.assertEquals(taskAbridged.getId(), resultAbridged.getId());
    Assert.assertEquals(client.getInstanceId(), resultAbridged.getServiceId());
    Assert.assertNull(resultAbridged.getBody());
}
Also used : OctaneResultAbridged(com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged) OctaneTaskAbridged(com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged) Test(org.junit.Test)

Example 8 with OctaneTaskAbridged

use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.

the class TaskingServiceTests method testRunThrowsExceptionAPI.

@Test
public void testRunThrowsExceptionAPI() {
    TasksProcessor tasksProcessor = client.getTasksProcessor();
    Assert.assertNotNull(tasksProcessor);
    OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(UUID.randomUUID().toString()).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/jobs/job-a/run");
    TaskingTestPluginServicesTest.runAPIThrowsException = true;
    OctaneResultAbridged resultAbridged = tasksProcessor.execute(taskAbridged);
    TaskingTestPluginServicesTest.runAPIThrowsException = false;
    runCommonAsserts(resultAbridged, taskAbridged.getId(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
    TaskProcessingErrorBody errorBody = dtoFactory.dtoFromJson(resultAbridged.getBody(), TaskProcessingErrorBody.class);
    Assert.assertNotNull(errorBody);
    Assert.assertNotNull(errorBody.getErrorMessage());
    Assert.assertTrue(errorBody.getErrorMessage().contains("runtime exception"));
}
Also used : OctaneResultAbridged(com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged) OctaneTaskAbridged(com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged) TaskProcessingErrorBody(com.hp.octane.integrations.dto.connectivity.TaskProcessingErrorBody) Test(org.junit.Test)

Example 9 with OctaneTaskAbridged

use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.

the class TaskingServiceTests method negativeTestC.

@Test(expected = IllegalArgumentException.class)
public void negativeTestC() {
    TasksProcessor tasksProcessor = client.getTasksProcessor();
    Assert.assertNotNull(tasksProcessor);
    OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setUrl("");
    tasksProcessor.execute(taskAbridged);
}
Also used : OctaneTaskAbridged(com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged) Test(org.junit.Test)

Example 10 with OctaneTaskAbridged

use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.

the class TaskingServiceTests method testJobNotExistsAPI.

@Test
public void testJobNotExistsAPI() {
    TasksProcessor tasksProcessor = client.getTasksProcessor();
    Assert.assertNotNull(tasksProcessor);
    OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(UUID.randomUUID().toString()).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/jobs/job-not-exists");
    OctaneResultAbridged resultAbridged = tasksProcessor.execute(taskAbridged);
    Assert.assertNotNull(resultAbridged);
    Assert.assertEquals(HttpStatus.SC_NOT_FOUND, resultAbridged.getStatus());
    Assert.assertNotNull(resultAbridged.getHeaders());
    Assert.assertTrue(resultAbridged.getHeaders().isEmpty());
    Assert.assertEquals(taskAbridged.getId(), resultAbridged.getId());
    Assert.assertEquals(client.getInstanceId(), resultAbridged.getServiceId());
    Assert.assertNull(resultAbridged.getBody());
}
Also used : OctaneResultAbridged(com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged) OctaneTaskAbridged(com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged) Test(org.junit.Test)

Aggregations

OctaneTaskAbridged (com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged)14 Test (org.junit.Test)13 OctaneResultAbridged (com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged)11 PipelineNode (com.hp.octane.integrations.dto.pipelines.PipelineNode)3 CIJobsList (com.hp.octane.integrations.dto.general.CIJobsList)2 TaskProcessingErrorBody (com.hp.octane.integrations.dto.connectivity.TaskProcessingErrorBody)1 CIParameter (com.hp.octane.integrations.dto.parameters.CIParameter)1 OctaneSPEndpointSimulator (com.hp.octane.integrations.testhelpers.OctaneSPEndpointSimulator)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 Response (org.eclipse.jetty.server.Response)1