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

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


    private FlexTable render(final FixtureList rfl,
                             final Scenario sc) {
        FlexTable data = new DirtyableFlexTable();

        for ( int i = 0; i < rfl.size(); i++ ) {
            final VerifyRuleFired v = (VerifyRuleFired) rfl.get( i );

            if ( showResults && v.getSuccessResult() != null ) {
                if ( !v.getSuccessResult().booleanValue() ) {
                    data.setWidget( i,
                            0,
                            new Image( CommonImages.INSTANCE.warning() ) );
                    data.setWidget( i,
                            4,
                            new HTML( TestScenarioConstants.INSTANCE.ActualResult(v.getActualResult().toString()) ) );

                    data.getCellFormatter().addStyleName( i,
                            4,
                            "testErrorValue" ); //NON-NLS

                } else {
                    data.setWidget( i,
                            0,
                            new Image( TestScenarioImages.INSTANCE.testPassed() ) );
                }

            }
            data.setWidget( i,
                    1,
                    new SmallLabel( v.getRuleName() + ":" ) );
            data.getFlexCellFormatter().setAlignment( i,
                    1,
                    HasHorizontalAlignment.ALIGN_RIGHT,
                    HasVerticalAlignment.ALIGN_MIDDLE );

            final ListBox b = new ListBox();
            b.addItem( TestScenarioConstants.INSTANCE.firedAtLeastOnce(),
                    "y" );
            b.addItem( TestScenarioConstants.INSTANCE.didNotFire(),
                    "n" );
            b.addItem( TestScenarioConstants.INSTANCE.firedThisManyTimes(),
                    "e" );
            final TextBox num = new TextBox();
            num.setVisibleLength( 5 );

            if ( v.getExpectedFire() != null ) {
                b.setSelectedIndex( (v.getExpectedFire().booleanValue()) ? 0 : 1 );
                num.setVisible( false );
            } else {
                b.setSelectedIndex( 2 );
                String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
                num.setText( xc );
            }

            b.addChangeHandler( new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    String s = b.getValue( b.getSelectedIndex() );
                    if ( s.equals( "y" ) || s.equals( "n" ) ) {
                        num.setVisible( false );
                        v.setExpectedFire( (s.equals( "y" )) ? Boolean.TRUE : Boolean.FALSE );
                        v.setExpectedCount( null );
                    } else {
                        num.setVisible( true );
                        v.setExpectedFire( null );
                        num.setText( "1" );
                        v.setExpectedCount( new Integer( 1 ) );
                    }
                }
            } );

            b.addItem( TestScenarioConstants.INSTANCE.ChooseDotDotDot() );

            num.addChangeHandler( new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    v.setExpectedCount( new Integer( num.getText() ) );
                }
            } );

            HorizontalPanel h = new HorizontalPanel();
            h.add( b );
View Full Code Here


            Widget selectRule = scenarioWidgetComponentCreator.getRuleSelectionWidget(
                    new RuleSelectionEvent() {

                        public void ruleSelected(String name) {
                            VerifyRuleFired verifyRuleFired = new VerifyRuleFired(name,
                                    null,
                                    Boolean.TRUE);
                            scenario.insertBetween(previousEx,
                                    verifyRuleFired);
                            parent.renderEditor();
View Full Code Here

                                "rule2",
                                "=="))

        );

        assertions[2] = new VerifyRuleFired("rule1",
                1,
                null);
        assertions[3] = new VerifyRuleFired("rule2",
                1,
                null);
        assertions[4] = new VerifyRuleFired("rule3",
                0,
                null);

        sc.getFixtures().addAll(Arrays.asList(assertions));
View Full Code Here

                                "rule2",
                                "=="))

        );

        assertions[2] = new VerifyRuleFired("rule1",
                1,
                null);
        assertions[3] = new VerifyRuleFired("rule2",
                1,
                null);
        assertions[4] = new VerifyRuleFired("rule3",
                0,
                null);

        sc.getFixtures().addAll(Arrays.asList(assertions));
View Full Code Here

                        "42",
                        "==")

                ));

        assertions[1] = new VerifyRuleFired("rule1",
                1,
                null);

        scenario.getFixtures().addAll(Arrays.asList(assertions));
View Full Code Here

        assertions[0] = new VerifyFact("c",
                ls(new VerifyField("num",
                        "42",
                        "==")));

        assertions[1] = new VerifyRuleFired("rule1",
                1,
                null);

        scenario.getFixtures().addAll(Arrays.asList(assertions));
View Full Code Here

                vf.getFieldValues().get(0).getExpected());
        assertEquals("rule1",
                vf.getFieldValues().get(0).getActualResult());
        assertNotNull(vf.getFieldValues().get(0).getExplanation());

        VerifyRuleFired vr = (VerifyRuleFired) assertions[4];
        assertFalse(vr.getSuccessResult());

        assertEquals(2,
                vr.getExpectedCount().intValue());
        assertEquals(0,
                vr.getActualResult().intValue());

    }
View Full Code Here

                                "rule2",
                                "==")

                ));

        assertions[2] = new VerifyRuleFired("rule1",
                1,
                null);
        assertions[3] = new VerifyRuleFired("rule2",
                1,
                null);
        assertions[4] = new VerifyRuleFired("rule3",
                2,
                null);

        sc.getFixtures().addAll(Arrays.asList(assertions));
        return assertions;
View Full Code Here

    private FlexTable render( final FixtureList rfl,
                              final Scenario sc ) {
        FlexTable data = new DirtyableFlexTable();

        for ( int i = 0; i < rfl.size(); i++ ) {
            final VerifyRuleFired v = (VerifyRuleFired) rfl.get( i );

            if ( showResults && v.getSuccessResult() != null ) {
                if ( !v.getSuccessResult().booleanValue() ) {
                    data.setWidget( i,
                                    0,
                                    new Image( CommonImages.INSTANCE.warning() ) );
                    data.setWidget( i,
                                    4,
                                    new HTML( TestScenarioConstants.INSTANCE.ActualResult( v.getActualResult().toString() ) ) );

                    data.getCellFormatter().addStyleName( i,
                                                          4,
                                                          "testErrorValue" ); //NON-NLS

                } else {
                    data.setWidget( i,
                                    0,
                                    new Image( TestScenarioImages.INSTANCE.testPassed() ) );
                }

            }
            data.setWidget( i,
                            1,
                            new SmallLabel( v.getRuleName() + ":" ) );
            data.getFlexCellFormatter().setAlignment( i,
                                                      1,
                                                      HasHorizontalAlignment.ALIGN_RIGHT,
                                                      HasVerticalAlignment.ALIGN_MIDDLE );

            final ListBox b = new ListBox();
            b.addItem( TestScenarioConstants.INSTANCE.firedAtLeastOnce(),
                       "y" );
            b.addItem( TestScenarioConstants.INSTANCE.didNotFire(),
                       "n" );
            b.addItem( TestScenarioConstants.INSTANCE.firedThisManyTimes(),
                       "e" );
            final TextBox num = new TextBox();
            num.setVisibleLength( 5 );

            if ( v.getExpectedFire() != null ) {
                b.setSelectedIndex( ( v.getExpectedFire().booleanValue() ) ? 0 : 1 );
                num.setVisible( false );
            } else {
                b.setSelectedIndex( 2 );
                String xc = ( v.getExpectedCount() != null ) ? "" + v.getExpectedCount().intValue() : "0";
                num.setText( xc );
            }

            b.addChangeHandler( new ChangeHandler() {
                public void onChange( ChangeEvent event ) {
                    String s = b.getValue( b.getSelectedIndex() );
                    if ( s.equals( "y" ) || s.equals( "n" ) ) {
                        num.setVisible( false );
                        v.setExpectedFire( ( s.equals( "y" ) ) ? Boolean.TRUE : Boolean.FALSE );
                        v.setExpectedCount( null );
                    } else {
                        num.setVisible( true );
                        v.setExpectedFire( null );
                        num.setText( "1" );
                        v.setExpectedCount( Integer.valueOf( 1 ) );
                    }
                }
            } );

            b.addItem( TestScenarioConstants.INSTANCE.ChooseDotDotDot() );

            num.addChangeHandler( new ChangeHandler() {
                public void onChange( ChangeEvent event ) {
                    v.setExpectedCount( Integer.valueOf( num.getText() ) );
                }
            } );

            HorizontalPanel h = new HorizontalPanel();
            h.add( b );
View Full Code Here

            Widget selectRule = scenarioWidgetComponentCreator.getRuleSelectionWidget(
                    new RuleSelectionEvent() {

                        public void ruleSelected( String name ) {
                            VerifyRuleFired verifyRuleFired = new VerifyRuleFired( name,
                                                                                   null,
                                                                                   Boolean.TRUE );
                            scenario.insertBetween( previousEx,
                                                    verifyRuleFired );
                            parent.renderEditor();
View Full Code Here

TOP

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