@Test public void shouldReadTradingEnvironmentMessagesCorreclty() throws CommunicationException { when(client.tryReceiveString()) .thenReturn("Some Broker").thenReturn("EUR").thenReturn("EURUSD").thenReturn("EURUSD") .thenReturn("Other Broker").thenReturn("GBP").thenReturn("CHFJPY").thenReturn("GBPJPY"); when(client.tryReceiveByte()).thenReturn(MessageType.TRADING_ENVIRONMENT_INFORMATION.getMessageNumber()); when(client.tryReceiveInteger()) .thenReturn(5).thenReturn(3) .thenReturn(216).thenReturn(8); when(client.tryReceiveLong()) .thenReturn(42L).thenReturn(20L).thenReturn(10L).thenReturn(1000L).thenReturn(3L) .thenReturn(80L).thenReturn(582L).thenReturn(1000L).thenReturn(2931868L).thenReturn(5L); final TradingEnvironmentInformationMessage message1 = cut .readMessage(TradingEnvironmentInformationMessage.class); final TradingEnvironmentInformationMessage message2 = cut .readMessage(TradingEnvironmentInformationMessage.class); assertThat(message1.getInformation().getAccountInformation().getBrokerName()).isEqualTo("Some Broker"); assertThat(message1.getInformation().getAccountInformation().getAccountNumber()).isEqualTo(42L); assertThat(message1.getInformation().getAccountInformation().getAccountCurrency()) .isEqualTo(Currency.getInstance("EUR")); assertThat(message1.getInformation().getTradeSymbol()).isEqualTo(new ForexSymbol("EURUSD")); assertThat(message1.getInformation().getAccountSymbol()).isEqualTo(new ForexSymbol("EURUSD")); assertThat(message1.getInformation().getSpecialFeesInformation().getMarkup()).isEqualTo(new Price(5)); assertThat(message1.getInformation().getSpecialFeesInformation().getCommission()).isEqualTo(new Price(3)); assertThat(message1.getInformation().getNonHistoricTime().getEpochSecond()).isEqualTo(20L); assertThat(message1.getInformation().getVolumeConstraints().getMinimalVolume()) .isEqualTo(new Volume(10L, BASE)); assertThat(message1.getInformation().getVolumeConstraints().getMaximalVolume()) .isEqualTo(new Volume(1000L, BASE)); assertThat(message1.getInformation().getVolumeConstraints().getAllowedStepSize()) .isEqualTo(new Volume(3L, BASE)); assertThat(message2.getInformation().getAccountInformation().getBrokerName()).isEqualTo("Other Broker"); assertThat(message2.getInformation().getAccountInformation().getAccountNumber()).isEqualTo(80L); assertThat(message2.getInformation().getAccountInformation().getAccountCurrency()) .isEqualTo(Currency.getInstance("GBP")); assertThat(message2.getInformation().getTradeSymbol()).isEqualTo(new ForexSymbol("CHFJPY")); assertThat(message2.getInformation().getAccountSymbol()).isEqualTo(new ForexSymbol("GBPJPY")); assertThat(message2.getInformation().getSpecialFeesInformation().getMarkup()).isEqualTo(new Price(216)); assertThat(message2.getInformation().getSpecialFeesInformation().getCommission()).isEqualTo(new Price(8)); assertThat(message2.getInformation().getNonHistoricTime().getEpochSecond()).isEqualTo(582L); assertThat(message2.getInformation().getVolumeConstraints().getMinimalVolume()) .isEqualTo(new Volume(1000L, BASE)); assertThat(message2.getInformation().getVolumeConstraints().getMaximalVolume()) .isEqualTo(new Volume(2931868L, BASE)); assertThat(message2.getInformation().getVolumeConstraints().getAllowedStepSize()) .isEqualTo(new Volume(5L, BASE)); }
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();  }