Examples of FieldData


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

    }

    Object populateFields(FactData fact,
            Object factObject) {
        for (int i = 0; i < fact.getFieldData().size(); i++) {
            FieldData field = (FieldData) fact.getFieldData().get(i);
            Object val = null;

            if (field.getValue() != null) {

                if (field.getValue().startsWith("=")) {
                    // eval the val into existence
                    val = eval(field.getValue().substring(1),
                            populatedData);
                } else if (field.getNature() == FieldData.TYPE_ENUM) {
                    // The string representation of a java enum value is a
                    // format like CheeseType.CHEDDAR
                    String valueOfEnum = field.getValue();
                    String fullName = null;
                    if (field.getValue().indexOf(".") != -1) {
                        String classNameOfEnum = field.getValue().substring(0,
                                field.getValue().lastIndexOf("."));
                        valueOfEnum = field.getValue().substring(field.getValue().lastIndexOf(".") + 1);
                        try {
                            //This is a Java enum type if the type can be resolved by ClassTypeResolver
                            //Revisit: Better way to determine java enum type or Guvnor enum type.
                            fullName = resolver.getFullTypeName(classNameOfEnum);
                            if (fullName != null && !"".equals(fullName)) {
                                valueOfEnum = fullName + "." + valueOfEnum;
                            }
                            val = eval(valueOfEnum);
                        } catch (ClassNotFoundException e) {
                            // This is a Guvnor enum type
                            fullName = classNameOfEnum;
                            if (fullName != null && !"".equals(fullName)) {
                                valueOfEnum = fullName + "." + valueOfEnum;
                            }
                            val = valueOfEnum;
                        }
                    } else {
                        val = valueOfEnum;
                    }
                } else {
                    val = field.getValue();
                }

                Map<String, Object> vars = new HashMap<String, Object>();
                vars.putAll(populatedData);
                vars.put("__val__",
                        val);
                vars.put("__fact__",
                        factObject);
                eval("__fact__." + field.getName() + " = __val__",
                        vars);
            }
        }
        return factObject;
    }
View Full Code Here

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

        Scenario sc = new Scenario();
        FactData person = new FactData();
        person.setName( "p" );
        person.setType( "Person" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        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;
View Full Code Here

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

        Scenario sc = new Scenario();
        FactData person = new FactData();
        person.setName( "c" );
        person.setType( "GenBean" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "mic" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
View Full Code Here

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

        //first, the green scenario
        Scenario sc = new Scenario();
        FactData person = new FactData();
        person.setName( "p" );
        person.setType( "Wang" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        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 );

        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.setName( "p" );
        person.setType( "Wang" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        vr = new VerifyRuleFired( "rule2",
View Full Code Here

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

        Scenario sc = new Scenario();
        FactData person = new FactData();
        person.setName( "p" );
        person.setType( "Board" );
        person.getFieldData().add( new FieldData( "cost",
                                                  "42" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "MyGoodRule",
View Full Code Here

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

        //first, the green scenario
        Scenario sc = new Scenario();
        FactData person = new FactData();
        person.setName( "p" );
        person.setType( "Person" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        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 );

        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.setName( "p" );
        person.setType( "Person" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        vr = new VerifyRuleFired( "rule2",
View Full Code Here

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

            if (selectionEvent.getSelectedItem() == FieldData.TYPE_COLLECTION) {
                CollectionFieldData collectionFieldData = new CollectionFieldData();
                collectionFieldData.setName(field.getName());
                return collectionFieldData;
            } else {
                FieldData fieldData = new FieldData(field.getName(), "");
                fieldData.setNature(selectionEvent.getSelectedItem());
                return fieldData;
            }
        }
    }
View Full Code Here

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

                    fact.getType());
            widget.setWidget(fieldRowIndex,
                    col,
                    editableCell);
            if (field instanceof FieldData) {
                FieldData fieldData = (FieldData) field;
                if (fieldData.getNature() == FieldData.TYPE_ENUM) {
                    enumEditorMap.put(fieldData, (FieldDataConstraintEditor) editableCell);
                }
            }
        }
        for (FieldDataConstraintEditor outerEnumEditor : enumEditorMap.values()) {
View Full Code Here

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

    DropDownData getEnums() {
        Map<String, String> currentValueMap = new HashMap<String, String>();
        for (Field f : fact.getFieldData()) {
            if (f instanceof FieldData) {
                FieldData otherFieldData = (FieldData) f;
                currentValueMap.put(otherFieldData.getName(),
                        otherFieldData.getValue());
            }
        }
        return dmo.getEnums(
                factType,
                field.getName(),
View Full Code Here

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

        parent.renderEditor();
    }

    @UiHandler("newItemBelow")
    public void newItemBelow(ClickEvent event) {
        FieldData newFieldData = new FieldData();
        newFieldData.setName(parentField.getName());
        parentField.getCollectionFieldList().add(index + 1,
                newFieldData);
        parent.renderEditor();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.