use of org.kie.workbench.common.stunner.client.widgets.editor.EditorSessionCommands 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.client.widgets.editor.EditorSessionCommands 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;
}
use of org.kie.workbench.common.stunner.client.widgets.editor.EditorSessionCommands in project kie-wb-common by kiegroup.
the class ValidationActionTest method loadingCompletedOnSuccess.
@Test
public void loadingCompletedOnSuccess() {
final Command loadingCompleted = mock(Command.class);
new ValidationAction(editorSessionCommands, () -> {
/* */
}, loadingCompleted, s -> {
/* */
}).validate();
verify(validateSessionCommand).execute(violationsArgumentCapture.capture());
violationsArgumentCapture.getValue().onSuccess();
verify(loadingCompleted).execute();
}
Aggregations