Search in sources :

Example 6 with ValidateSessionCommand

use of org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand 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();
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) EditorSessionCommands(org.kie.workbench.common.stunner.client.widgets.editor.EditorSessionCommands) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Collection(java.util.Collection) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Captor(org.mockito.Captor) Mockito.verify(org.mockito.Mockito.verify) HashSet(java.util.HashSet) Consumer(java.util.function.Consumer) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) Mockito.never(org.mockito.Mockito.never) ArgumentCaptor(org.mockito.ArgumentCaptor) Command(com.google.gwt.user.client.Command) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ValidateSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Command(com.google.gwt.user.client.Command) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) ValidateSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand) Test(org.junit.Test)

Example 7 with ValidateSessionCommand

use of org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand in project kie-wb-common by kiegroup.

the class ValidationActionTest method loadingCompletedOnError.

@Test
public void loadingCompletedOnError() {
    final Command loadingCompleted = mock(Command.class);
    final Consumer onError = mock(Consumer.class);
    new ValidationAction(editorSessionCommands, () -> {
    /*  */
    }, loadingCompleted, onError).validate();
    verify(validateSessionCommand).execute(violationsArgumentCapture.capture());
    violationsArgumentCapture.getValue().onError(new HashSet<>());
    verify(loadingCompleted).execute();
    verify(onError).accept(eq("[]"));
}
Also used : Consumer(java.util.function.Consumer) Command(com.google.gwt.user.client.Command) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) ValidateSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand) Test(org.junit.Test)

Aggregations

ValidateSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand)7 Test (org.junit.Test)6 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)6 Command (com.google.gwt.user.client.Command)5 Consumer (java.util.function.Consumer)3 EditorSessionCommands (org.kie.workbench.common.stunner.client.widgets.editor.EditorSessionCommands)3 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Before (org.junit.Before)2 RunWith (org.junit.runner.RunWith)2 DiagramElementViolation (org.kie.workbench.common.stunner.core.validation.DiagramElementViolation)2 ArgumentCaptor (org.mockito.ArgumentCaptor)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)2 Captor (org.mockito.Captor)2 Mock (org.mockito.Mock)2 Mockito.doReturn (org.mockito.Mockito.doReturn)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.never (org.mockito.Mockito.never)2