Search in sources :

Example 1 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.

the class ScenarioXMLPersistence method unmarshal.

public Scenario unmarshal(String xml) {
    if (xml == null)
        return new Scenario();
    if (xml.trim().equals(""))
        return new Scenario();
    Object o = xt.fromXML(xml);
    Scenario scenario = (Scenario) o;
    if (scenario.getImports() == null) {
        scenario.setImports(new Imports());
    }
    return scenario;
}
Also used : Imports(org.kie.soup.project.datamodel.imports.Imports) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario)

Example 2 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.

the class ScenarioRunner4JUnitTest method testBasic.

@Test
public void testBasic() throws Exception {
    HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
    ksessions.put("someId", ksession);
    Scenario scenario = new Scenario();
    scenario.getKSessions().add("someId");
    ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(scenario, ksessions);
    RunNotifier notifier = new RunNotifier();
    RunListener runListener = spy(new RunListener());
    notifier.addListener(runListener);
    runner4JUnit.run(notifier);
    verify(runListener, never()).testFailure(any(Failure.class));
    verify(runListener).testFinished(any(Description.class));
    verify(ksession).reset();
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Description(org.junit.runner.Description) HashMap(java.util.HashMap) KieSession(org.kie.api.runtime.KieSession) Failure(org.junit.runner.notification.Failure) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 3 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.

the class ScenarioRunner4JUnitTest method testIDNotSet.

@Test
public void testIDNotSet() throws Exception {
    HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
    ksessions.put(null, ksession);
    ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(new Scenario(), ksessions);
    RunNotifier notifier = new RunNotifier();
    RunListener runListener = spy(new RunListener());
    notifier.addListener(runListener);
    runner4JUnit.run(notifier);
    verify(runListener, never()).testFailure(any(Failure.class));
    verify(runListener).testFinished(any(Description.class));
    verify(ksession).reset();
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Description(org.junit.runner.Description) HashMap(java.util.HashMap) KieSession(org.kie.api.runtime.KieSession) Failure(org.junit.runner.notification.Failure) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 4 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.

the class ScenarioRunner4JUnitTest method testNoKieSession.

@Test
public void testNoKieSession() throws Exception {
    ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(new Scenario(), new HashMap<String, KieSession>());
    RunNotifier notifier = new RunNotifier();
    RunListener runListener = spy(new RunListener());
    notifier.addListener(runListener);
    runner4JUnit.run(notifier);
    verify(runListener).testFailure(any(Failure.class));
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) KieSession(org.kie.api.runtime.KieSession) Failure(org.junit.runner.notification.Failure) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 5 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.

the class ScenarioRunnerTest method testImports.

@Test
public void testImports() throws Exception {
    Scenario scenario = new Scenario();
    scenario.setPackageName("org.drools.workbench.models.testscenarios.backend");
    ScenarioRunner runner = new ScenarioRunner(ksession);
    scenario.getFixtures().add(new FactData("Cheese", "f1", Collections.EMPTY_LIST, false));
    runner.run(scenario);
    assertTrue(scenario.wasSuccessful());
}
Also used : FactData(org.drools.workbench.models.testscenarios.shared.FactData) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Aggregations

Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)59 Test (org.junit.Test)45 FactData (org.drools.workbench.models.testscenarios.shared.FactData)24 ExecutionTrace (org.drools.workbench.models.testscenarios.shared.ExecutionTrace)20 VerifyFact (org.drools.workbench.models.testscenarios.shared.VerifyFact)17 KieSession (org.kie.api.runtime.KieSession)14 Import (org.kie.soup.project.datamodel.imports.Import)14 VerifyField (org.drools.workbench.models.testscenarios.shared.VerifyField)13 FieldData (org.drools.workbench.models.testscenarios.shared.FieldData)12 ArrayList (java.util.ArrayList)11 VerifyRuleFired (org.drools.workbench.models.testscenarios.shared.VerifyRuleFired)9 Expectation (org.drools.workbench.models.testscenarios.shared.Expectation)6 Path (org.uberfire.backend.vfs.Path)6 Field (org.drools.workbench.models.testscenarios.shared.Field)5 HashMap (java.util.HashMap)4 RetractFact (org.drools.workbench.models.testscenarios.shared.RetractFact)4 Failure (org.junit.runner.notification.Failure)4 RunListener (org.junit.runner.notification.RunListener)4 RunNotifier (org.junit.runner.notification.RunNotifier)4 Date (java.util.Date)3