@Test public void shouldReadNewMarketDataExtendedMessages() throws CommunicationException { when(client.tryReceiveByte()).thenReturn(MessageType.NEW_MARKET_DATA_EXTENDED.getMessageNumber()); when(client.tryReceiveLong()).thenReturn(1405782575L); when(client.tryReceiveDouble()).thenReturn(1.0, 2.0, 3.0, 4.0); when(client.tryReceiveInteger()).thenReturn(50, 2000, 42); final NewMarketDataExtendedMessage readMessage = cut.readMessage(NewMarketDataExtendedMessage.class); assertThat(readMessage.getCandleStick()).isEqualTo(new MutableFullMarketData<>() .setTime(Instant.ofEpochSecond(1405782575L)).setOpen(1.0).setHigh(2.0).setLow(3.0).setClose(4.0) .setSpread(new Price(50)).setVolume(2, MICRO_LOT).setTickCount(42).toImmutableFullMarketData()); }
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();  }