Search in sources :

Example 1 with CommandManager

use of org.kie.workbench.common.stunner.core.command.CommandManager in project kie-wb-common by kiegroup.

the class RedoCommandHandlerTest method testExecuteOnNull.

@Test(expected = IllegalStateException.class)
@SuppressWarnings("unchecked")
public void testExecuteOnNull() {
    Object obj = mock(Object.class);
    CommandManager manager = mock(CommandManager.class);
    when(registryFactory.newCommandRegistry()).thenReturn(commandRegistry);
    when(commandRegistry.isEmpty()).thenReturn(true);
    tested = new RedoCommandHandler(registryFactory);
    tested.execute(obj, manager);
}
Also used : CommandManager(org.kie.workbench.common.stunner.core.command.CommandManager) Test(org.junit.Test)

Example 2 with CommandManager

use of org.kie.workbench.common.stunner.core.command.CommandManager in project kie-wb-common by kiegroup.

the class RedoCommandHandlerTest method testExecute.

@Test
@SuppressWarnings("unchecked")
public void testExecute() {
    Object obj = mock(Object.class);
    CommandManager manager = mock(CommandManager.class);
    CommandResult expectedResult = mock(CommandResult.class);
    when(commandRegistry.peek()).thenReturn(command1);
    when(manager.execute(obj, command1)).thenReturn(expectedResult);
    CommandResult actualResult = tested.execute(obj, manager);
    assertEquals(expectedResult, actualResult);
    verify(manager).execute(eq(obj), eq(command1));
}
Also used : CommandManager(org.kie.workbench.common.stunner.core.command.CommandManager) CommandResult(org.kie.workbench.common.stunner.core.command.CommandResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 CommandManager (org.kie.workbench.common.stunner.core.command.CommandManager)2 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)1