use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class JSONUnmarshallingTest method unmarshalNonExistingClassInDroolsCommand.
private Object unmarshalNonExistingClassInDroolsCommand() {
Set<Class<?>> extraClasses = new HashSet<Class<?>>();
Marshaller marshaller = MarshallerFactory.getMarshaller(extraClasses, MarshallingFormat.JSON, this.getClass().getClassLoader());
String json = "{\n" + " \"lookup\" : \"StatelessKieSession\",\n" + " \"commands\" : [ {\n" + " \"insert\" : {\n" + " \"object\" : {\"com.nonexisting.Person\":{\"name\":\"taro\",\"age\":\"20\"}},\n" + " \"out-identifier\" : \"person\",\n" + " \"return-object\" : \"true\",\n" + " \"entry-point\" : \"DEFAULT\"\n" + " }\n" + " }, {\n" + " \"fire-all-rules\" : { }\n" + " } ]\n" + "}";
return marshaller.unmarshall(json, BatchExecutionCommandImpl.class);
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class JSONUnmarshallingTest method unmarshalNonExistingClass.
private Object unmarshalNonExistingClass() {
Set<Class<?>> extraClasses = new HashSet<Class<?>>();
Marshaller marshaller = MarshallerFactory.getMarshaller(extraClasses, MarshallingFormat.JSON, this.getClass().getClassLoader());
String json = "{\"com.nonexisting.Person\":{\"name\":\"taro\",\"age\":\"20\"}}";
return marshaller.unmarshall(json, Object.class);
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class StringContentJSONTest method testStringContentMap.
@Test
public void testStringContentMap() {
Set<Class<?>> extraClasses = new HashSet<Class<?>>();
Marshaller marshaller = MarshallerFactory.getMarshaller(extraClasses, MarshallingFormat.JSON, this.getClass().getClassLoader());
String jsonMap = "{\"name\" : \"value\"}";
StringContentMap map = new StringContentMap(jsonMap);
// content must be of exact value as given in constructor
String marshall = marshaller.marshall(map);
assertEquals(jsonMap, marshall);
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class DroolsJmsResponseHandlerIntegrationTest method testExecuteSimpleRuleFlowProcessWithAsyncResponseHandler.
@Test
public void testExecuteSimpleRuleFlowProcessWithAsyncResponseHandler() {
Marshaller marshaller = MarshallerFactory.getMarshaller(new HashSet<Class<?>>(extraClasses.values()), configuration.getMarshallingFormat(), client.getClassLoader());
ResponseCallback responseCallback = new BlockingResponseCallback(marshaller);
ResponseHandler asyncResponseHandler = new AsyncResponseHandler(responseCallback);
ruleClient.setResponseHandler(asyncResponseHandler);
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(commandsFactory.newSetGlobal(LIST_NAME, new ArrayList<String>(), LIST_OUTPUT_NAME));
commands.add(commandsFactory.newStartProcess(PROCESS_ID));
commands.add(commandsFactory.newGetGlobal(LIST_NAME, LIST_OUTPUT_NAME));
BatchExecutionCommand batchExecution = commandsFactory.newBatchExecution(commands, KIE_SESSION);
ServiceResponse<?> response = ruleClient.executeCommandsWithResults(CONTAINER_ID, batchExecution);
assertThat(response).isNull();
ExecutionResults result = responseCallback.get(ExecutionResultImpl.class);
List<String> outcome = (List<String>) result.getValue(LIST_OUTPUT_NAME);
assertThat(outcome).isNotNull();
assertThat(outcome).containsExactly("Rule from first ruleflow group executed", "Rule from second ruleflow group executed");
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class KieServerDroolsIntegrationTest method testCallContainerWithStringPayload.
@Test
public void testCallContainerWithStringPayload() 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<ExecutionResults> reply = ruleClient.executeCommandsWithResults(CONTAINER_ID, marshalledCommands);
Assert.assertEquals(ServiceResponse.ResponseType.SUCCESS, reply.getType());
ExecutionResults results = reply.getResult();
Object value = results.getValue(MESSAGE_OUT_IDENTIFIER);
Assert.assertEquals(MESSAGE_RESPONSE, KieServerReflections.valueOf(value, MESSAGE_TEXT_FIELD));
}
Aggregations