use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto in project open-smart-grid-platform by OSGP.
the class SetAlarmNotificationsCommandExecutor method alarmNotifications.
private AlarmNotificationsDto alarmNotifications(final long alarmFilterLongValue, final DlmsObjectType alarmRegisterDlmsObjectType) {
final BitSet bitSet = BitSet.valueOf(new long[] { alarmFilterLongValue });
final Set<AlarmNotificationDto> notifications = new TreeSet<>();
for (final AlarmTypeDto alarmType : this.alarmHelperService.alarmTypesForRegister(alarmRegisterDlmsObjectType)) {
final boolean enabled = bitSet.get(this.alarmHelperService.getAlarmRegisterBitIndex(alarmType));
notifications.add(new AlarmNotificationDto(alarmType, enabled));
}
return new AlarmNotificationsDto(notifications);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto in project open-smart-grid-platform by OSGP.
the class AlarmNotificationsMappingTest method testWithSet.
// Tests if mapping with a Set with an entry succeeds.
@Test
public void testWithSet() {
// create test data
final AlarmNotification alarmNotification = new AlarmNotification(AlarmType.CLOCK_INVALID, true);
final Set<AlarmNotification> alarmNotificationSet = new TreeSet<>();
alarmNotificationSet.add(alarmNotification);
final AlarmNotifications alarmNotifications = new AlarmNotifications(alarmNotificationSet);
// actual mapping
final AlarmNotificationsDto alarmNotificationsDto = this.configurationMapper.map(alarmNotifications, AlarmNotificationsDto.class);
// check if mapping was successful
assertThat(alarmNotificationsDto).isNotNull();
assertThat(alarmNotificationsDto.getAlarmNotificationsSet()).isNotNull();
assertThat(alarmNotificationsDto.getAlarmNotificationsSet().size()).isEqualTo(alarmNotificationSet.size());
assertThat(alarmNotificationsDto.getAlarmNotificationsSet().isEmpty()).isFalse();
// To see if there is an AlarmNotifictionDto with the same variables as
// the AlarmNotification in the Set.
final AlarmNotificationDto alarmNotificationDto = new AlarmNotificationDto(AlarmTypeDto.CLOCK_INVALID, true);
assertThat(alarmNotificationsDto.getAlarmNotificationsSet().contains(alarmNotificationDto)).isTrue();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto in project open-smart-grid-platform by OSGP.
the class AlarmNotificationsMappingTest method testWithEmptySet.
// The Set may be empty. Tests if mapping with an empty Set succeeds.
@Test
public void testWithEmptySet() {
// create test data
final Set<AlarmNotification> alarmNotificationSet = new TreeSet<>();
final AlarmNotifications alarmNotifications = new AlarmNotifications(alarmNotificationSet);
// actual mapping
final AlarmNotificationsDto alarmNotificationsDto = this.configurationMapper.map(alarmNotifications, AlarmNotificationsDto.class);
// check if mapping was successful
assertThat(alarmNotificationsDto).isNotNull();
assertThat(alarmNotificationsDto.getAlarmNotificationsSet()).isNotNull();
assertThat(alarmNotificationsDto.getAlarmNotificationsSet()).isEmpty();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto in project open-smart-grid-platform by OSGP.
the class SetAlarmNotificationsCommandExecutorTest method execute.
private AccessResultCode execute(final AlarmNotificationDto... alarmNotificationDtos) throws OsgpException {
final Set<AlarmNotificationDto> alarmNotificationDtoSet = new HashSet<>(Arrays.asList(alarmNotificationDtos));
final AlarmNotificationsDto alarmNotificationsDto = new AlarmNotificationsDto(alarmNotificationDtoSet);
return this.executor.execute(this.connMgr, this.device, alarmNotificationsDto, this.messageMetadata);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto in project open-smart-grid-platform by OSGP.
the class SetAlarmNotificationsRequestMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
this.assertRequestObjectType(AlarmNotificationsDto.class, requestObject);
final AlarmNotificationsDto alarmNotifications = (AlarmNotificationsDto) requestObject;
this.configurationService.setAlarmNotifications(conn, device, alarmNotifications, messageMetadata);
return null;
}
Aggregations