Search in sources :

Example 1 with SetConfigurationResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationResponse in project open-smart-grid-platform by OSGP.

the class SetConfigurationSteps method thePlatformBufferesASetConfigurationResponseMessageForDevice.

@Then("^the platform buffers a set configuration response message for device \"([^\"]*)\"$")
public void thePlatformBufferesASetConfigurationResponseMessageForDevice(final String deviceIdentification, final Map<String, String> expectedResponseData) throws Throwable {
    final SetConfigurationAsyncRequest request = new SetConfigurationAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    final SetConfigurationResponse response = Wait.untilAndReturn(() -> {
        final SetConfigurationResponse retval = this.client.getSetConfiguration(request);
        assertThat(retval).isNotNull();
        return retval;
    });
    assertThat(response.getResult()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_RESULT, OsgpResultType.class));
}
Also used : SetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest) SetConfigurationResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationResponse) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType) SetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncRequest) Then(io.cucumber.java.en.Then)

Example 2 with SetConfigurationResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationResponse in project open-smart-grid-platform by OSGP.

the class ConfigurationManagementEndpoint method getSetConfigurationResponse.

@PayloadRoot(localPart = "SetConfigurationAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetConfigurationResponse getSetConfigurationResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetConfigurationAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Set Configuration Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    final SetConfigurationResponse response = new SetConfigurationResponse();
    try {
        final ResponseMessage responseMessage = this.getResponseMessage(request.getAsyncRequest());
        if (responseMessage != null) {
            throwExceptionIfResultNotOk(responseMessage, "setting configuration");
            response.setResult(OsgpResultType.fromValue(responseMessage.getResult().getValue()));
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    if (OsgpResultType.OK.equals(response.getResult())) {
        try {
            this.notificationService.sendNotification(organisationIdentification, request.getAsyncRequest().getDeviceId(), response.getResult().name(), request.getAsyncRequest().getCorrelationUid(), null, NotificationType.DEVICE_UPDATED);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
    return response;
}
Also used : SetConfigurationResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationResponse) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) 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)

Aggregations

SetConfigurationResponse (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationResponse)2 Then (io.cucumber.java.en.Then)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType)1 SetConfigurationAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncRequest)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)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