Search in sources :

Example 1 with ActualMeterReadsResponse

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

the class ActualMeterReadsSteps method theGetActualMeterReadsRequestGeneratingAnErrorIsReceived.

@When("^the get actual meter reads request generating an error is received$")
public void theGetActualMeterReadsRequestGeneratingAnErrorIsReceived(final Map<String, String> settings) throws Throwable {
    final ActualMeterReadsRequest request = ActualMeterReadsRequestFactory.fromParameterMap(settings);
    final ActualMeterReadsAsyncResponse asyncResponse = this.requestClient.doRequest(request);
    ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, asyncResponse.getCorrelationUid());
    final ActualMeterReadsAsyncRequest actualMeterReadsAsyncRequest = ActualMeterReadsRequestFactory.fromScenarioContext();
    assertThat(actualMeterReadsAsyncRequest).as("ActualMeterReadsAsyncRequest should not be null").isNotNull();
    try {
        final ActualMeterReadsResponse response = this.responseClient.getResponse(actualMeterReadsAsyncRequest);
        fail("Expected exception, but got a response: %s", response.toString());
    } catch (final Exception exception) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, exception);
    }
}
Also used : ActualMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsResponse) ActualMeterReadsRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsRequest) ActualMeterReadsAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsAsyncRequest) ActualMeterReadsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsAsyncResponse) When(io.cucumber.java.en.When)

Example 2 with ActualMeterReadsResponse

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

the class SmartMeteringMonitoringEndpoint method getActualMeterReadsResponse.

@PayloadRoot(localPart = "ActualMeterReadsAsyncRequest", namespace = SMARTMETER_MONITORING_NAMESPACE)
@ResponsePayload
public ActualMeterReadsResponse getActualMeterReadsResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ActualMeterReadsAsyncRequest request) throws OsgpException {
    log.debug("Incoming ActualMeterReadsAsyncRequest for meter: {}", request.getDeviceIdentification());
    ActualMeterReadsResponse response = null;
    try {
        final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), MeterReads.class, ComponentType.WS_SMART_METERING);
        this.throwExceptionIfResultNotOk(responseData, "retrieving the actual meter reads");
        response = this.monitoringMapper.map(responseData.getMessageData(), ActualMeterReadsResponse.class);
    } catch (final Exception e) {
        this.handleRetrieveException(e, request, organisationIdentification);
    }
    return response;
}
Also used : ActualMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsResponse) 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 ActualMeterReadsResponse

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

the class MeterReadsMappingTest method testMeterReadsMapping.

/**
 * Tests if a MeterReads object can be mapped.
 */
@Test
public void testMeterReadsMapping() {
    // build test data
    final OsgpMeterValue osgpMeterValue = new OsgpMeterValue(VALUE, OSGP_UNIT);
    final MeterReads meterReads = new MeterReads(DATE, new ActiveEnergyValues(osgpMeterValue, osgpMeterValue, osgpMeterValue, osgpMeterValue, osgpMeterValue, osgpMeterValue));
    // actual mapping
    final ActualMeterReadsResponse actualMeterReadsResponse = this.monitoringMapper.map(meterReads, ActualMeterReadsResponse.class);
    // check mapping
    assertThat(actualMeterReadsResponse).isNotNull();
    assertThat(actualMeterReadsResponse.getLogTime()).isNotNull();
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyExport());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyExportTariffOne());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyExportTariffTwo());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyImport());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyImportTariffOne());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyImportTariffTwo());
// For more information on the mapping of Date to XmlGregorianCalendar
// objects, refer to the DateMappingTest
}
Also used : ActualMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsResponse) MeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReads) ActiveEnergyValues(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues) OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) Test(org.junit.jupiter.api.Test)

Example 4 with ActualMeterReadsResponse

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

the class ActualMeterReadsSteps method theActualMeterReadsResultShouldBeReturned.

@Then("^the actual meter reads result should be returned$")
public void theActualMeterReadsResultShouldBeReturned(final Map<String, String> settings) throws Throwable {
    final ActualMeterReadsAsyncRequest asyncRequest = ActualMeterReadsRequestFactory.fromScenarioContext();
    final ActualMeterReadsResponse response = this.responseClient.getResponse(asyncRequest);
    assertThat(response).as("ActualMeterReadsResponse should not be null").isNotNull();
    assertThat(response.getActiveEnergyExport()).as("ActiveEnergyExport should not be null").isNotNull();
    assertThat(response.getActiveEnergyExportTariffOne()).as("ActiveEnergyExportTariffOne should not be null").isNotNull();
    assertThat(response.getActiveEnergyExportTariffTwo()).as("ActiveEnergyExportTariffTwo should not be null").isNotNull();
    assertThat(response.getActiveEnergyImport()).as("ActiveEnergyImport should not be null").isNotNull();
    assertThat(response.getActiveEnergyImportTariffOne()).as("ActiveEnergyImportTariffOne should not be null").isNotNull();
    assertThat(response.getActiveEnergyImportTariffTwo()).as("ActiveEnergyimportTariffTwo should not be null").isNotNull();
    assertThat(response.getLogTime()).as("LogTime should not be null").isNotNull();
}
Also used : ActualMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsResponse) ActualMeterReadsAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsAsyncRequest) Then(io.cucumber.java.en.Then)

Aggregations

ActualMeterReadsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsResponse)4 ActualMeterReadsAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsAsyncRequest)2 Then (io.cucumber.java.en.Then)1 When (io.cucumber.java.en.When)1 Test (org.junit.jupiter.api.Test)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 ActualMeterReadsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsAsyncResponse)1 ActualMeterReadsRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsRequest)1 ActiveEnergyValues (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues)1 MeterReads (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReads)1 OsgpMeterValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue)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