@Test public void shouldSendResponse() { final ProtocolResponseMessage responseMessage = this.createDefaultResponseMessage(); this.messageSender.send(responseMessage); verify(this.jmsTemplate).send(any(MessageCreator.class)); }
@Override public void send(final ResponseMessage responseMessage) { if (!(responseMessage instanceof ProtocolResponseMessage)) { LOGGER.error(LOG_MESSAGE_RESPONSE_MESSAGE_OF_WRONG_TYPE, responseMessage.getClass().getName()); return; } final ProtocolResponseMessage msg = (ProtocolResponseMessage) responseMessage; if (!ProtocolResponseMessageValidator.isValid(msg, LOGGER)) { return; } try { this.sendMessage(msg); } catch (final IllegalStateException | UncategorizedJmsException e) { if (this.isCloseConnectionsOnBrokerFailure) { LOGGER.error(LOG_MESSAGE_JMS_EXCEPTION, e); this.iec60870DeviceConnectionService.closeAllConnections(); } throw e; } }
DeviceResponseMessageSender implements ResponseMessageSender { @Override public void send(final ResponseMessage responseMessage) { if (!(responseMessage instanceof ProtocolResponseMessage)) { LOGGER.error(LOG_MESSAGE_RESPONSE_MESSAGE_OF_WRONG_TYPE, responseMessage.getClass().getName()); return; } final ProtocolResponseMessage msg = (ProtocolResponseMessage) responseMessage; if (!ProtocolResponseMessageValidator.isValid(msg, LOGGER)) { return; } try { this.sendMessage(msg); } catch (final IllegalStateException | UncategorizedJmsException e) { if (this.isCloseConnectionsOnBrokerFailure) { LOGGER.error(LOG_MESSAGE_JMS_EXCEPTION, e); this.iec60870DeviceConnectionService.closeAllConnections(); } throw e; } } }
DeviceResponseMessageSender implements ResponseMessageSender { @Override public void send(final ResponseMessage responseMessage) { if (!(responseMessage instanceof ProtocolResponseMessage)) { LOGGER.error(LOG_MESSAGE_RESPONSE_MESSAGE_OF_WRONG_TYPE, responseMessage.getClass().getName()); return; } final ProtocolResponseMessage msg = (ProtocolResponseMessage) responseMessage; if (!ProtocolResponseMessageValidator.isValid(msg, LOGGER)) { return; } try { this.sendMessage(msg); } catch (final IllegalStateException | UncategorizedJmsException e) { if (this.isCloseConnectionsOnBrokerFailure) { LOGGER.error(LOG_MESSAGE_JMS_EXCEPTION, e); this.iec60870DeviceConnectionService.closeAllConnections(); } throw e; } }  }
DeviceResponseMessageSender implements ResponseMessageSender { @Override public void send(final ResponseMessage responseMessage) { if (!(responseMessage instanceof ProtocolResponseMessage)) { LOGGER.error(LOG_MESSAGE_RESPONSE_MESSAGE_OF_WRONG_TYPE, responseMessage.getClass().getName()); return; } final ProtocolResponseMessage msg = (ProtocolResponseMessage) responseMessage; if (!ProtocolResponseMessageValidator.isValid(msg, LOGGER)) { return; } try { this.sendMessage(msg); } catch (final IllegalStateException | UncategorizedJmsException e) { if (this.isCloseConnectionsOnBrokerFailure) { LOGGER.error(LOG_MESSAGE_JMS_EXCEPTION, e); this.iec60870DeviceConnectionService.closeAllConnections(); } throw e; } }  @Override void send(final ResponseMessage responseMessage); }
DeviceResponseMessageSender implements ResponseMessageSender { @Override public void send(final ResponseMessage responseMessage) { if (!(responseMessage instanceof ProtocolResponseMessage)) { LOGGER.error(LOG_MESSAGE_RESPONSE_MESSAGE_OF_WRONG_TYPE, responseMessage.getClass().getName()); return; } final ProtocolResponseMessage msg = (ProtocolResponseMessage) responseMessage; if (!ProtocolResponseMessageValidator.isValid(msg, LOGGER)) { return; } try { this.sendMessage(msg); } catch (final IllegalStateException | UncategorizedJmsException e) { if (this.isCloseConnectionsOnBrokerFailure) { LOGGER.error(LOG_MESSAGE_JMS_EXCEPTION, e); this.iec60870DeviceConnectionService.closeAllConnections(); } throw e; } }  @Override void send(final ResponseMessage responseMessage);  }