Package org.drools.guvnor.models.testscenarios.backend

Examples of org.drools.guvnor.models.testscenarios.backend.Cheesery


    @Test
    public void testCallMethodNoArgumentOnFact() throws Exception {
        HashMap<String, Object> populatedData = new HashMap<String, Object>();
        MethodExecutor methodExecutor = new MethodExecutor( populatedData );

        Cheesery listChesse = new Cheesery();
        listChesse.setTotalAmount( 1000 );
        populatedData.put( "cheese",
                           listChesse );
        CallMethod mCall = new CallMethod();
        mCall.setVariable( "cheese" );
        mCall.setMethodName( "setTotalAmountToZero" );

        methodExecutor.executeMethod( mCall );

        assertTrue( listChesse.getTotalAmount() == 0 );
    }
View Full Code Here


    public void testCallMethodOnStandardArgumentOnFact() throws Exception {

        HashMap<String, Object> populatedData = new HashMap<String, Object>();
        MethodExecutor methodExecutor = new MethodExecutor( populatedData );

        Cheesery listChesse = new Cheesery();
        listChesse.setTotalAmount( 1000 );
        populatedData.put( "cheese",
                           listChesse );
        CallMethod mCall = new CallMethod();
        mCall.setVariable( "cheese" );
        mCall.setMethodName( "setTotalAmount" );
        CallFieldValue field = new CallFieldValue();
        field.value = "1005";
        mCall.addFieldValue( field );

        methodExecutor.executeMethod( mCall );
        assertTrue( listChesse.getTotalAmount() == 1005 );
    }
View Full Code Here

    public void testCallMethodOnClassArgumentOnFact() throws Exception {

        HashMap<String, Object> populatedData = new HashMap<String, Object>();
        MethodExecutor methodExecutor = new MethodExecutor( populatedData );

        Cheesery listChesse = new Cheesery();
        listChesse.setTotalAmount( 1000 );
        populatedData.put( "cheese",
                           listChesse );
        Cheesery.Maturity m = Cheesery.Maturity.OLD;
        populatedData.put( "m",
                           m );
        CallMethod mCall = new CallMethod();
        mCall.setVariable( "cheese" );
        mCall.setMethodName( "setMaturity" );
        CallFieldValue field = new CallFieldValue();
        field.value = "=m";
        mCall.addFieldValue( field );

        methodExecutor.executeMethod( mCall );

        assertTrue( listChesse.getMaturity().equals( m ) );
        assertTrue( listChesse.getMaturity() == m );
    }
View Full Code Here

    public void testCallMethodOnClassArgumentAndOnArgumentStandardOnFact() throws Exception {

        HashMap<String, Object> populatedData = new HashMap<String, Object>();
        MethodExecutor methodExecutor = new MethodExecutor( populatedData );

        Cheesery listCheese = new Cheesery();
        listCheese.setTotalAmount( 1000 );
        populatedData.put( "cheese",
                           listCheese );
        Cheesery.Maturity m = Cheesery.Maturity.YOUNG;
        populatedData.put( "m",
                           m );
        CallMethod mCall = new CallMethod();
        mCall.setVariable( "cheese" );
        mCall.setMethodName( "setMaturityAndStatus" );
        CallFieldValue field = new CallFieldValue();
        field.value = "=m";
        mCall.addFieldValue( field );
        CallFieldValue field2 = new CallFieldValue();
        field2.value = "1";
        mCall.addFieldValue( field2 );

        methodExecutor.executeMethod( mCall );
        assertEquals( m, listCheese.getMaturity() );
        assertEquals( 1, listCheese.getStatus() );
    }
View Full Code Here

                                     false );
        factPopulator.add( new NewFactPopulator( populatedData, typeResolver, getClassLoader(), lst ) );

        factPopulator.populate();

        Cheesery listChesse = (Cheesery) populatedData.get( "listChesse" );
        Cheese f1 = (Cheese) populatedData.get( "f1" );
        Cheese f2 = (Cheese) populatedData.get( "f2" );
        Cheese f3 = (Cheese) populatedData.get( "f3" );

        assertEquals( 3, listChesse.getCheeses().size() );
        assertTrue( listChesse.getCheeses().contains( f1 ) );
        assertTrue( listChesse.getCheeses().contains( f2 ) );
        assertTrue( listChesse.getCheeses().contains( f3 ) );

    }
View Full Code Here

                cheeseFactData2 ) );

        factPopulator.populate();

        assertTrue( populatedData.containsKey( "cheesery" ) );
        Cheesery cheesery = (Cheesery) populatedData.get( "cheesery" );
        assertNotNull( cheesery );

        assertEquals( 2, cheesery.getCheeses().size() );
        assertNotNull( cheesery.getCheeses().get( 0 ) );
        assertTrue( cheesery.getCheeses().get( 0 ) instanceof Cheese );
        assertNotNull( cheesery.getCheeses().get( 1 ) );
        assertTrue( cheesery.getCheeses().get( 1 ) instanceof Cheese );
    }
View Full Code Here

TOP

Related Classes of org.drools.guvnor.models.testscenarios.backend.Cheesery

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.