Search in sources :

Example 6 with CommandBasedStatefulKnowledgeSession

use of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession in project drools by kiegroup.

the class RuleFlowGroupRollbackTest method testRuleFlowGroupRollback.

@Test
public void testRuleFlowGroupRollback() throws Exception {
    CommandBasedStatefulKnowledgeSession ksession = createSession();
    List<String> list = new ArrayList<String>();
    list.add("Test");
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
    assertEquals(1, ksession.fireAllRules());
    try {
        ksession.execute(new ExceptionCommand());
        fail("Process must throw an exception");
    } catch (Exception e) {
        logger.info("The above " + RuntimeException.class.getSimpleName() + " was expected in this test.");
    }
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
    assertEquals(1, ksession.fireAllRules());
}
Also used : ArrayList(java.util.ArrayList) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) Test(org.junit.Test)

Aggregations

CommandBasedStatefulKnowledgeSession (org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession)6 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 InternalAgenda (org.drools.core.common.InternalAgenda)3 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)2 ClassPathResource (org.drools.core.io.impl.ClassPathResource)2 Environment (org.kie.api.runtime.Environment)2 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)2 DroolsPersistenceUtil.createEnvironment (org.drools.persistence.util.DroolsPersistenceUtil.createEnvironment)1