Search in sources :

Example 1 with PeriodicMeterReadsGasResponse

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

the class SmartMeteringMonitoringEndpoint method getPeriodicMeterReadsGasResponse.

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

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

the class PeriodicMeterReadsContainerGasMappingTest method testWithFilledList.

/**
 * Tests if mapping a PeriodicMeterReadsContainerGas object with a filled List and Set succeeds.
 */
@Test
public void testWithFilledList() {
    // 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 PeriodicMeterReadsGas periodicMeterReadsGas = new PeriodicMeterReadsGas(DATE, osgpMeterValue, DATE, amrProfileStatusCode);
    final List<PeriodicMeterReadsGas> periodicMeterReadsList = new ArrayList<>();
    periodicMeterReadsList.add(periodicMeterReadsGas);
    final PeriodicMeterReadsContainerGas periodicMeterReadsContainer = new PeriodicMeterReadsContainerGas(PERIODTYPE, periodicMeterReadsList);
    // actual mapping
    final PeriodicMeterReadsGasResponse periodicMeterReadsResponseGas = this.monitoringMapper.map(periodicMeterReadsContainer, PeriodicMeterReadsGasResponse.class);
    // check mapping
    assertThat(periodicMeterReadsResponseGas).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0)).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlag()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlag().get(0)).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption().getUnit()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption().getValue()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodType().name()).isEqualTo(PERIODTYPE.name());
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().size()).isEqualTo(periodicMeterReadsList.size());
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption().getValue()).isEqualTo(VALUE);
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption().getUnit()).isEqualTo(OSGP_UNITTYPE);
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().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 : PeriodicMeterReadsGasResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasResponse) AmrProfileStatusCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) AmrProfileStatusCodeFlag(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCodeFlag) PeriodicMeterReadsGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsGas) PeriodicMeterReadsContainerGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas) OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) Test(org.junit.jupiter.api.Test)

Example 3 with PeriodicMeterReadsGasResponse

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

the class PeriodicMeterReadsGasSteps method theMeterReadsGasResultShouldBeReturned.

@Then("^the \"([^\"]*)\" meter reads gas result should be returned$")
public void theMeterReadsGasResultShouldBeReturned(final String periodType, final Map<String, String> settings) throws Throwable {
    final PeriodicMeterReadsGasAsyncRequest asyncRequest = PeriodicMeterReadsGasRequestFactory.fromScenarioContext();
    LOGGER.warn("Asyncrequest: {} ", asyncRequest);
    final PeriodicMeterReadsGasResponse 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.getPeriodicMeterReadsGas()).as("Expected periodic meter reads gas").isNotNull();
}
Also used : PeriodicMeterReadsGasResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasResponse) PeriodicMeterReadsGasAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasAsyncRequest) Then(io.cucumber.java.en.Then)

Example 4 with PeriodicMeterReadsGasResponse

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

the class PeriodicMeterReadsContainerGasMappingTest method testWithEmptyList.

/**
 * Tests if mapping a PeriodicMeterReadsContainerGas object with an empty list succeeds.
 */
@Test
public void testWithEmptyList() {
    // build test data
    final List<PeriodicMeterReadsGas> periodicMeterReadsGasList = new ArrayList<>();
    final PeriodicMeterReadsContainerGas periodicMeterReadsContainerGas = new PeriodicMeterReadsContainerGas(PERIODTYPE, periodicMeterReadsGasList);
    // actual mapping
    final PeriodicMeterReadsGasResponse periodicMeterReadsGasResponse = this.monitoringMapper.map(periodicMeterReadsContainerGas, PeriodicMeterReadsGasResponse.class);
    // check mapping
    assertThat(periodicMeterReadsGasResponse).isNotNull();
    assertThat(periodicMeterReadsGasResponse.getPeriodicMeterReadsGas()).isNotNull();
    assertThat(periodicMeterReadsGasResponse.getPeriodType()).isNotNull();
    assertThat(periodicMeterReadsGasResponse.getPeriodicMeterReadsGas().isEmpty()).isTrue();
    assertThat(periodicMeterReadsGasResponse.getPeriodType().name()).isEqualTo(PERIODTYPE.name());
}
Also used : PeriodicMeterReadsGasResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasResponse) ArrayList(java.util.ArrayList) PeriodicMeterReadsGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsGas) PeriodicMeterReadsContainerGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas) Test(org.junit.jupiter.api.Test)

Aggregations

PeriodicMeterReadsGasResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasResponse)4 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 PeriodicMeterReadsContainerGas (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas)2 PeriodicMeterReadsGas (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsGas)2 Then (io.cucumber.java.en.Then)1 TreeSet (java.util.TreeSet)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 PeriodicMeterReadsGasAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasAsyncRequest)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