Search in sources :

Example 1 with ActualPowerQualityAsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncRequest in project open-smart-grid-platform by OSGP.

the class ActualPowerQualitySteps method theGetActualMeterReadsRequestGeneratingAnErrorIsReceived.

@When("^the get actual power quality request generating an error is received$")
public void theGetActualMeterReadsRequestGeneratingAnErrorIsReceived(final Map<String, String> settings) throws Throwable {
    final ActualPowerQualityRequest request = ActualPowerQualityRequestFactory.fromParameterMap(settings);
    final ActualPowerQualityAsyncResponse asyncResponse = this.requestClient.doRequest(request);
    ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, asyncResponse.getCorrelationUid());
    final ActualPowerQualityAsyncRequest actualPowerQualityAsyncRequest = ActualPowerQualityRequestFactory.fromScenarioContext();
    try {
        final ActualPowerQualityResponse response = this.responseClient.getResponse(actualPowerQualityAsyncRequest);
        fail("Expected exception, but got a response: %s", response.toString());
    } catch (final Exception exception) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, exception);
    }
}
Also used : ActualPowerQualityResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityResponse) ActualPowerQualityAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncResponse) ActualPowerQualityRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityRequest) ActualPowerQualityAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncRequest) When(io.cucumber.java.en.When)

Example 2 with ActualPowerQualityAsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncRequest in project open-smart-grid-platform by OSGP.

the class ActualPowerQualitySteps method theActualPowerQualityResultShouldBeReturned.

@Then("^the actual power quality result should be returned$")
public void theActualPowerQualityResultShouldBeReturned(final Map<String, String> settings) throws Throwable {
    final ActualPowerQualityAsyncRequest asyncRequest = ActualPowerQualityRequestFactory.fromScenarioContext();
    final ActualPowerQualityResponse response = this.responseClient.getResponse(asyncRequest);
    assertThat(response).as("ActualPowerQualityResponseData should not be null").isNotNull();
    final int expectedNumberOfPowerQualityObjects = getInteger(settings, "NumberOfPowerQualityObjects", 0);
    final List<PowerQualityObject> actualPowerQualityObjects = response.getActualPowerQualityData().getPowerQualityObjects().getPowerQualityObject();
    assertThat(actualPowerQualityObjects.size()).as("Number of power quality objects").isEqualTo(expectedNumberOfPowerQualityObjects);
    for (int i = 0; i < expectedNumberOfPowerQualityObjects; i++) {
        final PowerQualityObject actualPowerQualityObject = actualPowerQualityObjects.get(i);
        final Long expectedNameId = SettingsHelper.getLongValue(settings, "PowerQuality_Name", i + 1);
        if (expectedNameId != null) {
            this.validatePowerQualityObject(actualPowerQualityObject, settings, i + 1);
        }
    }
    final int expectedNumberOfPowerQualityValues = getInteger(settings, "NumberOfPowerQualityValues", 0);
    final List<PowerQualityValue> powerQualityValues = response.getActualPowerQualityData().getPowerQualityValues().getPowerQualityValue();
    assertThat(powerQualityValues.size()).as("Number of power quality values").isEqualTo(expectedNumberOfPowerQualityValues);
    if (expectedNumberOfPowerQualityValues > 0) {
        /*
       * Expected value equals expectedNumberOfPowerQualityObjects,
       * because the number of PowerQualityValues should match the number
       * of power quality objects from the buffer.
       */
        assertThat(powerQualityValues.size()).as("Number of power quality values").isEqualTo(expectedNumberOfPowerQualityObjects);
    }
}
Also used : ActualPowerQualityResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityResponse) PowerQualityObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityObject) PowerQualityValue(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityValue) ActualPowerQualityAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncRequest) Then(io.cucumber.java.en.Then)

Example 3 with ActualPowerQualityAsyncRequest

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncRequest in project open-smart-grid-platform by OSGP.

the class ActualPowerQualityRequestFactory method fromScenarioContext.

public static ActualPowerQualityAsyncRequest fromScenarioContext() {
    final ActualPowerQualityAsyncRequest actualPowerQualityAsyncRequest = new ActualPowerQualityAsyncRequest();
    actualPowerQualityAsyncRequest.setCorrelationUid(RequestFactoryHelper.getCorrelationUidFromScenarioContext());
    actualPowerQualityAsyncRequest.setDeviceIdentification(RequestFactoryHelper.getDeviceIdentificationFromScenarioContext());
    return actualPowerQualityAsyncRequest;
}
Also used : ActualPowerQualityAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncRequest)

Aggregations

ActualPowerQualityAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncRequest)3 ActualPowerQualityResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityResponse)2 Then (io.cucumber.java.en.Then)1 When (io.cucumber.java.en.When)1 ActualPowerQualityAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityAsyncResponse)1 ActualPowerQualityRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityRequest)1 PowerQualityObject (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityObject)1 PowerQualityValue (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityValue)1