Search in sources :

Example 1 with DeviceLifecycleStatus

use of org.opensmartgridplatform.domain.core.valueobjects.DeviceLifecycleStatus in project open-smart-grid-platform by OSGP.

the class CommonSetDeviceLifecycleStatusRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing common set device verification key message");
    String correlationUid = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    DeviceLifecycleStatus deviceLifecycleStatus = null;
    try {
        correlationUid = message.getJMSCorrelationID();
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        deviceLifecycleStatus = (DeviceLifecycleStatus) message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        return;
    }
    try {
        LOGGER.info("Calling application service function: {}", messageType);
        this.deviceManagementService.setDeviceLifecycleStatus(organisationIdentification, deviceIdentification, correlationUid, deviceLifecycleStatus);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, MessagePriorityEnum.DEFAULT.getPriority());
    }
}
Also used : DeviceLifecycleStatus(org.opensmartgridplatform.domain.core.valueobjects.DeviceLifecycleStatus) JMSException(javax.jms.JMSException) JMSException(javax.jms.JMSException)

Example 2 with DeviceLifecycleStatus

use of org.opensmartgridplatform.domain.core.valueobjects.DeviceLifecycleStatus in project open-smart-grid-platform by OSGP.

the class DeviceManagementServiceTest method testSetDeviceLifeCycleStatus.

@Test
public void testSetDeviceLifeCycleStatus() throws FunctionalException {
    this.deviceManagementService.setDeviceLifecycleStatus(TEST_ORGANISATION, TEST_DEVICE, TEST_UID, DeviceLifecycleStatus.UNDER_TEST);
    final ArgumentCaptor<DeviceLifecycleStatus> argumentDeviceLifecycleStatus = ArgumentCaptor.forClass(DeviceLifecycleStatus.class);
    verify(this.transactionalDeviceService).updateDeviceLifecycleStatus(this.argumentDeviceIdentification.capture(), argumentDeviceLifecycleStatus.capture());
    verify(this.webServiceResponseMessageSender).send(this.argumentResponseMessage.capture());
    final ResponseMessage expectedResponseMessage = ResponseMessage.newResponseMessageBuilder().withCorrelationUid(TEST_UID).withOrganisationIdentification(TEST_ORGANISATION).withDeviceIdentification(TEST_DEVICE).withMessageType(MessageType.SET_DEVICE_LIFECYCLE_STATUS.name()).withResult(ResponseMessageResultType.OK).build();
    assertThat(this.argumentDeviceIdentification.getValue()).isEqualTo(TEST_DEVICE);
    assertThat(argumentDeviceLifecycleStatus.getValue()).isEqualTo(DeviceLifecycleStatus.UNDER_TEST);
    assertThat(this.argumentResponseMessage.getValue()).usingRecursiveComparison().isEqualTo(expectedResponseMessage);
}
Also used : DeviceLifecycleStatus(org.opensmartgridplatform.domain.core.valueobjects.DeviceLifecycleStatus) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) Test(org.junit.jupiter.api.Test)

Aggregations

DeviceLifecycleStatus (org.opensmartgridplatform.domain.core.valueobjects.DeviceLifecycleStatus)2 JMSException (javax.jms.JMSException)1 Test (org.junit.jupiter.api.Test)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1