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

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


    }

    private FlexTable render(final VerifyFact vf) {
        FlexTable data = new FlexTable();
        for ( int i = 0; i < vf.getFieldValues().size(); i++ ) {
            final VerifyField fld = (VerifyField) vf.getFieldValues().get( i );
            data.setWidget( i,
                            1,
                            new SmallLabel( fld.getFieldName() + ":" ) );
            data.getFlexCellFormatter().setHorizontalAlignment( i,
                                                                1,
                                                                HasHorizontalAlignment.ALIGN_RIGHT );

            final ListBox opr = new ListBox();
            opr.addItem( Constants.INSTANCE.equalsScenario(),
                         "==" );
            opr.addItem( Constants.INSTANCE.doesNotEqualScenario(),
                         "!=" );
            if ( fld.getOperator().equals( "==" ) ) {
                opr.setSelectedIndex( 0 );
            } else {
                opr.setSelectedIndex( 1 );
            }
            opr.addChangeHandler( new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    fld.setOperator( opr.getValue( opr.getSelectedIndex() ) );
                }
            } );

            data.setWidget( i,
                            2,
                            opr );
            Widget cellEditor = new VerifyFieldConstraintEditor( type,
                                                                 new ValueChanged() {
                                                                     public void valueChanged(String newValue) {
                                                                         fld.setExpected( newValue );
                                                                     }

                                                                 },
                                                                 fld,
                                                                 sce,
                                                                 this.scenario,
                                                                 this.executionTrace );

            data.setWidget( i,
                            3,
                            cellEditor );

            Image del = new ImageButton( DroolsGuvnorImages.INSTANCE.deleteItemSmall(),
                                         Constants.INSTANCE.RemoveThisFieldExpectation(),
                                         new ClickHandler() {
                                             public void onClick(ClickEvent w) {
                                                 if ( Window.confirm( Constants.INSTANCE.AreYouSureYouWantToRemoveThisFieldExpectation(
                                                                                     fld.getFieldName() ) ) ) {
                                                     vf.getFieldValues().remove( fld );
                                                     FlexTable data = render( vf );
                                                     outer.setWidget( 1,
                                                                      0,
                                                                      data );
                                                 }
                                             }
                                         } );
            data.setWidget( i,
                            4,
                            del );

            if ( showResults && fld.getSuccessResult() != null ) {
                if ( !fld.getSuccessResult().booleanValue() ) {
                    data.setWidget( i,
                                    0,
                                    new Image( DroolsGuvnorImages.INSTANCE.warning() ) );
                    data.setWidget( i,
                                    5,
                                    new HTML( Constants.INSTANCE.ActualResult( fld.getActualResult() ) ) );

                    data.getCellFormatter().addStyleName( i,
                                                          5,
                                                          "testErrorValue" ); //NON-NLS
View Full Code Here


                total++;
            } else if ( fixture instanceof VerifyFact ) {
                VerifyFact verifyFact = (VerifyFact) fixture;
                for ( Iterator<VerifyField> fieldIterator = verifyFact.getFieldValues().iterator(); fieldIterator.hasNext(); ) {
                    total++;
                    VerifyField verifyField = fieldIterator.next();
                    HorizontalPanel panel = new HorizontalPanel();
                    if ( !verifyField.getSuccessResult().booleanValue() ) {
                        panel.add( new Image( DroolsGuvnorImageResources.INSTANCE.warning() ) );
                        failures++;
                    } else {
                        panel.add( new Image( DroolsGuvnorImageResources.INSTANCE.testPassed() ) );
                    }
                    panel.add( new SmallLabel( verifyField.getExplanation() ) );
                    resultsDetail.add( panel );
                }

            } else if ( fixture instanceof ExecutionTrace ) {
                ExecutionTrace ex = (ExecutionTrace) fixture;
View Full Code Here

                pop.addRow(b);
                Button ok = new Button(Constants.INSTANCE.OK());
                ok.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent w) {
                        String f = b.getItemText(b.getSelectedIndex());
                        vf.getFieldValues().add(new VerifyField(f,
                                "",
                                "=="));
                        FlexTable data = render(vf);
                        outer.setWidget(1,
                                0,
View Full Code Here

    }

    private FlexTable render(final VerifyFact vf) {
        FlexTable data = new FlexTable();
        for ( int i = 0; i < vf.getFieldValues().size(); i++ ) {
            final VerifyField fld = (VerifyField) vf.getFieldValues().get( i );
            data.setWidget( i,
                            1,
                            new SmallLabel( fld.getFieldName() + ":" ) );
            data.getFlexCellFormatter().setHorizontalAlignment( i,
                                                                1,
                                                                HasHorizontalAlignment.ALIGN_RIGHT );

            final ListBox opr = new ListBox();
            opr.addItem( Constants.INSTANCE.equalsScenario(),
                         "==" );
            opr.addItem( Constants.INSTANCE.doesNotEqualScenario(),
                         "!=" );
            if ( fld.getOperator().equals( "==" ) ) {
                opr.setSelectedIndex( 0 );
            } else {
                opr.setSelectedIndex( 1 );
            }
            opr.addChangeHandler( new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    fld.setOperator( opr.getValue( opr.getSelectedIndex() ) );
                }
            } );

            data.setWidget( i,
                            2,
                            opr );
            Widget cellEditor = new VerifyFieldConstraintEditor( type,
                                                                 new ValueChanged() {
                                                                     public void valueChanged(String newValue) {
                                                                         fld.setExpected( newValue );
                                                                     }

                                                                 },
                                                                 fld,
                                                                 sce,
                                                                 this.scenario,
                                                                 this.executionTrace );

            data.setWidget( i,
                            3,
                            cellEditor );

            Image del = DroolsGuvnorImages.INSTANCE.DeleteItemSmall();
            del.setAltText(Constants.INSTANCE.RemoveThisFieldExpectation());
            del.setTitle(Constants.INSTANCE.RemoveThisFieldExpectation());
            del.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent w) {
                    if (Window.confirm(Constants.INSTANCE.AreYouSureYouWantToRemoveThisFieldExpectation(
                            fld.getFieldName()))) {
                        vf.getFieldValues().remove(fld);
                        FlexTable data = render(vf);
                        outer.setWidget(1,
                                0,
                                data);
                    }
                }
            });
            data.setWidget( i,
                            4,
                            del );

            if ( showResults && fld.getSuccessResult() != null ) {
                if ( !fld.getSuccessResult().booleanValue() ) {
                    data.setWidget( i,
                                    0,
                                    new Image( DroolsGuvnorImageResources.INSTANCE.warning() ) );
                    data.setWidget( i,
                                    5,
                                    new HTML( Constants.INSTANCE.ActualResult( fld.getActualResult() ) ) );

                    data.getCellFormatter().addStyleName( i,
                                                          5,
                                                          "testErrorValue" ); //NON-NLS
View Full Code Here

                total++;
            } else if ( fixture instanceof VerifyFact ) {
                VerifyFact verifyFact = (VerifyFact) fixture;
                for ( Iterator<VerifyField> fieldIterator = verifyFact.getFieldValues().iterator(); fieldIterator.hasNext(); ) {
                    total++;
                    VerifyField verifyField = fieldIterator.next();
                    HorizontalPanel panel = new HorizontalPanel();
                    if ( !verifyField.getSuccessResult().booleanValue() ) {
                        panel.add( GuvnorImages.INSTANCE.WarningAlt() );
                        failures++;
                    } else {
                        panel.add( GuvnorImages.INSTANCE.TestPassedAlt() );
                    }
                    panel.add( new SmallLabel( verifyField.getExplanation() ) );
                    resultsDetail.add( panel );
                }

            } else if ( fixture instanceof ExecutionTrace ) {
                ExecutionTrace ex = (ExecutionTrace) fixture;
View Full Code Here

                                       f2 );

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

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

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

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

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

        runner.verify( vf );
        assertFalse( ((VerifyField) vf.getFieldValues().get( 0 )).getSuccessResult() );
        assertTrue( ((VerifyField) vf.getFieldValues().get( 1 )).getSuccessResult() );

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

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

        runner.verify( vf );
        assertFalse( ((VerifyField) vf.getFieldValues().get( 0 )).getSuccessResult() );
View Full Code Here

        runner.getPopulatedData().put( "f1",
                                       f1 );

        VerifyFact vf = new VerifyFact();
        vf.setName("f1");
        VerifyField verifyField = new VerifyField( "cheeseType",
                                                   "CheeseType.CHEDDAR",
                                                   "==" );
        verifyField.setNature( VerifyField.TYPE_ENUM );
        vf.setFieldValues( ls( verifyField ) );
        runner.verify( vf );
        for ( int i = 0; i < vf.getFieldValues().size(); i++ ) {
            assertTrue( ((VerifyField) vf.getFieldValues().get( i )).getSuccessResult() );
        }
View Full Code Here

        wm.facts.add( c );

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

        runner.verify( vf );

        assertTrue( vf.wasSuccessful() );

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

        runner.verify( vf );

        assertFalse( vf.wasSuccessful() );

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

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

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

        runner.verify( vf );
        assertFalse( vf.wasSuccessful() );
View Full Code Here

                                       f1 );

        // test all true
        VerifyFact vf = new VerifyFact();
        vf.setName("f1");
        vf.setFieldValues( ls( new VerifyField( "type",
                                                "cheddar",
                                                "==" ),
                               new VerifyField( "price",
                                                "4777",
                                                "!=" ) ) );
        runner.verify( vf );
        for ( int i = 0; i < vf.getFieldValues().size(); i++ ) {
            assertTrue( ((VerifyField) vf.getFieldValues().get( i )).getSuccessResult() );
        }

        vf = new VerifyFact();
        vf.setName("f1");
        vf.setFieldValues( ls( new VerifyField( "type",
                                                "cheddar",
                                                "!=" ) ) );
        runner.verify( vf );
        assertFalse( ((VerifyField) vf.getFieldValues().get( 0 )).getSuccessResult() );
View Full Code Here

                                       f1 );
        f1.setPrice( 42 );
        // test all true
        VerifyFact vf = new VerifyFact();
        vf.setName("f1");
        vf.setFieldValues( ls( new VerifyField( "price",
                                                "= 40 + 2",
                                                "==" ) ) );
        runner.verify( vf );

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

TOP

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

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.