Search in sources :

Example 1 with PeriodicMeterReadsResponse

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

the class SmartMeteringMonitoringEndpoint method getPeriodicMeterReadsResponse.

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

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

the class PeriodicMeterReadsContainerMappingTest method testWithEmptyList.

/**
 * Tests the mapping of a PeriodMeterReadsContainer object with an empty List.
 */
@Test
public void testWithEmptyList() {
    // build test data
    final List<PeriodicMeterReads> periodicMeterReadsList = new ArrayList<>();
    final PeriodicMeterReadsContainer periodicMeterReadsContainer = new PeriodicMeterReadsContainer(PERIODTYPE, periodicMeterReadsList);
    // actual mapping
    final PeriodicMeterReadsResponse periodicMeterReadsResponse = this.monitoringMapper.map(periodicMeterReadsContainer, PeriodicMeterReadsResponse.class);
    // check mapping
    assertThat(periodicMeterReadsResponse).isNotNull();
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().isEmpty()).isTrue();
    assertThat(periodicMeterReadsResponse.getPeriodType().name()).isEqualTo(PERIODTYPE.name());
}
Also used : PeriodicMeterReadsContainer(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer) ArrayList(java.util.ArrayList) PeriodicMeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads) PeriodicMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse) Test(org.junit.jupiter.api.Test)

Example 3 with PeriodicMeterReadsResponse

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

the class PeriodicMeterReadsSteps method theMeterReadsResultShouldBeReturned.

@Then("^the \"([^\"]*)\" meter reads result should be returned$")
public void theMeterReadsResultShouldBeReturned(final String periodType, final Map<String, String> settings) throws Throwable {
    final PeriodicMeterReadsAsyncRequest asyncRequest = PeriodicMeterReadsRequestFactory.fromScenarioContext();
    final PeriodicMeterReadsResponse response = this.responseClient.getResponse(asyncRequest);
    assertThat(response).as("PeriodicMeterReadsGasResponse should not be null").isNotNull();
    assertThat(response.getPeriodType()).as("PeriodType should match").isEqualTo(PeriodType.fromValue(periodType));
    assertThat(response.getPeriodicMeterReads()).as("Expected periodic meter reads gas").isNotNull();
}
Also used : PeriodicMeterReadsAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsAsyncRequest) PeriodicMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse) Then(io.cucumber.java.en.Then)

Example 4 with PeriodicMeterReadsResponse

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

the class PeriodicMeterReadsContainerMappingTest method testMappingWithFilledListAndSet.

/**
 * Tests the mapping of a PeriodicMeterReadsContainer object with a filled List and Set.
 */
@Test
public void testMappingWithFilledListAndSet() {
    // build test data
    final OsgpMeterValue osgpMeterValue = new OsgpMeterValue(VALUE, OSGP_UNIT);
    final Set<AmrProfileStatusCodeFlag> flagSet = new TreeSet<>();
    flagSet.add(AMRCODEFLAG);
    final AmrProfileStatusCode amrProfileStatusCode = new AmrProfileStatusCode(flagSet);
    final PeriodicMeterReads periodicMeterReads = new PeriodicMeterReads(DATE, osgpMeterValue, osgpMeterValue, amrProfileStatusCode);
    final List<PeriodicMeterReads> periodicMeterReadsList = new ArrayList<>();
    periodicMeterReadsList.add(periodicMeterReads);
    final PeriodicMeterReadsContainer periodicMeterReadsContainer = new PeriodicMeterReadsContainer(PERIODTYPE, periodicMeterReadsList);
    // actual mapping
    final PeriodicMeterReadsResponse periodicMeterReadsResponse = this.monitoringMapper.map(periodicMeterReadsContainer, PeriodicMeterReadsResponse.class);
    // check mapping
    assertThat(periodicMeterReadsResponse).isNotNull();
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads()).isNotNull();
    assertThat(periodicMeterReadsResponse.getPeriodType()).isNotNull();
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0)).isNotNull();
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyExport()).isNotNull();
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyImport()).isNotNull();
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getAmrProfileStatusCode()).isNotNull();
    assertThat(periodicMeterReadsResponse.getPeriodType().name()).isEqualTo(PERIODTYPE.name());
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().size()).isEqualTo(periodicMeterReadsList.size());
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyImport().getValue()).isEqualTo(VALUE);
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyImport().getUnit().name()).isEqualTo(OSGP_UNITTYPE.name());
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyExport().getValue()).isEqualTo(VALUE);
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyExport().getUnit().name()).isEqualTo(OSGP_UNITTYPE.name());
    assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlag().get(0).name()).isEqualTo(AMRCODEFLAG.name());
// For more information on the mapping of Date to XmlGregorianCalendar
// objects, refer to the DateMappingTest
}
Also used : AmrProfileStatusCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode) TreeSet(java.util.TreeSet) PeriodicMeterReadsContainer(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer) ArrayList(java.util.ArrayList) AmrProfileStatusCodeFlag(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCodeFlag) PeriodicMeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads) PeriodicMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse) OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) Test(org.junit.jupiter.api.Test)

Aggregations

PeriodicMeterReadsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse)4 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 PeriodicMeterReads (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads)2 PeriodicMeterReadsContainer (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer)2 Then (io.cucumber.java.en.Then)1 TreeSet (java.util.TreeSet)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 PeriodicMeterReadsAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsAsyncRequest)1 AmrProfileStatusCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode)1 AmrProfileStatusCodeFlag (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCodeFlag)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