@Test public void shouldSendMeasurementReportAndLogItemWhenHandlingAsdu() throws Exception { final ASdu asdu = AsduFactory.ofType(ASduType.M_ME_TF_1); final MeasurementReportDto measurementReportDto = this.mapper.map(asdu, MeasurementReportDto.class); final ResponseMetadata responseMetadata = new ResponseMetadata.Builder().withCorrelationUid(CORRELATION_UID) .withDeviceIdentification(DEVICE_IDENTIFICATION) .withDeviceType(DEVICE_TYPE) .withOrganisationIdentification(ORGANISATION_IDENTIFICATION) .build(); final LogItem logItem = new LogItem(DEVICE_IDENTIFICATION, ORGANISATION_IDENTIFICATION, true, asdu.toString()); when(this.responseMetadataFactory.createWithNewCorrelationUid(responseMetadata)).thenReturn(responseMetadata); when(this.converter.convert(asdu)).thenReturn(measurementReportDto); when(this.deviceResponseServiceRegistry.forDeviceType(DEVICE_TYPE)).thenReturn(this.deviceResponseService); when(this.logItemFactory.create(asdu, responseMetadata, true)).thenReturn(logItem); this.asduHandler.handleAsdu(asdu, responseMetadata); verify(this.deviceResponseService).process(measurementReportDto, responseMetadata); verify(this.loggingService).log(logItem); }
@Override public void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata) { LOGGER.info("Received measurement of type {}.", asdu.getTypeIdentification()); final ResponseMetadata newResponseMetadata = this.responseMetadataFactory .createWithNewCorrelationUid(responseMetadata); final MeasurementReportDto measurementReportDto = this.converter.convert(asdu); this.deviceResponseServiceRegistry.forDeviceType(responseMetadata.getDeviceType()) .process(measurementReportDto, newResponseMetadata); final LogItem logItem = this.logItemFactory.create(asdu, newResponseMetadata, true); this.loggingService.log(logItem); }
MeasurementAsduHandler extends AbstractClientAsduHandler { @Override public void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata) { LOGGER.info("Received measurement of type {}.", asdu.getTypeIdentification()); final ResponseMetadata newResponseMetadata = this.responseMetadataFactory .createWithNewCorrelationUid(responseMetadata); final MeasurementReportDto measurementReportDto = this.converter.convert(asdu); this.deviceResponseServiceRegistry.forDeviceType(responseMetadata.getDeviceType()) .process(measurementReportDto, newResponseMetadata); final LogItem logItem = this.logItemFactory.create(asdu, newResponseMetadata, true); this.loggingService.log(logItem); } }
MeasurementAsduHandler extends AbstractClientAsduHandler { @Override public void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata) { LOGGER.info("Received measurement of type {}.", asdu.getTypeIdentification()); final ResponseMetadata newResponseMetadata = this.responseMetadataFactory .createWithNewCorrelationUid(responseMetadata); final MeasurementReportDto measurementReportDto = this.converter.convert(asdu); this.deviceResponseServiceRegistry.forDeviceType(responseMetadata.getDeviceType()) .process(measurementReportDto, newResponseMetadata); final LogItem logItem = this.logItemFactory.create(asdu, newResponseMetadata, true); this.loggingService.log(logItem); } MeasurementAsduHandler(final ASduType asduType); }
MeasurementAsduHandler extends AbstractClientAsduHandler { @Override public void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata) { LOGGER.info("Received measurement of type {}.", asdu.getTypeIdentification()); final ResponseMetadata newResponseMetadata = this.responseMetadataFactory .createWithNewCorrelationUid(responseMetadata); final MeasurementReportDto measurementReportDto = this.converter.convert(asdu); this.deviceResponseServiceRegistry.forDeviceType(responseMetadata.getDeviceType()) .process(measurementReportDto, newResponseMetadata); final LogItem logItem = this.logItemFactory.create(asdu, newResponseMetadata, true); this.loggingService.log(logItem); } MeasurementAsduHandler(final ASduType asduType); @Override void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata); }
MeasurementAsduHandler extends AbstractClientAsduHandler { @Override public void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata) { LOGGER.info("Received measurement of type {}.", asdu.getTypeIdentification()); final ResponseMetadata newResponseMetadata = this.responseMetadataFactory .createWithNewCorrelationUid(responseMetadata); final MeasurementReportDto measurementReportDto = this.converter.convert(asdu); this.deviceResponseServiceRegistry.forDeviceType(responseMetadata.getDeviceType()) .process(measurementReportDto, newResponseMetadata); final LogItem logItem = this.logItemFactory.create(asdu, newResponseMetadata, true); this.loggingService.log(logItem); } MeasurementAsduHandler(final ASduType asduType); @Override void handleAsdu(final ASdu asdu, final ResponseMetadata responseMetadata);  }