@Test public void shouldReadResponsePlacePendingOrderMessagesCorrectly() throws CommunicationException { when(client.tryReceiveByte()).thenReturn(MessageType.RESPONSE_PLACE_PENDING_ORDER.getMessageNumber(), (byte) 0, MessageType.RESPONSE_PLACE_PENDING_ORDER.getMessageNumber(), (byte) 1); when(client.tryReceiveInteger()).thenReturn(42).thenReturn(83); final Message messageSuccess = cut.readMessage(); final Message messageFailed = cut.readMessage(); assertThat(messageSuccess).isInstanceOf(ResponsePlacePendingOrderMessage.class); assertThat(((ResponsePlacePendingOrderMessage) messageSuccess).getId()).isPresent().contains(42); assertThat(messageFailed).isInstanceOf(ResponsePlacePendingOrderMessage.class); assertThat(((ResponsePlacePendingOrderMessage) messageFailed).getErrorCode()).isPresent().contains(83); }
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();  }