@Test void processMessageTest() throws JMSException { final String correlationUid = "CorrelationID-1"; final String messageType = "GET_DATA"; final String organisationIdentification = "test-org"; final String deviceIdentification = "device1"; final ResponseMessageResultType resultType = ResponseMessageResultType.OK; final String payload = "the payload"; final ResponseMessage responseMessage = new ResponseMessage.Builder().withCorrelationUid(correlationUid) .withMessageType(messageType) .withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification) .withResult(resultType) .withDataObject(payload) .build(); when(this.receivedMessage.getJMSCorrelationID()).thenReturn(correlationUid); when(this.receivedMessage.getJMSType()).thenReturn(messageType); when(this.receivedMessage.getStringProperty(Constants.ORGANISATION_IDENTIFICATION)) .thenReturn(organisationIdentification); when(this.receivedMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION)).thenReturn(deviceIdentification); when(this.receivedMessage.getStringProperty(Constants.RESULT)).thenReturn(resultType.toString()); when(this.receivedMessage.getObject()).thenReturn(responseMessage); this.domainResponseMessageProcessor.processMessage(this.receivedMessage); verify(this.producer, times(1)).send(payload); }
@Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing distribution automation response message"); String correlationUid = null; MessageType messageType = null; String organisationIdentification = null; String deviceIdentification = null; ResponseMessageResultType resultType; String resultDescription; ResponseMessage dataObject; try { correlationUid = message.getJMSCorrelationID(); organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION); deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION); messageType = MessageType.valueOf(message.getJMSType()); resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT)); resultDescription = message.getStringProperty(Constants.DESCRIPTION); dataObject = (ResponseMessage) message.getObject(); } catch (final IllegalArgumentException e) { LOGGER.error("UNRECOVERABLE ERROR, received messageType {} is unknown.", messageType, e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } catch (final JMSException e) { LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } try { LOGGER.info("Handle message of type {} for device {} with result: {}, description {}.", messageType, deviceIdentification, resultType, resultDescription); this.handleMessage(messageType, dataObject); } catch (final RuntimeException e) { handleError(e, correlationUid); } }
DomainResponseMessageProcessor implements MessageProcessor { @Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing distribution automation response message"); String correlationUid = null; MessageType messageType = null; String organisationIdentification = null; String deviceIdentification = null; ResponseMessageResultType resultType; String resultDescription; ResponseMessage dataObject; try { correlationUid = message.getJMSCorrelationID(); organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION); deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION); messageType = MessageType.valueOf(message.getJMSType()); resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT)); resultDescription = message.getStringProperty(Constants.DESCRIPTION); dataObject = (ResponseMessage) message.getObject(); } catch (final IllegalArgumentException e) { LOGGER.error("UNRECOVERABLE ERROR, received messageType {} is unknown.", messageType, e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } catch (final JMSException e) { LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } try { LOGGER.info("Handle message of type {} for device {} with result: {}, description {}.", messageType, deviceIdentification, resultType, resultDescription); this.handleMessage(messageType, dataObject); } catch (final RuntimeException e) { handleError(e, correlationUid); } } }
DomainResponseMessageProcessor implements MessageProcessor { @Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing distribution automation response message"); String correlationUid = null; MessageType messageType = null; String organisationIdentification = null; String deviceIdentification = null; ResponseMessageResultType resultType; String resultDescription; ResponseMessage dataObject; try { correlationUid = message.getJMSCorrelationID(); organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION); deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION); messageType = MessageType.valueOf(message.getJMSType()); resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT)); resultDescription = message.getStringProperty(Constants.DESCRIPTION); dataObject = (ResponseMessage) message.getObject(); } catch (final IllegalArgumentException e) { LOGGER.error("UNRECOVERABLE ERROR, received messageType {} is unknown.", messageType, e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } catch (final JMSException e) { LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } try { LOGGER.info("Handle message of type {} for device {} with result: {}, description {}.", messageType, deviceIdentification, resultType, resultDescription); this.handleMessage(messageType, dataObject); } catch (final RuntimeException e) { handleError(e, correlationUid); } }  }
DomainResponseMessageProcessor implements MessageProcessor { @Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing distribution automation response message"); String correlationUid = null; MessageType messageType = null; String organisationIdentification = null; String deviceIdentification = null; ResponseMessageResultType resultType; String resultDescription; ResponseMessage dataObject; try { correlationUid = message.getJMSCorrelationID(); organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION); deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION); messageType = MessageType.valueOf(message.getJMSType()); resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT)); resultDescription = message.getStringProperty(Constants.DESCRIPTION); dataObject = (ResponseMessage) message.getObject(); } catch (final IllegalArgumentException e) { LOGGER.error("UNRECOVERABLE ERROR, received messageType {} is unknown.", messageType, e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } catch (final JMSException e) { LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } try { LOGGER.info("Handle message of type {} for device {} with result: {}, description {}.", messageType, deviceIdentification, resultType, resultDescription); this.handleMessage(messageType, dataObject); } catch (final RuntimeException e) { handleError(e, correlationUid); } }  @Override void processMessage(final ObjectMessage message); }
DomainResponseMessageProcessor implements MessageProcessor { @Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing distribution automation response message"); String correlationUid = null; MessageType messageType = null; String organisationIdentification = null; String deviceIdentification = null; ResponseMessageResultType resultType; String resultDescription; ResponseMessage dataObject; try { correlationUid = message.getJMSCorrelationID(); organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION); deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION); messageType = MessageType.valueOf(message.getJMSType()); resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT)); resultDescription = message.getStringProperty(Constants.DESCRIPTION); dataObject = (ResponseMessage) message.getObject(); } catch (final IllegalArgumentException e) { LOGGER.error("UNRECOVERABLE ERROR, received messageType {} is unknown.", messageType, e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } catch (final JMSException e) { LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e); logDebugInformation(messageType, correlationUid, organisationIdentification, deviceIdentification); return; } try { LOGGER.info("Handle message of type {} for device {} with result: {}, description {}.", messageType, deviceIdentification, resultType, resultDescription); this.handleMessage(messageType, dataObject); } catch (final RuntimeException e) { handleError(e, correlationUid); } }  @Override void processMessage(final ObjectMessage message);  }