Search in sources :

Example 1 with LightSensorStatus

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

the class StatusMappingTest method properlyMapsLightSensorStatus.

@Test
void properlyMapsLightSensorStatus() {
    final Status domainStatus = new LightSensorStatus(LightSensorStatusType.LIGHT);
    final org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Status wsStatus = this.adHocManagementMapper.map(domainStatus, org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Status.class);
    final org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightSensorStatus expected = new org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightSensorStatus();
    expected.setStatus(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightSensorStatusType.LIGHT);
    assertThat(wsStatus).isInstanceOf(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightSensorStatus.class).usingRecursiveComparison().isEqualTo(expected);
}
Also used : Status(org.opensmartgridplatform.domain.core.valueobjects.Status) DeviceStatus(org.opensmartgridplatform.domain.core.valueobjects.DeviceStatus) LightSensorStatus(org.opensmartgridplatform.domain.core.valueobjects.LightSensorStatus) LightSensorStatus(org.opensmartgridplatform.domain.core.valueobjects.LightSensorStatus) Test(org.junit.jupiter.api.Test)

Example 2 with LightSensorStatus

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

the class AdHocManagementService method handleGetLightSensorStatusResponse.

// === GET LIGHT SENSOR STATUS ===
public void handleGetLightSensorStatusResponse(final LightSensorStatusDto lightSensorStatusDto, final CorrelationIds ids, final String messageType, final int messagePriority, final ResponseMessageResultType deviceResult, final OsgpException exception) {
    LOGGER.info("handleResponse for MessageType: {}", messageType);
    final GetLightSensorStatusResponse response = new GetLightSensorStatusResponse();
    response.setOsgpException(exception);
    response.setResult(deviceResult);
    if (lightSensorStatusDto != null) {
        response.setLightSensorStatus(new LightSensorStatus(LightSensorStatusType.valueOf(lightSensorStatusDto.getStatus().name())));
        this.updateLastCommunicationTime(ids.getDeviceIdentification());
    }
    if (deviceResult == ResponseMessageResultType.NOT_OK || exception != null) {
        LOGGER.error("Device Response not ok.", exception);
    }
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withIds(ids).withResult(response.getResult()).withOsgpException(response.getOsgpException()).withDataObject(response.getLightSensorStatus()).withMessagePriority(messagePriority).build();
    if (!OsgpSystemCorrelationUid.CORRELATION_UID.equals(ids.getCorrelationUid())) {
        this.webServiceResponseMessageSender.send(responseMessage);
    } else {
        LOGGER.info("We used sensor status to keep 104 LMDs connected, ignore response: {}", responseMessage);
    }
}
Also used : GetLightSensorStatusResponse(org.opensmartgridplatform.adapter.domain.shared.GetLightSensorStatusResponse) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) LightSensorStatus(org.opensmartgridplatform.domain.core.valueobjects.LightSensorStatus)

Aggregations

LightSensorStatus (org.opensmartgridplatform.domain.core.valueobjects.LightSensorStatus)2 Test (org.junit.jupiter.api.Test)1 GetLightSensorStatusResponse (org.opensmartgridplatform.adapter.domain.shared.GetLightSensorStatusResponse)1 DeviceStatus (org.opensmartgridplatform.domain.core.valueobjects.DeviceStatus)1 Status (org.opensmartgridplatform.domain.core.valueobjects.Status)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1