@Test public void generateCommands() { FactMappingValue emptyFMV = new FactMappingValue(FactIdentifier.EMPTY, ExpressionIdentifier.DESCRIPTION, null); RuleStatelessScenarioExecutableBuilder builder = new RuleStatelessScenarioExecutableBuilder(null, null); Command<ExecutionResults> batchCommand = builder.generateCommands(null); assertTrue(verifyCommand(batchCommand, AddCoverageListenerCommand.class)); assertTrue(verifyCommand(batchCommand, FireAllRulesCommand.class)); assertFalse(verifyCommand(batchCommand, AgendaGroupSetFocusCommand.class)); assertFalse(verifyCommand(batchCommand, InsertElementsCommand.class)); assertFalse(verifyCommand(batchCommand, ValidateFactCommand.class)); builder.setActiveAgendaGroup("test"); batchCommand = builder.generateCommands(null); assertTrue(verifyCommand(batchCommand, AddCoverageListenerCommand.class)); assertTrue(verifyCommand(batchCommand, FireAllRulesCommand.class)); assertTrue(verifyCommand(batchCommand, AgendaGroupSetFocusCommand.class)); assertFalse(verifyCommand(batchCommand, InsertElementsCommand.class)); assertFalse(verifyCommand(batchCommand, ValidateFactCommand.class)); builder.insert(new Object()); batchCommand = builder.generateCommands(null); assertTrue(verifyCommand(batchCommand, AddCoverageListenerCommand.class)); assertTrue(verifyCommand(batchCommand, FireAllRulesCommand.class)); assertTrue(verifyCommand(batchCommand, AgendaGroupSetFocusCommand.class)); assertTrue(verifyCommand(batchCommand, InsertElementsCommand.class)); assertFalse(verifyCommand(batchCommand, ValidateFactCommand.class)); builder.addInternalCondition(String.class, obj -> null, new ScenarioResult(emptyFMV, null)); batchCommand = builder.generateCommands(null); assertTrue(verifyCommand(batchCommand, AddCoverageListenerCommand.class)); assertTrue(verifyCommand(batchCommand, FireAllRulesCommand.class)); assertTrue(verifyCommand(batchCommand, AgendaGroupSetFocusCommand.class)); assertTrue(verifyCommand(batchCommand, InsertElementsCommand.class)); assertTrue(verifyCommand(batchCommand, ValidateFactCommand.class)); }
protected Command<ExecutionResults> generateCommands(CoverageAgendaListener coverageAgendaListener) { List<Command<?>> toReturn = new ArrayList<>(); toReturn.add(new AddCoverageListenerCommand(coverageAgendaListener)); if (agendaGroup != null) { toReturn.add(commands.newAgendaGroupSetFocus(agendaGroup)); } if (!inputs.isEmpty()) { toReturn.add(commands.newInsertElements(inputs)); } toReturn.add(commands.newFireAllRules()); internalConditions.values() .forEach(factToCheck -> toReturn.add(new ValidateFactCommand(factToCheck))); return commands.newBatchExecution(toReturn); }
RuleStatelessScenarioExecutableBuilder implements RuleScenarioExecutableBuilder { protected Command<ExecutionResults> generateCommands(CoverageAgendaListener coverageAgendaListener) { List<Command<?>> toReturn = new ArrayList<>(); toReturn.add(new AddCoverageListenerCommand(coverageAgendaListener)); if (agendaGroup != null) { toReturn.add(commands.newAgendaGroupSetFocus(agendaGroup)); } if (!inputs.isEmpty()) { toReturn.add(commands.newInsertElements(inputs)); } toReturn.add(commands.newFireAllRules()); internalConditions.values() .forEach(factToCheck -> toReturn.add(new ValidateFactCommand(factToCheck))); return commands.newBatchExecution(toReturn); } }
RuleStatelessScenarioExecutableBuilder implements RuleScenarioExecutableBuilder { protected Command<ExecutionResults> generateCommands(CoverageAgendaListener coverageAgendaListener) { List<Command<?>> toReturn = new ArrayList<>(); toReturn.add(new AddCoverageListenerCommand(coverageAgendaListener)); if (agendaGroup != null) { toReturn.add(commands.newAgendaGroupSetFocus(agendaGroup)); } if (!inputs.isEmpty()) { toReturn.add(commands.newInsertElements(inputs)); } toReturn.add(commands.newFireAllRules()); internalConditions.values() .forEach(factToCheck -> toReturn.add(new ValidateFactCommand(factToCheck))); return commands.newBatchExecution(toReturn); } protected  RuleStatelessScenarioExecutableBuilder(KieContainer kieContainer, String sessionName); }
RuleStatelessScenarioExecutableBuilder implements RuleScenarioExecutableBuilder { protected Command<ExecutionResults> generateCommands(CoverageAgendaListener coverageAgendaListener) { List<Command<?>> toReturn = new ArrayList<>(); toReturn.add(new AddCoverageListenerCommand(coverageAgendaListener)); if (agendaGroup != null) { toReturn.add(commands.newAgendaGroupSetFocus(agendaGroup)); } if (!inputs.isEmpty()) { toReturn.add(commands.newInsertElements(inputs)); } toReturn.add(commands.newFireAllRules()); internalConditions.values() .forEach(factToCheck -> toReturn.add(new ValidateFactCommand(factToCheck))); return commands.newBatchExecution(toReturn); } protected  RuleStatelessScenarioExecutableBuilder(KieContainer kieContainer, String sessionName); @Override void addInternalCondition(Class<?> clazz,
                                     Function<Object, ValueWrapper> checkFunction,
                                     ScenarioResult scenarioResult); @Override void setActiveAgendaGroup(String agendaGroup); @Override void setActiveRuleFlowGroup(String ruleFlowGroup); @Override void insert(Object element); @Override Map<String, Object> run(); }
RuleStatelessScenarioExecutableBuilder implements RuleScenarioExecutableBuilder { protected Command<ExecutionResults> generateCommands(CoverageAgendaListener coverageAgendaListener) { List<Command<?>> toReturn = new ArrayList<>(); toReturn.add(new AddCoverageListenerCommand(coverageAgendaListener)); if (agendaGroup != null) { toReturn.add(commands.newAgendaGroupSetFocus(agendaGroup)); } if (!inputs.isEmpty()) { toReturn.add(commands.newInsertElements(inputs)); } toReturn.add(commands.newFireAllRules()); internalConditions.values() .forEach(factToCheck -> toReturn.add(new ValidateFactCommand(factToCheck))); return commands.newBatchExecution(toReturn); } protected  RuleStatelessScenarioExecutableBuilder(KieContainer kieContainer, String sessionName); @Override void addInternalCondition(Class<?> clazz,
                                     Function<Object, ValueWrapper> checkFunction,
                                     ScenarioResult scenarioResult); @Override void setActiveAgendaGroup(String agendaGroup); @Override void setActiveRuleFlowGroup(String ruleFlowGroup); @Override void insert(Object element); @Override Map<String, Object> run();  }