use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto in project open-smart-grid-platform by OSGP.
the class ActivityCalendarMappingTest method testWithCosemDateTimeAndEmptyList.
// Test mapping with a CosemDateTime object AND an empty list
@Test
public void testWithCosemDateTimeAndEmptyList() {
// build test data
final ActivityCalendar activityCalendar = new ActivityCalendarBuilder().withCosemDateTime(this.cosemDateTime).build();
// actual mapping
final ActivityCalendarDto activityCalendarDto = this.configurationMapper.map(activityCalendar, ActivityCalendarDto.class);
// check if mapping succeeded
assertThat(activityCalendarDto).isNotNull();
assertThat(activityCalendarDto.getActivatePassiveCalendarTime()).isNotNull();
assertThat(activityCalendarDto.getSeasonProfileList()).isNotNull();
assertThat(activityCalendarDto.getCalendarName()).isEqualTo(activityCalendar.getCalendarName());
this.checkEmptyListMapping(activityCalendar.getSeasonProfileList(), activityCalendarDto.getSeasonProfileList());
this.checkCosemDateTimeMapping(activityCalendar.getActivatePassiveCalendarTime(), activityCalendarDto.getActivatePassiveCalendarTime());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto 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.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto 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.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto 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.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto 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);
}
Aggregations