Search in sources :

Example 1 with GetPowerQualityProfileResponse

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

the class PowerQualityProfileSteps method theGetPowerQualityProfileResponseDataShouldBeReturned.

@Then("^the power quality profile response data should be returned$")
public void theGetPowerQualityProfileResponseDataShouldBeReturned(final Map<String, String> settings) throws Throwable {
    final GetPowerQualityProfileAsyncRequest asyncRequest = GetPowerQualityProfileRequestFactory.fromScenarioContext();
    final GetPowerQualityProfileResponse response = this.responseClient.getResponse(asyncRequest);
    assertThat(response).as("GetPowerQualityProfileResponseData should not be null").isNotNull();
    final int expectedNumberOfCaptureObjects = getInteger(settings, "NumberOfCaptureObjects", 0);
    final List<CaptureObject> actualCaptureObjects = response.getPowerQualityProfileDatas().get(0).getCaptureObjectList().getCaptureObjects();
    assertThat(actualCaptureObjects.size()).as("Number of capture objects").isEqualTo(expectedNumberOfCaptureObjects);
    for (int i = 0; i < expectedNumberOfCaptureObjects; i++) {
        final CaptureObject actualCaptureObject = actualCaptureObjects.get(i);
        this.validateCaptureObject(actualCaptureObject, settings, i + 1);
    }
    final int expectedNumberOfProfileEntries = getInteger(settings, "NumberOfProfileEntries", 0);
    final List<ProfileEntry> actualProfileEntries = response.getPowerQualityProfileDatas().get(0).getProfileEntryList().getProfileEntries();
    assertThat(actualProfileEntries.size()).as("Number of profile entries").isEqualTo(expectedNumberOfProfileEntries);
    if (expectedNumberOfProfileEntries > 0) {
        /*
       * Expected value equals expectedNumberOfCaptureObjects, because the
       * number of ProfileEntryValues in a ProfileEntry should match the
       * number of captured objects from the buffer.
       */
        assertThat(actualProfileEntries.get(0).getProfileEntryValue().size()).as("Number of profile entry values").isEqualTo(expectedNumberOfCaptureObjects);
    }
}
Also used : GetPowerQualityProfileResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.GetPowerQualityProfileResponse) CaptureObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.CaptureObject) ProfileEntry(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ProfileEntry) GetPowerQualityProfileAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.GetPowerQualityProfileAsyncRequest) Then(io.cucumber.java.en.Then)

Example 2 with GetPowerQualityProfileResponse

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

the class SmartMeteringMonitoringEndpoint method getGetPowerQualityProfileResponse.

@PayloadRoot(localPart = "GetPowerQualityProfileAsyncRequest", namespace = SMARTMETER_MONITORING_NAMESPACE)
@ResponsePayload
public GetPowerQualityProfileResponse getGetPowerQualityProfileResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetPowerQualityProfileAsyncRequest request) throws OsgpException {
    log.debug("Incoming GetPowerQualityProfileAsyncRequest for meter: {}.", request.getDeviceIdentification());
    GetPowerQualityProfileResponse response = null;
    try {
        final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileResponse.class, ComponentType.WS_SMART_METERING);
        this.throwExceptionIfResultNotOk(responseData, "retrieving power quality profile");
        response = this.monitoringMapper.map(responseData.getMessageData(), GetPowerQualityProfileResponse.class);
    } catch (final Exception e) {
        log.error("Exception: {} while sending GetPowerQualityProfileAsyncRequest for correlation UID: {} for organisation {}.", e.getMessage(), request.getCorrelationUid(), organisationIdentification);
        this.handleException(e);
    }
    return response;
}
Also used : GetPowerQualityProfileResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.GetPowerQualityProfileResponse) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 3 with GetPowerQualityProfileResponse

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

the class BundledGetPowerQualityProfileDataSteps method theBundleResponseShouldContainAGetPowerQualityProfileResponse.

@Then("^the bundle response should contain a power quality profile response with values$")
public void theBundleResponseShouldContainAGetPowerQualityProfileResponse(final Map<String, String> values) throws Throwable {
    final Response response = this.getNextBundleResponse();
    assertThat(response).isInstanceOf(GetPowerQualityProfileResponse.class);
    final GetPowerQualityProfileResponse getPowerQualityProfileResponse = (GetPowerQualityProfileResponse) response;
    final PowerQualityProfileData powerQualityProfileData = getPowerQualityProfileResponse.getPowerQualityProfileDatas().get(0);
    this.assertEqualCaptureObjects(powerQualityProfileData.getCaptureObjectList().getCaptureObjects(), values);
    this.assertEqualProfileEntries(powerQualityProfileData.getProfileEntryList().getProfileEntries(), values);
}
Also used : Response(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response) GetPowerQualityProfileResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.GetPowerQualityProfileResponse) GetPowerQualityProfileResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.GetPowerQualityProfileResponse) PowerQualityProfileData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityProfileData) Then(io.cucumber.java.en.Then)

Aggregations

GetPowerQualityProfileResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.GetPowerQualityProfileResponse)3 Then (io.cucumber.java.en.Then)2 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 CaptureObject (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.CaptureObject)1 ProfileEntry (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ProfileEntry)1 Response (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response)1 GetPowerQualityProfileAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.GetPowerQualityProfileAsyncRequest)1 PowerQualityProfileData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityProfileData)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1