Search in sources :

Example 1 with SetSpecialDaysRequest

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());
}
Also used : SetSpecialDaysAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysAsyncResponse) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) When(io.cucumber.java.en.When)

Example 2 with SetSpecialDaysRequest

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.
}
Also used : SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SpecialDaysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData) SpecialDay(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDay) Test(org.junit.jupiter.api.Test)

Example 3 with SetSpecialDaysRequest

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);
    });
}
Also used : SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SpecialDaysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData) SpecialDay(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDay) Test(org.junit.jupiter.api.Test)

Example 4 with SetSpecialDaysRequest

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();
}
Also used : SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SpecialDaysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData) Test(org.junit.jupiter.api.Test)

Example 5 with SetSpecialDaysRequest

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();
}
Also used : SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SetSpecialDaysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest) SpecialDaysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData) Test(org.junit.jupiter.api.Test)

Aggregations

SetSpecialDaysRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysRequest)6 Test (org.junit.jupiter.api.Test)4 SpecialDaysRequestData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDaysRequestData)4 SpecialDaysRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest)3 SpecialDay (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SpecialDay)2 When (io.cucumber.java.en.When)1 SetSpecialDaysAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetSpecialDaysAsyncResponse)1