DefaultFrontController implements FrontController { public void processCommand(WebsocketConnector connector, int operationCode, Object data) { WebsocketOperation operation = operations.get(operationCode); if (operation != null) { operation.performOperation(connector, usersContainer, data); } else { log.warn("Cannot perform operation with code " + operationCode + ", operation cannot be found."); } } DefaultFrontController(); void processCommand(WebsocketConnector connector, int operationCode, Object data);  }
@Test public void shouldProcessCloseFrameMessage() throws Exception { Object anyObject = new Object(); frontController.processCommand(anyConnector, WebsocketOperation.CLOSE_FRAME.getOperationCode().getCode(), anyObject); Mockito.verify(anyConnector).stop(); }
@Test public void shouldNotFailWhenProcessingUnknownOperation() throws Exception { frontController.processCommand(null, -1, null); }
@Test public void shouldProcessTextMessage() throws Exception { frontController.processCommand(anyConnector, WebsocketOperation.TEXT_FRAME.getOperationCode().getCode(), "sampleParam"); Mockito.verify(anyConnector.getDataController()).processTextData(eq("sampleParam"), Mockito.any(UserContext.class)); }
@Test public void shouldProcessBinaryMessage() throws Exception { frontController.processCommand(anyConnector, WebsocketOperation.BINARY_FRAME.getOperationCode().getCode(), new byte[]{1}); Mockito.verify(anyConnector.getDataController()).processBinaryData(eq(new byte[]{1}), Mockito.any(UserContext.class)); }