OutputAction extends AbstractRunnerAction implements LogMessagesHandler.ErrorHandler { @Override public void perform(@NotNull Runner runner) { runnerOutputHandler = handlerFactory.createLogMessageHandler(runner, this); webSocketChannel = OUTPUT_CHANNEL + runner.getProcessId(); webSocketUtil.subscribeHandler(webSocketChannel, runnerOutputHandler); } @Inject  OutputAction(HandlerFactory handlerFactory, WebSocketUtil webSocketUtil); @Override void perform(@NotNull Runner runner); @Override void stop(); @Override void onErrorHappened(); static final String OUTPUT_CHANNEL; }
@Test public void actionShouldBePerformed() throws Exception { action.perform(runner); verify(handlerFactory).createLogMessageHandler(runner, action); verify(runner).getProcessId(); verify(webSocketUtil).subscribeHandler(SOCKET_CHANEL, runnerOutputHandler); }
@Test public void actionShouldNotBeStoppedWhenOutputHandlerIsNull() throws Exception { when(handlerFactory.createLogMessageHandler(runner, action)).thenReturn(null); action.perform(runner); verify(webSocketUtil, never()).unSubscribeHandler(anyString(), any(LogMessagesHandler.class)); }