Search in sources :

Example 6 with BuildResultRest

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);
    }
}
Also used : BuildResultRest(org.jboss.pnc.bpm.model.BuildResultRest) HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) DefaultBuildDriverResult(org.jboss.pnc.termdbuilddriver.DefaultBuildDriverResult) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) DefaultBuildDriverResult(org.jboss.pnc.termdbuilddriver.DefaultBuildDriverResult) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) IOException(java.io.IOException) BuildDriverResultRest(org.jboss.pnc.bpm.model.BuildDriverResultRest) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 7 with BuildResultRest

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();
}
Also used : BuildResultRest(org.jboss.pnc.bpm.model.BuildResultRest) EnvironmentDriverResult(org.jboss.pnc.spi.environment.EnvironmentDriverResult) RepourResult(org.jboss.pnc.spi.repour.RepourResult) Test(org.junit.Test)

Aggregations

BuildResultRest (org.jboss.pnc.bpm.model.BuildResultRest)7 Test (org.junit.Test)5 IOException (java.io.IOException)2 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 HttpPost (org.apache.http.client.methods.HttpPost)2 StringEntity (org.apache.http.entity.StringEntity)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 BuildDriverResultRest (org.jboss.pnc.bpm.model.BuildDriverResultRest)2 BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)2 EnvironmentDriverResult (org.jboss.pnc.spi.environment.EnvironmentDriverResult)2 BuildExecutionConfiguration (org.jboss.pnc.spi.executor.BuildExecutionConfiguration)2 RepourResult (org.jboss.pnc.spi.repour.RepourResult)2 InputStream (java.io.InputStream)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 NameValuePair (org.apache.http.NameValuePair)1 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)1 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)1 BpmTask (org.jboss.pnc.bpm.BpmTask)1