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

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


                pop.addRow(b);
                Button ok = new Button(TestScenarioConstants.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( TestScenarioConstants.INSTANCE.equalsScenario(),
                    "==" );
            opr.addItem( TestScenarioConstants.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,
                    dmo,
                    this.scenario,
                    this.executionTrace );

            data.setWidget( i,
                    3,
                    cellEditor );

            Image del = CommonAltedImages.INSTANCE.DeleteItemSmall();
            del.setAltText(TestScenarioConstants.INSTANCE.RemoveThisFieldExpectation());
            del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisFieldExpectation());
            del.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent w) {
                    if (Window.confirm(TestScenarioConstants.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( CommonImages.INSTANCE.warning() ) );
                    data.setWidget( i,
                            5,
                            new HTML( TestScenarioConstants.INSTANCE.ActualResult( fld.getActualResult() ) ) );

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

                pop.addRow( b );
                Button ok = new Button( TestScenarioConstants.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( TestScenarioConstants.INSTANCE.equalsScenario(),
                         "==" );
            opr.addItem( TestScenarioConstants.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,
                                                                 oracle,
                                                                 this.scenario,
                                                                 this.executionTrace );

            data.setWidget( i,
                            3,
                            cellEditor );

            Image del = CommonAltedImages.INSTANCE.DeleteItemSmall();
            del.setAltText( TestScenarioConstants.INSTANCE.RemoveThisFieldExpectation() );
            del.setTitle( TestScenarioConstants.INSTANCE.RemoveThisFieldExpectation() );
            del.addClickHandler( new ClickHandler() {
                public void onClick( ClickEvent w ) {
                    if ( Window.confirm( TestScenarioConstants.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( CommonImages.INSTANCE.warning() ) );
                    data.setWidget( i,
                                    5,
                                    new HTML( TestScenarioConstants.INSTANCE.ActualResult( fld.getActualResult() ) ) );

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

        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() );
View Full Code Here

        FactVerifier factVerifier = new FactVerifier( populatedData, typeResolver, 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

        FactVerifier factVerifier = new FactVerifier( populatedData, typeResolver, 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

        FactVerifier factVerifier = new FactVerifier( populatedData, typeResolver, 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

        FactVerifier factVerifier = new FactVerifier( populatedData, typeResolver, 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() );
        assertEquals( "",
                      vfl.getActualResult() );

    }
View Full Code Here

                "sqlDateWrapper",
                sqlDateWrapper,
                typeResolver);

        List<VerifyField> fieldValues = new ArrayList<VerifyField>();
        VerifyField verifyField = new VerifyField("sqlDate", "12-DEC-2012", "==");
        fieldValues.add(verifyField);

        verifier.checkFields(fieldValues);

        assertTrue(verifyField.getSuccessResult());
    }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.testscenarios.shared.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.