Package org.drools.ide.common.client.modeldriven.testing

Examples of org.drools.ide.common.client.modeldriven.testing.VerifyRuleFired


    l.add(new FactData("Q", "y", new ArrayList(), true));
    l.add(new RetractFact("y"));

    VerifyFact vf1 = new VerifyFact();
    VerifyFact vf2 = new VerifyFact();
    VerifyRuleFired vr1 = new VerifyRuleFired();
    VerifyRuleFired vr2 = new VerifyRuleFired();
    l.add(vf1);
    l.add(vf2);
    l.add(vr1);
    l.add(vr2);
View Full Code Here


        for ( Iterator<Fixture> fixturesIterator = data.result.getScenario().getFixtures().iterator(); fixturesIterator.hasNext(); ) {
            Fixture fixture = fixturesIterator.next();
            if ( fixture instanceof VerifyRuleFired ) {

                VerifyRuleFired verifyRuleFired = (VerifyRuleFired) fixture;
                HorizontalPanel panel = new HorizontalPanel();
                if ( !verifyRuleFired.getSuccessResult().booleanValue() ) {
                    panel.add( new Image( images.warning() ) );
                    failures++;
                } else {
                    panel.add( new Image( images.testPassed() ) );
                }
                panel.add( new SmallLabel( verifyRuleFired.getExplanation() ) );
                resultsDetail.add( panel );
                total++;
            } else if ( fixture instanceof VerifyFact ) {
                VerifyFact verifyFact = (VerifyFact) fixture;
                for ( Iterator<VerifyField> fieldIterator = verifyFact.getFieldValues().iterator(); fieldIterator.hasNext(); ) {
View Full Code Here

        person.fieldData.add( new FieldData( "name",
                                             "michael" ) );

        sc.fixtures.add( person );
        sc.fixtures.add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.fixtures.add( vr );

        VerifyFact vf = new VerifyFact();
        vf.name = "p";
        vf.fieldValues.add( new VerifyField( "name",
                                             "michael",
                                             "==" ) );
        vf.fieldValues.add( new VerifyField( "age",
                                             "42",
                                             "==" ) );
        sc.fixtures.add( vf );

        FactData cheese = new FactData();
        cheese.name = "cheese";
        cheese.type = "Cheese";
        cheese.fieldData.add( new FieldData( "price",
                                             "42" ) );
        sc.globals.add( cheese );

        ScenarioRunResult res = impl.runScenario( pkg.getName(),
                                                  sc ).result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        res = impl.runScenario( pkg.getName(),
                                sc ).result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        impl.ruleBaseCache.clear();
        res = impl.runScenario( pkg.getName(),
                                sc ).result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        //BuilderResult[] results = impl.buildPackage(pkg.getUUID(), null, true);
        //assertNull(results);

        rule1.updateContent( "Junk" );
View Full Code Here

        person.fieldData.add( new FieldData( "name",
                                             "mic" ) );

        sc.fixtures.add( person );
        sc.fixtures.add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.fixtures.add( vr );

        VerifyFact vf = new VerifyFact();
        vf.name = "c";
        vf.fieldValues.add( new VerifyField( "name",
                                             "mic",
                                             "==" ) );
        vf.fieldValues.add( new VerifyField( "age",
                                             "42",
                                             "==" ) );
        sc.fixtures.add( vf );

        SingleScenarioResult res_ = impl.runScenario( pkg.getName(),
                                                      sc );
        assertTrue( res_.auditLog.size() > 0 );

        String[] logEntry = res_.auditLog.get( 0 );
        assertNotNull( logEntry[0],
                       logEntry[1] );

        ScenarioRunResult res = res_.result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

    }
View Full Code Here

        person.fieldData.add( new FieldData( "name",
                                             "michael" ) );

        sc.fixtures.add( person );
        sc.fixtures.add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.fixtures.add( vr );

        VerifyFact vf = new VerifyFact();
        vf.name = "p";
        vf.fieldValues.add( new VerifyField( "name",
                                             "michael",
                                             "==" ) );
        vf.fieldValues.add( new VerifyField( "age",
                                             "42",
                                             "==" ) );
        sc.fixtures.add( vf );

        AssetItem scenario1 = pkg.addAsset( "scen1",
                                            "" );
        scenario1.updateFormat( AssetFormats.TEST_SCENARIO );
        scenario1.updateContent( ScenarioXMLPersistence.getInstance().marshal( sc ) );
        scenario1.checkin( "" );

        //now the bad scenario
        sc = new Scenario();
        person = new FactData();
        person.name = "p";
        person.type = "Wang";
        person.fieldData.add( new FieldData( "age",
                                             "40" ) );
        person.fieldData.add( new FieldData( "name",
                                             "michael" ) );

        sc.fixtures.add( person );
        sc.fixtures.add( new ExecutionTrace() );
        vr = new VerifyRuleFired( "rule2",
                                  1,
                                  null );
        sc.fixtures.add( vr );

        AssetItem scenario2 = pkg.addAsset( "scen2",
View Full Code Here

        person.fieldData.add( new FieldData( "cost",
                                             "42" ) );

        sc.fixtures.add( person );
        sc.fixtures.add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "MyGoodRule",
                                                  1,
                                                  null );
        sc.fixtures.add( vr );

        VerifyFact vf = new VerifyFact();
        vf.name = "p";

        vf.fieldValues.add( new VerifyField( "cost",
                                             "42",
                                             "==" ) );
        sc.fixtures.add( vf );

        ScenarioRunResult res = impl.runScenario( pkg.getName(),
                                                  sc ).result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        res = impl.runScenario( pkg.getName(),
                                sc ).result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        impl.ruleBaseCache.clear();

        res = impl.runScenario( pkg.getName(),
                                sc ).result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

    }
View Full Code Here

        person.name = "p";
        person.type = "Person";

        sc.fixtures.add( person );
        sc.fixtures.add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "MyGoodRule",
                                                  1,
                                                  null );
        sc.fixtures.add( vr );

        ScenarioRunResult res = null;
        try {
            res = impl.runScenario( pkg.getName(),
                                    sc ).result;
        } catch ( ClassFormatError e ) {
            fail( "Probably failed when loading a source file instead of class file. " + e );
        }
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vr.wasSuccessful() );

        res = impl.runScenario( pkg.getName(),
                                sc ).result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vr.wasSuccessful() );

        impl.ruleBaseCache.clear();

        res = impl.runScenario( pkg.getName(),
                                sc ).result;
        assertEquals( null,
                      res.errors );
        assertNotNull( res.scenario );
        assertTrue( vr.wasSuccessful() );

    }
View Full Code Here

        person.fieldData.add( new FieldData( "name",
                                             "michael" ) );

        sc.fixtures.add( person );
        sc.fixtures.add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.fixtures.add( vr );

        VerifyFact vf = new VerifyFact();
        vf.name = "p";
        vf.fieldValues.add( new VerifyField( "name",
                                             "michael",
                                             "==" ) );
        vf.fieldValues.add( new VerifyField( "age",
                                             "42",
                                             "==" ) );
        sc.fixtures.add( vf );

        AssetItem scenario1 = pkg.addAsset( "scen1",
                                            "" );
        scenario1.updateFormat( AssetFormats.TEST_SCENARIO );
        scenario1.updateContent( ScenarioXMLPersistence.getInstance().marshal( sc ) );
        scenario1.checkin( "" );

        //now the bad scenario
        sc = new Scenario();
        person = new FactData();
        person.name = "p";
        person.type = "Person";
        person.fieldData.add( new FieldData( "age",
                                             "40" ) );
        person.fieldData.add( new FieldData( "name",
                                             "michael" ) );

        sc.fixtures.add( person );
        sc.fixtures.add( new ExecutionTrace() );
        vr = new VerifyRuleFired( "rule2",
                                  1,
                                  null );
        sc.fixtures.add( vr );

        AssetItem scenario2 = pkg.addAsset( "scen2",
View Full Code Here

        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );

        VerifyFact vf = new VerifyFact();
        vf.setName( "p" );
        vf.getFieldValues().add( new VerifyField( "name",
                                                  "michael",
                                                  "==" ) );
        vf.getFieldValues().add( new VerifyField( "age",
                                                  "42",
                                                  "==" ) );
        sc.getFixtures().add( vf );

        FactData cheese = new FactData();
        cheese.setName( "cheese" );
        cheese.setType( "Cheese" );
        cheese.getFieldData().add( new FieldData( "price",
                                                  "42" ) );
        sc.getGlobals().add( cheese );

        ScenarioRunResult res = repositoryPackageService.runScenario( pkg.getName(),
                                                                      sc ).result;
        assertNull( res.getErrors() );
        assertNotNull( res.getScenario() );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        res = repositoryPackageService.runScenario( pkg.getName(),
                                                    sc ).result;
        assertNull( res.getErrors() );
        assertNotNull( res.getScenario() );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        RuleBaseCache.getInstance().clearCache();
        res = repositoryPackageService.runScenario( pkg.getName(),
                                                    sc ).result;
        assertNull( res.getErrors() );
        assertNotNull( res.getScenario() );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        //BuilderResult[] results = impl.buildPackage(pkg.getUUID(), null, true);
        //assertNull(results);

        rule1.updateContent( "Junk" );
View Full Code Here

        person.getFieldData().add( new FieldData( "name",
                                                  "mic" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );

        VerifyFact vf = new VerifyFact();
        vf.setName( "c" );
        vf.getFieldValues().add( new VerifyField( "name",
                                                  "mic",
                                                  "==" ) );
        vf.getFieldValues().add( new VerifyField( "age",
                                                  "42",
                                                  "==" ) );
        sc.getFixtures().add( vf );

        SingleScenarioResult res_ = repositoryPackageService.runScenario( pkg.getName(),
                                                                          sc );
        assertTrue( res_.auditLog.size() > 0 );

        String[] logEntry = res_.auditLog.get( 0 );
        assertNotNull( logEntry[0],
                       logEntry[1] );

        ScenarioRunResult res = res_.result;

        assertNull( res.getErrors() );
        assertNotNull( res.getScenario() );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

    }
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.testing.VerifyRuleFired

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.