@Test @SuppressWarnings("unchecked") public void testExecute() { cutSelectionSessionCommand.bind(session); CopySelectionSessionCommand.getInstance(sessionManager).bind(session); cutSelectionSessionCommand.setCopySelectionSessionCommand(copySelectionSessionCommand); cutSelectionSessionCommand.execute(mainCallback); ArgumentCaptor<ClientSessionCommand.Callback> callbackArgumentCaptor = ArgumentCaptor.forClass(ClientSessionCommand.Callback.class); verify(copySelectionSessionCommand).execute(callbackArgumentCaptor.capture()); callbackArgumentCaptor.getValue().onSuccess(); verify(session.getCommandRegistry(), atLeastOnce()).peek(); verify(clipboardControl, atLeastOnce()).setRollbackCommand(deleteNodeCommand); verify(commandExecutedEvent, times(1)).fire(commandExecutedEventCaptor.capture()); assertEquals(session, commandExecutedEventCaptor.getValue().getClientSession()); assertEquals(cutSelectionSessionCommand, commandExecutedEventCaptor.getValue().getExecutedCommand()); Object error = new Object(); callbackArgumentCaptor.getValue().onError(error); verify(mainCallback, times(1)).onError(error); }
@Override public <V> void execute(Callback<V> callback) { copySelectionSessionCommand.execute(new Callback<V>() { @Override public void onSuccess() { deleteSelectionSessionCommand.execute(callback); Command<AbstractCanvasHandler, CanvasViolation> command = getSession().getCommandRegistry().peek(); clipboardControl.setRollbackCommand(command); commandExecutedEvent.fire(new CutSelectionSessionCommandExecutedEvent(CutSelectionSessionCommand.this, CutSelectionSessionCommand.this.getSession())); } @Override public void onError(V error) { LOGGER.severe("Error on cut selection." + String.valueOf(error)); callback.onError(error); } }); }
CutSelectionSessionCommand extends AbstractSelectionAwareSessionCommand<EditorSession> { @Override public <V> void execute(Callback<V> callback) { copySelectionSessionCommand.execute(new Callback<V>() { @Override public void onSuccess() { deleteSelectionSessionCommand.execute(callback); Command<AbstractCanvasHandler, CanvasViolation> command = getSession().getCommandRegistry().peek(); clipboardControl.setRollbackCommand(command); commandExecutedEvent.fire(new CutSelectionSessionCommandExecutedEvent(CutSelectionSessionCommand.this, CutSelectionSessionCommand.this.getSession())); } @Override public void onError(V error) { LOGGER.severe("Error on cut selection." + String.valueOf(error)); callback.onError(error); } }); } }
CutSelectionSessionCommand extends AbstractSelectionAwareSessionCommand<EditorSession> { @Override public <V> void execute(Callback<V> callback) { copySelectionSessionCommand.execute(new Callback<V>() { @Override public void onSuccess() { deleteSelectionSessionCommand.execute(callback); Command<AbstractCanvasHandler, CanvasViolation> command = getSession().getCommandRegistry().peek(); clipboardControl.setRollbackCommand(command); commandExecutedEvent.fire(new CutSelectionSessionCommandExecutedEvent(CutSelectionSessionCommand.this, CutSelectionSessionCommand.this.getSession())); } @Override public void onError(V error) { LOGGER.severe("Error on cut selection." + String.valueOf(error)); callback.onError(error); } }); } protected  CutSelectionSessionCommand(); @Inject  CutSelectionSessionCommand(final Event<CutSelectionSessionCommandExecutedEvent> commandExecutedEvent,
                                      final SessionManager sessionManager); }
CutSelectionSessionCommand extends AbstractSelectionAwareSessionCommand<EditorSession> { @Override public <V> void execute(Callback<V> callback) { copySelectionSessionCommand.execute(new Callback<V>() { @Override public void onSuccess() { deleteSelectionSessionCommand.execute(callback); Command<AbstractCanvasHandler, CanvasViolation> command = getSession().getCommandRegistry().peek(); clipboardControl.setRollbackCommand(command); commandExecutedEvent.fire(new CutSelectionSessionCommandExecutedEvent(CutSelectionSessionCommand.this, CutSelectionSessionCommand.this.getSession())); } @Override public void onError(V error) { LOGGER.severe("Error on cut selection." + String.valueOf(error)); callback.onError(error); } }); } protected  CutSelectionSessionCommand(); @Inject  CutSelectionSessionCommand(final Event<CutSelectionSessionCommandExecutedEvent> commandExecutedEvent,
                                      final SessionManager sessionManager); @Override void bind(final EditorSession session); void setCopySelectionSessionCommand(CopySelectionSessionCommand copySelectionSessionCommand); @Override boolean accepts(final ClientSession session); @Override void execute(Callback<V> callback); }
CutSelectionSessionCommand extends AbstractSelectionAwareSessionCommand<EditorSession> { @Override public <V> void execute(Callback<V> callback) { copySelectionSessionCommand.execute(new Callback<V>() { @Override public void onSuccess() { deleteSelectionSessionCommand.execute(callback); Command<AbstractCanvasHandler, CanvasViolation> command = getSession().getCommandRegistry().peek(); clipboardControl.setRollbackCommand(command); commandExecutedEvent.fire(new CutSelectionSessionCommandExecutedEvent(CutSelectionSessionCommand.this, CutSelectionSessionCommand.this.getSession())); } @Override public void onError(V error) { LOGGER.severe("Error on cut selection." + String.valueOf(error)); callback.onError(error); } }); } protected  CutSelectionSessionCommand(); @Inject  CutSelectionSessionCommand(final Event<CutSelectionSessionCommandExecutedEvent> commandExecutedEvent,
                                      final SessionManager sessionManager); @Override void bind(final EditorSession session); void setCopySelectionSessionCommand(CopySelectionSessionCommand copySelectionSessionCommand); @Override boolean accepts(final ClientSession session); @Override void execute(Callback<V> callback);  }