use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceQueryFilterSpecBuilderTest 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();
}
ProcessInstanceQueryFilterSpec filterSpec = new ProcessInstanceQueryFilterSpecBuilder().between(ProcessInstanceField.START_DATE, from, to).get();
QueryParam[] params = filterSpec.getParameters();
assertEquals(1, params.length);
QueryParam param = params[0];
assertEquals(ProcessInstanceField.START_DATE.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));
}
use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceQueryFilterSpecBuilderTest method testGetEqualsTo.
@Test
public void testGetEqualsTo() {
ProcessInstanceQueryFilterSpec filterSpec = new ProcessInstanceQueryFilterSpecBuilder().equalsTo(ProcessInstanceField.PROCESSID, "test-process").get();
QueryParam[] params = filterSpec.getParameters();
assertEquals(1, params.length);
QueryParam param = params[0];
assertEquals(ProcessInstanceField.PROCESSID.toString(), param.getColumn());
assertEquals("EQUALS_TO", param.getOperator());
assertEquals("test-process", param.getValue().stream().findFirst().get());
}
use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.
the class QueryFilterSpecBuilderTest method testExpression.
@Test
public void testExpression() {
QueryFilterSpec filter = QueryFilterSpec.builder().where(and(isNull("column1"), equalsTo("column2", 1234))).get();
Assert.assertNotNull(filter.getParameters());
QueryParam param = filter.getParameters()[0];
assertEquals("AND", param.getOperator());
List<QueryParam> params = (List<QueryParam>) param.getValue();
assertTrue(params.size() == 2);
}
use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.
the class Person 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)));
}
use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.
the class Person 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);
}
Aggregations