Search in sources :

Example 1 with JaxbLong

use of org.kie.server.api.model.type.JaxbLong in project droolsjbpm-integration by kiegroup.

the class JbpmRestIntegrationTest method testBasicJbpmRequest.

@Test
public void testBasicJbpmRequest() throws Exception {
    KieContainerResource resource = new KieContainerResource(CONTAINER, releaseId);
    Map<String, Object> valuesMap = new HashMap<String, Object>();
    valuesMap.put(CONTAINER_ID, resource.getContainerId());
    valuesMap.put(PROCESS_ID, HUMAN_TASK_OWN_TYPE_ID);
    Response response = null;
    try {
        WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + START_PROCESS_POST_URI, valuesMap));
        logger.info("[POST] " + clientRequest.getUri());
        response = clientRequest.request().post(createEntity(""));
        Assert.assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
        Assertions.assertThat((String) response.getHeaders().getFirst("Content-Type")).startsWith(getMediaType().toString());
        JaxbLong pId = response.readEntity(JaxbLong.class);
        valuesMap.put(PROCESS_INST_ID, pId.unwrap());
        clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + ABORT_PROCESS_INST_DEL_URI, valuesMap));
        logger.info("[DELETE] " + clientRequest.getUri());
        response = clientRequest.request(getMediaType()).delete();
        int noContentStatusCode = Response.Status.NO_CONTENT.getStatusCode();
        int okStatusCode = Response.Status.OK.getStatusCode();
        assertTrue("Wrong status code returned: " + response.getStatus(), response.getStatus() == noContentStatusCode || response.getStatus() == okStatusCode);
    } finally {
        if (response != null) {
            response.close();
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) JaxbString(org.kie.server.api.model.type.JaxbString) WebTarget(javax.ws.rs.client.WebTarget) KieContainerResource(org.kie.server.api.model.KieContainerResource) JaxbLong(org.kie.server.api.model.type.JaxbLong) Test(org.junit.Test)

Example 2 with JaxbLong

use of org.kie.server.api.model.type.JaxbLong in project droolsjbpm-integration by kiegroup.

the class JbpmRestIntegrationTest method testBasicJbpmRequestWithSingleAcceptHeader.

@Test
public void testBasicJbpmRequestWithSingleAcceptHeader() throws Exception {
    KieContainerResource resource = new KieContainerResource(CONTAINER, releaseId);
    Map<String, Object> valuesMap = new HashMap<String, Object>();
    valuesMap.put(CONTAINER_ID, resource.getContainerId());
    valuesMap.put(PROCESS_ID, HUMAN_TASK_OWN_TYPE_ID);
    Response response = null;
    try {
        WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + START_PROCESS_POST_URI, valuesMap));
        logger.info("[POST] " + clientRequest.getUri());
        response = clientRequest.request(getMediaType()).post(createEntity(""));
        Assert.assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
        Assertions.assertThat((String) response.getHeaders().getFirst("Content-Type")).startsWith(getMediaType().toString());
        JaxbLong pId = response.readEntity(JaxbLong.class);
        valuesMap.put(PROCESS_INST_ID, pId.unwrap());
        clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + ABORT_PROCESS_INST_DEL_URI, valuesMap));
        logger.info("[DELETE] " + clientRequest.getUri());
        response = clientRequest.request(getMediaType()).delete();
        int noContentStatusCode = Response.Status.NO_CONTENT.getStatusCode();
        int okStatusCode = Response.Status.OK.getStatusCode();
        assertTrue("Wrong status code returned: " + response.getStatus(), response.getStatus() == noContentStatusCode || response.getStatus() == okStatusCode);
    } finally {
        if (response != null) {
            response.close();
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) JaxbString(org.kie.server.api.model.type.JaxbString) WebTarget(javax.ws.rs.client.WebTarget) KieContainerResource(org.kie.server.api.model.KieContainerResource) JaxbLong(org.kie.server.api.model.type.JaxbLong) Test(org.junit.Test)

Example 3 with JaxbLong

use of org.kie.server.api.model.type.JaxbLong in project droolsjbpm-integration by kiegroup.

the class JbpmRestIntegrationTest method testBasicJbpmRequestManyAcceptHeaders.

@Test
public void testBasicJbpmRequestManyAcceptHeaders() throws Exception {
    KieContainerResource resource = new KieContainerResource(CONTAINER, releaseId);
    Map<String, Object> valuesMap = new HashMap<String, Object>();
    valuesMap.put(CONTAINER_ID, resource.getContainerId());
    valuesMap.put(PROCESS_ID, HUMAN_TASK_OWN_TYPE_ID);
    Response response = null;
    try {
        WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + START_PROCESS_POST_URI, valuesMap));
        logger.info("[POST] " + clientRequest.getUri());
        response = clientRequest.request(acceptHeadersByFormat.get(marshallingFormat)).post(createEntity(""));
        Assert.assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
        Assertions.assertThat((String) response.getHeaders().getFirst("Content-Type")).startsWith(getMediaType().toString());
        JaxbLong pId = response.readEntity(JaxbLong.class);
        valuesMap.put(PROCESS_INST_ID, pId.unwrap());
        clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + ABORT_PROCESS_INST_DEL_URI, valuesMap));
        logger.info("[DELETE] " + clientRequest.getUri());
        response = clientRequest.request(getMediaType()).delete();
        int noContentStatusCode = Response.Status.NO_CONTENT.getStatusCode();
        int okStatusCode = Response.Status.OK.getStatusCode();
        assertTrue("Wrong status code returned: " + response.getStatus(), response.getStatus() == noContentStatusCode || response.getStatus() == okStatusCode);
    } finally {
        if (response != null) {
            response.close();
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) JaxbString(org.kie.server.api.model.type.JaxbString) WebTarget(javax.ws.rs.client.WebTarget) KieContainerResource(org.kie.server.api.model.KieContainerResource) JaxbLong(org.kie.server.api.model.type.JaxbLong) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)3 WebTarget (javax.ws.rs.client.WebTarget)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 KieContainerResource (org.kie.server.api.model.KieContainerResource)3 JaxbLong (org.kie.server.api.model.type.JaxbLong)3 JaxbString (org.kie.server.api.model.type.JaxbString)3