private void validate() { loadingStarts(); sessionCommands.getValidateSessionCommand().execute(new ClientSessionCommand.Callback<Collection<DiagramElementViolation<RuleViolation>>>() { @Override public void onSuccess() { loadingCompleted(); } @Override public void onError(final Collection<DiagramElementViolation<RuleViolation>> violations) { AbstractProjectEditorMenuSessionItems.this.onError(violations.toString()); } }); }
@Override @SuppressWarnings("unchecked") public <V> void execute(final Callback<V> callback) { checkNotNull("callback", callback); final AbstractCanvasHandler canvasHandler = getSession().getCanvasHandler(); validator.validate(canvasHandler, elementViolations -> fireCallback(elementViolations, callback)); }
@SuppressWarnings("unchecked") public void testValidateBeforeSave() { tested.save(); verify(sessionValidateCommand, times(1)).execute(any(ClientSessionCommand.Callback.class)); }
@Test @SuppressWarnings("unchecked") public void testOnSaveRestore() { tested.open(diagram); doAnswer(i -> { ((ClientSessionCommand.Callback) i.getArguments()[0]).onSuccess(); return null; }).when(sessionValidateCommand).execute(any(ClientSessionCommand.Callback.class)); tested.onSave(); assertOnSaveSavedDiagram(); }
@Test @SuppressWarnings("unchecked") public void testOnSaveWithChanges() { tested.open(diagram); tested.setOriginalHash(diagram.hashCode() + 1); doAnswer(i -> { ((ClientSessionCommand.Callback) i.getArguments()[0]).onSuccess(); return null; }).when(sessionValidateCommand).execute(any(ClientSessionCommand.Callback.class)); tested.onSave(); assertOnSaveSavedDiagram(); }
@SuppressWarnings("unchecked") private ServiceCallback<String> assertBasicXMLSaveOperation(final String xml) { final String commitMessage = "message"; final Overview overview = openInvalidBPMNFile(xml); final Metadata metadata = overview.getMetadata(); EditorSessionCommands editorSessionCommands = mock(EditorSessionCommands.class); when(getMenuSessionItems().getCommands()).thenReturn(editorSessionCommands); ValidateSessionCommand validateSessionCommand = mock(ValidateSessionCommand.class); when(editorSessionCommands.getValidateSessionCommand()).thenReturn(validateSessionCommand); doAnswer(invocation -> { ClientSessionCommand.Callback callback = (ClientSessionCommand.Callback) invocation.getArguments()[0]; callback.onSuccess(); return null; }).when(validateSessionCommand).execute(any(ClientSessionCommand.Callback.class)); doReturn(xml).when(xmlEditorView).getContent(); presenter.save(); ArgumentCaptor<ParameterizedCommand> savePopupCommandCaptor = ArgumentCaptor.forClass(ParameterizedCommand.class); verify(savePopUpPresenter).show(eq(versionRecordManager.getCurrentPath()), savePopupCommandCaptor.capture()); final ParameterizedCommand<String> savePopupCommand = savePopupCommandCaptor.getValue(); savePopupCommand.execute(commitMessage); verify(view).showSaving(); ArgumentCaptor<ServiceCallback> serviceCallbackCaptor = ArgumentCaptor.forClass(ServiceCallback.class); verify(clientProjectDiagramService).saveAsXml(eq(versionRecordManager.getCurrentPath()), eq(xml), eq(metadata), eq(commitMessage), serviceCallbackCaptor.capture()); return serviceCallbackCaptor.getValue(); }
}).when(validateSessionCommand).execute(any(ClientSessionCommand.Callback.class)); presenter.save();
.getCommands() .getValidateSessionCommand() .execute(new ClientSessionCommand.Callback<Collection<DiagramElementViolation<RuleViolation>>>() { @Override public void onSuccess() {