use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDay in project open-smart-grid-platform by OSGP.
the class SetSpecialDaysRequestBuilder method getSpecialDay.
private SpecialDay getSpecialDay(final Map<String, String> parameters, final int index) {
final SpecialDay specialDay = new SpecialDay();
specialDay.setDayId(this.getSpecialDayId(parameters, index));
specialDay.setSpecialDayDate(this.getSpecialDayDate(parameters, index));
return specialDay;
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDay in project open-smart-grid-platform by OSGP.
the class SetSpecialDaysRequestFactory method fetchSpecialDays.
private static SpecialDaysRequestData fetchSpecialDays() {
/**
* 2 bytes for year (century byte and year byte, 0xFFFF = undefined). 1 for month, 0xFF
* (undefined), 0xFD (end daylight saving), 0xFE (begin daylight saving). 1 for day of month,
* 0xFF (undefined), 0xFD (2nd last day of month), 0xFE (last day of month). 1 for day of week,
* 1 is monday, 0xFF (undefined)
*/
// last Sunday in every year and month
final byte[] specialDayDateByteArray = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFE, 0x07 };
final SpecialDay specialDay = new SpecialDay();
specialDay.setDayId(1);
specialDay.setSpecialDayDate(specialDayDateByteArray);
final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestData();
final List<SpecialDay> specialDays = new ArrayList<>();
specialDays.add(specialDay);
specialDaysRequestData.getSpecialDays().addAll(specialDays);
return specialDaysRequestData;
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDay 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.adapter.ws.schema.smartmetering.configuration.SpecialDay in project open-smart-grid-platform by OSGP.
the class SetSpecialDaysRequestMappingTest method testWithoutByteArray.
/**
* Tests mapping of a SpecialDaysRequesData object. A NullPointerException should be thrown when
* no byte[] is specified for SpecialDay.
*/
@Test
public void testWithoutByteArray() {
// build test data
final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestData();
final SpecialDay specialDay = new SpecialDay();
specialDay.setDayId(DAY_ID);
// 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);
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
// actual mapping
this.configurationMapper.map(setSpecialDaysRequest, SpecialDaysRequest.class);
});
}
Aggregations