Search in sources :

Example 1 with TaskQueryFilterSpec

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

the class TaskQueryFilterSpecBuilderTest method testGetEqualsTo.

@Test
public void testGetEqualsTo() {
    TaskQueryFilterSpec filterSpec = new TaskQueryFilterSpecBuilder().equalsTo(TaskField.PROCESSID, "test-process").get();
    QueryParam[] params = filterSpec.getParameters();
    assertEquals(1, params.length);
    QueryParam param = params[0];
    assertEquals(TaskField.PROCESSID.toString(), param.getColumn());
    assertEquals("EQUALS_TO", param.getOperator());
    assertEquals("test-process", param.getValue().stream().findFirst().get());
}
Also used : TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryParam(org.kie.server.api.model.definition.QueryParam) Test(org.junit.Test)

Example 2 with TaskQueryFilterSpec

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

the class TaskQueryFilterSpecBuilderTest method testGetEqualsToAndBetween.

@Test
public void testGetEqualsToAndBetween() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date from = null;
    Date to = null;
    try {
        from = sdf.parse("2017-05-10");
        to = sdf.parse("2017-05-14");
    } catch (ParseException e) {
        e.printStackTrace();
    }
    TaskQueryFilterSpec filterSpec = new TaskQueryFilterSpecBuilder().equalsTo(TaskField.PROCESSID, "test-process").between(TaskField.CREATEDON, from, to).get();
    QueryParam[] params = filterSpec.getParameters();
    assertEquals(2, params.length);
    QueryParam paramEqualsTo = params[0];
    assertEquals(TaskField.PROCESSID.toString(), paramEqualsTo.getColumn());
    assertEquals("EQUALS_TO", paramEqualsTo.getOperator());
    assertEquals("test-process", paramEqualsTo.getValue().stream().findFirst().get());
    QueryParam paramBetween = params[1];
    assertEquals(TaskField.CREATEDON.toString(), paramBetween.getColumn());
    assertEquals("BETWEEN", paramBetween.getOperator());
    List<?> values = paramBetween.getValue();
    assertEquals(2, values.size());
    assertEquals(from, values.get(0));
    assertEquals(to, values.get(1));
}
Also used : TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryParam(org.kie.server.api.model.definition.QueryParam) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 3 with TaskQueryFilterSpec

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

the class TaskQueryFilterSpecBuilderTest method testGetBetween.

@Test
public void testGetBetween() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date from = null;
    Date to = null;
    try {
        from = sdf.parse("2017-05-10");
        to = sdf.parse("2017-05-14");
    } catch (ParseException e) {
        e.printStackTrace();
    }
    TaskQueryFilterSpec filterSpec = new TaskQueryFilterSpecBuilder().between(TaskField.CREATEDON, from, to).get();
    QueryParam[] params = filterSpec.getParameters();
    assertEquals(1, params.length);
    QueryParam param = params[0];
    assertEquals(TaskField.CREATEDON.toString(), param.getColumn());
    assertEquals("BETWEEN", param.getOperator());
    List<?> values = param.getValue();
    assertEquals(2, values.size());
    assertEquals(from, values.get(0));
    assertEquals(to, values.get(1));
}
Also used : TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryParam(org.kie.server.api.model.definition.QueryParam) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 4 with TaskQueryFilterSpec

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

the class MarshallerHelperTest method testJsonUnmarshallTaskQueryFilterSpec.

@Test
public void testJsonUnmarshallTaskQueryFilterSpec() {
    TaskQueryFilterSpec expectedTaskQfs = new TaskQueryFilterSpecBuilder().get();
    MarshallerHelper helper = new MarshallerHelper(null);
    String marshalledQFS = "{\"order-by\" : null, \"order-asc\" : false, \"query-params\" : null}";
    TaskQueryFilterSpec unmarshalledTaskQfs = helper.unmarshal(marshalledQFS, MarshallingFormat.JSON.toString(), TaskQueryFilterSpec.class);
    assertThat(expectedTaskQfs, new BaseMatcher<QueryFilterSpec>() {

        @Override
        public void describeTo(Description description) {
        }

        @Override
        public boolean matches(Object item) {
            return new ReflectionEquals(unmarshalledTaskQfs).matches(item);
        }
    });
}
Also used : TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) Description(org.hamcrest.Description) ProcessInstanceQueryFilterSpec(org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec) TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryFilterSpec(org.kie.server.api.model.definition.QueryFilterSpec) ReflectionEquals(org.mockito.internal.matchers.apachecommons.ReflectionEquals) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 TaskQueryFilterSpec (org.kie.server.api.model.definition.TaskQueryFilterSpec)4 QueryParam (org.kie.server.api.model.definition.QueryParam)3 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Description (org.hamcrest.Description)1 ProcessInstanceQueryFilterSpec (org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec)1 QueryFilterSpec (org.kie.server.api.model.definition.QueryFilterSpec)1 TaskQueryFilterSpecBuilder (org.kie.server.api.util.TaskQueryFilterSpecBuilder)1 ReflectionEquals (org.mockito.internal.matchers.apachecommons.ReflectionEquals)1