use of org.drools.workbench.models.testscenarios.shared.VerifyRuleFired 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.VerifyRuleFired 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.VerifyRuleFired in project drools by kiegroup.
the class RuleFiredVerifierTest method testRuleFiredWithEnum.
@Test
public void testRuleFiredWithEnum() throws Exception {
Map<String, Integer> firingCounts = new HashMap<String, Integer>();
firingCounts.put("foo", 2);
firingCounts.put("bar", 1);
// and baz, we leave out
RuleFiredVerifier ruleFiredVerifier = new RuleFiredVerifier();
ruleFiredVerifier.setFireCounter(firingCounts);
VerifyRuleFired v = new VerifyRuleFired();
v.setRuleName("foo");
v.setExpectedFire(true);
ruleFiredVerifier.verifyFiringCounts(v);
assertTrue(v.getSuccessResult());
assertEquals(2, v.getActualResult().intValue());
}
use of org.drools.workbench.models.testscenarios.shared.VerifyRuleFired in project drools by kiegroup.
the class RuleFiredVerifierTest method testVerifyRuleFired.
@Test
public void testVerifyRuleFired() throws Exception {
RuleFiredVerifier ruleFiredVerifier = new RuleFiredVerifier();
VerifyRuleFired vr = new VerifyRuleFired("qqq", 42, null);
Map<String, Integer> f = new HashMap<String, Integer>();
f.put("qqq", 42);
f.put("qaz", 1);
ruleFiredVerifier.setFireCounter(f);
ruleFiredVerifier.verifyFiringCounts(vr);
assertTrue(vr.wasSuccessful());
assertEquals(42, vr.getActualResult().intValue());
vr = new VerifyRuleFired("qqq", 41, null);
ruleFiredVerifier.setFireCounter(f);
ruleFiredVerifier.verifyFiringCounts(vr);
assertFalse(vr.wasSuccessful());
assertEquals(42, vr.getActualResult().intValue());
vr = new VerifyRuleFired("qaz", 1, null);
ruleFiredVerifier.setFireCounter(f);
ruleFiredVerifier.verifyFiringCounts(vr);
assertTrue(vr.wasSuccessful());
assertEquals(1, vr.getActualResult().intValue());
vr = new VerifyRuleFired("XXX", null, false);
ruleFiredVerifier.setFireCounter(f);
ruleFiredVerifier.verifyFiringCounts(vr);
assertTrue(vr.wasSuccessful());
assertEquals(0, vr.getActualResult().intValue());
vr = new VerifyRuleFired("qqq", null, true);
ruleFiredVerifier.setFireCounter(f);
ruleFiredVerifier.verifyFiringCounts(vr);
assertTrue(vr.wasSuccessful());
assertEquals(42, vr.getActualResult().intValue());
vr = new VerifyRuleFired("qqq", null, false);
ruleFiredVerifier.setFireCounter(f);
ruleFiredVerifier.verifyFiringCounts(vr);
assertFalse(vr.wasSuccessful());
assertEquals(42, vr.getActualResult().intValue());
}
use of org.drools.workbench.models.testscenarios.shared.VerifyRuleFired in project drools by kiegroup.
the class RuleFiredVerifierTest method testCountVerification.
@Test
public void testCountVerification() throws Exception {
Map<String, Integer> firingCounts = new HashMap<String, Integer>();
firingCounts.put("foo", 2);
firingCounts.put("bar", 1);
// and baz, we leave out
RuleFiredVerifier ruleFiredVerifier = new RuleFiredVerifier();
ruleFiredVerifier.setFireCounter(firingCounts);
VerifyRuleFired v = new VerifyRuleFired();
v.setRuleName("foo");
v.setExpectedFire(true);
ruleFiredVerifier.verifyFiringCounts(v);
assertTrue(v.getSuccessResult());
assertEquals(2, v.getActualResult().intValue());
v = new VerifyRuleFired();
v.setRuleName("foo");
v.setExpectedFire(false);
ruleFiredVerifier.verifyFiringCounts(v);
assertFalse(v.getSuccessResult());
assertEquals(2, v.getActualResult().intValue());
assertNotNull(v.getExplanation());
v = new VerifyRuleFired();
v.setRuleName("foo");
v.setExpectedCount(2);
ruleFiredVerifier.verifyFiringCounts(v);
assertTrue(v.getSuccessResult());
assertEquals(2, v.getActualResult().intValue());
}
Aggregations