Search in sources :

Example 1 with AsyncRequest

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

the class ResumeScheduleSteps method getResponseWithCorrelationUID.

private ResumeScheduleResponse getResponseWithCorrelationUID(final String deviceIdentification, final String correlationUID) throws InterruptedException, SoapFaultClientException {
    final ResumeScheduleAsyncRequest request = new ResumeScheduleAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid(correlationUID);
    request.setAsyncRequest(asyncRequest);
    return Wait.untilAndReturn(() -> {
        final ResumeScheduleResponse retval = this.client.getResumeScheduleResponse(request);
        assertThat(retval).isNotNull();
        return retval;
    });
}
Also used : ResumeScheduleAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest) ResumeScheduleAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncRequest) ResumeScheduleResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleResponse)

Example 2 with AsyncRequest

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

the class SetTransitionSteps method thePlatformDoesNotBufferASetTransitionResponseMessage.

@Then("^the platform does not buffer a set transition response message for device \"([^\"]*)\"$")
public void thePlatformDoesNotBufferASetTransitionResponseMessage(final String deviceIdentification, final Map<String, String> expectedResult) throws Throwable {
    final SetTransitionAsyncRequest request = new SetTransitionAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformPubliclightingKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    Wait.until(() -> {
        SetTransitionResponse response = null;
        try {
            response = this.client.getSetTransitionResponse(request);
        } catch (final Exception e) {
        // do nothing
        }
        assertThat(response).isNotNull();
        assertThat(response.getResult()).isEqualTo(Enum.valueOf(OsgpResultType.class, expectedResult.get(PlatformPubliclightingKeys.KEY_RESULT)));
    });
}
Also used : SetTransitionAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncRequest) SetTransitionAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType) SetTransitionResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionResponse) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) Then(io.cucumber.java.en.Then)

Example 3 with AsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest 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 4 with AsyncRequest

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

the class SetLightSteps method thePlatformBuffersASetLightResponseMessage.

@Then("^the platform buffers a set light response message for device \"([^\"]*)\"$")
public void thePlatformBuffersASetLightResponseMessage(final String deviceIdentification, final Map<String, String> expectedResult) {
    final SetLightAsyncRequest request = new SetLightAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    Wait.until(() -> {
        SetLightResponse response = null;
        try {
            response = this.client.getSetLightResponse(request);
        } catch (final Exception e) {
        // do nothing
        }
        assertThat(response).isNotNull();
        assertThat(response.getResult()).isEqualTo(Enum.valueOf(OsgpResultType.class, expectedResult.get(PlatformKeys.KEY_RESULT)));
    });
}
Also used : SetLightAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType) SetLightAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncRequest) SetLightResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightResponse) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) Then(io.cucumber.java.en.Then)

Example 5 with AsyncRequest

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

the class GetStatusSteps method getGetStatusAsyncRequest.

private GetStatusAsyncRequest getGetStatusAsyncRequest(final String deviceIdentification) {
    final GetStatusAsyncRequest request = new GetStatusAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformPubliclightingKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    return request;
}
Also used : GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest) GetStatusAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest)

Aggregations

AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest)8 Then (io.cucumber.java.en.Then)5 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)5 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType)4 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)2 GetStatusAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest)2 SetTransitionAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncRequest)2 SetTransitionResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionResponse)2 SetScheduleAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest)2 GetStatusResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusResponse)1 ResumeScheduleAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncRequest)1 ResumeScheduleResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleResponse)1 SetLightAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncRequest)1 SetLightResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightResponse)1 SetScheduleResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleResponse)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)1