@Test public void shouldReadAlgorithmRequestMessages() throws CommunicationException { when(client.tryReceiveByte()).thenReturn(MessageType.REQUEST_TRADING_ALGORITHM.getMessageNumber()) .thenReturn((byte) 0).thenReturn(MessageType.REQUEST_TRADING_ALGORITHM.getMessageNumber()) .thenReturn((byte) 1); when(client.tryReceiveInteger()).thenReturn(4813).thenReturn(-816); final RequestTradingAlgorithmMessage message1 = cut.readMessage(RequestTradingAlgorithmMessage.class); assertThat(message1.getAlgorithmNumber()).isEqualTo(4813); assertThat(message1.getAlgorithmType()).isEqualTo(RequestTradingAlgorithmMessage.AlgorithmType.EXPERT_ADVISOR); final RequestTradingAlgorithmMessage message2 = cut.readMessage(RequestTradingAlgorithmMessage.class); assertThat(message2.getAlgorithmNumber()).isEqualTo(-816); assertThat(message2.getAlgorithmType()).isEqualTo(RequestTradingAlgorithmMessage.AlgorithmType.TREND_INDICATOR); }
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();  }