Search in sources :

Example 1 with Scenario

use of org.drools.scenariosimulation.api.model.Scenario in project drools by kiegroup.

the class RuleScenarioRunnerHelperTest method groupByFactIdentifierAndFilterTest.

@Test
public void groupByFactIdentifierAndFilterTest() {
    Map<FactIdentifier, List<FactMappingValue>> scenario1Given = runnerHelper.groupByFactIdentifierAndFilter(scenario1.getUnmodifiableFactMappingValues(), FactMappingType.GIVEN);
    Map<FactIdentifier, List<FactMappingValue>> scenario1Expected = runnerHelper.groupByFactIdentifierAndFilter(scenario1.getUnmodifiableFactMappingValues(), FactMappingType.EXPECT);
    Map<FactIdentifier, List<FactMappingValue>> scenario2Given = runnerHelper.groupByFactIdentifierAndFilter(scenario2.getUnmodifiableFactMappingValues(), FactMappingType.GIVEN);
    Map<FactIdentifier, List<FactMappingValue>> scenario2Expected = runnerHelper.groupByFactIdentifierAndFilter(scenario2.getUnmodifiableFactMappingValues(), FactMappingType.EXPECT);
    assertEquals(1, scenario1Given.keySet().size());
    assertEquals(1, scenario1Expected.keySet().size());
    assertEquals(2, scenario2Given.keySet().size());
    assertEquals(2, scenario2Expected.keySet().size());
    assertEquals(1, scenario1Given.get(personFactIdentifier).size());
    assertEquals(1, scenario1Expected.get(personFactIdentifier).size());
    assertEquals(1, scenario2Given.get(disputeFactIdentifier).size());
    assertEquals(1, scenario2Expected.get(disputeFactIdentifier).size());
    Scenario scenario = new Scenario();
    scenario.addMappingValue(FactIdentifier.EMPTY, ExpressionIdentifier.DESCRIPTION, null);
    assertEquals(0, runnerHelper.groupByFactIdentifierAndFilter(scenario.getUnmodifiableFactMappingValues(), FactMappingType.GIVEN).size());
}
Also used : Collections.singletonList(java.util.Collections.singletonList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) FactIdentifier(org.drools.scenariosimulation.api.model.FactIdentifier) Scenario(org.drools.scenariosimulation.api.model.Scenario) AbstractRuleCoverageTest(org.drools.scenariosimulation.backend.fluent.AbstractRuleCoverageTest) Test(org.junit.Test)

Example 2 with Scenario

use of org.drools.scenariosimulation.api.model.Scenario in project drools by kiegroup.

the class AbstractScenarioRunnerTest method getDescriptionForScenario.

@Test
public void getDescriptionForScenario() {
    final Scenario scenario = scenarioRunnerDTOLocal.getScenarioWithIndices().get(2).getScesimData();
    Description retrieved = AbstractScenarioRunner.getDescriptionForScenario(Optional.empty(), 1, scenario.getDescription());
    commonVerifyDescriptionForScenario(retrieved, 1, scenario.getDescription(), AbstractScenarioRunner.class.getSimpleName());
    retrieved = AbstractScenarioRunner.getDescriptionForScenario(Optional.of("src/test/Test.scesim"), 1, scenario.getDescription());
    commonVerifyDescriptionForScenario(retrieved, 1, scenario.getDescription(), "Test");
}
Also used : Description(org.junit.runner.Description) Scenario(org.drools.scenariosimulation.api.model.Scenario) Test(org.junit.Test)

Example 3 with Scenario

use of org.drools.scenariosimulation.api.model.Scenario in project drools by kiegroup.

the class AbstractScenarioRunnerTest method getScenarioRunnerDTO.

private ScenarioRunnerDTO getScenarioRunnerDTO() {
    Simulation simulation = new Simulation();
    IntStream.range(0, SCENARIO_DATA).forEach(index -> {
        Scenario scenario = simulation.addData();
        scenario.setDescription("INDEX-" + index);
    });
    ScenarioSimulationModel model = new ScenarioSimulationModel();
    model.setSimulation(simulation);
    return new ScenarioRunnerDTO(model, "test.scesim");
}
Also used : Simulation(org.drools.scenariosimulation.api.model.Simulation) ScenarioRunnerDTO(org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerDTO) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Scenario(org.drools.scenariosimulation.api.model.Scenario)

Example 4 with Scenario

use of org.drools.scenariosimulation.api.model.Scenario in project drools-wb by kiegroup.

the class ScenarioSimulationEditorBusinessCentralWrapperTest method onRunScenario.

@Test
public void onRunScenario() {
    scenarioWithIndexLocal.add(new ScenarioWithIndex(1, new Scenario()));
    scenarioWithIndexLocal.add(new ScenarioWithIndex(2, new Scenario()));
    scenarioWithIndexLocal.add(new ScenarioWithIndex(3, new Scenario()));
    RemoteCallback<SimulationRunResult> remoteCallback = mock(RemoteCallback.class);
    ScenarioSimulationHasBusyIndicatorDefaultErrorCallback errorCallback = mock(ScenarioSimulationHasBusyIndicatorDefaultErrorCallback.class);
    scenarioSimulationEditorBusinessClientWrapper.onRunScenario(remoteCallback, errorCallback, simulationDescriptorMock, settingsLocal, scenarioWithIndexLocal, backgroundLocal);
    verify(scenarioSimulationEditorBusinessClientWrapper, times(1)).unpublishTestResultsAlerts();
    verify(scenarioSimulationCaller, times(1)).call(eq(remoteCallback), eq(errorCallback));
    verify(scenarioSimulationServiceMock, times(1)).runScenario(eq(observablePathMock), eq(simulationDescriptorMock), eq(scenarioWithIndexLocal), eq(settingsLocal), eq(backgroundLocal));
}
Also used : SimulationRunResult(org.drools.workbench.screens.scenariosimulation.model.SimulationRunResult) ScenarioSimulationHasBusyIndicatorDefaultErrorCallback(org.drools.workbench.screens.scenariosimulation.client.handlers.ScenarioSimulationHasBusyIndicatorDefaultErrorCallback) ScenarioWithIndex(org.drools.scenariosimulation.api.model.ScenarioWithIndex) Scenario(org.drools.scenariosimulation.api.model.Scenario) Test(org.junit.Test) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest)

Example 5 with Scenario

use of org.drools.scenariosimulation.api.model.Scenario in project drools-wb by kiegroup.

the class CoverageReportPresenterTest method setup.

@Before
public void setup() {
    presenterSpy = spy(presenter);
    presenterSpy.downloadReportCommand = downloadReportCommandMock;
    when(coverageReportViewMock.getDonutChart()).thenReturn(donutChartMock);
    when(coverageReportViewMock.getList()).thenReturn(list);
    when(coverageReportViewMock.getScenarioList()).thenReturn(scenarioList);
    when(coverageReportViewMock.getDownloadReportButton()).thenReturn(downloadReportButtonMock);
    availableLocal = 10;
    executedLocal = 6;
    coverageLocal = (double) executedLocal / availableLocal * 100;
    outputCounterLocal = new HashMap<>();
    outputCounterLocal.put("d1", 1);
    outputCounterLocal.put("d2", 2);
    scenarioCounterLocal = new HashMap<>();
    Map<String, Integer> scenario1Data = new HashMap<>();
    scenario1Data.put("d1", 1);
    scenario1Data.put("d2", 1);
    Map<String, Integer> scenario2Data = new HashMap<>();
    scenario2Data.put("d2", 1);
    scenarioCounterLocal.put(new ScenarioWithIndex(1, new Scenario()), scenario1Data);
    scenarioCounterLocal.put(new ScenarioWithIndex(2, new Scenario()), scenario2Data);
    simulationRunMetadataLocal = new SimulationRunMetadata(availableLocal, executedLocal, outputCounterLocal, scenarioCounterLocal, auditLog);
}
Also used : HashMap(java.util.HashMap) SimulationRunMetadata(org.drools.scenariosimulation.api.model.SimulationRunMetadata) Matchers.anyString(org.mockito.Matchers.anyString) ScenarioWithIndex(org.drools.scenariosimulation.api.model.ScenarioWithIndex) Scenario(org.drools.scenariosimulation.api.model.Scenario) Before(org.junit.Before)

Aggregations

Scenario (org.drools.scenariosimulation.api.model.Scenario)19 Test (org.junit.Test)10 ScenarioWithIndex (org.drools.scenariosimulation.api.model.ScenarioWithIndex)9 ScesimModelDescriptor (org.drools.scenariosimulation.api.model.ScesimModelDescriptor)6 Simulation (org.drools.scenariosimulation.api.model.Simulation)6 ArrayList (java.util.ArrayList)4 ExpressionIdentifier (org.drools.scenariosimulation.api.model.ExpressionIdentifier)4 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)3 SimulationRunMetadata (org.drools.scenariosimulation.api.model.SimulationRunMetadata)3 SimulationRunResult (org.drools.workbench.screens.scenariosimulation.model.SimulationRunResult)3 Matchers.anyString (org.mockito.Matchers.anyString)3 HashMap (java.util.HashMap)2 List (java.util.List)2 AuditLogLine (org.drools.scenariosimulation.api.model.AuditLogLine)2 Background (org.drools.scenariosimulation.api.model.Background)2 Settings (org.drools.scenariosimulation.api.model.Settings)2 TestUtils.commonCheckAuditLogLine (org.drools.scenariosimulation.backend.TestUtils.commonCheckAuditLogLine)2 AbstractRuleCoverageTest (org.drools.scenariosimulation.backend.fluent.AbstractRuleCoverageTest)2 ScenarioResultMetadata (org.drools.scenariosimulation.backend.runner.model.ScenarioResultMetadata)2 TestResultMessage (org.guvnor.common.services.shared.test.TestResultMessage)2