@Test public void shouldReadResponseChangeCloseConditionsMessagesCorrectly() throws CommunicationException { when(client.tryReceiveByte()).thenReturn(MessageType.RESPONSE_CHANGE_CLOSE_CONDITIONS.getMessageNumber(), (byte) 0, MessageType.RESPONSE_CHANGE_CLOSE_CONDITIONS.getMessageNumber(), (byte) 1); when(client.tryReceiveInteger()).thenReturn(868); final ResponseChangeCloseConditionsMessage changeSucceed = cut .readMessage(ResponseChangeCloseConditionsMessage.class); assertThat(changeSucceed.getErrorCode()).isEmpty(); final ResponseChangeCloseConditionsMessage changeFailed = cut .readMessage(ResponseChangeCloseConditionsMessage.class); assertThat(changeFailed.getErrorCode()).isPresent().contains(868); }
public Message readMessage() throws CommunicationException { return readMessage(readMessageTypeOrFail()); }
MessageBasedClientConnection { public Message readMessage() throws CommunicationException { return readMessage(readMessageTypeOrFail()); } }
MessageBasedClientConnection { public Message readMessage() throws CommunicationException { return readMessage(readMessageTypeOrFail()); } MessageBasedClientConnection(final ClientConnection connection); }
MessageBasedClientConnection { public Message readMessage() throws CommunicationException { return readMessage(readMessageTypeOrFail()); } MessageBasedClientConnection(final ClientConnection connection); Message readMessage(); @SuppressWarnings("unchecked") M readMessage(final Class<M> messageClass); void sendMessage(final Message message); @Override String toString(); }
MessageBasedClientConnection { public Message readMessage() throws CommunicationException { return readMessage(readMessageTypeOrFail()); } MessageBasedClientConnection(final ClientConnection connection); Message readMessage(); @SuppressWarnings("unchecked") M readMessage(final Class<M> messageClass); void sendMessage(final Message message); @Override String toString();  }