ScenarioSimulationEditorBusinessCentralWrapper extends KieEditor<ScenarioSimulationModel> implements ScenarioSimulationEditorWrapper { 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)); } } ScenarioSimulationEditorBusinessCentralWrapper(); @Inject  ScenarioSimulationEditorBusinessCentralWrapper(final Caller<ScenarioSimulationService> service,
                                                          final ScenarioSimulationEditorPresenter scenarioSimulationEditorPresenter,
                                                          final ImportsWidgetPresenter importsWidget,
                                                          final AsyncPackageDataModelOracleFactory oracleFactory,
                                                          final PlaceManager placeManager,
                                                          final Caller<DMNTypeService> dmnTypeService,
                                                          final Caller<ImportExportService> importExportService,
                                                          final Caller<RunnerReportService> runnerReportService,
                                                          final ScenarioSimulationBusinessCentralDocksHandler scenarioSimulationBusinessCentralDocksHandler); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @OnClose @Override void onClose(); @OnMayClose boolean mayClose(); @Override @WorkbenchPartTitle String getTitleText(); @Override @WorkbenchPartTitleDecoration IsWidget getTitle(); @Override @WorkbenchPartView IsWidget getWidget(); @Override @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @Override void showDocks(); @Override void wrappedRegisterDock(String id, IsWidget widget); @Override void onImport(String fileContents, RemoteCallback<AbstractScesimModel> importCallBack, ErrorCallback<Object> importErrorCallback, AbstractScesimModel<? extends AbstractScesimData> scesimModel); @Override void onExportToCsv(RemoteCallback<String> exportCallBack, ScenarioSimulationHasBusyIndicatorDefaultErrorCallback scenarioSimulationHasBusyIndicatorDefaultErrorCallback, AbstractScesimModel<? extends AbstractScesimData> scesimModel); @Override void onDownloadReportToCsv(RemoteCallback<String> exportCallBack,
                                      ScenarioSimulationHasBusyIndicatorDefaultErrorCallback scenarioSimulationHasBusyIndicatorDefaultErrorCallback,
                                      SimulationRunMetadata simulationRunMetadata,
                                      ScenarioSimulationModel.Type modelType); @Override void hideDocks(); @Override void onRunScenario(RemoteCallback<SimulationRunResult> refreshModelCallback, ScenarioSimulationHasBusyIndicatorDefaultErrorCallback scenarioSimulationHasBusyIndicatorDefaultErrorCallback, ScesimModelDescriptor simulationDescriptor, Settings settings, List<ScenarioWithIndex> toRun, Background background); @Override Integer getOriginalHash(); @Override void addDownloadMenuItem(FileMenuBuilder fileMenuBuilder); @Override void validate(Simulation simulation, Settings settings, RemoteCallback<?> callback); @Override void onRefreshedModelContent(SimulationRunResult testResult); @Override void onEditTabSelected(); @Override void onOverviewSelected(); @Override void addBackgroundPage(final ScenarioGridWidget scenarioGridWidget); @Override void selectSimulationTab(); @Override void selectBackgroundTab(); @Override AbstractScenarioSimulationDocksHandler getScenarioSimulationDocksHandler(); @Override ScenarioSimulationEditorPresenter getScenarioSimulationEditorPresenter(); @Override void populateDocks(String identifier);  }
@Test public void setCoverageReport() { AuditLog auditLogMock = mock(AuditLog.class); CoverageReportView.Presenter presenterSpy = spy(CoverageReportView.Presenter.class); scenarioSimulationEditorBusinessClientWrapper.setCoverageReport(presenterSpy); verify(presenterSpy, times(1)).populateCoverageReport(eq(DMN), eq(null)); reset(presenterSpy, simulationRunMetadataMock, scenarioSimulationEditorBusinessClientWrapper); scenarioSimulationEditorBusinessClientWrapper.lastRunResult = simulationRunResultMock; scenarioSimulationEditorBusinessClientWrapper.setCoverageReport(presenterSpy); verify(presenterSpy, times(1)).populateCoverageReport(eq(DMN), eq(simulationRunMetadataMock)); verify(presenterSpy, never()).setDownloadReportCommand(any()); reset(presenterSpy, simulationRunMetadataMock, scenarioSimulationEditorBusinessClientWrapper); when(simulationRunMetadataMock.getAuditLog()).thenReturn(auditLogMock); scenarioSimulationEditorBusinessClientWrapper.lastRunResult = simulationRunResultMock; scenarioSimulationEditorBusinessClientWrapper.setCoverageReport(presenterSpy); verify(presenterSpy, times(1)).populateCoverageReport(eq(DMN), eq(simulationRunMetadataMock)); verify(presenterSpy, times(1)).setDownloadReportCommand(commandArgumentCaptor.capture()); commandArgumentCaptor.getValue().execute(); verify(scenarioSimulationEditorBusinessClientWrapper, times(1)).onDownloadReportToCsv(eq(exportCallBackMock), isA(ScenarioSimulationHasBusyIndicatorDefaultErrorCallback.class), eq(simulationRunMetadataMock), eq(DMN)); reset(presenterSpy, simulationRunMetadataMock, scenarioSimulationEditorBusinessClientWrapper); scenarioSimulationEditorBusinessClientWrapper.lastRunResult = null; when(scenarioSimulationEditorPresenterMock.getDataManagementStrategy()).thenReturn(mock(AbstractDMODataManagementStrategy.class)); scenarioSimulationEditorBusinessClientWrapper.setCoverageReport(presenterSpy); verify(presenterSpy, times(1)).populateCoverageReport(eq(RULE), eq(null)); reset(presenterSpy, simulationRunMetadataMock, scenarioSimulationEditorBusinessClientWrapper); scenarioSimulationEditorBusinessClientWrapper.lastRunResult = simulationRunResultMock; scenarioSimulationEditorBusinessClientWrapper.setCoverageReport(presenterSpy); verify(presenterSpy, times(1)).populateCoverageReport(eq(RULE), eq(simulationRunMetadataMock)); verify(presenterSpy, never()).setDownloadReportCommand(any()); reset(presenterSpy, simulationRunMetadataMock, scenarioSimulationEditorBusinessClientWrapper); when(simulationRunMetadataMock.getAuditLog()).thenReturn(auditLogMock); scenarioSimulationEditorBusinessClientWrapper.lastRunResult = simulationRunResultMock; scenarioSimulationEditorBusinessClientWrapper.setCoverageReport(presenterSpy); verify(presenterSpy, times(1)).populateCoverageReport(eq(RULE), eq(simulationRunMetadataMock)); verify(presenterSpy, times(1)).setDownloadReportCommand(commandArgumentCaptor.capture()); commandArgumentCaptor.getValue().execute(); verify(scenarioSimulationEditorBusinessClientWrapper, times(1)).onDownloadReportToCsv(eq(exportCallBackMock), isA(ScenarioSimulationHasBusyIndicatorDefaultErrorCallback.class), eq(simulationRunMetadataMock), eq(RULE)); }