use of org.drools.workbench.models.testscenarios.shared.FactData in project drools by kiegroup.
the class ScenarioTest method testCountSuccessFailures.
@Test
public void testCountSuccessFailures() {
Scenario sc = new Scenario();
sc.getFixtures().add(new FactData());
sc.getFixtures().add(new ExecutionTrace());
VerifyRuleFired vr = new VerifyRuleFired();
vr.setSuccessResult(false);
sc.getFixtures().add(vr);
VerifyField vf = new VerifyField();
vf.setSuccessResult(true);
VerifyField vf2 = new VerifyField();
vf2.setSuccessResult(false);
VerifyFact vfact = new VerifyFact();
vfact.getFieldValues().add(vf);
vfact.getFieldValues().add(vf2);
sc.getFixtures().add(vfact);
int[] totals = sc.countFailuresTotal();
assertEquals(2, totals[0]);
assertEquals(3, totals[1]);
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools by kiegroup.
the class ScenarioTest method testAllowRemoveFact.
@Test
public void testAllowRemoveFact() {
Scenario sc = new Scenario();
FactData fd1 = new FactData("X", "x", new ArrayList(), false);
sc.getFixtures().add(fd1);
FactData fd2 = new FactData("Q", "q", new ArrayList(), false);
sc.getFixtures().add(fd2);
FactData fd3 = new FactData("Z", "z", new ArrayList(), false);
sc.getFixtures().add(fd3);
ExecutionTrace ex1 = new ExecutionTrace();
FactData fd4 = new FactData("I", "i", new ArrayList(), false);
sc.getGlobals().add(fd4);
sc.getFixtures().add(ex1);
sc.getFixtures().add(new RetractFact("z"));
sc.getFixtures().add(new FactData("Z", "z", new ArrayList(), true));
sc.getFixtures().add(new VerifyFact("q", new ArrayList()));
assertFalse(sc.isFactDataReferenced(fd1));
assertTrue(sc.isFactDataReferenced(fd2));
assertTrue(sc.isFactDataReferenced(fd3));
assertFalse(sc.isFactDataReferenced(fd4));
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools by kiegroup.
the class ScenarioTest method testRemoveFixture.
@Test
public void testRemoveFixture() {
Scenario sc = new Scenario();
VerifyRuleFired vf1 = new VerifyRuleFired();
VerifyRuleFired vf2 = new VerifyRuleFired();
VerifyRuleFired vf3 = new VerifyRuleFired();
FactData fd = new FactData();
sc.getFixtures().add(vf1);
sc.getFixtures().add(vf2);
sc.getFixtures().add(vf3);
sc.getGlobals().add(fd);
sc.removeFixture(vf2);
assertEquals(2, sc.getFixtures().size());
assertEquals(vf1, sc.getFixtures().get(0));
assertEquals(vf3, sc.getFixtures().get(1));
assertEquals(1, sc.getGlobals().size());
sc.removeFixture(fd);
assertEquals(0, sc.getGlobals().size());
assertEquals(2, sc.getFixtures().size());
}
use of org.drools.workbench.models.testscenarios.shared.FactData 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());
}
use of org.drools.workbench.models.testscenarios.shared.FactData 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));
}
Aggregations