use of org.kie.api.command.ExecutableCommand in project drools by kiegroup.
the class StatelessSessionTest method testInsertObject.
@Test
public void testInsertObject() throws Exception {
String str = "";
str += "package org.kie \n";
str += "import org.drools.mvel.compiler.Cheese \n";
str += "rule rule1 \n";
str += " when \n";
str += " $c : Cheese() \n";
str += " \n";
str += " then \n";
str += " $c.setPrice( 30 ); \n";
str += "end\n";
Cheese stilton = new Cheese("stilton", 5);
final StatelessKieSession ksession = getSession2(ResourceFactory.newByteArrayResource(str.getBytes()));
final ExecutableCommand cmd = (ExecutableCommand) CommandFactory.newInsert(stilton, "outStilton");
final BatchExecutionCommandImpl batch = new BatchExecutionCommandImpl(Arrays.asList(new ExecutableCommand<?>[] { cmd }));
final ExecutionResults result = (ExecutionResults) ksession.execute(batch);
stilton = (Cheese) result.getValue("outStilton");
assertEquals(30, stilton.getPrice());
}
Aggregations