Search in sources :

Example 1 with SetScheduleAsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest in project open-smart-grid-platform by OSGP.

the class SetLightScheduleSteps method thePlatformBuffersASetLightScheduleResponseMessageForDeviceContainsSoapFault.

@Then("^the platform buffers a set light schedule response message for device \"([^\"]*)\" that contains a soap fault$")
public void thePlatformBuffersASetLightScheduleResponseMessageForDeviceContainsSoapFault(final String deviceIdentification, final Map<String, String> expectedResponseData) throws Throwable {
    final SetScheduleAsyncRequest request = new SetScheduleAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformPubliclightingKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    Wait.untilAndReturn(() -> {
        try {
            this.client.getSetSchedule(request);
        } catch (final SoapFaultClientException ex) {
            LOGGER.info("Received a SOAP fault on setSchedule");
            final String faultString = ex.getFaultStringOrReason();
            if ("CorrelationUid is unknown.".equals(faultString)) {
                throw new Exception("Received a SOAP fault on setSchedule that could be rejected because the CorrelationUid is unknown");
            }
            ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
            return null;
        }
        throw new Exception("Received a setSchedule message without a SOAP fault");
    });
    GenericResponseSteps.verifySoapFault(expectedResponseData);
}
Also used : SetScheduleAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) SetScheduleAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) Then(io.cucumber.java.en.Then)

Example 2 with SetScheduleAsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest in project open-smart-grid-platform by OSGP.

the class SetLightScheduleSteps method thePlatformBuffersASetLightScheduleResponseMessageForDevice.

@Then("^the platform buffers a set light schedule response message for device \"([^\"]*)\"$")
public void thePlatformBuffersASetLightScheduleResponseMessageForDevice(final String deviceIdentification, final Map<String, String> expectedResult) throws Throwable {
    final SetScheduleAsyncRequest request = new SetScheduleAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformPubliclightingKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    final SetScheduleResponse response = Wait.untilAndReturn(() -> {
        try {
            return this.client.getSetSchedule(request);
        } catch (final SoapFaultClientException ex) {
            LOGGER.info("Received a SOAP fault on setSchedule");
            if ("CorrelationUid is unknown.".equals(ex.getFaultStringOrReason())) {
                throw new Exception("Received a SOAP fault on setSchedule that could be rejected because the CorrelationUid is unknown");
            }
            return null;
        }
    });
    assertThat(response).isNotNull();
    assertThat(response.getResult()).isEqualTo(getEnum(expectedResult, PlatformKeys.KEY_RESULT, OsgpResultType.class));
    if (expectedResult.containsKey(PlatformPubliclightingKeys.KEY_DESCRIPTION)) {
        assertThat(response.getDescription()).isEqualTo(getString(expectedResult, PlatformPubliclightingKeys.KEY_DESCRIPTION, PlatformPubliclightingDefaults.DEFAULT_PUBLICLIGHTING_DESCRIPTION));
    }
}
Also used : SetScheduleAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType) SetScheduleResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleResponse) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) SetScheduleAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) Then(io.cucumber.java.en.Then)

Aggregations

Then (io.cucumber.java.en.Then)2 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)2 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest)2 SetScheduleAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest)2 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)2 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType)1 SetScheduleResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleResponse)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1