use of org.drools.core.command.runtime.rule.InsertObjectCommand in project drools by kiegroup.
the class CommandFactoryServiceImpl method newInsert.
public Command newInsert(Object object, String outIdentifier) {
InsertObjectCommand cmd = new InsertObjectCommand(object);
cmd.setOutIdentifier(outIdentifier);
return cmd;
}
use of org.drools.core.command.runtime.rule.InsertObjectCommand in project drools by kiegroup.
the class KiePMMLSessionUtilsTest method kiePMMLSessionUtils.
@Test
public void kiePMMLSessionUtils() {
List<Command> retrieved = kiePMMLSessionUtils.commands;
assertNotNull(retrieved);
assertEquals(3, retrieved.size());
assertTrue(retrieved.get(0) instanceof InsertObjectCommand);
InsertObjectCommand insertObjectCommand = (InsertObjectCommand) retrieved.get(0);
assertEquals("DEFAULT", insertObjectCommand.getEntryPoint());
assertNotNull(insertObjectCommand.getObject());
assertTrue(insertObjectCommand.getObject() instanceof KiePMMLStatusHolder);
KiePMMLStatusHolder kiePMMLStatusHolder = (KiePMMLStatusHolder) insertObjectCommand.getObject();
assertEquals(0.0, kiePMMLStatusHolder.getAccumulator(), 0.0);
assertNull(kiePMMLStatusHolder.getStatus());
assertTrue(retrieved.get(1) instanceof InsertObjectCommand);
insertObjectCommand = (InsertObjectCommand) retrieved.get(1);
assertEquals("DEFAULT", insertObjectCommand.getEntryPoint());
assertNotNull(insertObjectCommand.getObject());
assertTrue(insertObjectCommand.getObject() instanceof PMML4Result);
assertEquals(PMML4_RESULT, insertObjectCommand.getObject());
assertTrue(retrieved.get(2) instanceof SetGlobalCommand);
SetGlobalCommand setGlobalCommand = (SetGlobalCommand) retrieved.get(2);
assertEquals("$pmml4Result", setGlobalCommand.getIdentifier());
assertTrue(setGlobalCommand.getObject() instanceof PMML4Result);
assertEquals(PMML4_RESULT, setGlobalCommand.getObject());
}
use of org.drools.core.command.runtime.rule.InsertObjectCommand in project drools by kiegroup.
the class KiePMMLSessionUtilsTest method insertObjectInSession.
@Test
public void insertObjectInSession() {
final List<Command> retrieved = kiePMMLSessionUtils.commands;
assertNotNull(retrieved);
assertEquals(3, retrieved.size());
final Object toInsert = "TO_INSERT";
final String globalName = "GLOBAL_NAME";
kiePMMLSessionUtils.insertObjectInSession(toInsert, globalName);
assertEquals(5, retrieved.size());
assertTrue(retrieved.get(3) instanceof InsertObjectCommand);
InsertObjectCommand insertObjectCommand = (InsertObjectCommand) retrieved.get(3);
assertEquals("DEFAULT", insertObjectCommand.getEntryPoint());
assertNotNull(insertObjectCommand.getObject());
assertEquals(toInsert, insertObjectCommand.getObject());
assertTrue(retrieved.get(4) instanceof SetGlobalCommand);
SetGlobalCommand setGlobalCommand = (SetGlobalCommand) retrieved.get(4);
assertEquals(globalName, setGlobalCommand.getIdentifier());
assertEquals(toInsert, setGlobalCommand.getObject());
}
use of org.drools.core.command.runtime.rule.InsertObjectCommand in project drools by kiegroup.
the class CommandSerializationTest method insertObjectCommandEmptyListTest.
@Test
public void insertObjectCommandEmptyListTest() throws Exception {
List<String> objectList = new ArrayList<String>();
objectList.add("one-element");
InsertObjectCommand cmd = new InsertObjectCommand(objectList, "out-id");
// test list with 1 element
InsertObjectCommand copyCmd = roundTrip(cmd);
assertNotNull(copyCmd);
assertThat(copyCmd.getObject(), is(instanceOf(List.class)));
assertEquals("object", cmd.getObject(), copyCmd.getObject());
// test empty list
objectList.clear();
copyCmd = roundTrip(cmd);
assertNotNull(copyCmd);
assertThat(copyCmd.getObject(), is(instanceOf(List.class)));
assertEquals("object", cmd.getObject(), copyCmd.getObject());
}
Aggregations