Package org.drools.simulation.fluent.simulation

Examples of org.drools.simulation.fluent.simulation.SimulationFluent


        // @formatter:on
    }

    @Test
    public void rejectMinors() throws IOException {
        SimulationFluent simulationFluent = new DefaultSimulationFluent();

        Driver john = new Driver("John", "Smith", new LocalDate().minusYears(10));
        Car mini = new Car("MINI-01", CarType.SMALL, false, new BigDecimal("10000.00"));
        PolicyRequest johnMiniPolicyRequest = new PolicyRequest(john, mini);
        johnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COLLISION));
        johnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COMPREHENSIVE));

        String rules = readInputStreamReaderAsString( new InputStreamReader( getClass().getResourceAsStream( "policyRequestApprovalRules.drl" ) ) );
        ReleaseId releaseId = createKJarWithMultipleResources( "KBase1", new String[]{rules}, new ResourceType[] {ResourceType.DRL} );

        // @formatter:off
        simulationFluent
        .newKieSession(releaseId, "KBase1.KSession1")
            .insert(john).set("john")
            .insert(mini).set("mini")
            .insert(johnMiniPolicyRequest).set("johnMiniPolicyRequest")
            .fireAllRules()
View Full Code Here


        // @formatter:on
    }

    @Test(expected = AssertionError.class)
    public void rejectMinorsFailingAssertion() throws IOException {
        SimulationFluent simulationFluent = new DefaultSimulationFluent();

        Driver john = new Driver("John", "Smith", new LocalDate().minusYears(10));
        Car mini = new Car("MINI-01", CarType.SMALL, false, new BigDecimal("10000.00"));
        PolicyRequest johnMiniPolicyRequest = new PolicyRequest(john, mini);
        johnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COLLISION));
        johnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COMPREHENSIVE));

        String rules = readInputStreamReaderAsString( new InputStreamReader( getClass().getResourceAsStream( "policyRequestApprovalRules.drl" ) ) );
        ReleaseId releaseId = createKJarWithMultipleResources( "KBase1", new String[]{rules}, new ResourceType[] {ResourceType.DRL} );

        // @formatter:off
        simulationFluent
        .newKieSession(releaseId, "KBase1.KSession1")
            .insert(john).set("john")
            .insert(mini).set("mini")
            .insert(johnMiniPolicyRequest).set("johnMiniPolicyRequest")
            .fireAllRules()
View Full Code Here

public class PolicyApprovalWorkflowTest extends SimulateTestBase {

    @Test
    public void approvePolicyRequest() throws IOException {
        SimulationFluent simulationFluent = new DefaultSimulationFluent();

        Map<String, Object> processParams = new HashMap<String, Object>();

        Driver john = new Driver("John", "Smith", new LocalDate(1970, 1, 1));
        Car mini = new Car("MINI-01", CarType.SMALL, false, new BigDecimal("10000.00"));
        PolicyRequest johnMiniPolicyRequest = new PolicyRequest(john, mini);
        johnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COLLISION));
        johnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COMPREHENSIVE));
        processParams.put("policyRequest", johnMiniPolicyRequest);

        assertEquals(false, johnMiniPolicyRequest.isManuallyApproved());
       
        String process = readInputStreamReaderAsString( new InputStreamReader( getClass().getResourceAsStream( "policyRequestWorkflow.bpmn" ) ) );
        ReleaseId releaseId = createKJarWithMultipleResources( "KBase1", new String[]{process}, new ResourceType[] {ResourceType.BPMN2} );
       
        // @formatter:off         
        simulationFluent
        .newKieSession(releaseId, "KBase1.KSession1")
            .startProcess("policyRequestProcess", processParams)
            .end()
        .runSimulation();
        // @formatter:on
View Full Code Here

        ReleaseId releaseId = TestUtils.createKJarWithMultipleResources("TestKbase",
                new String[]{"BPMN-SimpleExclusiveGatewayProcess.bpmn2"}, new ResourceType[]{ResourceType.BPMN2});
       
        SimulationDataProvider provider = context.getDataProvider();
       
        SimulationFluent f = new DefaultSimulationFluent();
        // @formatter:off
        // FIXME why building knowledge base on this level does not work??
        int numberOfAllInstances = 10;
        int counter = 0;
        // default interval 2 seconds, meaning each step in a path will be started after 2 seconds
        long interval = 2*1000*60;
        for (SimulationPath path : paths) {
           
            double probability = provider.calculatePathProbability(path);
            f.newPath("path" + counter);
           
            // count how many instances/steps should current path have
            int instancesOfPath = (int) (numberOfAllInstances * probability);
           
            for (int i = 0; i < instancesOfPath; i++) {
                f.newStep( interval * i )
                    .newKieSession( releaseId, "TestKbase.KSession1" )
                        .end(World.ROOT, StatefulKnowledgeSession.class.getName())
                    .addCommand(new SimulateProcessPathCommand("defaultPackage.test", context, path));
            }
           
            counter++;
        }
        f.runSimulation();
        // @formatter:on
       
    }
View Full Code Here

        ReleaseId releaseId = TestUtils.createKJarWithMultipleResources("TestKbase",
                new String[]{"BPMN-SimpleExclusiveGatewayProcess.bpmn2"}, new ResourceType[]{ResourceType.BPMN2});
       
        SimulationDataProvider provider = context.getDataProvider();
       
        SimulationFluent f = new DefaultSimulationFluent();
        // @formatter:off
        // FIXME why building knowledge base on this level does not work??
        int numberOfAllInstances = 10;
        int counter = 0;
        // default interval 2 seconds, meaning each step in a path will be started after 2 seconds
        long interval = 2*1000*60;
        for (SimulationPath path : paths) {
           
            double probability = provider.calculatePathProbability(path);
            f.newPath("path" + counter);
           
            // count how many instances/steps should current path have
            int instancesOfPath = (int) (numberOfAllInstances * probability);
           
            for (int i = 0; i < instancesOfPath; i++) {
                f.newStep( interval * i )
                    .newKieSession( releaseId, "TestKbase.KSession1" )
                        .end(World.ROOT, StatefulKnowledgeSession.class.getName())
                    .addCommand(new SimulateProcessPathCommand("defaultPackage.test", context, path));
            }
           
            counter++;
        }
        f.runSimulation();
        // @formatter:on
       
    }
View Full Code Here

        List<SimulationPath> paths = finder.findPaths(new SimulationFilterPathFormatConverter());
        SimulationContext context = SimulationContextFactory.newContext(new HardCodedSimulationDataProvider());
        ReleaseId releaseId = TestUtils.createKJarWithMultipleResources("TestKbase",
                new String[]{"BPMN2-ExclusiveSplit.bpmn2"}, new ResourceType[]{ResourceType.BPMN2});
       
        SimulationFluent f = new DefaultSimulationFluent();
        // @formatter:off
        f.newPath("path1")
            .newStep( 0 )
                .newKieSession( releaseId, "TestKbase.KSession1" )
                    .end(World.ROOT, StatefulKnowledgeSession.class.getName())
                .addCommand(new SimulateProcessPathCommand("com.sample.test", context, paths.get(0)))
        .newPath("path2")
View Full Code Here

        List<SimulationPath> paths = finder.findPaths(new SimulationFilterPathFormatConverter());
        SimulationContext context = SimulationContextFactory.newContext(new HardCodedSimulationDataProvider());
        ReleaseId releaseId = TestUtils.createKJarWithMultipleResources("TestKbase",
                new String[]{"BPMN2-UserTask.bpmn2"}, new ResourceType[]{ResourceType.BPMN2});
       
        SimulationFluent f = new DefaultSimulationFluent();
        // @formatter:off
        f.newPath("path1")
            .newStep( 0 )
                .newKieSession( releaseId, "TestKbase.KSession1" )
                    .end(World.ROOT, StatefulKnowledgeSession.class.getName())
                .addCommand(new SimulateProcessPathCommand("UserTask", context, paths.get(0)))
            .newStep( 5, TimeUnit.MINUTES )
View Full Code Here

        SimulationContext context = SimulationContextFactory.newContext(new BPMN2SimulationDataProvider(this.getClass().getResourceAsStream("/BPMN2-UserTaskWithSimulationMetaData.bpmn2")));
       
        ReleaseId releaseId = TestUtils.createKJarWithMultipleResources("TestKbase",
                new String[]{"BPMN2-UserTaskWithSimulationMetaData.bpmn2"}, new ResourceType[]{ResourceType.BPMN2});
       
        SimulationFluent f = new DefaultSimulationFluent();
        // @formatter:off       
        f.newPath("path1")
            .newStep( 0 )
                .newKieSession( releaseId, "TestKbase.KSession1" )
                    .end(World.ROOT, StatefulKnowledgeSession.class.getName())
                .addCommand(new SimulateProcessPathCommand("UserTask", context, paths.get(0)))
            .newStep( 5, TimeUnit.MINUTES )
View Full Code Here

        ReleaseId releaseId = TestUtils.createKJarWithMultipleResources("TestKbase",
                new String[]{"BPMN-SimpleExclusiveGatewayProcess.bpmn2"}, new ResourceType[]{ResourceType.BPMN2});
       
        SimulationDataProvider provider = context.getDataProvider();
       
        SimulationFluent f = new DefaultSimulationFluent();
        // @formatter:off
        // FIXME why building knowledge base on this level does not work??
        int numberOfAllInstances = 10;
        int counter = 0;
        // default interval 2 seconds, meaning each step in a path will be started after 2 seconds
        long interval = 2*1000*60;
        for (SimulationPath path : paths) {
           
            double probability = provider.calculatePathProbability(path);
            f.newPath("path" + counter);
           
            // count how many instances/steps should current path have
            int instancesOfPath = (int) (numberOfAllInstances * probability);
           
            for (int i = 0; i < instancesOfPath; i++) {
                f.newStep( interval * i )
                    .newKieSession( releaseId, "TestKbase.KSession1" )
                        .end(World.ROOT, StatefulKnowledgeSession.class.getName())
                    .addCommand(new SimulateProcessPathCommand("defaultPackage.test", context, path));
            }
           
            counter++;
        }
        f.runSimulation();
        // @formatter:on
       
    }
View Full Code Here

public class PolicyRequestFraudDetectionRulesTest extends SimulateTestBase {

    @Test @Ignore( "need to fix kjar generation when using existing domain models.")
    public void lyingAboutAge() throws IOException {
        SimulationFluent simulationFluent = new DefaultSimulationFluent();


        Driver realJohn = new Driver("John", "Smith", new LocalDate().minusYears(10));
        Car realMini = new Car("MINI-01", CarType.SMALL, false, new BigDecimal("10000.00"));
        PolicyRequest realJohnMiniPolicyRequest = new PolicyRequest(realJohn, realMini);
        realJohnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COLLISION));
        realJohnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COMPREHENSIVE));
        realJohnMiniPolicyRequest.setAutomaticallyRejected(true);
        realJohnMiniPolicyRequest.addRejectedMessage("Too young.");

        Driver fakeJohn = new Driver("John", "Smith", new LocalDate().minusYears(30));
        Car fakeMini = new Car("MINI-01", CarType.SMALL, false, new BigDecimal("10000.00"));
        PolicyRequest fakeJohnMiniPolicyRequest = new PolicyRequest(fakeJohn, fakeMini);
        fakeJohnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COLLISION));
        fakeJohnMiniPolicyRequest.addCoverageRequest(new CoverageRequest(CoverageType.COMPREHENSIVE));
        fakeJohnMiniPolicyRequest.setAutomaticallyRejected(false);

        String rules = readInputStreamReaderAsString( new InputStreamReader( getClass().getResourceAsStream( "policyRequestFraudDetectionRules.drl" ) ) );
        ReleaseId releaseId = createKJarWithMultipleResources( "org.drools.KBase1", new String[]{rules}, new ResourceType[] {ResourceType.DRL} );

        // @formatter:off
        simulationFluent
        .newStep(1000)
        .newKieSession(releaseId, "org.drools.KBase1.KSession1")
            .insert(realJohn).set("realJohn")
            .insert(realMini).set("realMini")
            .insert(realJohnMiniPolicyRequest).set("realJohnMiniPolicyRequest")
View Full Code Here

TOP

Related Classes of org.drools.simulation.fluent.simulation.SimulationFluent

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.