ClientConnectionEventListener implements ConnectionEventListener { @Override public void newASdu(final ASdu asdu) { LOGGER.info("Received incoming ASDU {} from device {}", asdu, this.deviceIdentification); try { final ClientAsduHandler asduHandler = this.asduHandlerRegistry.getHandler(asdu); asduHandler.handleAsdu(asdu, this.responseMetadata); } catch (final Iec60870AsduHandlerNotFoundException e) { LOGGER.error("Unknown request received, no handler available for ASDU: {}", asdu, e); } catch (final Exception e) { LOGGER.error("Exception occurred while handling an incoming ASDU from device {}.", this.deviceIdentification, e); } } ClientConnectionEventListener(final String deviceIdentification, final ClientConnectionCache connectionCache,
            final ClientAsduHandlerRegistry asduHandlerRegistry, final ResponseMetadata responseMetadata); @Override void newASdu(final ASdu asdu); @Override void connectionClosed(final IOException e);  }
@Test public void shouldHandleAsduWhenNewAsduIsReceived() throws Exception { final ASdu asdu = AsduFactory.ofType(ASduType.C_IC_NA_1); when(this.asduHandlerRegistry.getHandler(asdu)).thenReturn(this.asduHandler); this.clientConnectionEventListener.newASdu(asdu); verify(this.asduHandler).handleAsdu(asdu, this.responseMetadata); }