GlobalsEditorPresenter extends KieEditor<GlobalsModel> { @Override protected void save() { ParameterizedCommand<String> doSave = (commitMessage) -> { baseView.showSaving(); globalsEditorService .call(getSaveSuccessCallback(model.hashCode()), new HasBusyIndicatorDefaultErrorCallback(view)) .save(versionRecordManager.getCurrentPath(), model, metadata, commitMessage); concurrentUpdateSessionInfo = null; }; Command showPopUp = () -> { savePopUpPresenter.show(versionRecordManager.getCurrentPath(), doSave); }; Command command = () -> { if (saveWithComments) { showPopUp.execute(); } else { doSave.execute(""); } }; validationService.call((obj) -> { List<ValidationMessage> validationMessages = (List<ValidationMessage>) obj; if (validationMessages.isEmpty()) { command.execute(); } else { validationPopup.showSaveValidationMessages(command, () -> {}, validationMessages); } }).validateForSave(versionRecordManager.getCurrentPath(), model); concurrentUpdateSessionInfo = null; } GlobalsEditorPresenter(); @Inject  GlobalsEditorPresenter(final GlobalsEditorView baseView); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @Override void onSourceTabSelected(); @WorkbenchPartView IsWidget getWidget(); @OnClose @Override void onClose(); @OnMayClose boolean mayClose(); @WorkbenchPartTitleDecoration IsWidget getTitle(); @WorkbenchPartTitle String getTitleText(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); static final String EDITOR_ID; }
@Test public void saveNoValidationErrors() { when(validationService.validateForSave(any(Path.class), any(GlobalsModel.class))).thenReturn(Collections.emptyList()); presenter.save(); verify(validationService, times(1)).validateForSave(any(Path.class), any(GlobalsModel.class)); verify(savePopUpPresenter, times(1)).show(any(Path.class), any(ParameterizedCommand.class)); }
@Test public void saveValidationErrors() { when(validationService.validateForSave(any(Path.class), any(GlobalsModel.class))).thenReturn(Arrays.asList(new ValidationMessage())); presenter.save(); verify(validationService, times(1)).validateForSave(any(Path.class), any(GlobalsModel.class)); verify(validationPopup, times(1)).showSaveValidationMessages(any(Command.class), any(Command.class), anyListOf(ValidationMessage.class)); }