Search in sources :

Example 1 with MyCollectionWrapper

use of org.drools.workbench.models.testscenarios.backend.MyCollectionWrapper in project drools by kiegroup.

the class FactPopulatorTest method testCollectionSums.

@Test
public void testCollectionSums() throws Exception {
    TypeResolver typeResolver = getTypeResolver();
    List<Field> fieldData = new ArrayList<Field>();
    CollectionFieldData collectionFieldData = new CollectionFieldData();
    collectionFieldData.setName("list");
    fieldData.add(collectionFieldData);
    collectionFieldData.getCollectionFieldList().add(new FieldData("list", "=1+3"));
    FactData wrapperFactData = new FactData("MyCollectionWrapper", "wrapper", fieldData, false);
    factPopulator.add(new NewFactPopulator(populatedData, typeResolver, wrapperFactData));
    factPopulator.populate();
    assertTrue(populatedData.containsKey("wrapper"));
    MyCollectionWrapper wrapper = (MyCollectionWrapper) populatedData.get("wrapper");
    assertNotNull(wrapper);
    assertEquals(1, wrapper.getList().size());
    assertNotNull(wrapper.getList().get(0));
    assertEquals(4, wrapper.getList().get(0));
}
Also used : CollectionFieldData(org.drools.workbench.models.testscenarios.shared.CollectionFieldData) FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) Field(org.drools.workbench.models.testscenarios.shared.Field) MyCollectionWrapper(org.drools.workbench.models.testscenarios.backend.MyCollectionWrapper) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) TypeResolver(org.kie.soup.project.datamodel.commons.types.TypeResolver) FactData(org.drools.workbench.models.testscenarios.shared.FactData) ArrayList(java.util.ArrayList) CollectionFieldData(org.drools.workbench.models.testscenarios.shared.CollectionFieldData) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 MyCollectionWrapper (org.drools.workbench.models.testscenarios.backend.MyCollectionWrapper)1 CollectionFieldData (org.drools.workbench.models.testscenarios.shared.CollectionFieldData)1 FactData (org.drools.workbench.models.testscenarios.shared.FactData)1 Field (org.drools.workbench.models.testscenarios.shared.Field)1 FieldData (org.drools.workbench.models.testscenarios.shared.FieldData)1 Test (org.junit.Test)1 ClassTypeResolver (org.kie.soup.project.datamodel.commons.types.ClassTypeResolver)1 TypeResolver (org.kie.soup.project.datamodel.commons.types.TypeResolver)1