use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType in project open-smart-grid-platform by OSGP.
the class AlarmRegisterMappingTest method testWithFilledSet.
/**
* Test to see if an AlarmRegister object is mapped correctly with a filled Set.
*/
@Test
public void testWithFilledSet() {
// build test data
final Set<AlarmType> alarmTypeSet = new TreeSet<>();
alarmTypeSet.add(ALARMTYPE);
final AlarmRegister original = new AlarmRegister(alarmTypeSet);
// actual mapping
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.AlarmRegister mapped = this.monitoringMapper.map(original, org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.AlarmRegister.class);
// check mapping
assertThat(mapped).isNotNull();
assertThat(mapped.getAlarmTypes()).isNotNull();
assertThat(mapped.getAlarmTypes().get(0)).isNotNull();
assertThat(mapped.getAlarmTypes().size()).isEqualTo(original.getAlarmTypes().size());
assertThat(mapped.getAlarmTypes().get(0).name()).isEqualTo(ALARMTYPE.name());
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType 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.domain.core.valueobjects.smartmetering.AlarmType in project open-smart-grid-platform by OSGP.
the class AlarmNotificationsConverter method convertFrom.
@Override
public AlarmNotifications convertFrom(final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotifications source, final Type<AlarmNotifications> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final Set<AlarmNotification> alarmNotifications = new TreeSet<AlarmNotification>();
final List<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotification> sourceNotifications = source.getAlarmNotification();
for (final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.AlarmNotification sourceNotification : sourceNotifications) {
final AlarmType alarmType = AlarmType.valueOf(sourceNotification.getAlarmType().name());
final boolean enabled = sourceNotification.isEnabled();
alarmNotifications.add(new AlarmNotification(alarmType, enabled));
}
return new AlarmNotifications(alarmNotifications);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmType 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.domain.core.valueobjects.smartmetering.AlarmType 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