Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.simulation.fluent.session.impl;
 
 import java.util.List;
 import java.util.Map;
 
 
         implements KieSessionSimulationFluent {
     
     
     public DefaultStatefulKnowledgeSessionSimFluent(SimulationFluent simulationFluent) {
         super();
         this. = simulationFluent;
     }
 
     protected KieSessionSimulationFluent addCommand(Command command) {
         .addCommand(command);
         return this;
     }
 
     public KieSessionSimulationFluent setGlobal(String identifier,
                                                             Object object) {
         addCommand(new SetGlobalCommand(identifierobject));
         return this;
     }    
     
     public KieSessionSimulationFluent insert(Object object) {
         addCommand(new InsertObjectCommand(object));
         
         return this;
     }
     
     public KieSessionSimulationFluent update(FactHandle handleObject object) {
         addCommand(new UpdateCommand(handleobject));
         return this;
     }
     
     public KieSessionSimulationFluent delete(FactHandle handle) {
         addCommand(new DeleteCommand(handle));
         return this;
     }
     
         addCommand(new FireAllRulesCommand());
         return this;
     }
 
     public KieSessionSimulationFluent assertRuleFired(String ruleName) {
         return assertRuleFired(ruleName, 1);
     }
 
     public KieSessionSimulationFluent assertRuleFired(String ruleNameint fireCount) {
         FiredRuleCounter firedRuleCounter = new FiredRuleCounter();
        firedRuleCounter.setInclusiveRuleNameList(Collections.singletonList(ruleName));
        insertFireRuleCounter(activeStepfiredRuleCounter);
        AssertRulesFiredCommand assertRulesFiredCommand = new AssertRulesFiredCommand(firedRuleCounter);
        assertRulesFiredCommand.addAssertRuleFired(ruleNamefireCount);
        addCommand(assertRulesFiredCommand);
        return this;
    }
    private void insertFireRuleCounter(SimulationStep activeStepFiredRuleCounter firedRuleCounter) {
        // Add the EventListener just before the last FireAllRules in this step
        int lastFireAllRulesIndex = -1;
        List<Commandcommands = activeStep.getCommands();
        for (ListIterator<Commandit = commands.listIterator(); it.hasNext();) {
            int i = it.nextIndex();
            Command command = it.next();
            if (command instanceof FireAllRulesCommand) {
                lastFireAllRulesIndex = i;
            }
        }
        if (lastFireAllRulesIndex < 0) {
            throw new IllegalArgumentException(
                    "Cannot assertRuleFired, because in this step, fireAllRules() hasn't been called yet.");
        }
        commands.add(lastFireAllRulesIndexnew AddEventListenerCommand(firedRuleCounter));
    }
        return .getActiveKieSessionId();
    }
    
    public SimulationFluent end(String contextString name) {
        addCommand(new SetVariableCommandFromLastReturn(contextname));
        return ;
    }
    
    public SimulationFluent end(String name) {
        addCommand(new SetVariableCommandFromLastReturn(name));
        return ;
    }
    public SimulationFluent end() {
        return ;
    }
    public KieSessionSimulationFluent set(String name) {
        addCommand(new SetVariableCommandFromLastReturn(nullname));
        return this;
    }
    public KieSessionSimulationFluent startProcess(String identifierMap<StringObjectparams) {
        addCommand(new StartProcessCommand(identifierparams));
        return this;
    }
    public KieSessionSimulationFluent startProcess(String identifier) {
        addCommand(new StartProcessCommand(identifier));
        return this;
    }
    
    public KieSessionSimulationFluent createProcessInstance(String identifierMap<StringObjectparams) {
        addCommand(new CreateProcessInstanceCommand(identifierparams));
        return this;
    }
    public KieSessionSimulationFluent startProcessInstance(long processId) {
        addCommand(new StartProcessInstanceCommand(processId));
        return this;
    }
    public KieSessionSimulationFluent abortProcessInstance(long processInstanceId) {
        cmd.setProcessInstanceId(processInstanceId);
        addCommand(cmd);
        return this;
    }
    public KieSessionSimulationFluent signalEvent(String idObject eventlong processId) {
        addCommand(new SignalEventCommand(processIdidevent));
        return this;
    }
    public KieSessionSimulationFluent signalEvent(String idObject event) {
        addCommand(new SignalEventCommand(idevent));
        return this;
    }
    public KieSessionSimulationFluent newStep(long distanceMillis) {
        .newStep(distanceMillis);
        return this;
    }
    public KieSessionSimulationFluent newStep(long distanceMillisTimeUnit timeUnit) {
        .newStep(distanceMillistimeUnit);
        return this;
    }
    public KieSessionSimulationFluent newRelativeStep(long relativeDistance) {
        .newRelativeStep(relativeDistance);
        return this;
    }
    public KieSessionSimulationFluent newRelativeStep(long relativeDistanceTimeUnit timeUnit) {
        .newRelativeStep(relativeDistancetimeUnit);
        return this;
    }
    @Override
    public KieSessionSimulationFluent out() {
        throw new UnsupportedOperationException("Not supported yet.");    }
    @Override
    public KieSessionSimulationFluent out(String name) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    @Override
    public KieSessionSimulationFluent getGlobal(String identifier) {
        addCommand(new GetGlobalCommand(identifier));
        return this;
    }
    @Override
        return new DefaultWorkItemManagerSimFluentImpl(this);
    }
New to GrepCode? Check out our FAQ X