use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.
the class TaskingServiceTests method testJobsNoParamsAPI.
@Test
public void testJobsNoParamsAPI() {
TasksProcessor tasksProcessor = client.getTasksProcessor();
Assert.assertNotNull(tasksProcessor);
OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(UUID.randomUUID().toString()).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/jobs?parameters=false");
OctaneResultAbridged resultAbridged = tasksProcessor.execute(taskAbridged);
runCommonAsserts(resultAbridged, taskAbridged.getId(), HttpStatus.SC_OK);
CIJobsList ciJobsList = dtoFactory.dtoFromJson(resultAbridged.getBody(), CIJobsList.class);
Assert.assertNotNull(ciJobsList);
Assert.assertNotNull(ciJobsList.getJobs());
Assert.assertEquals(3, ciJobsList.getJobs().length);
for (PipelineNode ciJob : ciJobsList.getJobs()) {
Assert.assertNotNull(ciJob);
Assert.assertTrue(ciJob.getName().startsWith("Job "));
Assert.assertTrue(ciJob.getJobCiId().startsWith("job-"));
Assert.assertNotNull(ciJob.getParameters());
Assert.assertTrue(ciJob.getParameters().isEmpty());
}
}
use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.
the class TaskingServiceTests method testJobsWithParamsAPI.
@Test
public void testJobsWithParamsAPI() {
TasksProcessor tasksProcessor = client.getTasksProcessor();
Assert.assertNotNull(tasksProcessor);
OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(UUID.randomUUID().toString()).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/jobs");
OctaneResultAbridged resultAbridged = tasksProcessor.execute(taskAbridged);
runCommonAsserts(resultAbridged, taskAbridged.getId(), HttpStatus.SC_OK);
CIJobsList ciJobsList = dtoFactory.dtoFromJson(resultAbridged.getBody(), CIJobsList.class);
Assert.assertNotNull(ciJobsList);
Assert.assertNotNull(ciJobsList.getJobs());
Assert.assertEquals(3, ciJobsList.getJobs().length);
for (PipelineNode ciJob : ciJobsList.getJobs()) {
Assert.assertNotNull(ciJob);
Assert.assertTrue(ciJob.getName().startsWith("Job "));
Assert.assertTrue(ciJob.getJobCiId().startsWith("job-"));
Assert.assertNotNull(ciJob.getParameters());
Assert.assertEquals(3, ciJob.getParameters().size());
for (CIParameter ciParameter : ciJob.getParameters()) {
Assert.assertNotNull(ciParameter);
Assert.assertNotNull(ciParameter.getName());
Assert.assertNotNull(ciParameter.getType());
Assert.assertNotNull(ciParameter.getValue());
}
}
}
use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.
the class TaskingServiceTests method negativeTestB.
@Test(expected = IllegalArgumentException.class)
public void negativeTestB() {
TasksProcessor tasksProcessor = client.getTasksProcessor();
Assert.assertNotNull(tasksProcessor);
OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class);
tasksProcessor.execute(taskAbridged);
}
use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.
the class TaskingServiceTests method negativeTestD.
@Test(expected = IllegalArgumentException.class)
public void negativeTestD() {
TasksProcessor tasksProcessor = client.getTasksProcessor();
Assert.assertNotNull(tasksProcessor);
OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setUrl("some_wrong_url");
tasksProcessor.execute(taskAbridged);
}
use of com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged in project octane-ci-java-sdk by MicroFocus.
the class TaskingServiceE2ETests method setupOctaneEPSimulator.
private static OctaneSPEndpointSimulator setupOctaneEPSimulator(String sspId) {
OctaneSPEndpointSimulator result = OctaneSPEndpointSimulator.addInstance(sspId);
// remove default NOOP GET tasks API handler
result.removeApiHandler(HttpMethod.GET, "^.*tasks$");
// install GET tasks API handler
result.installApiHandler(HttpMethod.GET, "^.*tasks$", request -> {
try {
Response response = request.getResponse();
OctaneTaskAbridged task = tasks.poll(500, TimeUnit.MILLISECONDS);
if (task != null) {
logger.info("got task to dispatch to CI Server - " + task.getUrl() + " - " + task.getId() + "...");
response.setStatus(HttpStatus.SC_OK);
response.addHeader(CONTENT_TYPE, "application/json");
response.getWriter().write(dtoFactory.dtoCollectionToJson(Collections.singletonList(task)));
response.flushBuffer();
logger.info("... task dispatched");
} else {
results.put("timeout_flow_verification_part", null);
response.setStatus(HttpStatus.SC_REQUEST_TIMEOUT);
}
} catch (Exception e) {
logger.error("failed during simulation of Octane EP - GET tasks", e);
}
});
// install PUT results API handler
result.installApiHandler(HttpMethod.PUT, "^.*result$", request -> {
try {
String rawBody = CIPluginSDKUtils.inputStreamToUTF8String(new GZIPInputStream(request.getInputStream()));
OctaneResultAbridged taskResult = dtoFactory.dtoFromJson(rawBody, OctaneResultAbridged.class);
logger.info("received and parsed result for task " + taskResult.getId());
Assert.assertNotNull(taskResult);
Assert.assertNotNull(taskResult.getId());
results.put(taskResult.getId(), taskResult);
} catch (Exception e) {
logger.error("failed during simulation of Octane EP - PUT results", e);
}
});
return result;
}
Aggregations