Search in sources :

Example 11 with FireAllRulesCommand

use of org.drools.core.command.runtime.rule.FireAllRulesCommand in project drools by kiegroup.

the class XStreamXMLTest method testFireAllRulesCommand.

@Test
public void testFireAllRulesCommand() {
    RuleNameEndsWithAgendaFilter filter = new RuleNameEndsWithAgendaFilter("mySuffix", true);
    FireAllRulesCommand cmd = new FireAllRulesCommand("ABC", 100, filter);
    String xmlString = xstream.toXML(cmd);
    String expected = "<fire-all-rules max=\"100\" out-identifier=\"ABC\">\n" + "  <agendaFilter class=\"org.drools.core.base.RuleNameEndsWithAgendaFilter\">\n" + "    <suffix>mySuffix</suffix>\n" + "    <accept>true</accept>\n" + "  </agendaFilter>\n" + "</fire-all-rules>";
    Assertions.assertThat(expected).isEqualToIgnoringWhitespace(xmlString);
    FireAllRulesCommand cmd2 = (FireAllRulesCommand) xstream.fromXML(xmlString);
    Assert.assertEquals(100, cmd2.getMax());
    Assert.assertEquals(RuleNameEndsWithAgendaFilter.class, cmd2.getAgendaFilter().getClass());
    Assert.assertEquals("mySuffix", ((RuleNameEndsWithAgendaFilter) cmd2.getAgendaFilter()).getSuffix());
    Assert.assertTrue(((RuleNameEndsWithAgendaFilter) cmd2.getAgendaFilter()).isAccept());
}
Also used : FireAllRulesCommand(org.drools.core.command.runtime.rule.FireAllRulesCommand) RuleNameEndsWithAgendaFilter(org.drools.core.base.RuleNameEndsWithAgendaFilter) Test(org.junit.Test)

Aggregations

FireAllRulesCommand (org.drools.core.command.runtime.rule.FireAllRulesCommand)11 Test (org.junit.Test)9 Command (org.kie.api.command.Command)9 ArrayList (java.util.ArrayList)7 StatelessKieSession (org.kie.api.runtime.StatelessKieSession)5 ExecutionResults (org.kie.api.runtime.ExecutionResults)4 BatchExecutionCommandImpl (org.drools.core.command.runtime.BatchExecutionCommandImpl)3 BatchExecutionCommand (org.kie.api.command.BatchExecutionCommand)3 Cheese (org.drools.compiler.Cheese)2 RuleNameEndsWithAgendaFilter (org.drools.core.base.RuleNameEndsWithAgendaFilter)2 ContextImpl (org.drools.core.command.impl.ContextImpl)2 ExecutionResultImpl (org.drools.core.runtime.impl.ExecutionResultImpl)2 Cheese (org.drools.mvel.compiler.Cheese)2 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)2 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1 UserTransaction (javax.transaction.UserTransaction)1