use of org.drools.core.command.runtime.rule.UpdateCommand in project drools by kiegroup.
the class CommandSerializationTest method updateCommandTest.
// TESTS ----------------------------------------------------------------------------------------------------------------------
@Test
public void updateCommandTest() throws Exception {
DisconnectedFactHandle discFactHandle = new DisconnectedFactHandle(2, 3, 4, 5l, "entry-point-id", "str-obj", true);
DisconnectedFactHandle copyDiscFactHandle = roundTrip(discFactHandle);
verifyDisconnectedFactHandle(discFactHandle, copyDiscFactHandle);
UpdateCommand cmd = new UpdateCommand(discFactHandle, "new-str-object");
UpdateCommand copyCmd = roundTrip(cmd);
verifyDisconnectedFactHandle(discFactHandle, copyCmd.getHandle());
assertEquals("entry point", cmd.getEntryPoint(), copyCmd.getEntryPoint());
assertEquals("object", cmd.getObject(), copyCmd.getObject());
}
use of org.drools.core.command.runtime.rule.UpdateCommand in project drools by kiegroup.
the class XStreamXMLTest method testUpdateCommand.
@Test
public void testUpdateCommand() {
FactHandle factHandle = DefaultFactHandle.createFromExternalFormat("0:1:10:10:20:null:NON_TRAIT:null");
UpdateCommand cmd = new UpdateCommand(factHandle, new Message("Hello World!"), new String[] { "msg" });
String xmlString = xstream.toXML(cmd);
String expected = "<update fact-handle=\"0:1:10:10:20:null:NON_TRAIT:null\" entryPoint=\"DEFAULT\">\n" + " <org.drools.xml.support.XStreamXMLTest_-Message>\n" + " <msg>Hello World!</msg>\n" + " </org.drools.xml.support.XStreamXMLTest_-Message>\n" + " <modifiedProperty value=\"msg\"/>\n" + "</update>";
Assertions.assertThat(expected).isEqualToIgnoringWhitespace(xmlString);
UpdateCommand cmd2 = (UpdateCommand) xstream.fromXML(xmlString);
Assert.assertEquals(factHandle.toExternalForm(), cmd2.getHandle().toExternalForm());
Assert.assertEquals(1, cmd2.getModifiedProperties().length);
Assert.assertEquals("msg", cmd2.getModifiedProperties()[0]);
}
Aggregations