ChannelHandler { T fromClientMessage(String message) { try { T clientMessage = clientMessageReader.fromJSON(message); clientMessageValidator.validate(clientMessage, false); return clientMessage; } catch (ValidationException e) { throw new BadRequestException(e.getMessage(), e.errorCode(), e); } catch (IOException e) { throw new BadRequestException(e.getMessage(), "INVALID_WS_MESSAGE", e); } } ChannelHandler(Class<T> clientMessageClass, Class<V> serverMessageClass, ChannelListener<T, V> listener);   }
@Test void fromClientMessage() { assertThatThrownBy(() -> handler.fromClientMessage("message")) .isInstanceOf(BadRequestException.class) .satisfies(e -> assertThat(((BadRequestException) e).errorCode()).isEqualTo("INVALID_WS_MESSAGE")); assertThatThrownBy(() -> handler.fromClientMessage("{}")) .isInstanceOf(BadRequestException.class) .satisfies(e -> assertThat(((BadRequestException) e).errorCode()).isEqualTo("VALIDATION_ERROR")); }