use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm 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.PushNotificationAlarm 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());
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm in project open-smart-grid-platform by OSGP.
the class PushNotificationAlarmMappingTest method testWithNonEmptyEnumSet.
// Test if mapping a PushNotificationAlarm object succeeds when the EnumSet
// is not empty
@Test
public void testWithNonEmptyEnumSet() {
// build test data
final String deviceId = "device1";
final EnumSet<AlarmTypeDto> alarms = EnumSet.of(AlarmTypeDto.CLOCK_INVALID);
final PushNotificationAlarmDto pushNotificationAlarmDto = new PushNotificationAlarmDto(deviceId, alarms, this.alarmBytes);
// actual mapping
final PushNotificationAlarm pushNotificationAlarm = this.mapperFactory.getMapperFacade().map(pushNotificationAlarmDto, PushNotificationAlarm.class);
// test mapping
assertThat(pushNotificationAlarm).isNotNull();
assertThat(pushNotificationAlarm.getDeviceIdentification()).isEqualTo(deviceId);
assertThat(pushNotificationAlarm.getAlarms().size()).isEqualTo(alarms.size());
assertThat(pushNotificationAlarm.getAlarms().contains(AlarmType.CLOCK_INVALID)).isTrue();
assertThat(this.alarmBytes).isEqualTo(pushNotificationAlarm.getAlarmBytes());
}
Aggregations