use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData 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.SpecialDaysRequestData 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.SpecialDaysRequestData 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);
});
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData 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.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData in project open-smart-grid-platform by OSGP.
the class SetSpecialDaysRequestMappingTest method testSpecialDaysRequestMappingEmptyList.
/**
* Tests mapping of a SetSpecialDaysRequest, when its SpecialDaysRequestData object has an empty
* List.
*/
@Test
public void testSpecialDaysRequestMappingEmptyList() {
// build test data
// No-arg constructor for SpecialDaysRequestData takes care of creating
// a empty List.
final SpecialDaysRequestData specialDaysRequestData = new SpecialDaysRequestData();
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.getDeviceIdentification()).isEqualTo(DEVICE_ID);
assertThat(specialDaysRequest.getSpecialDaysRequestData().getSpecialDays().isEmpty()).isTrue();
}
Aggregations