Package org.drools.core.command.impl

Examples of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession


        if ( environment == null ) {
            throw new IllegalArgumentException( "Environment cannot be null" );
        }

        return new CommandBasedStatefulKnowledgeSession( (CommandService) buildCommandService( kbase,
                                                                             mergeConfig( configuration ),
                                                                             environment ) );
    }
View Full Code Here


        if ( environment == null ) {
            throw new IllegalArgumentException( "Environment cannot be null" );
        }

        return new CommandBasedStatefulKnowledgeSession( (CommandService) buildCommandService( id,
                                                                                              kbase,
                                                                                              mergeConfig( configuration ),
                                                                                              environment ) );
    }
View Full Code Here

  }

    @Test 
  public void testRuleFlowGroupOnly() throws Exception {
   
    CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "ruleflow-groups.drl");
   
    org.drools.core.spi.AgendaGroup[] groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
    // only main is available
    assertEquals(1, groups.length);
    assertEquals("MAIN", groups[0].getName());
    int id = ksession.getId();
    List<String> list = new ArrayList<String>();
    list.add("Test");
   
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
   
    ksession.dispose();       
        ksession = createSession(id, "ruleflow-groups.drl");
       
        groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // main and rule flow is now on the agenda
        assertEquals(2, groups.length);
View Full Code Here

  }
   
    @Test  
    public void testAgendaGroupOnly() throws Exception {
       
        CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "agenda-groups.drl");
       
        org.drools.core.spi.AgendaGroup[] groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // only main is available
        assertEquals(1, groups.length);
        assertEquals("MAIN", groups[0].getName());
        int id = ksession.getId();
        List<String> list = new ArrayList<String>();
        list.add("Test");
       
        ksession.insert(list);
        ksession.execute(new ActivateAgendaGroupCommand("agenda-group"));
       
        ksession.dispose();       
        ksession = createSession(id, "agenda-groups.drl");
       
        groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // main and agenda group is now on the agenda
        assertEquals(2, groups.length);
View Full Code Here

    }
   
    @Test  
    public void testAgendaGroupAndRuleFlowGroup() throws Exception {
       
        CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "agenda-groups.drl", "ruleflow-groups.drl");
       
        org.drools.core.spi.AgendaGroup[] groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // only main is available
        assertEquals(1, groups.length);
        assertEquals("MAIN", groups[0].getName());
        int id = ksession.getId();
        List<String> list = new ArrayList<String>();
        list.add("Test");
       
        ksession.insert(list);
        ksession.execute(new ActivateAgendaGroupCommand("agenda-group"));
        ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
       
        ksession.dispose();       
        ksession = createSession(id, "agenda-groups.drl", "ruleflow-groups.drl");
       
        groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // main and agenda group is now on the agenda
        assertEquals(3, groups.length);
View Full Code Here

  }

    @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());
   
  }
View Full Code Here

  }

    @Test 
  public void testRuleFlowGroupOnly() throws Exception {
   
    CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "ruleflow-groups.drl");
   
    org.drools.core.spi.AgendaGroup[] groups = ((AgendaImpl)stripSession(ksession).getAgenda()).getAgenda().getAgendaGroups();
    // only main is available
    assertEquals(1, groups.length);
    assertEquals("MAIN", groups[0].getName());
    int id = ksession.getId();
    List<String> list = new ArrayList<String>();
    list.add("Test");
   
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
   
    ksession.dispose();       
        ksession = createSession(id, "ruleflow-groups.drl");
       
        groups = ((AgendaImpl)stripSession(ksession).getAgenda()).getAgenda().getAgendaGroups();
        // main and rule flow is now on the agenda
        assertEquals(2, groups.length);
View Full Code Here

  }
   
    @Test  
    public void testAgendaGroupOnly() throws Exception {
       
        CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "agenda-groups.drl");
       
        org.drools.core.spi.AgendaGroup[] groups = ((AgendaImpl)stripSession(ksession).getAgenda()).getAgenda().getAgendaGroups();
        // only main is available
        assertEquals(1, groups.length);
        assertEquals("MAIN", groups[0].getName());
        int id = ksession.getId();
        List<String> list = new ArrayList<String>();
        list.add("Test");
       
        ksession.insert(list);
        ksession.execute(new ActivateAgendaGroupCommand("agenda-group"));
       
        ksession.dispose();       
        ksession = createSession(id, "agenda-groups.drl");
       
        groups = ((AgendaImpl)stripSession(ksession).getAgenda()).getAgenda().getAgendaGroups();
        // main and agenda group is now on the agenda
        assertEquals(2, groups.length);
View Full Code Here

    }
   
    @Test  
    public void testAgendaGroupAndRuleFlowGroup() throws Exception {
       
        CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "agenda-groups.drl", "ruleflow-groups.drl");
       
        org.drools.core.spi.AgendaGroup[] groups = ((AgendaImpl)stripSession(ksession).getAgenda()).getAgenda().getAgendaGroups();
        // only main is available
        assertEquals(1, groups.length);
        assertEquals("MAIN", groups[0].getName());
        int id = ksession.getId();
        List<String> list = new ArrayList<String>();
        list.add("Test");
       
        ksession.insert(list);
        ksession.execute(new ActivateAgendaGroupCommand("agenda-group"));
        ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
       
        ksession.dispose();       
        ksession = createSession(id, "agenda-groups.drl", "ruleflow-groups.drl");
       
        groups = ((AgendaImpl)stripSession(ksession).getAgenda()).getAgenda().getAgendaGroups();
        // main and agenda group is now on the agenda
        assertEquals(3, groups.length);
View Full Code Here

  }

    @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());
   
  }
View Full Code Here

TOP

Related Classes of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.