use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringMonitoringEndpoint method getRetrievePushNotificationAlarmResponse.
@PayloadRoot(localPart = "RetrievePushNotificationAlarmRequest", namespace = SMARTMETER_MONITORING_NAMESPACE)
@ResponsePayload
public RetrievePushNotificationAlarmResponse getRetrievePushNotificationAlarmResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final RetrievePushNotificationAlarmRequest request) throws OsgpException {
log.info("Incoming RetrievePushNotificationAlarmRequest for correlation UID: {}", request.getCorrelationUid());
RetrievePushNotificationAlarmResponse response = null;
try {
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), PushNotificationAlarm.class, ComponentType.WS_SMART_METERING);
this.throwExceptionIfResultNotOk(responseData, "retrieving the push notification alarm");
response = this.monitoringMapper.map(responseData.getMessageData(), RetrievePushNotificationAlarmResponse.class);
} catch (final FunctionalException e) {
throw e;
} catch (final Exception e) {
log.error("Exception: {} while sending RetrievePushNotificationAlarmRequest for correlation UID: {} for organisation {}.", e.getMessage(), request.getCorrelationUid(), organisationIdentification);
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse in project open-smart-grid-platform by OSGP.
the class PushNotificationAlarmMappingTest method testPushNotificiationAlarmMappingWithNullSet.
/**
* Tests if mapping a PushNotificationAlarm object succeeds with a null Set.
*/
@Test
void testPushNotificiationAlarmMappingWithNullSet() {
// build test data
final Set<AlarmType> alarms = null;
final PushNotificationAlarm original = new PushNotificationAlarm(DEVICE_ID, alarms, this.alarmBytes);
// actual mapping
final RetrievePushNotificationAlarmResponse mapped = this.monitoringMapper.map(original, RetrievePushNotificationAlarmResponse.class);
// check mapping
assertThat(mapped).isNotNull();
assertThat(mapped.getDeviceIdentification()).isNotNull();
assertThat(mapped.getDeviceIdentification()).isEqualTo(DEVICE_ID);
// constructor for PushNotificationAlarm creates a new Set when passed a
// null value, so we should check for an empty List
assertThat(mapped.getAlarmRegister()).isNotNull();
assertThat(mapped.getAlarmRegister().getAlarmTypes()).isNotNull();
assertThat(mapped.getAlarmRegister().getAlarmTypes().isEmpty()).isTrue();
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse in project open-smart-grid-platform by OSGP.
the class PushNotificationsAlarmConverter method convert.
@Override
public RetrievePushNotificationAlarmResponse convert(final PushNotificationAlarm source, final Type<? extends RetrievePushNotificationAlarmResponse> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final RetrievePushNotificationAlarmResponse response = new RetrievePushNotificationAlarmResponse();
response.setDeviceIdentification(source.getDeviceIdentification());
final AlarmRegister alarmRegister = new AlarmRegister();
final List<AlarmType> alarmTypes = alarmRegister.getAlarmTypes();
final Set<org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType> alarms = source.getAlarms();
for (final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType alarm : alarms) {
alarmTypes.add(AlarmType.valueOf(alarm.name()));
}
response.setAlarmRegister(alarmRegister);
return response;
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse in project open-smart-grid-platform by OSGP.
the class PushNotificationAlarmMappingTest method testPushNotificationAlarmMappingWithEmptySet.
/**
* Tests if a PushNotificationAlarm is mapped correctly with an empty Set.
*/
@Test
void testPushNotificationAlarmMappingWithEmptySet() {
// build test data
final Set<AlarmType> alarms = new TreeSet<>();
final PushNotificationAlarm original = new PushNotificationAlarm(DEVICE_ID, alarms, this.alarmBytes);
// actual mapping
final RetrievePushNotificationAlarmResponse mapped = this.monitoringMapper.map(original, RetrievePushNotificationAlarmResponse.class);
// check mapping
assertThat(mapped).isNotNull();
assertThat(mapped.getDeviceIdentification()).isNotNull();
assertThat(mapped.getAlarmRegister()).isNotNull();
assertThat(mapped.getAlarmRegister().getAlarmTypes()).isNotNull();
assertThat(mapped.getDeviceIdentification()).isEqualTo(DEVICE_ID);
assertThat(mapped.getAlarmRegister().getAlarmTypes().isEmpty()).isTrue();
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.RetrievePushNotificationAlarmResponse in project open-smart-grid-platform by OSGP.
the class PushNotificationAlarmMappingTest method testPushNotificationAlarmMappingWithFilledSet.
/**
* Tests if a PushNotificationAlarm object is mapped correctly with a filled Set.
*/
@Test
void testPushNotificationAlarmMappingWithFilledSet() {
// build test data
final Set<AlarmType> alarms = new TreeSet<>();
alarms.add(ALARMTYPE);
final PushNotificationAlarm original = new PushNotificationAlarm(DEVICE_ID, alarms, this.alarmBytes);
// actual mapping
final RetrievePushNotificationAlarmResponse mapped = this.monitoringMapper.map(original, RetrievePushNotificationAlarmResponse.class);
// check mapping
assertThat(mapped).isNotNull();
assertThat(mapped.getDeviceIdentification()).isNotNull();
assertThat(mapped.getAlarmRegister()).isNotNull();
assertThat(mapped.getAlarmRegister().getAlarmTypes()).isNotEmpty();
assertThat(mapped.getAlarmRegister().getAlarmTypes().get(0)).isNotNull();
assertThat(mapped.getDeviceIdentification()).isEqualTo(DEVICE_ID);
assertThat(mapped.getAlarmRegister().getAlarmTypes().get(0).name()).isEqualTo(ALARMTYPE.name());
}
Aggregations