Search in sources :

Example 1 with GetDataAsyncRequest

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

the class ReportingSteps method doGetDataRequest.

private void doGetDataRequest(final Map<String, String> settings) throws Throwable {
    final GetDataRequest getDataRequest = new GetDataRequest();
    getDataRequest.setDeviceIdentification(settings.get(PlatformMicrogridsKeys.KEY_DEVICE_IDENTIFICATION));
    GetDataAsyncResponse asyncResponse;
    asyncResponse = this.adHocManagementClient.getDataAsync(getDataRequest);
    final GetDataAsyncRequest getDataAsyncRequest = new GetDataAsyncRequest();
    final AsyncRequest value = new AsyncRequest();
    value.setCorrelationUid(asyncResponse.getAsyncResponse().getCorrelationUid());
    value.setDeviceId(asyncResponse.getAsyncResponse().getDeviceId());
    getDataAsyncRequest.setAsyncRequest(value);
    this.adHocManagementClient.getData(getDataAsyncRequest);
}
Also used : GetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncRequest) GetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest) GetDataRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataRequest) GetDataAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncResponse)

Example 2 with GetDataAsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest 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 3 with GetDataAsyncRequest

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

the class GetDataRequestBuilder method fromParameterMapAsync.

public static GetDataAsyncRequest fromParameterMapAsync(final Map<String, String> requestParameters) {
    final String correlationUid = (String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID);
    if (correlationUid == null) {
        throw new AssertionError("ScenarioContext must contain the correlation UID for key \"" + PlatformKeys.KEY_CORRELATION_UID + "\" before creating an async request.");
    }
    final String deviceIdentification = requestParameters.get(PlatformKeys.KEY_DEVICE_IDENTIFICATION);
    if (deviceIdentification == null) {
        throw new AssertionError("The Step DataTable must contain the device identification for key \"" + PlatformKeys.KEY_DEVICE_IDENTIFICATION + "\" when creating an async request.");
    }
    final GetDataAsyncRequest getDataAsyncRequest = new GetDataAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setCorrelationUid(correlationUid);
    asyncRequest.setDeviceId(deviceIdentification);
    getDataAsyncRequest.setAsyncRequest(asyncRequest);
    return getDataAsyncRequest;
}
Also used : AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncRequest) GetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest) GetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest)

Example 4 with GetDataAsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest 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

GetDataAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncRequest)4 Then (io.cucumber.java.en.Then)2 GetDataResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataResponse)2 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncRequest)2 GetDataAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataAsyncResponse)1 GetDataRequest (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataRequest)1 GetDataSystemIdentifier (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataSystemIdentifier)1 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)1