use of org.kie.kogito.codegen.data.Address in project kogito-runtimes by kiegroup.
the class RuleUnitCompilerIT method test2PatternsOopath.
@ParameterizedTest
@EnumSource(SessionType.class)
public void test2PatternsOopath(SessionType sessionType) throws Exception {
Application application = createApplication(sessionType, "org/kie/kogito/codegen/unit/TwoPatternsQuery.drl");
AdultUnit adults = new AdultUnit();
Person mario = new Person("Mario", 42);
mario.addAddress(new Address("Milano"));
Person mark = new Person("Mark", 40);
mark.addAddress(new Address("London"));
Person edson = new Person("Edson", 37);
edson.addAddress(new Address("Toronto"));
adults.getPersons().add(mario);
adults.getPersons().add(mark);
adults.getPersons().add(edson);
RuleUnit<AdultUnit> unit = application.get(RuleUnits.class).create(AdultUnit.class);
RuleUnitInstance<AdultUnit> instance = unit.createInstance(adults);
List<Person> results = instance.executeQuery("FindPeopleInMilano").stream().map(m -> m.get("$p")).map(Person.class::cast).collect(toList());
assertEquals(1, results.size());
assertEquals("Mario", results.get(0).getName());
}
use of org.kie.kogito.codegen.data.Address in project kogito-runtimes by kiegroup.
the class CallActivityTaskIT method testCallActivityTaskWithExpressionsForIONested.
@Test
public void testCallActivityTaskWithExpressionsForIONested() throws Exception {
Application app = generateCodeProcessesOnly("subprocess/CallActivityWithIOexpressionNested.bpmn2", "subprocess/CallActivitySubProcess.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.get(Processes.class).processById("ParentProcess");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
PersonWithAddress pa = new PersonWithAddress("john", 0);
pa.setAddress(new Address("test", null, null, null));
parameters.put("person", pa);
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
Model result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(1).containsKeys("person");
PersonWithAddress person = (PersonWithAddress) result.toMap().get("person");
assertEquals("john", person.getName());
assertEquals("test", person.getAddress().getStreet());
assertEquals("new value", person.getAddress().getCity());
List<WorkItem> workItems = processInstance.workItems(securityPolicy);
assertEquals(1, workItems.size());
WorkItem wi = workItems.get(0);
assertEquals("MyTask", wi.getName());
assertEquals(Active.ID, wi.getPhase());
assertEquals(Active.STATUS, wi.getPhaseStatus());
processInstance.transitionWorkItem(workItems.get(0).getId(), new HumanTaskTransition(Complete.ID, null, securityPolicy));
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Aggregations