Search in sources :

Example 11 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class JAXBMarshallerTest method testMarshallQueryParam.

@Test
public void testMarshallQueryParam() {
    Marshaller marshaller = MarshallerFactory.getMarshaller(new HashSet<>(), MarshallingFormat.JAXB, getClass().getClassLoader());
    QueryParam subParam = new QueryParam("col2", "EQUALS_TO", Collections.singletonList("XXX"));
    QueryParam param = new QueryParam("hola", "OR", Collections.singletonList(subParam));
    String converted = marshaller.marshall(param);
    QueryParam param2 = marshaller.unmarshall(converted, QueryParam.class);
    assertTrue(param2.getValue().get(0) instanceof QueryParam);
}
Also used : QueryParam(org.kie.server.api.model.definition.QueryParam) Test(org.junit.Test)

Example 12 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class CaseServiceIntegrationTest method testQueryByVariable.

@Test
public void testQueryByVariable() {
    Assume.assumeTrue(configuration.isRest());
    String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
    Assertions.assertThat(caseId).isNotNull();
    Assertions.assertThat(caseId).startsWith(CLAIM_CASE_ID_PREFIX);
    CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
    caseClient.closeCaseInstance(CONTAINER_ID, caseId, "work done at the moment");
    CaseInstance closed = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(closed.getCaseStatus()).isEqualTo(2);
    Assertions.assertThat(closed.getCompletionMessage()).isEqualTo("work done at the moment");
    Map<String, Object> data = new HashMap<>();
    data.put("additionalComment", "reopening the case");
    caseClient.reopenCase(caseId, CONTAINER_ID, CLAIM_CASE_DEF_ID, data);
    caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(caseInstance).isNotNull();
    Assertions.assertThat(caseInstance.getCaseId()).isEqualTo(caseId);
    Object additionalComment = caseClient.getCaseInstanceData(CONTAINER_ID, caseId, "additionalComment");
    Assertions.assertThat(additionalComment).isNotNull();
    Assertions.assertThat(additionalComment).isEqualTo("reopening the case");
    List<QueryParam> attrs = list(equalsTo(CASE_ATTR_CORRELATION_KEY, caseId));
    SearchQueryFilterSpec filter = new SearchQueryFilterSpec();
    filter.setAttributesQueryParams(attrs);
    List<CaseInstanceCustomVars> caseInstanceCustomVarsList = caseClient.queryCasesByVariables(filter, 0, 2);
    assertNotNull(caseInstanceCustomVarsList);
    Assertions.assertThat(caseInstanceCustomVarsList).hasSize(2);
    attrs = list(likeTo(CASE_ATTR_CORRELATION_KEY, false, CLAIM_CASE_ID_PREFIX + "%"));
    filter = new SearchQueryFilterSpec();
    filter.setAttributesQueryParams(attrs);
    caseInstanceCustomVarsList = caseClient.queryCasesByVariables(filter, 0, 2);
    assertNotNull(caseInstanceCustomVarsList);
    caseInstanceCustomVarsList.stream().forEach(e -> assertTrue(e.getCaseId().startsWith(CLAIM_CASE_ID_PREFIX)));
    List<CaseUserTaskWithVariables> caseUserTaskWithVariablesList = caseClient.queryUserTaskByVariables(new SearchQueryFilterSpec(), 0, 2);
    assertNotNull(caseUserTaskWithVariablesList);
    Assertions.assertThat(caseUserTaskWithVariablesList.size()).isGreaterThan(0);
}
Also used : CaseInstance(org.kie.server.api.model.cases.CaseInstance) HashMap(java.util.HashMap) QueryParam(org.kie.server.api.model.definition.QueryParam) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec) CaseInstanceCustomVars(org.kie.server.api.model.cases.CaseInstanceCustomVars) CaseUserTaskWithVariables(org.kie.server.api.model.cases.CaseUserTaskWithVariables) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 13 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class JSONMarshallerTest method testMarshallQueryParam.

@Test
public void testMarshallQueryParam() {
    Marshaller marshaller = MarshallerFactory.getMarshaller(new HashSet<>(), MarshallingFormat.JSON, getClass().getClassLoader());
    QueryParam subParam = new QueryParam("col2", "EQUALS_TO", Collections.singletonList("XXX"));
    QueryParam param = new QueryParam("hola", "OR", Collections.singletonList(subParam));
    String converted = marshaller.marshall(param);
    QueryParam param2 = marshaller.unmarshall(converted, QueryParam.class);
    assertTrue(param2.getValue().get(0) instanceof QueryParam);
}
Also used : JSONMarshaller(org.kie.server.api.marshalling.json.JSONMarshaller) QueryParam(org.kie.server.api.model.definition.QueryParam) Test(org.junit.Test)

Example 14 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class JSONMarshallerTest method testParam.

@Test
public void testParam() throws Exception {
    Marshaller marshaller = MarshallerFactory.getMarshaller(new HashSet<>(), MarshallingFormat.JSON, getClass().getClassLoader());
    URL url = Thread.currentThread().getContextClassLoader().getResource("marshaller.json");
    String input = Files.contentOf(new File(url.toURI()), "UTF-8");
    QueryParam[] params = marshaller.unmarshall(input, QueryParam[].class);
    assertEquals(1, params.length);
    assertThat(Arrays.asList(params), everyItem(instanceOf(QueryParam.class)));
}
Also used : JSONMarshaller(org.kie.server.api.marshalling.json.JSONMarshaller) QueryParam(org.kie.server.api.model.definition.QueryParam) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 QueryParam (org.kie.server.api.model.definition.QueryParam)14 ParseException (java.text.ParseException)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Date (java.util.Date)4 JSONMarshaller (org.kie.server.api.marshalling.json.JSONMarshaller)4 ProcessInstanceQueryFilterSpec (org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec)3 TaskQueryFilterSpec (org.kie.server.api.model.definition.TaskQueryFilterSpec)3 File (java.io.File)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 QueryFilterSpec (org.kie.server.api.model.definition.QueryFilterSpec)2 List (java.util.List)1 CaseInstance (org.kie.server.api.model.cases.CaseInstance)1 CaseInstanceCustomVars (org.kie.server.api.model.cases.CaseInstanceCustomVars)1 CaseUserTaskWithVariables (org.kie.server.api.model.cases.CaseUserTaskWithVariables)1 QueryDefinition (org.kie.server.api.model.definition.QueryDefinition)1 SearchQueryFilterSpec (org.kie.server.api.model.definition.SearchQueryFilterSpec)1 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)1 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)1