use of org.drools.scenariosimulation.api.model.SimulationRunMetadata in project drools-wb by kiegroup.
the class ScenarioSimulationEditorBusinessCentralWrapper method setCoverageReport.
protected void setCoverageReport(CoverageReportView.Presenter presenter) {
ScenarioSimulationModel.Type modelType = scenarioSimulationEditorPresenter.getDataManagementStrategy() instanceof AbstractDMODataManagementStrategy ? ScenarioSimulationModel.Type.RULE : ScenarioSimulationModel.Type.DMN;
SimulationRunMetadata simulationRunMetadata = lastRunResult != null ? lastRunResult.getSimulationRunMetadata() : null;
presenter.populateCoverageReport(modelType, simulationRunMetadata);
if (simulationRunMetadata != null && simulationRunMetadata.getAuditLog() != null) {
presenter.setDownloadReportCommand(() -> onDownloadReportToCsv(scenarioSimulationEditorPresenter.getExportCallBack(), new ScenarioSimulationHasBusyIndicatorDefaultErrorCallback(scenarioSimulationEditorPresenter.getView()), simulationRunMetadata, modelType));
}
}
use of org.drools.scenariosimulation.api.model.SimulationRunMetadata 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);
}
use of org.drools.scenariosimulation.api.model.SimulationRunMetadata in project drools-wb by kiegroup.
the class ScenarioCsvDownloadReportTest method printOverallStatsLine.
@Test
public void printOverallStatsLine() throws IOException {
StringBuilder stringBuilder = new StringBuilder();
CSVPrinter printer = getCSVPrinter(stringBuilder);
AuditLog auditLog = new AuditLog();
auditLog.addAuditLogLine(getAuditLogLine());
SimulationRunMetadata simulationRunMetadata = getSimulationRunMetadata(auditLog);
scenarioCsvDownloadReport.printOverallStatsLine(printer, simulationRunMetadata.getAvailable(), simulationRunMetadata.getExecuted(), simulationRunMetadata.getCoveragePercentage());
String retrieved = stringBuilder.toString();
List<String> data = Arrays.asList(String.valueOf(simulationRunMetadata.getAvailable()), String.valueOf(simulationRunMetadata.getExecuted()), String.valueOf(simulationRunMetadata.getCoveragePercentage()));
commonCheckRetrievedString(retrieved, data);
}
use of org.drools.scenariosimulation.api.model.SimulationRunMetadata in project drools-wb by kiegroup.
the class ScenarioCsvDownloadReportTest method getSimulationRunMetadata.
private SimulationRunMetadata getSimulationRunMetadata(AuditLog auditLog) {
Random random = new Random();
Map<String, Integer> rules = new HashMap<>();
rules.put("Rule,1", random.nextInt(7));
return new SimulationRunMetadata(random.nextInt(10), random.nextInt(5), rules, Collections.emptyMap(), auditLog);
}
use of org.drools.scenariosimulation.api.model.SimulationRunMetadata in project drools-wb by kiegroup.
the class ScenarioSimulationEditorPresenterTest method refreshModelContent.
@Test
public void refreshModelContent() {
when(scenarioSimulationModelMock.getSimulation()).thenReturn(simulationMock);
List<ScenarioWithIndex> scenarioWithIndex = new ArrayList<>();
int scenarioNumber = 1;
int scenarioIndex = scenarioNumber - 1;
Scenario scenario = mock(Scenario.class);
scenarioWithIndex.add(new ScenarioWithIndex(scenarioNumber, scenario));
List<BackgroundDataWithIndex> backgroundDataWithIndex = new ArrayList<>();
BackgroundData backgroundData = mock(BackgroundData.class);
backgroundDataWithIndex.add(new BackgroundDataWithIndex(scenarioNumber, backgroundData));
TestResultMessage testResultMessage = mock(TestResultMessage.class);
SimulationRunResult testRunResult = new SimulationRunResult(scenarioWithIndex, backgroundDataWithIndex, new SimulationRunMetadata(), testResultMessage);
presenterSpy.refreshModelContent(testRunResult);
verify(scenarioSimulationViewMock, times(1)).hideBusyIndicator();
verify(simulationMock, times(1)).replaceData(eq(scenarioIndex), eq(scenario));
assertEquals(scenarioSimulationModelMock, presenterSpy.getModel());
verify(scenarioGridWidgetSpy, times(1)).refreshContent(eq(simulationMock));
assertEquals(scenarioSimulationContextLocal.getStatus().getSimulation(), simulationMock);
verify(backgroundMock, times(1)).replaceData(eq(scenarioIndex), eq(backgroundData));
verify(backgroundGridWidgetSpy, times(1)).refreshContent(eq(backgroundMock));
assertEquals(scenarioSimulationContextLocal.getStatus().getBackground(), backgroundMock);
assertEquals(scenarioSimulationModelMock, presenterSpy.getModel());
verify(abstractScenarioSimulationDocksHandlerMock, times(1)).expandTestResultsDock();
verify(dataManagementStrategyMock, times(1)).setModel(eq(scenarioSimulationModelMock));
verify(scenarioSimulationEditorWrapperMock, times(1)).onRefreshedModelContent(eq(testRunResult));
}
Aggregations