@Test public void shouldWriteEventHandlingFinishedMessagesCorrectly() throws CommunicationException { cut.sendMessage(new EventHandlingFinishedMessage()); verify(client).trySendByte(MessageType.EVENT_HANDLING_FINISHED.getMessageNumber()); verifyNoMoreInteractions(client); }
public void sendMessage(final Message message) throws CommunicationException { final MessageType messageType = MessageType.forMessageClass(message.getClass()); writeMessageNumber(messageType); switch (messageType) { case TREND_FOR_MARKET_DATA: writeMessage((TrendForMarketDataMessage) message); break; case CLOSE_OR_CANCEL_PENDING_ORDER: writeMessage((CloseOrCancelPendingOrderMessage) message); break; case PLACE_PENDING_ORDER: writeMessage((PlacePendingOrderMessage) message); break; case CHANGE_CLOSE_CONDITIONS: writeMessage((ChangeCloseConditionsMessage) message); break; case EVENT_HANDLING_FINISHED: break; default: throw new UnsupportedOperationException("Writing of " + messageType + " messages is not supported."); } }
MessageBasedClientConnection { public void sendMessage(final Message message) throws CommunicationException { final MessageType messageType = MessageType.forMessageClass(message.getClass()); writeMessageNumber(messageType); switch (messageType) { case TREND_FOR_MARKET_DATA: writeMessage((TrendForMarketDataMessage) message); break; case CLOSE_OR_CANCEL_PENDING_ORDER: writeMessage((CloseOrCancelPendingOrderMessage) message); break; case PLACE_PENDING_ORDER: writeMessage((PlacePendingOrderMessage) message); break; case CHANGE_CLOSE_CONDITIONS: writeMessage((ChangeCloseConditionsMessage) message); break; case EVENT_HANDLING_FINISHED: break; default: throw new UnsupportedOperationException("Writing of " + messageType + " messages is not supported."); } } }
MessageBasedClientConnection { public void sendMessage(final Message message) throws CommunicationException { final MessageType messageType = MessageType.forMessageClass(message.getClass()); writeMessageNumber(messageType); switch (messageType) { case TREND_FOR_MARKET_DATA: writeMessage((TrendForMarketDataMessage) message); break; case CLOSE_OR_CANCEL_PENDING_ORDER: writeMessage((CloseOrCancelPendingOrderMessage) message); break; case PLACE_PENDING_ORDER: writeMessage((PlacePendingOrderMessage) message); break; case CHANGE_CLOSE_CONDITIONS: writeMessage((ChangeCloseConditionsMessage) message); break; case EVENT_HANDLING_FINISHED: break; default: throw new UnsupportedOperationException("Writing of " + messageType + " messages is not supported."); } } MessageBasedClientConnection(final ClientConnection connection); }
MessageBasedClientConnection { public void sendMessage(final Message message) throws CommunicationException { final MessageType messageType = MessageType.forMessageClass(message.getClass()); writeMessageNumber(messageType); switch (messageType) { case TREND_FOR_MARKET_DATA: writeMessage((TrendForMarketDataMessage) message); break; case CLOSE_OR_CANCEL_PENDING_ORDER: writeMessage((CloseOrCancelPendingOrderMessage) message); break; case PLACE_PENDING_ORDER: writeMessage((PlacePendingOrderMessage) message); break; case CHANGE_CLOSE_CONDITIONS: writeMessage((ChangeCloseConditionsMessage) message); break; case EVENT_HANDLING_FINISHED: break; default: throw new UnsupportedOperationException("Writing of " + messageType + " messages is not supported."); } } MessageBasedClientConnection(final ClientConnection connection); Message readMessage(); @SuppressWarnings("unchecked") M readMessage(final Class<M> messageClass); void sendMessage(final Message message); @Override String toString(); }
MessageBasedClientConnection { public void sendMessage(final Message message) throws CommunicationException { final MessageType messageType = MessageType.forMessageClass(message.getClass()); writeMessageNumber(messageType); switch (messageType) { case TREND_FOR_MARKET_DATA: writeMessage((TrendForMarketDataMessage) message); break; case CLOSE_OR_CANCEL_PENDING_ORDER: writeMessage((CloseOrCancelPendingOrderMessage) message); break; case PLACE_PENDING_ORDER: writeMessage((PlacePendingOrderMessage) message); break; case CHANGE_CLOSE_CONDITIONS: writeMessage((ChangeCloseConditionsMessage) message); break; case EVENT_HANDLING_FINISHED: break; default: throw new UnsupportedOperationException("Writing of " + messageType + " messages is not supported."); } } MessageBasedClientConnection(final ClientConnection connection); Message readMessage(); @SuppressWarnings("unchecked") M readMessage(final Class<M> messageClass); void sendMessage(final Message message); @Override String toString();  }