use of org.jboss.pnc.bpm.model.BuildResultRest in project pnc by project-ncl.
the class BuildTaskEndpointTest method shouldAcceptCompletionResultAsSingleJson.
@Test
public void shouldAcceptCompletionResultAsSingleJson() throws RemoteResourceException {
// given
BuildDriverResult buildDriverResult = new DefaultBuildDriverResult("The log!", BuildStatus.SYSTEM_ERROR, java.util.Optional.of("12345"));
BuildDriverResultRest buildDriverResultRest = new BuildDriverResultRest(buildDriverResult);
BuildResultRest buildResultRest = new BuildResultRest();
buildResultRest.setBuildDriverResult(buildDriverResultRest);
// when
HttpPost request = new HttpPost(url + BASE_REST_PATH + "/build-tasks/42/completed");
request.addHeader(Credentials.USER.createAuthHeader(BasicHeader::new));
request.addHeader("Content-type", MediaType.APPLICATION_JSON);
String jsonBody = JsonOutputConverterMapper.apply(buildResultRest);
log.debug("Json body: {}.", jsonBody);
request.setEntity(new StringEntity(jsonBody, ContentType.APPLICATION_JSON));
// then
int statusCode = -1;
try (CloseableHttpClient httpClient = HttpUtils.getPermissiveHttpClient()) {
try (CloseableHttpResponse response = httpClient.execute(request)) {
statusCode = response.getStatusLine().getStatusCode();
Assert.assertEquals("Received error response code. Response: " + printEntity(response), // validation failure is expected; 500 when deserialization fails
400, statusCode);
}
} catch (IOException e) {
Assertions.fail("Cannot invoke remote endpoint.", e);
}
}
use of org.jboss.pnc.bpm.model.BuildResultRest in project pnc by project-ncl.
the class BuildResultRestTest method shouldGetLimitedToStringWithSomeValues.
@Test
public void shouldGetLimitedToStringWithSomeValues() {
BuildResultRest buildResultRest = new BuildResultRest();
buildResultRest.setCompletionStatus(CompletionStatus.SUCCESS);
buildResultRest.setProcessException(null);
buildResultRest.setProcessLog(LOG);
buildResultRest.setBuildExecutionConfiguration(null);
buildResultRest.setBuildDriverResult(null);
buildResultRest.setRepositoryManagerResult(null);
EnvironmentDriverResult environmentDriverResult = new EnvironmentDriverResult(CompletionStatus.SUCCESS, "SUCCESS", Optional.empty());
buildResultRest.setEnvironmentDriverResult(environmentDriverResult);
buildResultRest.setRepourResult(new RepourResult(CompletionStatus.SUCCESS, "Repour Success", "org.jboss", "1.1.0.Final-redhat-1"));
buildResultRest.toString();
}
Aggregations