Search in sources :

Example 1 with SetLightResponse

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

the class PublicLightingAdHocManagementEndpoint method getSetLightResponse.

@PayloadRoot(localPart = "SetLightAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetLightResponse getSetLightResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetLightAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Set Light Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    final SetLightResponse response = new SetLightResponse();
    try {
        final ResponseMessage message = this.adHocManagementService.dequeueSetLightResponse(request.getAsyncRequest().getCorrelationUid());
        if (message != null) {
            response.setResult(OsgpResultType.fromValue(message.getResult().getValue()));
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) SetLightResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with SetLightResponse

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightResponse 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)

Aggregations

SetLightResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightResponse)2 Then (io.cucumber.java.en.Then)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 SetLightAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncRequest)1 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncRequest)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType)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 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)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