Search in sources :

Example 1 with ScenarioRunner4JUnit

use of org.drools.workbench.models.testscenarios.backend.ScenarioRunner4JUnit in project drools-wb by kiegroup.

the class ScenarioRunnerService method run.

public TestScenarioResult run(final String identifier, final Scenario scenario, final KieModule module) {
    try {
        final HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
        final String ksessionName = getKSessionName(scenario.getKSessions());
        ksessions.put(ksessionName, loadKSession(module, ksessionName));
        final AuditLogger auditLogger = new AuditLogger(ksessions);
        final ScenarioRunner4JUnit scenarioRunner = new ScenarioRunner4JUnit(scenario, ksessions, getMaxRuleFirings());
        run(identifier, scenarioRunner, defaultTestResultMessageEvent);
        return new TestScenarioResult(scenario, auditLogger.getLog());
    } catch (InitializationError initializationError) {
        throw new GenericPortableException(initializationError.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) InitializationError(org.junit.runners.model.InitializationError) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException) KieSession(org.kie.api.runtime.KieSession) ScenarioRunner4JUnit(org.drools.workbench.models.testscenarios.backend.ScenarioRunner4JUnit) TestScenarioResult(org.drools.workbench.screens.testscenario.model.TestScenarioResult)

Example 2 with ScenarioRunner4JUnit

use of org.drools.workbench.models.testscenarios.backend.ScenarioRunner4JUnit in project drools-wb by kiegroup.

the class ScenarioRunnerService method runAllTests.

@Override
public void runAllTests(final String identifier, final Path path, final Event<TestResultMessage> customTestResultEvent) {
    try {
        final List<Scenario> scenarios = scenarioLoader.loadScenarios(path);
        ScenarioRunner4JUnit scenarioRunner = new ScenarioRunner4JUnit(scenarios, getKSessions(path, scenarios), getMaxRuleFirings());
        run(identifier, scenarioRunner, customTestResultEvent);
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : ScenarioRunner4JUnit(org.drools.workbench.models.testscenarios.backend.ScenarioRunner4JUnit) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario)

Aggregations

ScenarioRunner4JUnit (org.drools.workbench.models.testscenarios.backend.ScenarioRunner4JUnit)2 GenericPortableException (org.guvnor.common.services.shared.exceptions.GenericPortableException)2 HashMap (java.util.HashMap)1 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)1 TestScenarioResult (org.drools.workbench.screens.testscenario.model.TestScenarioResult)1 InitializationError (org.junit.runners.model.InitializationError)1 KieSession (org.kie.api.runtime.KieSession)1