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);
}
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);
}
}
Aggregations