@Test public void testUnknownDevice() { when(this.deviceRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(null); assertThatExceptionOfType(JMSException.class).isThrownBy(() -> { this.pushNotificationSmsMessageProcessor.processMessage(this.message); }); }
@Override public void processMessage(final ObjectMessage message) throws JMSException { final MessageMetadata metadata = MessageMetadata.fromMessage(message); LOGGER.info("Received message of messageType: {} organisationIdentification: {} deviceIdentification: {}", messageType, metadata.getOrganisationIdentification(), metadata.getDeviceIdentification()); final RequestMessage requestMessage = (RequestMessage) message.getObject(); final Object dataObject = requestMessage.getRequest(); try { final Device device = getDevice(metadata.getDeviceIdentification()); final PushNotificationSmsDto pushNotificationSms = (PushNotificationSmsDto) dataObject; this.storeSmsAsEvent(pushNotificationSms); if (pushNotificationSms.getIpAddress() != null && !"".equals(pushNotificationSms.getIpAddress())) { LOGGER.info("Updating device {} IP address from {} to {}", metadata.getDeviceIdentification(), requestMessage.getIpAddress(), pushNotificationSms.getIpAddress()); final InetAddress address = InetAddress.getByName(pushNotificationSms.getIpAddress()); device.updateRegistrationData(address, device.getDeviceType()); device.updateConnectionDetailsToSuccess(); this.deviceRepository.save(device); } else { LOGGER.warn("Sms notification request for device = {} has no new IP address. Discard request.", metadata.getDeviceIdentification()); } } catch (final UnknownHostException | FunctionalException e) { String errorMessage = String.format("%s occurred, reason: %s", e.getClass().getName(), e.getMessage()); LOGGER.error(errorMessage, e); throw new JMSException(errorMessage); } }
PushNotificationSmsMessageProcessor extends AbstractProtocolRequestMessageProcessor { @Override public void processMessage(final ObjectMessage message) throws JMSException { final MessageMetadata metadata = MessageMetadata.fromMessage(message); LOGGER.info("Received message of messageType: {} organisationIdentification: {} deviceIdentification: {}", messageType, metadata.getOrganisationIdentification(), metadata.getDeviceIdentification()); final RequestMessage requestMessage = (RequestMessage) message.getObject(); final Object dataObject = requestMessage.getRequest(); try { final Device device = getDevice(metadata.getDeviceIdentification()); final PushNotificationSmsDto pushNotificationSms = (PushNotificationSmsDto) dataObject; this.storeSmsAsEvent(pushNotificationSms); if (pushNotificationSms.getIpAddress() != null && !"".equals(pushNotificationSms.getIpAddress())) { LOGGER.info("Updating device {} IP address from {} to {}", metadata.getDeviceIdentification(), requestMessage.getIpAddress(), pushNotificationSms.getIpAddress()); final InetAddress address = InetAddress.getByName(pushNotificationSms.getIpAddress()); device.updateRegistrationData(address, device.getDeviceType()); device.updateConnectionDetailsToSuccess(); this.deviceRepository.save(device); } else { LOGGER.warn("Sms notification request for device = {} has no new IP address. Discard request.", metadata.getDeviceIdentification()); } } catch (final UnknownHostException | FunctionalException e) { String errorMessage = String.format("%s occurred, reason: %s", e.getClass().getName(), e.getMessage()); LOGGER.error(errorMessage, e); throw new JMSException(errorMessage); } } }
PushNotificationSmsMessageProcessor extends AbstractProtocolRequestMessageProcessor { @Override public void processMessage(final ObjectMessage message) throws JMSException { final MessageMetadata metadata = MessageMetadata.fromMessage(message); LOGGER.info("Received message of messageType: {} organisationIdentification: {} deviceIdentification: {}", messageType, metadata.getOrganisationIdentification(), metadata.getDeviceIdentification()); final RequestMessage requestMessage = (RequestMessage) message.getObject(); final Object dataObject = requestMessage.getRequest(); try { final Device device = getDevice(metadata.getDeviceIdentification()); final PushNotificationSmsDto pushNotificationSms = (PushNotificationSmsDto) dataObject; this.storeSmsAsEvent(pushNotificationSms); if (pushNotificationSms.getIpAddress() != null && !"".equals(pushNotificationSms.getIpAddress())) { LOGGER.info("Updating device {} IP address from {} to {}", metadata.getDeviceIdentification(), requestMessage.getIpAddress(), pushNotificationSms.getIpAddress()); final InetAddress address = InetAddress.getByName(pushNotificationSms.getIpAddress()); device.updateRegistrationData(address, device.getDeviceType()); device.updateConnectionDetailsToSuccess(); this.deviceRepository.save(device); } else { LOGGER.warn("Sms notification request for device = {} has no new IP address. Discard request.", metadata.getDeviceIdentification()); } } catch (final UnknownHostException | FunctionalException e) { String errorMessage = String.format("%s occurred, reason: %s", e.getClass().getName(), e.getMessage()); LOGGER.error(errorMessage, e); throw new JMSException(errorMessage); } } protected  PushNotificationSmsMessageProcessor(); }
PushNotificationSmsMessageProcessor extends AbstractProtocolRequestMessageProcessor { @Override public void processMessage(final ObjectMessage message) throws JMSException { final MessageMetadata metadata = MessageMetadata.fromMessage(message); LOGGER.info("Received message of messageType: {} organisationIdentification: {} deviceIdentification: {}", messageType, metadata.getOrganisationIdentification(), metadata.getDeviceIdentification()); final RequestMessage requestMessage = (RequestMessage) message.getObject(); final Object dataObject = requestMessage.getRequest(); try { final Device device = getDevice(metadata.getDeviceIdentification()); final PushNotificationSmsDto pushNotificationSms = (PushNotificationSmsDto) dataObject; this.storeSmsAsEvent(pushNotificationSms); if (pushNotificationSms.getIpAddress() != null && !"".equals(pushNotificationSms.getIpAddress())) { LOGGER.info("Updating device {} IP address from {} to {}", metadata.getDeviceIdentification(), requestMessage.getIpAddress(), pushNotificationSms.getIpAddress()); final InetAddress address = InetAddress.getByName(pushNotificationSms.getIpAddress()); device.updateRegistrationData(address, device.getDeviceType()); device.updateConnectionDetailsToSuccess(); this.deviceRepository.save(device); } else { LOGGER.warn("Sms notification request for device = {} has no new IP address. Discard request.", metadata.getDeviceIdentification()); } } catch (final UnknownHostException | FunctionalException e) { String errorMessage = String.format("%s occurred, reason: %s", e.getClass().getName(), e.getMessage()); LOGGER.error(errorMessage, e); throw new JMSException(errorMessage); } } protected  PushNotificationSmsMessageProcessor(); @Override void processMessage(final ObjectMessage message); }
PushNotificationSmsMessageProcessor extends AbstractProtocolRequestMessageProcessor { @Override public void processMessage(final ObjectMessage message) throws JMSException { final MessageMetadata metadata = MessageMetadata.fromMessage(message); LOGGER.info("Received message of messageType: {} organisationIdentification: {} deviceIdentification: {}", messageType, metadata.getOrganisationIdentification(), metadata.getDeviceIdentification()); final RequestMessage requestMessage = (RequestMessage) message.getObject(); final Object dataObject = requestMessage.getRequest(); try { final Device device = getDevice(metadata.getDeviceIdentification()); final PushNotificationSmsDto pushNotificationSms = (PushNotificationSmsDto) dataObject; this.storeSmsAsEvent(pushNotificationSms); if (pushNotificationSms.getIpAddress() != null && !"".equals(pushNotificationSms.getIpAddress())) { LOGGER.info("Updating device {} IP address from {} to {}", metadata.getDeviceIdentification(), requestMessage.getIpAddress(), pushNotificationSms.getIpAddress()); final InetAddress address = InetAddress.getByName(pushNotificationSms.getIpAddress()); device.updateRegistrationData(address, device.getDeviceType()); device.updateConnectionDetailsToSuccess(); this.deviceRepository.save(device); } else { LOGGER.warn("Sms notification request for device = {} has no new IP address. Discard request.", metadata.getDeviceIdentification()); } } catch (final UnknownHostException | FunctionalException e) { String errorMessage = String.format("%s occurred, reason: %s", e.getClass().getName(), e.getMessage()); LOGGER.error(errorMessage, e); throw new JMSException(errorMessage); } } protected  PushNotificationSmsMessageProcessor(); @Override void processMessage(final ObjectMessage message);  }