Search in sources :

Example 11 with CaseFile

use of org.kie.server.api.model.cases.CaseFile in project droolsjbpm-integration by kiegroup.

the class CaseServiceRestOnlyIntegrationTest method testCreateCase.

@Test
public void testCreateCase() {
    CaseFile caseFileObj = CaseFile.builder().addUserAssignments(CASE_OWNER_ROLE, USER_YODA).addUserAssignments(CASE_CONTACT_ROLE, USER_JOHN).build();
    Entity<CaseFile> caseFile = Entity.entity(caseFileObj, getMediaType());
    Map<String, Object> valuesMap = new HashMap<String, Object>();
    valuesMap.put(RestURI.CONTAINER_ID, CONTAINER_ID);
    valuesMap.put(RestURI.CASE_DEF_ID, CASE_HR_DEF_ID);
    WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), RestURI.CASE_URI + "/" + RestURI.START_CASE_POST_URI, valuesMap));
    logger.debug("Start case: [POST] " + clientRequest.getUri());
    response = clientRequest.request(getMediaType()).post(caseFile);
    Assert.assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    String caseId = response.readEntity(JaxbString.class).getValue();
    assertNotNull(caseId);
}
Also used : JaxbString(org.kie.server.api.model.type.JaxbString) CaseFile(org.kie.server.api.model.cases.CaseFile) HashMap(java.util.HashMap) JaxbString(org.kie.server.api.model.type.JaxbString) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) RestJbpmBaseIntegrationTest(org.kie.server.integrationtests.jbpm.rest.RestJbpmBaseIntegrationTest)

Example 12 with CaseFile

use of org.kie.server.api.model.cases.CaseFile in project droolsjbpm-integration by kiegroup.

the class CustomCaseIdIntegrationTest method testCustomCaseId.

@Test
public void testCustomCaseId() {
    Assume.assumeFalse(TestConfig.isLocalServer());
    Map<String, Object> data = new HashMap<>();
    data.put("s", "first case started");
    CaseFile caseFile = CaseFile.builder().addUserAssignments(CASE_OWNER_ROLE, USER_YODA).data(data).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CASE_HR_DEF_ID, caseFile);
    assertNotNull(caseId);
    assertTrue("Created Case Id doesn't start with expected value, value is: " + caseId, caseId.startsWith("HR-01234"));
}
Also used : HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile) Test(org.junit.Test)

Example 13 with CaseFile

use of org.kie.server.api.model.cases.CaseFile in project droolsjbpm-integration by kiegroup.

the class CaseRuntimeDataServiceIntegrationTest method testCaseRolesCardinality.

@Test
public void testCaseRolesCardinality() {
    Map<String, Object> data = new HashMap<>();
    data.put("s", "first case started");
    CaseFile caseFile = CaseFile.builder().data(data).addUserAssignments(CASE_INSURED_ROLE, USER_YODA).addUserAssignments(CASE_INS_REP_ROLE, USER_JOHN).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CLAIM_CASE_DEF_ID, caseFile);
    assertNotNull(caseId);
    // Try to add second user to insured role with cardinality 1
    assertClientException(() -> caseClient.assignUserToRole(CONTAINER_ID, caseId, CASE_INSURED_ROLE, USER_YODA), 400, "Cannot add more users for role " + CASE_INSURED_ROLE);
}
Also used : HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest) Test(org.junit.Test)

Example 14 with CaseFile

use of org.kie.server.api.model.cases.CaseFile in project droolsjbpm-integration by kiegroup.

the class CaseRuntimeDataServiceIntegrationTest method startUserTaskCase.

private String startUserTaskCase(String owner, String contact) {
    Map<String, Object> data = new HashMap<>();
    data.put("s", "first case started");
    CaseFile caseFile = CaseFile.builder().addUserAssignments(CASE_OWNER_ROLE, owner).addUserAssignments(CASE_CONTACT_ROLE, contact).data(data).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CASE_HR_DEF_ID, caseFile);
    assertNotNull(caseId);
    return caseId;
}
Also used : HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile)

Example 15 with CaseFile

use of org.kie.server.api.model.cases.CaseFile in project droolsjbpm-integration by kiegroup.

the class CaseRuntimeDataServiceIntegrationTest method startCarInsuranceClaimCase.

private String startCarInsuranceClaimCase(String insured, String insuranceRep, String assessor) {
    Map<String, Object> data = new HashMap<>();
    data.put("s", "first case started");
    CaseFile caseFile = CaseFile.builder().addUserAssignments(CASE_INSURED_ROLE, insured).addUserAssignments(CASE_INS_REP_ROLE, insuranceRep).addUserAssignments(CASE_ASSESSOR_ROLE, assessor).data(data).build();
    String caseId = caseClient.startCase(CONTAINER_ID, CLAIM_CASE_DEF_ID, caseFile);
    assertNotNull(caseId);
    return caseId;
}
Also used : HashMap(java.util.HashMap) CaseFile(org.kie.server.api.model.cases.CaseFile)

Aggregations

CaseFile (org.kie.server.api.model.cases.CaseFile)23 HashMap (java.util.HashMap)17 Test (org.junit.Test)13 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)9 CaseInstance (org.kie.server.api.model.cases.CaseInstance)3 TaskSummary (org.kie.server.api.model.instance.TaskSummary)3 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 WebTarget (javax.ws.rs.client.WebTarget)1 CaseDefinitionNotFoundException (org.jbpm.casemgmt.api.CaseDefinitionNotFoundException)1 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)1 CaseRuntimeDataService (org.jbpm.casemgmt.api.CaseRuntimeDataService)1 CaseService (org.jbpm.casemgmt.api.CaseService)1 TaskSpecification (org.jbpm.casemgmt.api.dynamic.TaskSpecification)1