@Test public void processShouldDelegateProcessingReportsForEachDeviceBehindTheGateway() { final Iec60870Device gatewayDevice = fromSettings(this.getGatewayDeviceSettings()); final Iec60870Device lightMeasurementDevice1 = fromSettings(this.getLightMeasurementDevice1Settings()); final Iec60870Device lightMeasurementDevice2 = fromSettings(this.getLightMeasurementDevice2Settings()); when(this.iec60870DeviceRepository.findByGatewayDeviceIdentification(gatewayDevice.getDeviceIdentification())) .thenReturn(Arrays.asList(lightMeasurementDevice1, lightMeasurementDevice2)); final MeasurementReportDto measurementReportDto = this.getMeasurementReportDto(); final ResponseMetadata responseMetadata = this.getResponseMetadata(GATEWAY_DEVICE_IDENTIFICATION); this.lightMeasurementGatewayDeviceResponseService.process(measurementReportDto, responseMetadata); verify(this.lightMeasurementDeviceResponseService, times(1)).sendLightSensorStatusResponse( same(measurementReportDto), same(lightMeasurementDevice1), same(responseMetadata), anyString()); verify(this.lightMeasurementDeviceResponseService, times(1)).sendLightSensorStatusResponse( same(measurementReportDto), same(lightMeasurementDevice2), same(responseMetadata), anyString()); }
@Override public void process(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata) { final String gatewayDeviceIdentification = responseMetadata.getDeviceIdentification(); LOGGER.info("Received measurement report {} for light measurement gateway {}.", measurementReport, gatewayDeviceIdentification); this.findLightMeasurementDevicesAndThen(gatewayDeviceIdentification, device -> this.processMeasurementReportForDevice(measurementReport, responseMetadata, device, gatewayDeviceIdentification)); }
LightMeasurementGatewayDeviceResponseService extends AbstractDeviceResponseService { @Override public void process(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata) { final String gatewayDeviceIdentification = responseMetadata.getDeviceIdentification(); LOGGER.info("Received measurement report {} for light measurement gateway {}.", measurementReport, gatewayDeviceIdentification); this.findLightMeasurementDevicesAndThen(gatewayDeviceIdentification, device -> this.processMeasurementReportForDevice(measurementReport, responseMetadata, device, gatewayDeviceIdentification)); } }
LightMeasurementGatewayDeviceResponseService extends AbstractDeviceResponseService { @Override public void process(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata) { final String gatewayDeviceIdentification = responseMetadata.getDeviceIdentification(); LOGGER.info("Received measurement report {} for light measurement gateway {}.", measurementReport, gatewayDeviceIdentification); this.findLightMeasurementDevicesAndThen(gatewayDeviceIdentification, device -> this.processMeasurementReportForDevice(measurementReport, responseMetadata, device, gatewayDeviceIdentification)); } LightMeasurementGatewayDeviceResponseService(); }
LightMeasurementGatewayDeviceResponseService extends AbstractDeviceResponseService { @Override public void process(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata) { final String gatewayDeviceIdentification = responseMetadata.getDeviceIdentification(); LOGGER.info("Received measurement report {} for light measurement gateway {}.", measurementReport, gatewayDeviceIdentification); this.findLightMeasurementDevicesAndThen(gatewayDeviceIdentification, device -> this.processMeasurementReportForDevice(measurementReport, responseMetadata, device, gatewayDeviceIdentification)); } LightMeasurementGatewayDeviceResponseService(); @Override void process(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata); @Override void processEvent(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata); }
LightMeasurementGatewayDeviceResponseService extends AbstractDeviceResponseService { @Override public void process(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata) { final String gatewayDeviceIdentification = responseMetadata.getDeviceIdentification(); LOGGER.info("Received measurement report {} for light measurement gateway {}.", measurementReport, gatewayDeviceIdentification); this.findLightMeasurementDevicesAndThen(gatewayDeviceIdentification, device -> this.processMeasurementReportForDevice(measurementReport, responseMetadata, device, gatewayDeviceIdentification)); } LightMeasurementGatewayDeviceResponseService(); @Override void process(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata); @Override void processEvent(final MeasurementReportDto measurementReport, final ResponseMetadata responseMetadata);  }