use of org.drools.scenariosimulation.backend.runner.RuleScenarioRunner in project drools-wb by kiegroup.
the class ScenarioRunnerServiceImplTest method runFailed.
@Test
public void runFailed() {
when(buildInfoServiceMock.getBuildInfo(any())).thenReturn(buildInfoMock);
when(buildInfoMock.getKieContainer()).thenReturn(kieContainerMock);
simulationLocal.addData();
Scenario scenario = simulationLocal.getDataByIndex(0);
scenario.setDescription("Test Scenario");
String errorMessage = "Test Error";
scenarioRunnerService.setRunnerSupplier((kieContainer, scenarioRunnerDTO) -> new RuleScenarioRunner(kieContainer, scenarioRunnerDTO) {
@Override
protected void internalRunScenario(ScenarioWithIndex scenarioWithIndex, ScenarioRunnerData scenarioRunnerData, Settings settings, Background background) {
throw new ScenarioException(errorMessage);
}
});
SimulationRunResult test = scenarioRunnerService.runTest("test", mock(Path.class), simulationLocal.getScesimModelDescriptor(), simulationLocal.getScenarioWithIndex(), settingsLocal, backgroundLocal);
TestResultMessage value = test.getTestResultMessage();
List<org.guvnor.common.services.shared.test.Failure> failures = value.getFailures();
assertEquals(1, failures.size());
String testDescription = String.format("#%d: %s", 1, scenario.getDescription());
String errorMessageFormatted = String.format("#%d %s: %s", 1, scenario.getDescription(), errorMessage);
org.guvnor.common.services.shared.test.Failure failure = failures.get(0);
assertEquals(errorMessageFormatted, failure.getMessage());
assertEquals(1, value.getRunCount());
assertTrue(failure.getDisplayName().startsWith(testDescription));
}
Aggregations