use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest in project open-smart-grid-platform by OSGP.
the class SetSpecialDays method theSetSpecialDaysRequestIsReceived.
@When("^the set special days request is received$")
public void theSetSpecialDaysRequestIsReceived(final Map<String, String> requestData) throws Throwable {
final SetSpecialDaysRequest setSpecialDaysRequest = SetSpecialDaysRequestFactory.fromParameterMap(requestData);
final SetSpecialDaysAsyncResponse setSpecialDaysAsyncResponse = this.smartMeteringConfigurationClient.setSpecialDays(setSpecialDaysRequest);
LOGGER.info("Set special days response is received {}", setSpecialDaysAsyncResponse);
assertThat(setSpecialDaysAsyncResponse).as("Set special days response should not be null").isNotNull();
ScenarioContext.current().put(PlatformSmartmeteringKeys.KEY_CORRELATION_UID, setSpecialDaysAsyncResponse.getCorrelationUid());
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest 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.SetSpecialDaysRequest 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.SetSpecialDaysRequest 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.SetSpecialDaysRequest 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