Search in sources :

Example 1 with SetDataAsyncRequest

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

the class SetDataRequestBuilder method fromParameterMapAsync.

public static SetDataAsyncRequest 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 SetDataAsyncRequest setDataAsyncRequest = new SetDataAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setCorrelationUid(correlationUid);
    asyncRequest.setDeviceId(deviceIdentification);
    setDataAsyncRequest.setAsyncRequest(asyncRequest);
    return setDataAsyncRequest;
}
Also used : SetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncRequest) SetDataAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncRequest)

Example 2 with SetDataAsyncRequest

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

SetDataAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataAsyncRequest)2 Then (io.cucumber.java.en.Then)1 SetDataResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataResponse)1 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.microgrids.common.AsyncRequest)1