Package org.drools.workbench.models.testscenarios.backend

Examples of org.drools.workbench.models.testscenarios.backend.Cheese


    @Test
    public void testVerifyAnonymousFacts() throws Exception {
        TypeResolver typeResolver = mock( TypeResolver.class );
        FactVerifier factVerifier = new FactVerifier( new HashMap<String, Object>(), typeResolver, ksession, new HashMap<String, Object>() );

        Cheese c = new Cheese();
        c.setPrice( 42 );
        c.setType( "stilton" );

        // configure the mock to return the value
        Set o = Collections.singleton( (Object) c );
        when( ksession.getObjects() ).thenReturn( o );
View Full Code Here


    @Test
    public void testVerifyFactsWithOperator() throws Exception {
        TypeResolver typeResolver = mock( TypeResolver.class );

        Cheese f1 = new Cheese( "cheddar",
                                42 );
        HashMap<String, Object> populatedData = new HashMap<String, Object>();
        populatedData.put( "f1", f1 );

        // configure the mock to return the value
View Full Code Here

        factPopulator.populate();

        assertTrue( populatedData.containsKey( "c1" ) );

        Cheese cheese = (Cheese) populatedData.get( "c1" );
        assertEquals( CheeseType.CHEDDAR, cheese.getCheeseType() );
    }
View Full Code Here

    @Test
    public void testVerifyFactsWithExpression() throws Exception {
        TypeResolver typeResolver = mock( TypeResolver.class );

        Cheese f1 = new Cheese( "cheddar",
                                42 );
        f1.setPrice( 42 );

        HashMap<String, Object> populatedData = new HashMap<String, Object>();
        populatedData.put( "f1", f1 );

        // configure the mock to return the value
View Full Code Here

        assertTrue( vf.getFieldValues().get( 0 ).getSuccessResult() );
    }

    @Test
    public void testVerifyFactExplanation() throws Exception {
        Cheese f1 = new Cheese();
        f1.setType( null );

        TypeResolver typeResolver = mock( TypeResolver.class );

        HashMap<String, Object> populatedData = new HashMap<String, Object>();
        populatedData.put( "f1", f1 );
View Full Code Here

        assertTrue( populatedData.get( "c1" ) instanceof Cheese );
    }

    @Test
    public void testPopulatingExistingFact() throws Exception {
        Cheese cheese = new Cheese();
        cheese.setType( "whee" );
        cheese.setPrice( 1 );

        Map<String, Object> populatedData = new HashMap<String, Object>();
        populatedData.put(
                "x",
                cheese );

        factPopulator.add(
                new ExistingFactPopulator(
                        populatedData,
                        getTypeResolver(),
                        new FactData(
                                "Cheese",
                                "x",
                                Arrays.<Field>asList(
                                        new FieldData(
                                                "type",
                                                null ),
                                        new FieldData(
                                                "price",
                                                "42" ) ),
                                false ) ) );

        factPopulator.populate();

        assertEquals( "whee", cheese.getType() );
        assertEquals( 42, cheese.getPrice() );
    }
View Full Code Here

    }

    @Test
    public void testVerifyFieldAndActualIsNull() throws Exception {
        Cheese f1 = new Cheese();
        f1.setType( null );

        TypeResolver typeResolver = mock( TypeResolver.class );

        HashMap<String, Object> populatedData = new HashMap<String, Object>();
        populatedData.put( "f1", f1 );
View Full Code Here

        factPopulator.populate();

        assertTrue( populatedData.containsKey( "c1" ) );
        assertTrue( populatedData.containsKey( "p1" ) );

        Cheese c = (Cheese) populatedData.get( "c1" );
        assertNotNull( c.getUsedBy() );

    }
View Full Code Here

        factPopulator.populate();

        assertTrue( populatedData.containsKey( "c1" ) );
        assertTrue( populatedData.containsKey( "c2" ) );

        Cheese c = (Cheese) populatedData.get( "c1" );
        assertEquals( "cheddar", c.getType() );
        assertEquals( 42, c.getPrice() );

        Cheese c2 = (Cheese) populatedData.get( "c2" );
        assertEquals( c.getType(), c2.getType() );
    }
View Full Code Here

        assertEquals( c.getType(), c2.getType() );
    }

    @Test
    public void testPopulateEmptyString() throws Exception {
        Cheese cheese = new Cheese();
        cheese.setType( "whee" );
        cheese.setPrice( 1 );
        populatedData.put( "x", cheese );

        assertEquals( 1, cheese.getPrice() );

        //An empty String is a 'value' as opposed to null
        factPopulator.add(
                new ExistingFactPopulator(
                        populatedData,
                        getTypeResolver(),
                        new FactData(
                                "Cheese",
                                "x",
                                Arrays.<Field>asList(
                                        new FieldData(
                                                "type",
                                                "" ),
                                        new FieldData(
                                                "price",
                                                "42" ) ),
                                false ) ) );

        factPopulator.populate();

        assertEquals( "", cheese.getType() );
        assertEquals( 42, cheese.getPrice() );
    }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.testscenarios.backend.Cheese

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.