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

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


            @Override
            public Fixture getFixture() {
                String factName = valueWidget.getItemText( valueWidget.getSelectedIndex() );

                return new RetractFact( factName );
            }
View Full Code Here


                                           2 );

        int row = 1;
        for ( Fixture fixture : retractList ) {
            if ( fixture instanceof RetractFact ) {
                final RetractFact retractFact = (RetractFact) fixture;
                setWidget( row,
                           0,
                           new SmallLabel( retractFact.getName() ) );

                setWidget( row,
                           1,
                           new DeleteButton( retractFact ) );
View Full Code Here

                                    workingMemory.insert(factObject));
                        }
                    });
                }
            } else if (fixture instanceof RetractFact) {
                RetractFact retractFact = (RetractFact) fixture;
                this.workingMemory.retract(this.factHandles.get(retractFact.getName()));
                this.populatedData.remove(retractFact.getName());
            } else if (fixture instanceof CallMethod) {
                CallMethod aCall = (CallMethod) (fixture);
                Object targetInstance = populatedData.get(aCall.getVariable());
                executeMethodOnObject(aCall,
                        targetInstance);
View Full Code Here

        l.add(ex1);

        l.add(new FactData("Z", "z", new ArrayList(), false));
        l.add(new FactData("Q", "x", new ArrayList(), true));
        l.add(new FactData("Q", "y", new ArrayList(), true));
        l.add(new RetractFact("y"));
        l.add(new CallMethod("x","hello"));


        VerifyFact vf1 = new VerifyFact();
        VerifyFact vf2 = new VerifyFact();
        VerifyRuleFired vr1 = new VerifyRuleFired();
        VerifyRuleFired vr2 = new VerifyRuleFired();
        l.add(vf1);
        l.add(vf2);
        l.add(vr1);
        l.add(vr2);

        ExecutionTrace ex2 = new ExecutionTrace();
        l.add(ex2);

        VerifyFact vf3 = new VerifyFact();
        l.add(vf3);

        ScenarioHelper hlp = new ScenarioHelper();

        List fx = hlp.lumpyMap(l);
        assertEquals(9, fx.size());

        Map first  = (Map) fx.get(0);
        assertEquals(2, first.size());
        List fdl = (List) first.get("Q");
        assertEquals(2, fdl.size());
        FactData fd = (FactData) fdl.get(0);
        assertEquals("x", fd.getName());
        fd = (FactData) fdl.get(1);
        assertEquals("y", fd.getName());

        fdl = (List) first.get("X");
        assertEquals(2, fdl.size());
        fd = (FactData) fdl.get(0);
        assertEquals("a", fd.getName());

        CallFixtureMap callMap = (CallFixtureMap)fx.get(1);
        assertEquals(2, callMap.size());
        assertTrue(callMap.containsKey("x"));
        FixtureList lcall1 = callMap.get("x");
        CallMethod c1 = (CallMethod)lcall1.get(0);
        assertTrue(c1.getVariable().equals("x"));
        assertTrue(c1.getMethodName().equals("hello"));
        CallMethod c2 = (CallMethod)lcall1.get(1);
        assertTrue(c2.getVariable().equals("x"));
        assertTrue(c2.getMethodName().equals("helloItherWay"));
        assertTrue(callMap.containsKey("v"));
        FixtureList lcall2 = callMap.get("v");
        CallMethod c3= (CallMethod)lcall2.get(0);
        assertTrue(c3.getVariable().equals("v"));
        assertTrue(c3.getMethodName().equals("helloAgain"));


        assertEquals(ex1, fx.get(2));

        List ruleFired = (List) fx.get(3);
        assertEquals(2, ruleFired.size());
        assertEquals(vr1, ruleFired.get(0));
        assertEquals(vr2, ruleFired.get(1));

        List verifyFact = (List) fx.get(4);
        assertEquals(2, verifyFact.size());
        assertEquals(vf1, verifyFact.get(0));
        assertEquals(vf2, verifyFact.get(1));



        Map second = (Map) fx.get(5);
        assertEquals(3, second.size());
        assertTrue(second.containsKey("Z"));
        assertTrue(second.containsKey("Q"));
        fdl = (List) second.get("Q");
        assertEquals(2, fdl.size());

        assertTrue(second.containsKey("retract"));
        List retracts = (List) second.get("retract");
        assertEquals(1, retracts.size());
        RetractFact ret = (RetractFact) retracts.get(0);
        assertEquals("y", ret.getName());


        CallFixtureMap third = (CallFixtureMap)fx.get(6);
        assertEquals(1, third.size());
        assertTrue(third.containsKey("x"));
View Full Code Here

    l.add(ex1);

    l.add(new FactData("Z", "z", new ArrayList(), false));
    l.add(new FactData("Q", "x", new ArrayList(), true));
    l.add(new FactData("Q", "y", new ArrayList(), true));
    l.add(new RetractFact("y"));

    VerifyFact vf1 = new VerifyFact();
    VerifyFact vf2 = new VerifyFact();
    VerifyRuleFired vr1 = new VerifyRuleFired();
    VerifyRuleFired vr2 = new VerifyRuleFired();
    l.add(vf1);
    l.add(vf2);
    l.add(vr1);
    l.add(vr2);

    ExecutionTrace ex2 = new ExecutionTrace();
    l.add(ex2);

    VerifyFact vf3 = new VerifyFact();
    l.add(vf3);

    ScenarioHelper hlp = new ScenarioHelper();

    List fx = hlp.lumpyMap(l);
    assertEquals(7, fx.size());

    Map first  = (Map) fx.get(0);
    assertEquals(2, first.size());
    List fdl = (List) first.get("Q");
    assertEquals(2, fdl.size());
    FactData fd = (FactData) fdl.get(0);
    assertEquals("x", fd.name);
    fd = (FactData) fdl.get(1);
    assertEquals("y", fd.name);

    fdl = (List) first.get("X");
    assertEquals(2, fdl.size());
    fd = (FactData) fdl.get(0);
    assertEquals("a", fd.name);

    assertEquals(ex1, fx.get(1));

    List ruleFired = (List) fx.get(2);
    assertEquals(2, ruleFired.size());
    assertEquals(vr1, ruleFired.get(0));
    assertEquals(vr2, ruleFired.get(1));

    List verifyFact = (List) fx.get(3);
    assertEquals(2, verifyFact.size());
    assertEquals(vf1, verifyFact.get(0));
    assertEquals(vf2, verifyFact.get(1));


//    List retracts = (List) fx.get(4);
//    assertEquals(1, retracts.size());
//    RetractFact ret = (RetractFact) retracts.get(0);
//    assertEquals("y", ret.name);


    Map second = (Map) fx.get(4);
    assertEquals(3, second.size());
    assertTrue(second.containsKey("Z"));
    assertTrue(second.containsKey("Q"));
    fdl = (List) second.get("Q");
    assertEquals(2, fdl.size());

    assertTrue(second.containsKey("retract"));
    List retracts = (List) second.get("retract");
    assertEquals(1, retracts.size());
    RetractFact ret = (RetractFact) retracts.get(0);
    assertEquals("y", ret.name);

    assertEquals(ex2, fx.get(5));

View Full Code Here

                    add = new Button(constants.Add());
                    add.addClickListener(new ClickListener() {

                        public void onClick(Widget w) {
                            String fn = retractFacts.getItemText(retractFacts.getSelectedIndex());
                            scenario.insertBetween(previousEx, new RetractFact(fn));
                            renderEditor();
                            pop.hide();
                        }
                    });
                    HorizontalPanel retractFact = new HorizontalPanel();
View Full Code Here

        outer.setWidget(0, 0, new SmallLabel(constants.RetractFacts()));
        outer.getFlexCellFormatter().setColSpan(0, 0, 2);

        int row = 1;
        for (Iterator iterator = retList.iterator(); iterator.hasNext();) {
      final RetractFact r = (RetractFact) iterator.next();
      outer.setWidget(row, 0, new SmallLabel(r.name));
      Image del = new ImageButton("images/delete_item_small.gif", constants.RemoveThisRetractStatement(), new ClickListener() {
        public void onClick(Widget w) {
          retList.remove(r);
          sc.fixtures.remove(r);
View Full Code Here

            @Override
            public Fixture getFixture() {
                String factName = valueWidget.getItemText( valueWidget.getSelectedIndex() );

                return new RetractFact( factName );
            }
View Full Code Here

                                           2 );

        int row = 1;
        for ( Fixture fixture : retractList ) {
            if ( fixture instanceof RetractFact ) {
                final RetractFact retractFact = (RetractFact) fixture;
                setWidget( row,
                           0,
                           new SmallLabel( retractFact.name ) );

                setWidget( row,
View Full Code Here

                                           2 );

        int row = 1;
        for ( Fixture fixture : retractList ) {
            if ( fixture instanceof RetractFact ) {
                final RetractFact retractFact = (RetractFact) fixture;
                setWidget( row,
                           0,
                           new SmallLabel( retractFact.getName() ) );

                setWidget( row,
                           1,
                           new DeleteButton( retractFact ) );
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.testing.RetractFact

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.