use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.
the class ScenarioRunner4JUnitTest method testNoKieWithGivenIDSession.
@Test
public void testNoKieWithGivenIDSession() throws Exception {
HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
ksessions.put("someID", ksession);
Scenario scenario = new Scenario();
scenario.getKSessions().add("someOtherID");
ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(scenario, ksessions);
RunNotifier notifier = new RunNotifier();
RunListener runListener = spy(new RunListener());
notifier.addListener(runListener);
runner4JUnit.run(notifier);
verify(runListener).testFailure(any(Failure.class));
}
use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.
the class ScenarioRunnerTest method testIntegrationWithModify.
@Test
public void testIntegrationWithModify() throws Exception {
Scenario sc = new Scenario();
sc.getImports().addImport(new Import("org.drools.workbench.models.testscenarios.backend.Cheese"));
sc.getFixtures().add(new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("price", "1")), false));
sc.getFixtures().add(new ExecutionTrace());
sc.getFixtures().add(new VerifyFact("c1", ls(new VerifyField("type", "rule1", "=="))));
sc.getFixtures().add(new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("price", "42")), true));
sc.getFixtures().add(new ExecutionTrace());
sc.getFixtures().add(new VerifyFact("c1", ls(new VerifyField("type", "rule3", "=="))));
KieSession ksession = getKieSession("test_stateful.drl");
ScenarioRunner run = new ScenarioRunner(ksession);
run.run(sc);
assertTrue(sc.wasSuccessful());
}
use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.
the class ScenarioRunnerTest method testVerifyFactsWithEnumWildCardImport.
@Test
public void testVerifyFactsWithEnumWildCardImport() throws Exception {
FieldData cheeseType = new FieldData("cheeseType", "CheeseType.CHEDDAR");
cheeseType.setNature(FieldData.TYPE_ENUM);
FactData f1 = new FactData("Cheese", "f1", Arrays.<Field>asList(cheeseType), false);
Scenario scenario = new Scenario();
scenario.setPackageName("org.drools.workbench.models.testscenarios.backend");
scenario.getFixtures().add(f1);
ScenarioRunner runner = new ScenarioRunner(ksession);
runner.run(scenario);
}
use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.
the class ScenarioRunnerTest method testIntegrationWithFailure.
@Test
public void testIntegrationWithFailure() throws Exception {
Scenario sc = new Scenario();
sc.getImports().addImport(new Import("org.drools.workbench.models.testscenarios.backend.Cheese"));
sc.getImports().addImport(new Import("org.drools.workbench.models.testscenarios.backend.Person"));
Expectation[] assertions = populateScenarioForFailure(sc);
KieSession ksession = getKieSession("test_rules2.drl");
ScenarioRunner run = new ScenarioRunner(ksession);
run.run(sc);
assertFalse(sc.wasSuccessful());
VerifyFact vf = (VerifyFact) assertions[1];
assertFalse((vf.getFieldValues().get(0)).getSuccessResult());
assertEquals("XXX", vf.getFieldValues().get(0).getExpected());
assertEquals("rule1", vf.getFieldValues().get(0).getActualResult());
assertNotNull(vf.getFieldValues().get(0).getExplanation());
VerifyRuleFired vr = (VerifyRuleFired) assertions[4];
assertFalse(vr.getSuccessResult());
assertEquals(2, vr.getExpectedCount().intValue());
assertEquals(0, vr.getActualResult().intValue());
}
use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.
the class ScenarioRunnerTest method testIntgerationStateful.
@Test
public void testIntgerationStateful() throws Exception {
Scenario sc = new Scenario();
sc.getImports().addImport(new Import("org.drools.workbench.models.testscenarios.backend.Cheese"));
sc.getFixtures().add(new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("price", "1")), false));
ExecutionTrace ex = new ExecutionTrace();
sc.getFixtures().add(ex);
sc.getFixtures().add(new FactData("Cheese", "c2", Arrays.<Field>asList(new FieldData("price", "2")), false));
sc.getFixtures().add(new VerifyFact("c1", ls(new VerifyField("type", "rule1", "=="))));
ex = new ExecutionTrace();
sc.getFixtures().add(ex);
sc.getFixtures().add(new VerifyFact("c1", ls(new VerifyField("type", "rule2", "=="))));
KieSession ksession = getKieSession("test_stateful.drl");
ScenarioRunner run = new ScenarioRunner(ksession);
run.run(sc);
assertTrue(sc.wasSuccessful());
}
Aggregations