WebSocketErrorMessageSender implements ErrorMessageConsumer { @Override public void consumeMessage(ErrorMessage message) { webSocket.convertAndSend(TOPIC_ERROR, PortableErrorMessage.fromMessage(message)); } @Autowired  WebSocketErrorMessageSender(SimpMessagingTemplate webSocket); @Override void consumeMessage(ErrorMessage message);  }
@Test void should_send_consumed_message_over_websocket(@Mock SimpMessagingTemplate webSocket) { ErrorMessage message = ErrorMessage.of("id", "error"); new WebSocketErrorMessageSender(webSocket).consumeMessage(message); verify(webSocket).convertAndSend( WebSocketErrorMessageSender.TOPIC_ERROR, PortableErrorMessage.fromMessage(message)); }