use of org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand in project kie-wb-common by kiegroup.
the class BPMNDiagramEditorTest method testMigrateWhenDirty.
@SuppressWarnings("unchecked")
@Test
public void testMigrateWhenDirty() {
ObservablePath currentPath = mock(ObservablePath.class);
when(versionRecordManager.getCurrentPath()).thenReturn(currentPath);
doReturn(true).when(diagramEditor).isDirty(any(Integer.class));
diagramEditor.onMigrate();
verify(popupUtil, times(1)).showConfirmPopup(eq(MIGRATE_ACTION_TITLE), eq(MIGRATE_ACTION_WARNING), eq(InlineNotification.InlineNotificationType.WARNING), eq(MIGRATE_ACTION), eq(Button.ButtonStyleType.PRIMARY), eq(MIGRATE_CONFIRM_ACTION), commandCaptor.capture());
commandCaptor.getValue().execute();
ValidateSessionCommand validateSessionCommand = sessionCommandFactory.newValidateCommand();
verify(validateSessionCommand, times(1)).execute(sessionCommandCallback.capture());
sessionCommandCallback.getValue().onSuccess();
verify(savePopUpPresenter, times(1)).show(eq(currentPath), parameterizedCommandCaptor.capture());
parameterizedCommandCaptor.getValue().execute(COMMIT_MESSAGE);
verify(clientProjectDiagramService, times(1)).saveOrUpdate(eq(currentPath), any(ProjectDiagram.class), any(Metadata.class), eq(COMMIT_MESSAGE), serviceCallbackCaptor.capture());
serviceCallbackCaptor.getValue().onSuccess(diagram);
verify(migrateDiagramEvent, times(1)).fire(migrateDiagramEventCaptor.capture());
assertEquals(currentPath, migrateDiagramEventCaptor.getValue().getSourcePath());
assertEquals(currentPlace, migrateDiagramEventCaptor.getValue().getSourcePlace());
}
use of org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand in project kie-wb-common by kiegroup.
the class ValidationActionTest method loadingStarts.
@Test
public void loadingStarts() {
final Command loadingStarts = mock(Command.class);
new ValidationAction(editorSessionCommands, loadingStarts, () -> {
/* */
}, s -> {
/* */
}).validate();
verify(loadingStarts).execute();
verify(validateSessionCommand).execute(any());
}
use of org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand in project kie-wb-common by kiegroup.
the class ValidationActionTest method runAfterValidationActionsOnFailure.
@Test
public void runAfterValidationActionsOnFailure() {
final ValidationAction validationAction = new ValidationAction(editorSessionCommands, () -> {
/* */
}, () -> {
/* */
}, s -> {
/* */
});
final Command onAfterValidation = mock(Command.class);
validationAction.setAfterValidation(onAfterValidation);
validationAction.validate();
verify(validateSessionCommand).execute(violationsArgumentCapture.capture());
violationsArgumentCapture.getValue().onError(new HashSet<>());
verify(onAfterValidation).execute();
}
use of org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand in project kie-wb-common by kiegroup.
the class ValidationActionTest method runAfterValidationActionsOnSuccess.
@Test
public void runAfterValidationActionsOnSuccess() {
final ValidationAction validationAction = new ValidationAction(editorSessionCommands, () -> {
/* */
}, () -> {
/* */
}, s -> {
/* */
});
final Command onAfterValidation = mock(Command.class);
validationAction.setAfterValidation(onAfterValidation);
validationAction.validate();
verify(validateSessionCommand).execute(violationsArgumentCapture.capture());
violationsArgumentCapture.getValue().onSuccess();
verify(onAfterValidation).execute();
}
use of org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand in project kie-wb-common by kiegroup.
the class AbstractProjectDiagramEditorTest method assertBasicStunnerSaveOperation.
@SuppressWarnings("unchecked")
protected Overview assertBasicStunnerSaveOperation(final boolean validateSuccess) {
tested.open(diagram);
EditorSessionCommands editorSessionCommands = mock(EditorSessionCommands.class);
when(menuSessionItems.getCommands()).thenReturn(editorSessionCommands);
ValidateSessionCommand validateSessionCommand = mock(ValidateSessionCommand.class);
when(editorSessionCommands.getValidateSessionCommand()).thenReturn(validateSessionCommand);
doAnswer(invocation -> {
ClientSessionCommand.Callback callback = (ClientSessionCommand.Callback) invocation.getArguments()[0];
if (validateSuccess) {
callback.onSuccess();
} else {
DiagramElementViolation<RuleViolation> violation = mock(DiagramElementViolation.class);
when(violation.getViolationType()).thenReturn(Violation.Type.ERROR);
callback.onError(Collections.singletonList(violation));
}
return null;
}).when(validateSessionCommand).execute(Mockito.<ClientSessionCommand.Callback>any());
tested.onSave();
return overview;
}
Aggregations