Search in sources :

Example 1 with SetScheduleResponse

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

the class PublicLightingScheduleManagementEndpoint method getSetLightScheduleResponse.

@PayloadRoot(localPart = "SetScheduleAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetScheduleResponse getSetLightScheduleResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetScheduleAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Set Schedule Response Request received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    final SetScheduleResponse response = new SetScheduleResponse();
    try {
        final ResponseData responseData = this.responseDataService.dequeue(request.getAsyncRequest().getCorrelationUid(), COMPONENT_WS_PUBLIC_LIGHTING);
        response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
        if (responseData.getMessageData() instanceof String) {
            response.setDescription((String) responseData.getMessageData());
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SetScheduleResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleResponse) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with SetScheduleResponse

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

SetScheduleResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleResponse)2 Then (io.cucumber.java.en.Then)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType)1 SetScheduleAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.SetScheduleAsyncRequest)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)1