use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar in project open-smart-grid-platform by OSGP.
the class ActivityCalendarMappingTest method testNullCosemDateTime.
// Neither the CosemDateTime or List<SeasonProfile> of a ActivityCalendar
// may ever be null. Tests to make sure a NullPointerException is thrown
// when one is.
@Test
public void testNullCosemDateTime() {
final String calendarName = "calendar";
final CosemDateTime activePassiveCalendarTime = null;
final List<SeasonProfile> seasonProfileList = new ArrayList<>();
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
new ActivityCalendar(calendarName, activePassiveCalendarTime, seasonProfileList);
});
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar 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.domain.core.valueobjects.smartmetering.ActivityCalendar in project open-smart-grid-platform by OSGP.
the class ActivityCalendarMappingTest method testNullList.
// Neither the CosemDateTime or List<SeasonProfile> of a ActivityCalendar
// may ever be null. Tests to make sure a NullPointerException is thrown
// when one is.
@Test
public void testNullList() {
final String calendarName = "calendar";
final CosemDateTime activePassiveCalendarTime = new CosemDateTime();
final List<SeasonProfile> seasonProfileList = null;
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
new ActivityCalendar(calendarName, activePassiveCalendarTime, seasonProfileList);
});
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar in project open-smart-grid-platform by OSGP.
the class SmartMeteringConfigurationEndpoint method setActivityCalendar.
@PayloadRoot(localPart = "SetActivityCalendarRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public SetActivityCalendarAsyncResponse setActivityCalendar(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetActivityCalendarRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
final ActivityCalendar activityCalendar = this.configurationMapper.map(request.getActivityCalendarData().getActivityCalendar(), ActivityCalendar.class);
final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(request.getDeviceIdentification()).withDeviceFunction(DeviceFunction.SET_ACTIVITY_CALENDAR).withMessageType(MessageType.SET_ACTIVITY_CALENDAR).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
final AsyncResponse asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, activityCalendar);
this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
return this.configurationMapper.map(asyncResponse, SetActivityCalendarAsyncResponse.class);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar in project open-smart-grid-platform by OSGP.
the class ActivityCalendarTypeMappingTest method testActivityCalendarTypeMapping.
/**
* Method to test mapping from ActivityCalendarType to ActivityCalendar.
*/
@Test
public void testActivityCalendarTypeMapping() {
// build test data
final ActivityCalendarType activityCalendarType = this.buildActivityCalendarTypeObject();
// actual mapping
final ActivityCalendar activityCalendar = this.configurationMapper.map(activityCalendarType, ActivityCalendar.class);
// check mapping
assertThat(activityCalendar).isNotNull();
assertThat(activityCalendar.getSeasonProfileList()).isNotNull();
assertThat(activityCalendar.getSeasonProfileList().get(0)).isNotNull();
// For more info on byte[] to CosemDateTime object mapping, refer to the
// CosemDateTimeConverterTest.
assertThat(activityCalendar.getActivatePassiveCalendarTime()).isNotNull();
assertThat(activityCalendar.getSeasonProfileList().get(0).getSeasonStart()).isNotNull();
assertThat(activityCalendar.getCalendarName()).isEqualTo(CALENDARNAME);
assertThat(activityCalendar.getSeasonProfileList().get(0).getSeasonProfileName()).isEqualTo(SEASONPROFILENAME);
this.checkWeekProfileMapping(activityCalendar.getSeasonProfileList().get(0).getWeekProfile());
}
Aggregations