use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest in project open-smart-grid-platform by OSGP.
the class SetSpecialDaysRequestMappingTest method testSetSpecialDaysRequestMappingFilledList.
/**
* Tests mapping of a SetSpecialDaysRequest object, when its SpecialDaysRequestData object has a
* filled List (1 entry).
*/
@Test
public void testSetSpecialDaysRequestMappingFilledList() {
// build test data
final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestData();
final SpecialDay specialDay = new SpecialDay();
specialDay.setDayId(DAY_ID);
specialDay.setSpecialDayDate(COSEMDATE_BYTE_ARRAY);
// To add a SpecialDay to the List, you need to use the getter in
// combination with add()
specialDaysRequestData.getSpecialDays().add(specialDay);
final SetSpecialDaysRequest setSpecialDaysRequest = new SetSpecialDaysRequest();
setSpecialDaysRequest.setDeviceIdentification(DEVICE_ID);
setSpecialDaysRequest.setSpecialDaysRequestData(specialDaysRequestData);
// actual mapping
final SpecialDaysRequest specialDaysRequest = this.configurationMapper.map(setSpecialDaysRequest, SpecialDaysRequest.class);
// check mapping
assertThat(specialDaysRequest).isNotNull();
assertThat(specialDaysRequest.getDeviceIdentification()).isNotNull();
assertThat(specialDaysRequest.getSpecialDaysRequestData()).isNotNull();
assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays()).isNotNull();
assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().get(0)).isNotNull();
assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().get(0).getSpecialDayDate()).isNotNull();
assertThat(specialDaysRequest.getDeviceIdentification()).isEqualTo(DEVICE_ID);
assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().size()).isEqualTo(specialDaysRequestData.getSpecialDays().size());
assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().get(0).getDayId()).isEqualTo(DAY_ID);
// For more info on the mapping of byte[] to CosemDate object, see the
// CosemDateConverterTest.
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest in project open-smart-grid-platform by OSGP.
the class SetSpecialDaysRequestMappingTest method testSpecialDaysRequestMappingNull.
/**
* Tests mapping of a SetSpecialDaysRequest object, when its SetSpecialDaysRequest object is null.
*/
@Test
public void testSpecialDaysRequestMappingNull() {
// build test data
final SpecialDaysRequestData specialDaysRequestData = null;
final SetSpecialDaysRequest setSpecialDaysRequest = new SetSpecialDaysRequest();
setSpecialDaysRequest.setDeviceIdentification(DEVICE_ID);
setSpecialDaysRequest.setSpecialDaysRequestData(specialDaysRequestData);
// actual mapping
final SpecialDaysRequest specialDaysRequest = this.configurationMapper.map(setSpecialDaysRequest, SpecialDaysRequest.class);
// check mapping
assertThat(specialDaysRequest.getDeviceIdentification()).isEqualTo(DEVICE_ID);
assertThat(specialDaysRequest.getSpecialDaysRequestData()).isNull();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest in project open-smart-grid-platform by OSGP.
the class SpecialDaysRequestMappingTest method testSpecialDaysRequestMappingNonEmptyListNoCosemDate.
// To check mapping of SpecialDaysRequest, when its SpecialDaysRequestData
// has a filled List (1 value), where CosemDate is not specified.
@Test
public void testSpecialDaysRequestMappingNonEmptyListNoCosemDate() {
final String deviceIdentification = "nr1";
final int dayId = 1;
final SpecialDay specialDay = new SpecialDay(new CosemDate(), dayId);
final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestDataBuilder().addSpecialDay(specialDay).build();
final SpecialDaysRequest specialDaysRequestValueObject = new SpecialDaysRequest(deviceIdentification, specialDaysRequestData);
final SpecialDaysRequestDto specialDaysRequestDto = this.configurationMapper.map(specialDaysRequestValueObject, SpecialDaysRequestDto.class);
assertThat(specialDaysRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
final SpecialDaysRequestDataDto requestDataDto = specialDaysRequestDto.getSpecialDaysRequestData();
assertThat(requestDataDto).isNotNull();
assertThat(requestDataDto.getSpecialDays()).isNotNull();
assertThat(requestDataDto.getSpecialDays().size()).isEqualTo(dayId);
final SpecialDayDto specialDayDto = requestDataDto.getSpecialDays().get(0);
assertThat(specialDayDto.getDayId()).isEqualTo(dayId);
final CosemDate specialDayDate = specialDay.getSpecialDayDate();
final CosemDateDto specialDayDateDto = specialDayDto.getSpecialDayDate();
assertThat(specialDayDateDto.getYear()).isEqualTo(specialDayDate.getYear());
assertThat(specialDayDateDto.getMonth()).isEqualTo(specialDayDate.getMonth());
assertThat(specialDayDateDto.getDayOfMonth()).isEqualTo(specialDayDate.getDayOfMonth());
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest in project open-smart-grid-platform by OSGP.
the class SpecialDaysRequestMappingTest method testSpecialDaysRequestMappingNonEmptyList.
// To check mapping of SpecialDaysRequest, when its SpecialDaysRequestData
// has a filled List (1 value).
@Test
public void testSpecialDaysRequestMappingNonEmptyList() {
final String deviceIdentification = "nr1";
final int year = 2016;
final int month = 3;
final int dayOfMonth = 11;
final int dayId = 1;
final SpecialDay specialDay = new SpecialDay(new CosemDate(year, month, dayOfMonth), dayId);
final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestDataBuilder().addSpecialDay(specialDay).build();
final SpecialDaysRequest specialDaysRequestValueObject = new SpecialDaysRequest(deviceIdentification, specialDaysRequestData);
final SpecialDaysRequestDto specialDaysRequestDto = this.configurationMapper.map(specialDaysRequestValueObject, SpecialDaysRequestDto.class);
assertThat(specialDaysRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
final SpecialDaysRequestDataDto requestDataDto = specialDaysRequestDto.getSpecialDaysRequestData();
assertThat(requestDataDto).isNotNull();
assertThat(requestDataDto.getSpecialDays()).isNotNull();
assertThat(requestDataDto.getSpecialDays().size()).isEqualTo(dayId);
final SpecialDayDto specialDayDto = requestDataDto.getSpecialDays().get(0);
assertThat(specialDayDto.getDayId()).isEqualTo(dayId);
final CosemDateDto specialDayDateDto = specialDayDto.getSpecialDayDate();
assertThat(specialDayDateDto.getYear()).isEqualTo(year);
assertThat(specialDayDateDto.getMonth()).isEqualTo(month);
assertThat(specialDayDateDto.getDayOfMonth()).isEqualTo(dayOfMonth);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest in project open-smart-grid-platform by OSGP.
the class SpecialDaysRequestMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final Object dataObject) throws FunctionalException {
final SpecialDaysRequest specialDaysRequest = (SpecialDaysRequest) dataObject;
this.configurationService.setSpecialDays(deviceMessageMetadata, specialDaysRequest);
}
Aggregations