ScenarioSimulationEditorPresenter { public void onRunScenario() { List<Integer> indexes = IntStream.range(0, context.getStatus().getSimulation().getUnmodifiableData().size()) .boxed() .collect(Collectors.toList()); onRunScenario(indexes); } ScenarioSimulationEditorPresenter(); @Inject  ScenarioSimulationEditorPresenter(final AbstractScenarioSimulationProducer abstractScenarioSimulationProducer,
                                             final ScenarioSimulationResourceType type,
                                             final PlaceManager placeManager,
                                             final AbstractScenarioSimulationDocksHandler abstractScenarioSimulationDocksHandler,
                                             final TextFileExport textFileExport,
                                             final ConfirmPopupPresenter confirmPopupPresenter); void setWrapper(ScenarioSimulationEditorWrapper scenarioSimulationEditorWrapper); void setPath(ObservablePath path); ObservablePath getPath(); void setPackageName(String packageName); void onClose(); void showDocks(PlaceStatus status); void hideDocks(); void onUberfireDocksInteractionEvent(@Observes final UberfireDocksInteractionEvent uberfireDocksInteractionEvent); void expandToolsDock(); ScenarioSimulationView getView(); ScenarioSimulationModel getModel(); Command getPopulateTestToolsCommand(); void reloadTestTools(boolean disable); void onRunScenario(); void onRunScenario(List<Integer> indexOfScenarioToRun); void onUndo(); void onRedo(); void setUndoButtonEnabledStatus(boolean enabled); void setRedoButtonEnabledStatus(boolean enabled); void setItemMenuEnabled(boolean enabled); void addDownloadMenuItem(FileMenuBuilder fileMenuBuilder, Supplier<Path> pathSupplier); DataManagementStrategy getDataManagementStrategy(); void onImport(String fileContents, GridWidget gridWidget); EventBus getEventBus(); ScenarioSimulationContext getContext(); void sendNotification(String text, NotificationEvent.NotificationType type); void sendNotification(String text, NotificationEvent.NotificationType type, boolean autoHide); void makeMenuBar(FileMenuBuilder fileMenuBuilder); void addCommonActions(final FileMenuBuilder fileMenuBuilder, MenuItem versionMenuItem, MenuItem alertsButtonMenuItem); void loadContent(); boolean isDirty(); void onEditTabSelected(); void onBackgroundTabSelected(); void onOverviewSelected(); void onImportsTabSelected(); void validateSimulation(); void selectSimulationTab(); void selectBackgroundTab(); RemoteCallback<String> getExportCallBack(); ErrorCallback<Boolean> getValidationFailedCallback(); void populateRightDocks(String identifier); void getModelSuccessCallbackMethod(DataManagementStrategy dataManagementStrategy, ScenarioSimulationModel model); ScenarioSimulationResourceType getType(); void setTestTools(TestToolsView.Presenter presenter); void setCheatSheet(CheatSheetView.Presenter presenter); void setSettings(SettingsView.Presenter presenter); String getJsonModel(ScenarioSimulationModel model); static final String IDENTIFIER; }
@Test public void onRunTest() { presenterSpy.onRunScenario(); verify(presenterSpy, times(1)).onRunScenario(eq(Arrays.asList(0))); }
@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())); when(simulationMock.getDataByIndex(anyInt())).thenReturn(mock(Scenario.class)); List<Integer> indexList = Arrays.asList(0, 2); presenterSpy.onRunScenario(indexList); verify(scenarioGridWidgetSpy, times(1)).resetErrors(); verify(backgroundGridWidgetSpy, times(1)).resetErrors(); verify(scenarioSimulationModelMock, times(1)).setSimulation(simulationMock); verify(scenarioSimulationModelMock, times(1)).setBackground(backgroundMock); verify(scenarioSimulationViewMock, times(1)).showBusyIndicator(anyString()); verify(scenarioSimulationEditorWrapperMock, times(1)).onRunScenario(any(), any(), any(), eq(settingsLocal), scenarioWithIndexCaptor.capture(), any()); List<ScenarioWithIndex> capturedValue = scenarioWithIndexCaptor.getValue(); assertEquals(2, capturedValue.size()); for (Integer requestedIndex : indexList) { assertEquals(1, capturedValue.stream().filter(elem -> elem.getIndex() == (requestedIndex + 1)).count()); } }