StatelessKieSession ksession = (StatelessKieSession) context.getBean("ksession-table-1");
assertNotNull(ksession);
// Cheeses selection
Cheese cheese = new Cheese();
cheese.setPrice(250);
cheese.setType("cheddar");
// Young person
Person person = new Person();
person.setName("Young Scott");
person.setAge(21);
List cmds = new ArrayList();
cmds.add( CommandFactory.newSetGlobal("list", new ArrayList(), true) );
cmds.add( CommandFactory.newInsert(person,"yscott"));
cmds.add( CommandFactory.newInsert(cheese,"cheddar"));
cmds.add( CommandFactory.newFireAllRules());
// Execute the list
ExecutionResults results = ksession.execute(CommandFactory.newBatchExecution(cmds));
List list = (List) results.getValue("list");
assertEquals(1, list.size());
assertTrue(list.contains("Young man cheddar"));
// Old person
person = new Person();
person.setName("Old Scott");
person.setAge(42);
cheese = new Cheese();
cheese.setPrice(150);
cheese.setType("stilton");
cmds = new ArrayList();
cmds.add( CommandFactory.newSetGlobal("list", new ArrayList(), true) );
cmds.add( CommandFactory.newInsert(person,"oscott"));
cmds.add( CommandFactory.newInsert(cheese,"stilton"));