Search in sources :

Example 1 with SetDataResponse

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

the class AdHocManagementEndpoint method getSetDataResponse.

@PayloadRoot(localPart = "SetDataAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetDataResponse getSetDataResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetDataAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Set Data Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    final SetDataResponse response = new SetDataResponse();
    try {
        final EmptyResponse setDataResponse = this.service.dequeueSetDataResponse(request.getAsyncRequest().getCorrelationUid());
        if (setDataResponse != null) {
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getSetDataResponse", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) SetDataResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataResponse) EmptyResponse(org.opensmartgridplatform.domain.microgrids.valueobjects.EmptyResponse) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) 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 SetDataResponse

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

the class AdHocManagementClient method setData.

public SetDataResponse setData(final SetDataAsyncRequest request) throws WebServiceSecurityException {
    final String correlationUid = request.getAsyncRequest().getCorrelationUid();
    this.waitForNotification(correlationUid);
    final WebServiceTemplate webServiceTemplate = this.webServiceTemplateFactoryMicrogridsAdHocManagement.getTemplate(this.getOrganizationIdentification(), this.getUserName());
    return (SetDataResponse) webServiceTemplate.marshalSendAndReceive(request);
}
Also used : WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) SetDataResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataResponse)

Example 3 with SetDataResponse

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

the class SetDataSteps method theSetDataResponseShouldBeReturned.

@Then("^the set data response should be returned$")
public void theSetDataResponseShouldBeReturned(final Map<String, String> responseParameters) throws Throwable {
    final String correlationUid = (String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID);
    final Map<String, String> extendedParameters = SettingsHelper.addDefault(responseParameters, PlatformKeys.KEY_CORRELATION_UID, correlationUid);
    final SetDataAsyncRequest setDataAsyncRequest = SetDataRequestBuilder.fromParameterMapAsync(extendedParameters);
    final SetDataResponse response = this.client.setData(setDataAsyncRequest);
    final String expectedResult = responseParameters.get(PlatformKeys.KEY_RESULT);
    assertThat(response.getResult()).as("Result").isNotNull();
    assertThat(response.getResult().name()).as("Result").isEqualTo(expectedResult);
}
Also used : SetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncRequest) SetDataResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataResponse) Then(io.cucumber.java.en.Then)

Aggregations

SetDataResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataResponse)3 Then (io.cucumber.java.en.Then)1 ResponseNotFoundException (org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException)1 SetDataAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncRequest)1 EmptyResponse (org.opensmartgridplatform.domain.microgrids.valueobjects.EmptyResponse)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1