use of com.hp.octane.integrations.dto.pipelines.PipelineContext in project octane-ci-java-sdk by MicroFocus.
the class PipelineContextServiceImpl method updatePipeline.
@Override
public PipelineContext updatePipeline(String serverIdentity, String jobName, PipelineContext pipelineContext) throws IOException {
String url = getConfigurationUrl(serverIdentity, jobName);
validateReleaseAndMilestone(pipelineContext);
OctaneRestClient octaneRestClient = restService.obtainOctaneRestClient();
Map<String, String> headers = new HashMap<>();
headers.put(ACCEPT_HEADER, ContentType.APPLICATION_JSON.getMimeType());
headers.put(CONTENT_TYPE_HEADER, ContentType.APPLICATION_JSON.getMimeType());
PipelineContextList list = dtoFactory.newDTO(PipelineContextList.class).setData(Arrays.asList(pipelineContext));
String jsonData = dtoFactory.dtoToJson(list);
OctaneRequest request = dtoFactory.newDTO(OctaneRequest.class).setMethod(HttpMethod.PUT).setUrl(url).setBody(jsonData).setHeaders(headers);
OctaneResponse response = octaneRestClient.execute(request);
validateResponse(HttpStatus.SC_OK, response);
PipelineContextList resultList = dtoFactory.dtoFromJson(response.getBody(), PipelineContextList.class);
// we might receive several pipeline context from other workspaces.
// find updated context by id
PipelineContext result = resultList.getData().stream().filter(p -> p.getContextEntityId() == pipelineContext.getContextEntityId()).findFirst().get();
return result;
}
use of com.hp.octane.integrations.dto.pipelines.PipelineContext in project octane-ci-java-sdk by MicroFocus.
the class EntityDTOTests method testParsePipelineContext.
@Test
public void testParsePipelineContext() {
String json = "{\"contextEntityId\":2014,\"contextEntityName\":\"ss\",\"workspaceId\":1004,\"releaseId\":1013,\"ciJob\":{\"ciServer\":{\"id\":2002,\"workspaceId\":1004,\"instanceId\":\"d7cb541b-c22e-4ed5-a566-65854fb7aae1\",\"url\":\"http://localhost:9192/jenkins\",\"type\":\"jenkins\",\"name\":\"local\",\"sendingTime\":null},\"jobId\":2008,\"workspaceId\":1004,\"jobCiId\":\"ss\",\"name\":\"ss\",\"parameters\":[]},\"ignoreTests\":true,\"rootJobCiId\":\"ss\",\"taxonomies\":[{\"id\":1120,\"parent\":{\"id\":1087,\"name\":\"DB\"}}],\"listFields\":{\"test_tool_type\":[],\"test_level\":[{\"id\":1457}],\"test_type\":[],\"test_framework\":[]},\"contextEntityType\":\"pipeline\",\"pipelineRoot\":true}";
PipelineContext pc = dtoFactory.dtoFromJson(json, PipelineContext.class);
Assert.assertEquals(pc.getContextEntityId(), 2014);
}
use of com.hp.octane.integrations.dto.pipelines.PipelineContext in project octane-ci-java-sdk by MicroFocus.
the class PipelineContextServiceImpl method createPipeline.
@Override
public PipelineContext createPipeline(String serverIdentity, String jobName, PipelineContext pipelineContext) throws IOException {
String url = getConfigurationUrl(serverIdentity, jobName);
validateReleaseAndMilestone(pipelineContext);
OctaneRestClient octaneRestClient = restService.obtainOctaneRestClient();
Map<String, String> headers = new HashMap<>();
headers.put(ACCEPT_HEADER, ContentType.APPLICATION_JSON.getMimeType());
headers.put(CONTENT_TYPE_HEADER, ContentType.APPLICATION_JSON.getMimeType());
String jsonData = dtoFactory.dtoToJson(pipelineContext);
OctaneRequest request = dtoFactory.newDTO(OctaneRequest.class).setMethod(HttpMethod.POST).setUrl(url).setBody(jsonData).setHeaders(headers);
OctaneResponse response = octaneRestClient.execute(request);
validateResponse(HttpStatus.SC_CREATED, response);
PipelineContextList list = dtoFactory.dtoFromJson(response.getBody(), PipelineContextList.class);
// we might receive several pipeline context from other workspaces.
// find updated context by workspace id
PipelineContext result = list.getData().stream().filter(p -> p.getWorkspaceId() == pipelineContext.getWorkspaceId()).findFirst().get();
return result;
}
Aggregations