Search in sources :

Example 1 with OuterFact

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

the class FactPopulatorTest method testPopulateNestedWrongOrder.

@Test
public void testPopulateNestedWrongOrder() throws Exception {
    TypeResolver typeResolver = getTypeResolver();
    FactData outerFactData = new FactData("OuterFact", "p1", Arrays.<Field>asList(new FieldData("name", "mic"), new FieldData("innerFact", "=c1")), false);
    factPopulator.add(new NewFactPopulator(populatedData, typeResolver, outerFactData));
    FactData cheeseFactData = new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("type", "cheddar"), new FieldData("price", "42")), false);
    factPopulator.add(new NewFactPopulator(populatedData, typeResolver, cheeseFactData));
    factPopulator.populate();
    assertTrue(populatedData.containsKey("c1"));
    assertTrue(populatedData.containsKey("p1"));
    OuterFact o = (OuterFact) populatedData.get("p1");
    assertEquals(populatedData.get("c1"), o.getInnerFact());
}
Also used : CollectionFieldData(org.drools.workbench.models.testscenarios.shared.CollectionFieldData) FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) 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) OuterFact(org.drools.workbench.models.testscenarios.backend.OuterFact) Test(org.junit.Test)

Example 2 with OuterFact

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

the class FactPopulatorTest method testPopulateNested.

@Test
public void testPopulateNested() throws Exception {
    TypeResolver typeResolver = getTypeResolver();
    FactData cheeseFactData = new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("type", "cheddar"), new FieldData("price", "42")), false);
    factPopulator.add(new NewFactPopulator(populatedData, typeResolver, cheeseFactData));
    FactData outerFactData = new FactData("OuterFact", "p1", Arrays.<Field>asList(new FieldData("name", "mic"), new FieldData("innerFact", "=c1")), false);
    factPopulator.add(new NewFactPopulator(populatedData, typeResolver, outerFactData));
    factPopulator.populate();
    assertTrue(populatedData.containsKey("c1"));
    assertTrue(populatedData.containsKey("p1"));
    OuterFact o = (OuterFact) populatedData.get("p1");
    assertEquals(populatedData.get("c1"), o.getInnerFact());
}
Also used : CollectionFieldData(org.drools.workbench.models.testscenarios.shared.CollectionFieldData) FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) 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) OuterFact(org.drools.workbench.models.testscenarios.backend.OuterFact) Test(org.junit.Test)

Aggregations

OuterFact (org.drools.workbench.models.testscenarios.backend.OuterFact)2 CollectionFieldData (org.drools.workbench.models.testscenarios.shared.CollectionFieldData)2 FactData (org.drools.workbench.models.testscenarios.shared.FactData)2 FieldData (org.drools.workbench.models.testscenarios.shared.FieldData)2 Test (org.junit.Test)2 ClassTypeResolver (org.kie.soup.project.datamodel.commons.types.ClassTypeResolver)2 TypeResolver (org.kie.soup.project.datamodel.commons.types.TypeResolver)2