Search in sources :

Example 6 with InsertObjectCommand

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;
}
Also used : InsertObjectCommand(org.drools.core.command.runtime.rule.InsertObjectCommand)

Example 7 with InsertObjectCommand

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());
}
Also used : SetGlobalCommand(org.drools.core.command.runtime.SetGlobalCommand) PMML4Result(org.kie.api.pmml.PMML4Result) Command(org.kie.api.command.Command) InsertObjectCommand(org.drools.core.command.runtime.rule.InsertObjectCommand) SetGlobalCommand(org.drools.core.command.runtime.SetGlobalCommand) KiePMMLStatusHolder(org.kie.pmml.models.drools.executor.KiePMMLStatusHolder) InsertObjectCommand(org.drools.core.command.runtime.rule.InsertObjectCommand) Test(org.junit.Test)

Example 8 with InsertObjectCommand

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());
}
Also used : SetGlobalCommand(org.drools.core.command.runtime.SetGlobalCommand) Command(org.kie.api.command.Command) InsertObjectCommand(org.drools.core.command.runtime.rule.InsertObjectCommand) SetGlobalCommand(org.drools.core.command.runtime.SetGlobalCommand) InsertObjectCommand(org.drools.core.command.runtime.rule.InsertObjectCommand) Test(org.junit.Test)

Example 9 with InsertObjectCommand

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());
}
Also used : ArrayList(java.util.ArrayList) InsertObjectCommand(org.drools.core.command.runtime.rule.InsertObjectCommand) Test(org.junit.Test)

Aggregations

InsertObjectCommand (org.drools.core.command.runtime.rule.InsertObjectCommand)9 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)4 SetGlobalCommand (org.drools.core.command.runtime.SetGlobalCommand)3 List (java.util.List)2 Command (org.kie.api.command.Command)2 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1 XmlElement (javax.xml.bind.annotation.XmlElement)1 XmlElements (javax.xml.bind.annotation.XmlElements)1 ClassObjectFilter (org.drools.core.ClassObjectFilter)1 ClassObjectSerializationFilter (org.drools.core.ClassObjectSerializationFilter)1 RuleNameEndsWithAgendaFilter (org.drools.core.base.RuleNameEndsWithAgendaFilter)1 RuleNameEqualsAgendaFilter (org.drools.core.base.RuleNameEqualsAgendaFilter)1 RuleNameMatchesAgendaFilter (org.drools.core.base.RuleNameMatchesAgendaFilter)1 RuleNameStartsWithAgendaFilter (org.drools.core.base.RuleNameStartsWithAgendaFilter)1 ExecuteCommand (org.drools.core.command.ExecuteCommand)1 BatchExecutionCommandImpl (org.drools.core.command.runtime.BatchExecutionCommandImpl)1