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);
}
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());
}
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());
}
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);
}
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);
}
});
}
Aggregations