Search in sources :

Example 1 with QueryFilterSpecBuilder

use of org.kie.server.api.util.QueryFilterSpecBuilder in project droolsjbpm-integration by kiegroup.

the class MarshallerHelperTest method testJsonUnmarshallNotNull.

@Test
public void testJsonUnmarshallNotNull() throws JSONException {
    KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class);
    Set<Class<?>> extraClasses = new HashSet<>();
    // simulate server conditions
    extraClasses.add(Date.class);
    extraClasses.add(org.kie.server.api.model.type.JaxbByteArray.class);
    Mockito.when(kieServerRegistryMock.getExtraClasses()).thenReturn(extraClasses);
    MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock);
    JSONAssert.assertEquals("{\"order-asc\" : false}", helper.marshal("application/json ; fields = not_null ", new QueryFilterSpecBuilder().get()), true);
    // test reset
    JSONAssert.assertEquals("{\"order-by\" : null, \"order-asc\" : false, \"query-params\" : null, \"result-column-mapping\" : null, \"order-by-clause\" : null}", helper.marshal("application/json", new QueryFilterSpecBuilder().get()), true);
}
Also used : ProcessInstanceQueryFilterSpecBuilder(org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder) QueryFilterSpecBuilder(org.kie.server.api.util.QueryFilterSpecBuilder) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with QueryFilterSpecBuilder

use of org.kie.server.api.util.QueryFilterSpecBuilder in project droolsjbpm-integration by kiegroup.

the class MarshallerHelperTest method testMarshallWithoutContainer.

@Test
public void testMarshallWithoutContainer() {
    KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class);
    MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock);
    QueryFilterSpec queryFilterSpec = new QueryFilterSpecBuilder().get();
    String marshalledQFS = helper.marshal(MarshallingFormat.JAXB.toString(), queryFilterSpec);
    String expectedMarshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>";
    assertThat(marshalledQFS, CompareMatcher.isIdenticalTo(expectedMarshalledQFS).ignoreWhitespace());
}
Also used : ProcessInstanceQueryFilterSpecBuilder(org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder) QueryFilterSpecBuilder(org.kie.server.api.util.QueryFilterSpecBuilder) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) ProcessInstanceQueryFilterSpec(org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec) TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryFilterSpec(org.kie.server.api.model.definition.QueryFilterSpec) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) Test(org.junit.Test)

Example 3 with QueryFilterSpecBuilder

use of org.kie.server.api.util.QueryFilterSpecBuilder in project droolsjbpm-integration by kiegroup.

the class MarshallerHelperTest method testMarshallWithNullRegistry.

/**
 * Tests that MarshallerHelper can also be used when passing in a <code>null</code> KieServerRegistry.
 */
@Test
public void testMarshallWithNullRegistry() {
    MarshallerHelper helper = new MarshallerHelper(null);
    QueryFilterSpec queryFilterSpec = new QueryFilterSpecBuilder().get();
    String marshalledQFS = helper.marshal(MarshallingFormat.JAXB.toString(), queryFilterSpec);
    String expectedMarshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>";
    assertThat(marshalledQFS, CompareMatcher.isIdenticalTo(expectedMarshalledQFS).ignoreWhitespace());
}
Also used : ProcessInstanceQueryFilterSpecBuilder(org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder) QueryFilterSpecBuilder(org.kie.server.api.util.QueryFilterSpecBuilder) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) ProcessInstanceQueryFilterSpec(org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec) TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryFilterSpec(org.kie.server.api.model.definition.QueryFilterSpec) Test(org.junit.Test)

Example 4 with QueryFilterSpecBuilder

use of org.kie.server.api.util.QueryFilterSpecBuilder in project droolsjbpm-integration by kiegroup.

the class MarshallerHelperTest method testJsonMarshallWithNullRegistry.

@Test
public void testJsonMarshallWithNullRegistry() throws Exception {
    MarshallerHelper helper = new MarshallerHelper(null);
    QueryFilterSpec queryFilterSpec = new QueryFilterSpecBuilder().get();
    String marshalledQFS = helper.marshal(MarshallingFormat.JSON.toString(), queryFilterSpec);
    System.out.println(marshalledQFS);
    String expectedMarshalledTEC = "{\"order-by\" : null, \"order-asc\" : false, \"query-params\" : null, \"result-column-mapping\" : null}";
    JSONAssert.assertEquals(expectedMarshalledTEC, marshalledQFS, false);
}
Also used : ProcessInstanceQueryFilterSpecBuilder(org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder) QueryFilterSpecBuilder(org.kie.server.api.util.QueryFilterSpecBuilder) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) ProcessInstanceQueryFilterSpec(org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec) TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryFilterSpec(org.kie.server.api.model.definition.QueryFilterSpec) Test(org.junit.Test)

Example 5 with QueryFilterSpecBuilder

use of org.kie.server.api.util.QueryFilterSpecBuilder in project droolsjbpm-integration by kiegroup.

the class MarshallerHelperTest method testUnmarshallWithoutNullRegistry.

/**
 * Tests that MarshallerHelper can also be used when passing in a <code>null</code> KieServerRegistry.
 */
@Test
public void testUnmarshallWithoutNullRegistry() {
    MarshallerHelper helper = new MarshallerHelper(null);
    QueryFilterSpec expectedQueryFilterSpec = new QueryFilterSpecBuilder().get();
    String marshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>";
    QueryFilterSpec unmarshalledQFS = helper.unmarshal(marshalledQFS, MarshallingFormat.JAXB.toString(), QueryFilterSpec.class);
    // QueryFilterSpec does not implement equals method, so using Mockito ReflectionEquals.
    assertThat(expectedQueryFilterSpec, new BaseMatcher<QueryFilterSpec>() {

        @Override
        public void describeTo(Description description) {
        }

        @Override
        public boolean matches(Object item) {
            return new ReflectionEquals(unmarshalledQFS).matches(item);
        }
    });
}
Also used : ProcessInstanceQueryFilterSpecBuilder(org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder) QueryFilterSpecBuilder(org.kie.server.api.util.QueryFilterSpecBuilder) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) 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) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 QueryFilterSpecBuilder (org.kie.server.api.util.QueryFilterSpecBuilder)14 QueryFilterSpec (org.kie.server.api.model.definition.QueryFilterSpec)10 ProcessInstanceQueryFilterSpecBuilder (org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder)7 TaskQueryFilterSpecBuilder (org.kie.server.api.util.TaskQueryFilterSpecBuilder)7 ProcessInstanceQueryFilterSpec (org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec)6 QueryDefinition (org.kie.server.api.model.definition.QueryDefinition)6 TaskQueryFilterSpec (org.kie.server.api.model.definition.TaskQueryFilterSpec)6 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)4 KieServerRegistry (org.kie.server.services.api.KieServerRegistry)4 QueryContext (org.kie.internal.query.QueryContext)3 TaskInstance (org.kie.server.api.model.instance.TaskInstance)3 HashMap (java.util.HashMap)2 Description (org.hamcrest.Description)2 UserTaskInstanceWithVarsDesc (org.jbpm.services.api.model.UserTaskInstanceWithVarsDesc)2 TaskSummary (org.kie.server.api.model.instance.TaskSummary)2 ReflectionEquals (org.mockito.internal.matchers.apachecommons.ReflectionEquals)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1