use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class KieServerBackwardCompatDroolsIntegrationTest method testCallContainerWithStringPayloadRuleClient.
@Test
public void testCallContainerWithStringPayloadRuleClient() throws Exception {
Marshaller marshaller = MarshallerFactory.getMarshaller(new HashSet<Class<?>>(extraClasses.values()), configuration.getMarshallingFormat(), kjarClassLoader);
Object message = createInstance(MESSAGE_CLASS_NAME);
KieServerReflections.setValue(message, MESSAGE_TEXT_FIELD, MESSAGE_REQUEST);
List<Command<?>> commands = new ArrayList<Command<?>>();
BatchExecutionCommand batchExecution = commandsFactory.newBatchExecution(commands, KIE_SESSION);
commands.add(commandsFactory.newInsert(message, MESSAGE_OUT_IDENTIFIER));
commands.add(commandsFactory.newFireAllRules());
String marshalledCommands = marshaller.marshall(batchExecution);
ServiceResponse<String> reply = ruleClient.executeCommands(CONTAINER_ID, marshalledCommands);
Assert.assertEquals(ServiceResponse.ResponseType.SUCCESS, reply.getType());
ExecutionResults results = marshaller.unmarshall(reply.getResult(), ExecutionResultImpl.class);
Object value = results.getValue(MESSAGE_OUT_IDENTIFIER);
Assert.assertEquals(MESSAGE_RESPONSE, KieServerReflections.valueOf(value, MESSAGE_TEXT_FIELD));
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class RestMalformedRequestIntegrationTest method testInvalidCommandBodyOnCallContainer.
@Test
public void testInvalidCommandBodyOnCallContainer() throws Exception {
Marshaller marshaller = MarshallerFactory.getMarshaller(marshallingFormat, this.getClass().getClassLoader());
Response response = null;
try {
// empty commands can be considered as invalid request
String body = marshaller.marshall(new BatchExecutionCommandImpl());
WebTarget clientRequest = newRequest(TestConfig.getKieServerHttpUrl() + "/containers/instances/" + CONTAINER_ID);
response = clientRequest.request(getMediaType()).post(createEntity(body));
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
ServiceResponse<KieContainerResource> serviceResponse = response.readEntity(new GenericType<ServiceResponse<KieContainerResource>>() {
});
assertEquals(ServiceResponse.ResponseType.FAILURE, serviceResponse.getType());
assertEquals("Bad request, no commands to be executed - either wrong format or no data", serviceResponse.getMsg());
} catch (Exception e) {
throw new RuntimeException("Unexpected exception on empty body", e);
} finally {
if (response != null) {
response.close();
}
}
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class MarshallingRoundTripNestedClassesWithAnnotationsTest method testJSON.
@Test
public void testJSON() {
Marshaller marshaller = MarshallerFactory.getMarshaller(getCustomClasses(), MarshallingFormat.JSON, getClass().getClassLoader());
verifyMarshallingRoundTrip(marshaller, createTestObject());
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class MarshallingRoundTripNestedClassesWithAnnotationsTest method testJaxb.
@Test
public void testJaxb() {
Marshaller marshaller = MarshallerFactory.getMarshaller(getCustomClasses(), MarshallingFormat.JAXB, getClass().getClassLoader());
verifyMarshallingRoundTrip(marshaller, createTestObject());
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class MarshallingRoundTripTest method testMapWithDateJSON.
@Test
public void testMapWithDateJSON() {
Marshaller marshaller = MarshallerFactory.getMarshaller(MarshallingFormat.JSON, getClass().getClassLoader());
Map<String, Object> map = new HashMap<>();
map.put("date", new Date());
verifyMarshallingRoundTrip(marshaller, map);
}
Aggregations