@Test public void processMessageShouldUpdateFirmwareWhenFirmwareFileAvailable() throws JMSException, OsgpException { final String firmwareIdentification = "available"; final ObjectMessage message = new ObjectMessageBuilder().withObject(firmwareIdentification).build(); when(this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)).thenReturn(true); this.processor.processMessage(message); verify(this.configurationService, times(1)).updateFirmware(null, this.device, firmwareIdentification); }
@Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing {} request message", this.messageType); MessageMetadata messageMetadata = null; try { messageMetadata = MessageMetadata.fromMessage(message); LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); final String firmwareIdentification = (String) message.getObject(); if (this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)) { LOGGER.info("[{}] - Firmware file [{}] available. Updating firmware on device [{}]", messageMetadata.getCorrelationUid(), firmwareIdentification, messageMetadata.getDeviceIdentification()); this.processUpdateFirmwareRequest(messageMetadata, firmwareIdentification); } else { LOGGER.info("[{}] - Firmware file [{}] not available. Sending GetFirmwareFile request to core.", messageMetadata.getCorrelationUid(), firmwareIdentification); this.sendGetFirmwareFileRequest(messageMetadata, firmwareIdentification); } } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } }
UpdateFirmwareRequestMessageProcessor extends DeviceRequestMessageProcessor { @Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing {} request message", this.messageType); MessageMetadata messageMetadata = null; try { messageMetadata = MessageMetadata.fromMessage(message); LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); final String firmwareIdentification = (String) message.getObject(); if (this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)) { LOGGER.info("[{}] - Firmware file [{}] available. Updating firmware on device [{}]", messageMetadata.getCorrelationUid(), firmwareIdentification, messageMetadata.getDeviceIdentification()); this.processUpdateFirmwareRequest(messageMetadata, firmwareIdentification); } else { LOGGER.info("[{}] - Firmware file [{}] not available. Sending GetFirmwareFile request to core.", messageMetadata.getCorrelationUid(), firmwareIdentification); this.sendGetFirmwareFileRequest(messageMetadata, firmwareIdentification); } } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } } }
UpdateFirmwareRequestMessageProcessor extends DeviceRequestMessageProcessor { @Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing {} request message", this.messageType); MessageMetadata messageMetadata = null; try { messageMetadata = MessageMetadata.fromMessage(message); LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); final String firmwareIdentification = (String) message.getObject(); if (this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)) { LOGGER.info("[{}] - Firmware file [{}] available. Updating firmware on device [{}]", messageMetadata.getCorrelationUid(), firmwareIdentification, messageMetadata.getDeviceIdentification()); this.processUpdateFirmwareRequest(messageMetadata, firmwareIdentification); } else { LOGGER.info("[{}] - Firmware file [{}] not available. Sending GetFirmwareFile request to core.", messageMetadata.getCorrelationUid(), firmwareIdentification); this.sendGetFirmwareFileRequest(messageMetadata, firmwareIdentification); } } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } } protected  UpdateFirmwareRequestMessageProcessor(); }
UpdateFirmwareRequestMessageProcessor extends DeviceRequestMessageProcessor { @Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing {} request message", this.messageType); MessageMetadata messageMetadata = null; try { messageMetadata = MessageMetadata.fromMessage(message); LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); final String firmwareIdentification = (String) message.getObject(); if (this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)) { LOGGER.info("[{}] - Firmware file [{}] available. Updating firmware on device [{}]", messageMetadata.getCorrelationUid(), firmwareIdentification, messageMetadata.getDeviceIdentification()); this.processUpdateFirmwareRequest(messageMetadata, firmwareIdentification); } else { LOGGER.info("[{}] - Firmware file [{}] not available. Sending GetFirmwareFile request to core.", messageMetadata.getCorrelationUid(), firmwareIdentification); this.sendGetFirmwareFileRequest(messageMetadata, firmwareIdentification); } } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } } protected  UpdateFirmwareRequestMessageProcessor(); @Override void processMessage(final ObjectMessage message); }
UpdateFirmwareRequestMessageProcessor extends DeviceRequestMessageProcessor { @Override public void processMessage(final ObjectMessage message) { LOGGER.debug("Processing {} request message", this.messageType); MessageMetadata messageMetadata = null; try { messageMetadata = MessageMetadata.fromMessage(message); LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); final String firmwareIdentification = (String) message.getObject(); if (this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)) { LOGGER.info("[{}] - Firmware file [{}] available. Updating firmware on device [{}]", messageMetadata.getCorrelationUid(), firmwareIdentification, messageMetadata.getDeviceIdentification()); this.processUpdateFirmwareRequest(messageMetadata, firmwareIdentification); } else { LOGGER.info("[{}] - Firmware file [{}] not available. Sending GetFirmwareFile request to core.", messageMetadata.getCorrelationUid(), firmwareIdentification); this.sendGetFirmwareFileRequest(messageMetadata, firmwareIdentification); } } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } } protected  UpdateFirmwareRequestMessageProcessor(); @Override void processMessage(final ObjectMessage message);  }