Search in sources :

Example 1 with GetDataResponse

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

the class FaultSteps method aSoapFaultShouldBeReturned.

@Then("^a SOAP fault should be returned$")
public void aSoapFaultShouldBeReturned(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 GetDataAsyncRequest getDataAsyncRequest = GetDataRequestBuilder.fromParameterMapAsync(extendedParameters);
    try {
        final GetDataResponse response = this.client.getData(getDataAsyncRequest);
        Assertions.fail("Expected a SOAP fault, but got a GetDataResponse with result " + response.getResult().value() + ".");
    } catch (final SoapFaultClientException e) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, e);
    }
    GenericResponseSteps.verifySoapFault(responseParameters);
}
Also used : GetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest) GetDataResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataResponse) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) Then(io.cucumber.java.en.Then)

Example 2 with GetDataResponse

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

the class AdHocManagementEndpoint method getGetDataResponse.

@PayloadRoot(localPart = "GetDataAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetDataResponse getGetDataResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetDataAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Data Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    GetDataResponse response = new GetDataResponse();
    try {
        final org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataResponse dataResponse = this.service.dequeueGetDataResponse(request.getAsyncRequest().getCorrelationUid());
        if (dataResponse != null) {
            response = this.mapper.map(dataResponse, GetDataResponse.class);
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getGetDataResponse", 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) GetDataResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataResponse) 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 3 with GetDataResponse

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

the class AdHocManagementClient method getData.

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

Example 4 with GetDataResponse

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

the class GetDataSteps method theGetDataResponseShouldBeReturned.

@Then("^the get data response should be returned$")
public void theGetDataResponseShouldBeReturned(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 GetDataAsyncRequest getDataAsyncRequest = GetDataRequestBuilder.fromParameterMapAsync(extendedParameters);
    final GetDataResponse response = this.client.getData(getDataAsyncRequest);
    final String expectedResult = responseParameters.get(PlatformKeys.KEY_RESULT);
    assertThat(response.getResult()).as("Result").isNotNull();
    assertThat(response.getResult().name()).as("Result").isEqualTo(expectedResult);
    if (!responseParameters.containsKey(PlatformKeys.KEY_NUMBER_OF_SYSTEMS)) {
        throw new AssertionError("The Step DataTable must contain the expected number of systems with key \"" + PlatformKeys.KEY_NUMBER_OF_SYSTEMS + "\" when confirming a returned get data response.");
    }
    final int expectedNumberOfSystems = Integer.parseInt(responseParameters.get(PlatformKeys.KEY_NUMBER_OF_SYSTEMS));
    final List<GetDataSystemIdentifier> systemIdentifiers = response.getSystem();
    assertThat(systemIdentifiers.size()).as("Number of Systems").isEqualTo(expectedNumberOfSystems);
    for (int i = 0; i < expectedNumberOfSystems; i++) {
        this.assertSystemResponse(responseParameters, systemIdentifiers, i);
    }
}
Also used : GetDataSystemIdentifier(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataSystemIdentifier) GetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest) GetDataResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataResponse) Then(io.cucumber.java.en.Then)

Aggregations

GetDataResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataResponse)4 Then (io.cucumber.java.en.Then)2 GetDataAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest)2 ResponseNotFoundException (org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException)1 GetDataSystemIdentifier (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataSystemIdentifier)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 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)1