Search in sources :

Example 6 with AsyncRequest

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

the class OsgpPublicLightingClientSoapService method getGetStatusResponse.

/**
 * Async request. Sends a GetStatusAsyncRequest to the platform using the deviceId and
 * correlationId parameters.
 *
 * <p>Returns the response from the Platform.
 */
public GetStatusResponse getGetStatusResponse(final String deviceId, final String correlationId) {
    final AsyncRequest asyncRequest = new AsyncRequest();
    final GetStatusAsyncRequest asyncStatusRequest = new GetStatusAsyncRequest();
    asyncRequest.setCorrelationUid(correlationId);
    asyncRequest.setDeviceId(deviceId);
    asyncStatusRequest.setAsyncRequest(asyncRequest);
    final WebServiceTemplate template = this.soapRequestHelper.createPublicLightingRequest();
    return (GetStatusResponse) template.marshalSendAndReceive(asyncStatusRequest);
}
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) GetStatusResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusResponse) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate)

Example 7 with AsyncRequest

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

the class SetTransitionSteps method thePlatformBuffersASetTransitionResponseMessage.

@Then("^the platform buffers a set transition response message for device \"([^\"]*)\"$")
public void thePlatformBuffersASetTransitionResponseMessage(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 8 with AsyncRequest

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

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