use of org.kie.camel.container.api.model.Person in project droolsjbpm-integration by kiegroup.
the class RuleEngineIntegrationTest method testFireAllRules.
@Test
public void testFireAllRules() {
final Person oldPerson = new Person("Tom", 30);
final Person youngPerson = new Person("John", 15);
final FactHandle oldPersonFactHandle = insertObject(oldPerson);
final FactHandle youngPersonFactHandle = insertObject(youngPerson);
final FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
fireAllRulesCommand.setOutIdentifier(DEFAULT_OUT_ID);
ExecutionResults executionResults = runCommand(fireAllRulesCommand);
Assertions.assertThat(executionResults).isNotNull();
Assertions.assertThat(executionResults.getValue(DEFAULT_OUT_ID)).isEqualTo(2);
final Person oldPerson2 = (Person) getObject(oldPersonFactHandle);
Assertions.assertThat(oldPerson2.isCanDrink()).isTrue();
final Person youngPerson2 = (Person) getObject(youngPersonFactHandle);
Assertions.assertThat(youngPerson2.isCanDrink()).isFalse();
}
use of org.kie.camel.container.api.model.Person in project droolsjbpm-integration by kiegroup.
the class RuleClientIntegrationTest method testExecuteCommand.
@Test
public void testExecuteCommand() {
final Person person = new Person();
person.setName("John");
person.setAge(25);
final InsertObjectCommand insertObjectCommand = new InsertObjectCommand();
insertObjectCommand.setOutIdentifier("person");
insertObjectCommand.setObject(person);
final FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
final List<ExecutableCommand<?>> commands = new ArrayList<ExecutableCommand<?>>();
final BatchExecutionCommandImpl executionCommand = new BatchExecutionCommandImpl(commands);
executionCommand.setLookup("defaultKieSession");
executionCommand.addCommand(insertObjectCommand);
executionCommand.addCommand(fireAllRulesCommand);
Map<String, Object> parameters = new HashMap<>();
parameters.put("id", CONTAINER_ID);
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("rule");
executionServerCommand.setOperation("executeCommands");
executionServerCommand.setParameters(parameters);
executionServerCommand.setBodyParam("cmd");
executionServerCommand.setBody(executionCommand);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(String.class);
final String responseString = (String) response;
Assertions.assertThat(responseString).contains("execution-results");
}
use of org.kie.camel.container.api.model.Person in project droolsjbpm-integration by kiegroup.
the class RuleEngineIntegrationTest method testRuleEvaluationService.
@Test
public void testRuleEvaluationService() {
Person person = new Person();
person.setName("George");
person.setAge(15);
Person response = kieCamelTestService.verifyAge(person);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response.isCanDrink()).isFalse();
person = new Person();
person.setName("John");
person.setAge(25);
response = kieCamelTestService.verifyAge(person);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response.isCanDrink()).isTrue();
}
use of org.kie.camel.container.api.model.Person in project droolsjbpm-integration by kiegroup.
the class RuleEngineIntegrationTest method testInsertGetDeleteFact.
@Test
public void testInsertGetDeleteFact() {
final Person person = new Person("John", 15);
final FactHandle factHandle = insertObject(person);
final Person returnedPerson = (Person) getObject(factHandle);
Assertions.assertThat(returnedPerson).isEqualToComparingFieldByField(person);
final DeleteCommand deleteCommand = new DeleteCommand(factHandle);
runCommand(deleteCommand);
Assertions.assertThat(getObject(factHandle)).isNull();
}
Aggregations