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

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


        run.run(scenario);

    }

    private Expectation[] populateScenarioForFailure(Scenario sc) {
        FactData[] facts = new FactData[]{new FactData("Cheese",
                "c1",
                Arrays.<Field>asList(new FieldData("type",
                        "cheddar"),
                        new FieldData("price",
                                "42")),
                false)

        };
        sc.getFixtures().addAll(Arrays.asList(facts));
        sc.getGlobals().add(new FactData("Person",
                "p",
                new ArrayList(),
                false));

        ExecutionTrace executionTrace = new ExecutionTrace();
View Full Code Here


public class GlobalFactPopulatorTest {

    @Test
    public void testWithGlobals() throws Exception {

        FactData global = new FactData( "Cheese",
                                        "c",
                                        Arrays.<Field>asList( new FieldData( "type",
                                                                             "cheddar" ) ),
                                        false );

        TypeResolver resolver = new ClassTypeResolver( new HashSet<String>(),
                                                       Thread.currentThread().getContextClassLoader() );
        resolver.addImport( "org.drools.workbench.models.testscenarios.backend.Cheese" );

        KieSession ksession = mock( KieSession.class );
        Map<String, Object> populatedData = new HashMap<String, Object>();
        Map<String, Object> globalData = new HashMap<String, Object>();
        GlobalFactPopulator globalFactPopulator = new GlobalFactPopulator( populatedData,
                                                                           resolver,
                                                                           global,
                                                                           globalData );

        globalFactPopulator.populate( ksession,
                                      new HashMap<String, FactHandle>() );

        verify( ksession ).setGlobal( eq( global.getName() ),
                                      any( Object.class ) );
        assertEquals( 1,
                      globalData.size() );
        assertEquals( 0,
                      populatedData.size() );
View Full Code Here

        List<Field> fieldData = new ArrayList<Field>();
        fieldData.add( new FieldData( "type",
                                      "cheddar" ) );
        fieldData.add( new FieldData( "price",
                                      "42" ) );
        FactData fact = new FactData( "Cheese",
                                      "c1",
                                      fieldData,
                                      false );

        NewFactPopulator newFactPopulator = new NewFactPopulator(
View Full Code Here

    public void build( final String headerText,
                       final Fact fact ) {

        if ( fact instanceof FactData ) {
            FactData factData = (FactData) fact;
            widget.setWidget( 0,
                              ++col,
                              new SmallLabel( "[" + factData.getName() + "]" ) );
        } else {
            col++;
        }

        widget.setWidget(
View Full Code Here

                                                                 CallMethodWidget.this.variableClass = (String) CallMethodWidget.this.oracle.getGlobalVariable( mCall.getVariable() );
                                                             }
                                                         } );
        } else {

            final FactData pattern = (FactData) scenario.getFactTypes().get( mCall.getVariable() );
            if ( pattern != null ) {
                this.oracle.getMethodInfos( pattern.getType(),
                                            new Callback<List<MethodInfo>>() {
                                                @Override
                                                public void callback( final List<MethodInfo> methodInfos ) {
                                                    CallMethodWidget.this.fieldCompletionTexts = new String[ methodInfos.size() ];
                                                    CallMethodWidget.this.fieldCompletionValues = new String[ methodInfos.size() ];
                                                    int i = 0;
                                                    for ( MethodInfo methodInfo : methodInfos ) {
                                                        CallMethodWidget.this.fieldCompletionTexts[ i ] = methodInfo.getName();
                                                        CallMethodWidget.this.fieldCompletionValues[ i ] = methodInfo.getNameWithParameters();
                                                        i++;
                                                    }
                                                    CallMethodWidget.this.variableClass = pattern.getType();
                                                    CallMethodWidget.this.isBoundFact = true;
                                                }
                                            } );
            }
        }
View Full Code Here

        final Scenario model = new Scenario();
        model.getImports().getImports().addAll( imports );
        model.setPackageName( packageName );
        model.setName( name );

        model.getFixtures().add( new FactData( "Applicant",
                                               "$a",
                                               new ArrayList<Field>() {{
                                                   add( new FieldData( "age",
                                                                       "33" ) );
                                               }},
View Full Code Here

        final Scenario model = new Scenario();
        model.getImports().getImports().addAll( imports );
        model.setPackageName( packageName );
        model.setName( name );

        model.getFixtures().add( new FactData( "Applicant",
                                               "$a",
                                               new ArrayList<Field>() {{
                                                   add( new FieldData( "age",
                                                                       "33" ) );
                                               }},
View Full Code Here

            box.addItem( CommonConstants.INSTANCE.Choose() );
        }
        int j = 0;
        for ( int i = 0; i < vars.size(); i++ ) {
            String var = vars.get( i );
            FactData f = scenario.getFactTypes().get( var );
            String fieldType = oracle.getFieldType( this.factType,
                                                    field.getFieldName() );
            if ( f.getType().equals( fieldType ) ) {
                if ( box.getItemCount() == 0 ) {
                    box.addItem( "..." );
                    j++;
                }
                box.addItem( "=" + var );
View Full Code Here

        List<String> vars = this.scenario.getFactNamesInScope( executionTrace,
                                                               true );
        if ( vars.size() > 0 ) {
            for ( int i = 0; i < vars.size(); i++ ) {
                String var = vars.get( i );
                FactData f = scenario.getFactTypes().get( var );
                String fieldType = oracle.getFieldType( this.factType,
                                                        field.getFieldName() );
                if ( f.getType().equals( fieldType ) ) {
                    retour = true;
                    break;
                }
            }
        }
View Full Code Here

                    public void onClick( ClickEvent event ) {
                        String text = factTypes.getItemText( factTypes.getSelectedIndex() );
                        if ( scenario.isFactNameReserved( text ) ) {
                            Window.alert( TestScenarioConstants.INSTANCE.TheName0IsAlreadyInUsePleaseChooseAnotherName( text ) );
                        } else {
                            FactData factData = new FactData( oracle.getGlobalVariable( text ),
                                                              text,
                                                              false );
                            scenario.getGlobals().add( factData );
                            parent.renderEditor();
View Full Code Here

TOP

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

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.