use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutorTest method testSetActivityCalendarWithMultipleSeasons.
@Test
void testSetActivityCalendarWithMultipleSeasons() throws ProtocolAdapterException, IOException, FunctionalException {
// SETUP
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.activationExecutor.execute(this.conn, this.DLMS_DEVICE, null, this.messageMetadata)).thenReturn(MethodResultCode.SUCCESS);
final List<Short> dayIds = Collections.singletonList((short) 1);
final List<CosemTimeDto> actionStartTimes = Collections.singletonList(new CosemTimeDto(0, 0, 0, 0));
final List<String> weekNames = Collections.singletonList("1");
final List<String> seasonNames = Arrays.asList("1", "2");
final List<CosemDateDto> seasonStarts = Arrays.asList(new CosemDateDto(0xFFFF, 1, 1), new CosemDateDto(0xFFFF, 6, 15));
final ActivityCalendarDto activityCalendar = this.createActivityCalendar(seasonNames, seasonStarts, weekNames, dayIds, actionStartTimes);
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, activityCalendar, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(4)).set(this.setParameterArgumentCaptor.capture());
this.activityCalendarValidator.verify(() -> ActivityCalendarValidator.validate(activityCalendar), times(1));
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifySetParameters(setParameters, dayIds, actionStartTimes, weekNames, seasonNames, seasonStarts);
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutorTest method testSetActivityCalendarWithSingleSeason.
@Test
void testSetActivityCalendarWithSingleSeason() throws ProtocolAdapterException, IOException, FunctionalException {
// SETUP
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.activationExecutor.execute(this.conn, this.DLMS_DEVICE, null, this.messageMetadata)).thenReturn(MethodResultCode.SUCCESS);
final List<Short> dayIds = Collections.singletonList((short) 1);
final List<CosemTimeDto> actionStartTimes = Collections.singletonList(new CosemTimeDto(0, 0, 0, 0));
final List<String> weekNames = Collections.singletonList("1");
final List<String> seasonNames = Collections.singletonList("1");
final List<CosemDateDto> seasonStarts = Collections.singletonList(new CosemDateDto(0xFFFF, 1, 1));
final ActivityCalendarDto activityCalendar = this.createActivityCalendar(seasonNames, seasonStarts, weekNames, dayIds, actionStartTimes);
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, activityCalendar, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(4)).set(this.setParameterArgumentCaptor.capture());
this.activityCalendarValidator.verify(() -> ActivityCalendarValidator.validate(activityCalendar), times(1));
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifySetParameters(setParameters, dayIds, actionStartTimes, weekNames, seasonNames, seasonStarts);
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutorTest method testSetActivityCalendarEmpty.
@Test
void testSetActivityCalendarEmpty() throws ProtocolAdapterException, IOException, FunctionalException {
// SETUP
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.activationExecutor.execute(this.conn, this.DLMS_DEVICE, null, this.messageMetadata)).thenReturn(MethodResultCode.SUCCESS);
final ActivityCalendarDto activityCalendar = new ActivityCalendarDto(CALENDAR_NAME, ACTIVATE_PASSIVE_CALENDAR_TIME, Collections.emptyList());
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, activityCalendar, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(4)).set(this.setParameterArgumentCaptor.capture());
this.activityCalendarValidator.verify(() -> ActivityCalendarValidator.validate(activityCalendar), times(1));
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifySetParameters(setParameters, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutorTest method testSetActivityCalendarWithMultipleSeasonsWeeksDaysAndActions.
@Test
void testSetActivityCalendarWithMultipleSeasonsWeeksDaysAndActions() throws ProtocolAdapterException, IOException, FunctionalException {
// SETUP
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.activationExecutor.execute(this.conn, this.DLMS_DEVICE, null, this.messageMetadata)).thenReturn(MethodResultCode.SUCCESS);
final List<Short> dayIds = Arrays.asList((short) 1, (short) 2, (short) 3);
final List<CosemTimeDto> actionStartTimes = Arrays.asList(new CosemTimeDto(0, 0, 0, 0), new CosemTimeDto(10, 15, 0, 0));
final List<String> weekNames = Arrays.asList("1", "2");
final List<String> seasonNames = Arrays.asList("1", "2", "3");
final List<CosemDateDto> seasonStarts = Arrays.asList(new CosemDateDto(0xFFFF, 1, 1), new CosemDateDto(0xFFFF, 6, 15), new CosemDateDto(0xFFFF, 12, 25));
final ActivityCalendarDto activityCalendar = this.createActivityCalendar(seasonNames, seasonStarts, weekNames, dayIds, actionStartTimes);
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, activityCalendar, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(4)).set(this.setParameterArgumentCaptor.capture());
this.activityCalendarValidator.verify(() -> ActivityCalendarValidator.validate(activityCalendar), times(1));
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifySetParameters(setParameters, dayIds, actionStartTimes, weekNames, seasonNames, seasonStarts);
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetPushObjectList.
@Test
void testSetPushObjectList() throws ProtocolAdapterException, IOException {
// SETUP
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(new GetResultImpl(DataObject.newNullData(), AccessResultCode.SUCCESS));
final PushSetupAlarmDto.Builder pushSetupAlarmBuilder = new PushSetupAlarmDto.Builder();
pushSetupAlarmBuilder.withPushObjectList(PUSH_OBJECT_LIST);
final PushSetupAlarmDto pushSetupAlarmDto = pushSetupAlarmBuilder.build();
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, pushSetupAlarmDto, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(1)).set(this.setParameterArgumentCaptor.capture());
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifyPushObjectListParameter(setParameters.get(0));
}
Aggregations