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

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


        rule2.checkin( "" );
        repo.save();

        //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


        asset.updateContent( "rule 'MyGoodRule' \n dialect 'mvel' \n when Board() then System.err.println(42); \n end" );
        asset.checkin( "" );
        repo.save();

        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

        asset.updateContent( "rule 'MyGoodRule' \n dialect 'mvel' \n when \n Person() \n then \n insert( new Banana() ); \n end" );
        asset.checkin( "" );
        repo.save();

        Scenario sc = new Scenario();
        FactData person = new FactData();
        person.setName( "p" );
        person.setType( "Person" );

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

        rule2.checkin( "" );
        repo.save();

        //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

     * Group the globals together by fact type.
     */
    public Map lumpyMapGlobals(List globals) {
        Map g = new HashMap();
        for ( Iterator iterator = globals.iterator(); iterator.hasNext(); ) {
            FactData f = (FactData) iterator.next();
            accumulateData( g,
                            f );
        }
        return g;
    }
View Full Code Here

    }

    private void accumulateData(Map dataInput,
                                Fixture f) {
        if ( f instanceof FactData ) {
            FactData fd = (FactData) f;
            if ( !dataInput.containsKey( fd.type ) ) {
                dataInput.put( fd.type,
                               new ArrayList() );
            }
            ((List) dataInput.get( fd.type )).add( fd );
View Full Code Here

    }

    static void removeFields(List factData,
                             String field) {
        for ( Iterator iterator = factData.iterator(); iterator.hasNext(); ) {
            FactData fa = (FactData) iterator.next();
            for ( Iterator iterator2 = fa.fieldData.iterator(); iterator2.hasNext(); ) {
                FieldData fi = (FieldData) iterator2.next();
                if ( fi.name.equals( field ) ) {
                    iterator2.remove();
                }
View Full Code Here


        if (isGlobal) {
            outer.setWidget(0, 0, getLabel(Format.format(constants.globalForScenario(), factType), defList, parent, sc));
        } else {
            FactData first = (FactData) defList.get(0);
            if (first.isModify) {
                outer.setWidget(0, 0,  getLabel(Format.format(constants.modifyForScenario(), factType), defList, parent, sc));
            } else {
                outer.setWidget(0, 0, getLabel(Format.format(constants.insertForScenario(), factType), defList, parent, sc));
            }
View Full Code Here

      public void onClick(Widget w) {

        //build up a list of what we have got, don't want to add it twice
        HashSet existingFields = new HashSet();
        if (defList.size() > 0) {
          FactData d = (FactData) defList.get(0);
          for (Iterator iterator = d.fieldData.iterator(); iterator.hasNext();) {
            FieldData f = (FieldData) iterator.next();
            existingFields.add(f.name);
          }

        }
        String[] fields = (String[]) sce.getModelFields(type);
        final FormStylePopup pop = new FormStylePopup(); //NON-NLS
                pop.setTitle(constants.ChooseDotDotDot());
        final ListBox b = new ListBox();
        for (int i = 0; i < fields.length; i++) {
          String fld = fields[i];
          if (!existingFields.contains(fld)) b.addItem(fld);
        }

        Button ok = new Button(constants.OK());
        ok.addClickListener(new ClickListener() {
                  public void onClick(Widget w) {
                    String f = b.getItemText(b.getSelectedIndex());
                    for (Iterator iterator = defList.iterator(); iterator.hasNext();) {
                      FactData fd = (FactData) iterator.next();
                      fd.fieldData.add(new FieldData(f, ""));
                    }
                        outer.setWidget(1, 0, render(defList, parent, sc));
                        pop.hide();
                  }
View Full Code Here

        Map fields = new HashMap();
        int col = 0;
        int totalCols = defList.size();
        for (Iterator iterator = defList.iterator(); iterator.hasNext();) {
            final FactData d = (FactData) iterator.next();

            for (int i = 0; i < d.fieldData.size(); i++) {
                final FieldData fd = d.fieldData.get(i);
                if (!fields.containsKey(fd.name)) {
                    int idx = fields.size() + 1;
                    fields.put(fd.name, new Integer(idx));
                    t.setWidget(idx, 0, new SmallLabel(fd.name + ":"));
                    Image del = new ImageButton("images/delete_item_small.gif", constants.RemoveThisRow(), new ClickListener() {
                public void onClick(Widget w) {
                  if (Window.confirm(constants.AreYouSureYouWantToRemoveThisRow())) {
                    ScenarioHelper.removeFields(defList, fd.name);
                    outer.setWidget(1, 0, render(defList, parent, sc));

                  }
                }
              });
                    t.setWidget(idx, totalCols + 1, del);
                    t.getCellFormatter().setHorizontalAlignment(idx, 0, HasHorizontalAlignment.ALIGN_RIGHT);
                }
            }
        }

        int totalRows = fields.size();

        t.getFlexCellFormatter().setHorizontalAlignment(totalRows + 1, 0, HasHorizontalAlignment.ALIGN_RIGHT);

        //now we go through the facts and the fields, adding them to the grid
        //if a fact is missing a FieldData, we will add it in (so people can enter data later on)
        col = 0;
        for (Iterator iterator = defList.iterator(); iterator.hasNext();) {
            final FactData d = (FactData) iterator.next();
            t.setWidget(0, ++col, new SmallLabel("[" + d.name + "]"));
            Image del = new ImageButton("images/delete_item_small.gif", Format.format(constants.RemoveTheColumnForScenario(), d.name), new ClickListener() {
        public void onClick(Widget w) {
          if (scenario.isFactNameUsed(d)) {
                        Window.alert(Format.format(constants.CanTRemoveThisColumnAsTheName0IsBeingUsed(), d.name));
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.testing.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.