Search in sources :

Example 11 with AlarmTypeDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto in project open-smart-grid-platform by OSGP.

the class SetAlarmNotificationsCommandExecutorTest method testSetSettingEnabledRegister.

@ParameterizedTest
@CsvSource({ "1,VOLTAGE_SAG_IN_PHASE_DETECTED_L1", "2,VOLTAGE_SAG_IN_PHASE_DETECTED_L2", "4,VOLTAGE_SAG_IN_PHASE_DETECTED_L3", "8,VOLTAGE_SWELL_IN_PHASE_DETECTED_L1", "16,VOLTAGE_SWELL_IN_PHASE_DETECTED_L2", "32,VOLTAGE_SWELL_IN_PHASE_DETECTED_L3", "3,VOLTAGE_SAG_IN_PHASE_DETECTED_L1;VOLTAGE_SAG_IN_PHASE_DETECTED_L2", "7,VOLTAGE_SAG_IN_PHASE_DETECTED_L1;VOLTAGE_SAG_IN_PHASE_DETECTED_L2;VOLTAGE_SAG_IN_PHASE_DETECTED_L3" })
void testSetSettingEnabledRegister(final long expectedValue, final String alarmTypesInput) throws OsgpException {
    final List<AlarmTypeDto> alarmTypes = Arrays.stream(alarmTypesInput.split(";")).map(AlarmTypeDto::valueOf).collect(toList());
    final AccessResultCode res = this.execute(alarmTypes.stream().map(alarmType -> new AlarmNotificationDto(alarmType, true)).toArray(AlarmNotificationDto[]::new));
    assertThat(res).isEqualTo(AccessResultCode.SUCCESS);
    assertThat(this.setParametersReceived.size()).isEqualTo(1);
    assertThat((long) this.setParametersReceived.get(0).getData().getValue()).isEqualTo(expectedValue);
}
Also used : AlarmNotificationDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationDto) AlarmTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto) AccessResultCode(org.openmuc.jdlms.AccessResultCode) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AlarmTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmTypeDto)11 Test (org.junit.jupiter.api.Test)7 TreeSet (java.util.TreeSet)4 PushNotificationAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushNotificationAlarm)3 AlarmNotificationDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationDto)3 AlarmRegisterResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmRegisterResponseDto)3 PushNotificationAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto)3 ByteBuf (io.netty.buffer.ByteBuf)2 ArrayList (java.util.ArrayList)2 BitSet (java.util.BitSet)2 AccessResultCode (org.openmuc.jdlms.AccessResultCode)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 DlmsPushNotification (org.opensmartgridplatform.dlms.DlmsPushNotification)2 AlarmRegister (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmRegister)2 AlarmNotificationsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto)2 IOException (java.io.IOException)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1