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;
}
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());
}
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();
}
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
}
Aggregations