Package org.drools.workbench.models.testscenarios.shared

Examples of org.drools.workbench.models.testscenarios.shared.VerifyFact


        sc.setInclusive(true);
        sc.getFixtures().add(executionTrace);

        Expectation[] assertions = new Expectation[5];

        assertions[0] = new VerifyFact("c1",
                ls(new VerifyField("type",
                        "cheddar",
                        "==")

                ));

        assertions[1] = new VerifyFact("p",
                ls(new VerifyField("name",
                        "XXX",
                        "=="),
                        new VerifyField("status",
                                "rule2",
View Full Code Here


                                            "C",
                                            new ArrayList(),
                                            true ) );
        ExecutionTrace ex1 = new ExecutionTrace();
        sc.getFixtures().add( ex1 );
        sc.getFixtures().add( new VerifyFact() );
        sc.getFixtures().add( new RetractFact() );
        sc.getFixtures().add( new FactData( "D",
                                            "D",
                                            new ArrayList(),
                                            false ) );
        sc.getFixtures().add( new FactData( "E",
                                            "E",
                                            new ArrayList(),
                                            false ) );
        ExecutionTrace ex2 = new ExecutionTrace();
        sc.getFixtures().add( ex2 );
        sc.getFixtures().add( new VerifyFact() );
        sc.getFixtures().add( new FactData( "F",
                                            "F",
                                            new ArrayList(),
                                            false ) );
        ExecutionTrace ex3 = new ExecutionTrace();
View Full Code Here

        sc.getFixtures().add( new RetractFact( "z" ) );
        sc.getFixtures().add( new FactData( "Z",
                                            "z",
                                            new ArrayList(),
                                            true ) );
        sc.getFixtures().add( new VerifyFact( "q",
                                              new ArrayList() ) );

        assertFalse( sc.isFactDataReferenced( fd1 ) );
        assertTrue( sc.isFactDataReferenced( fd2 ) );
        assertTrue( sc.isFactDataReferenced( fd3 ) );
View Full Code Here

        VerifyField vf = new VerifyField();
        vf.setSuccessResult( true );
        VerifyField vf2 = new VerifyField();
        vf2.setSuccessResult( false );
        VerifyFact vfact = new VerifyFact();
        vfact.getFieldValues().add( vf );
        vfact.getFieldValues().add( vf2 );
        sc.getFixtures().add( vfact );

        int[] totals = sc.countFailuresTotal();
        assertEquals( 2,
                      totals[0] );
View Full Code Here

        // configure the mock to return the value
        Set o = Collections.singleton( (Object) c );
        when( ksession.getObjects() ).thenReturn( o );

        VerifyFact vf = new VerifyFact( "Cheese",
                                        new ArrayList<VerifyField>(),
                                        true );
        vf.getFieldValues().add( new VerifyField( "price",
                                                  "42",
                                                  "==" ) );
        vf.getFieldValues().add( new VerifyField( "type",
                                                  "stilton",
                                                  "==" ) );

        factVerifier.verify( vf );
        assertTrue( vf.wasSuccessful() );

        vf = new VerifyFact( "Person",
                             new ArrayList<VerifyField>(),
                             true );
        vf.getFieldValues().add( new VerifyField( "age",
                                                  "42",
                                                  "==" ) );

        factVerifier.verify( vf );
        assertFalse( vf.wasSuccessful() );

        vf = new VerifyFact( "Cheese",
                             new ArrayList<VerifyField>(),
                             true );
        vf.getFieldValues().add( new VerifyField( "price",
                                                  "43",
                                                  "==" ) );
        vf.getFieldValues().add( new VerifyField( "type",
                                                  "stilton",
                                                  "==" ) );

        factVerifier.verify( vf );
        assertFalse( vf.wasSuccessful() );
        assertEquals( Boolean.FALSE,
                      vf.getFieldValues().get( 0 ).getSuccessResult() );

        vf = new VerifyFact( "Cell",
                             new ArrayList<VerifyField>(),
                             true );
        vf.getFieldValues().add( new VerifyField( "value",
                                                  "43",
                                                  "==" ) );

        factVerifier.verify( vf );
        assertFalse( vf.wasSuccessful() );
        assertEquals( Boolean.FALSE,
                      vf.getFieldValues().get( 0 ).getSuccessResult() );

    }
View Full Code Here

        when( ksession.getObjects() ).thenReturn( o );

        FactVerifier factVerifier = new FactVerifier( populatedData, typeResolver, classLoader, ksession, new HashMap<String, Object>() );

        // test all true
        VerifyFact vf = new VerifyFact();
        vf.setName( "f1" );
        vf.getFieldValues().add( new VerifyField( "type",
                                                  "cheddar",
                                                  "==" ) );
        vf.getFieldValues().add( new VerifyField( "price",
                                                  "4777",
                                                  "!=" ) );

        factVerifier.verify( vf );

        for ( int i = 0; i < vf.getFieldValues().size(); i++ ) {
            assertTrue( vf.getFieldValues().get( i ).getSuccessResult() );
        }

        vf = new VerifyFact();
        vf.setName( "f1" );
        vf.getFieldValues().add( new VerifyField( "type",
                                                  "cheddar",
                                                  "!=" ) );
        factVerifier.verify( vf );
        assertFalse( vf.getFieldValues().get( 0 ).getSuccessResult() );

    }
View Full Code Here

        when( ksession.getObjects() ).thenReturn( o );

        FactVerifier factVerifier = new FactVerifier( populatedData, typeResolver, classLoader, ksession, new HashMap<String, Object>() );

        // test all true
        VerifyFact vf = new VerifyFact();
        vf.setName( "f1" );
        vf.getFieldValues().add( new VerifyField( "price",
                                                  "= 40 + 2",
                                                  "==" ) );
        factVerifier.verify( vf );

        assertTrue( vf.getFieldValues().get( 0 ).getSuccessResult() );
    }
View Full Code Here

        Set o = Collections.singleton( (Object) f1 );
        when( ksession.getObjects() ).thenReturn( o );

        FactVerifier factVerifier = new FactVerifier( populatedData, typeResolver, classLoader, ksession, new HashMap<String, Object>() );

        VerifyFact vf = new VerifyFact();
        vf.setName( "f1" );
        vf.getFieldValues().add( new VerifyField( "type",
                                                  "boo",
                                                  "!=" ) );

        factVerifier.verify( vf );
        VerifyField vfl = vf.getFieldValues().get( 0 );
        assertEquals( "[f1] field [type] was not [boo].",
                      vfl.getExplanation() );

    }
View Full Code Here

        Set o = Collections.singleton( (Object) f1 );
        when( ksession.getObjects() ).thenReturn( o );

        FactVerifier factVerifier = new FactVerifier( populatedData, typeResolver, classLoader, ksession, new HashMap<String, Object>() );

        VerifyFact vf = new VerifyFact();
        vf.setName( "f1" );
        vf.getFieldValues().add( new VerifyField( "type",
                                                  "boo",
                                                  "==" ) );

        factVerifier.verify( vf );
        VerifyField vfl = vf.getFieldValues().get( 0 );

        assertEquals( "[f1] field [type] was [] expected [boo].",
                      vfl.getExplanation() );
        assertEquals( "boo",
                      vfl.getExpected() );
View Full Code Here

                                        "33")),
                        false
                ));

        // test all true
        VerifyFact verifyCheddar = new VerifyFact();
        verifyCheddar.setName("f1");
        verifyCheddar.setFieldValues(
                asList(
                        new VerifyField(
                                "type",
                                "cheddar",
                                "=="),
                        new VerifyField(
                                "price",
                                "42",
                                "==")));

        scenario.getFixtures().add(verifyCheddar);

        VerifyFact michaelVerifyFact = new VerifyFact();
        michaelVerifyFact.setName("f2");
        michaelVerifyFact.setFieldValues(
                asList(
                        new VerifyField(
                                "name",
                                "michael",
                                "=="),
                        new VerifyField(
                                "age",
                                "33",
                                "==")));

        scenario.getFixtures().add(michaelVerifyFact);

        // test one false
        VerifyFact markVerifyFact = new VerifyFact();
        markVerifyFact.setName("f2");
        markVerifyFact.setFieldValues(
                asList(
                        new VerifyField(
                                "name",
                                "mark",
                                "=="),
                        new VerifyField(
                                "age",
                                "33",
                                "==")));

        scenario.getFixtures().add(markVerifyFact);

        // test 2 false
        VerifyFact mark2VerifyFact = new VerifyFact();
        mark2VerifyFact.setName("f2");
        mark2VerifyFact.setFieldValues(
                asList(
                        new VerifyField(
                                "name",
                                "mark",
                                "=="),
                        new VerifyField(
                                "age",
                                "32",
                                "==")));

        scenario.getFixtures().add(mark2VerifyFact);

        runner.run(scenario);

        for (VerifyField verifyField : verifyCheddar.getFieldValues()) {
            assertTrue(verifyField.getSuccessResult());
        }

        for (VerifyField verifyField : michaelVerifyFact.getFieldValues()) {
            assertTrue(verifyField.getSuccessResult());
        }

        assertFalse((markVerifyFact.getFieldValues().get(0)).getSuccessResult());
        assertTrue((markVerifyFact.getFieldValues().get(1)).getSuccessResult());

        assertEquals("michael", markVerifyFact.getFieldValues().get(0).getActualResult());
        assertEquals("mark", markVerifyFact.getFieldValues().get(0).getExpected());

        assertFalse((mark2VerifyFact.getFieldValues().get(0)).getSuccessResult());
        assertFalse((mark2VerifyFact.getFieldValues().get(1)).getSuccessResult());

        assertEquals("michael", mark2VerifyFact.getFieldValues().get(0).getActualResult());
        assertEquals("mark", mark2VerifyFact.getFieldValues().get(0).getExpected());

        assertEquals("33", mark2VerifyFact.getFieldValues().get(1).getActualResult());
        assertEquals("32", mark2VerifyFact.getFieldValues().get(1).getExpected());
    }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.testscenarios.shared.VerifyFact

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.