Iec60870InterrogationCommandAsduHandler extends Iec60870AsduHandler { @Override public void handleAsdu(final Connection connection, final ASdu asdu) throws IOException { LOGGER.info("Received interrogation command. Sending confirmation for ASDU: {}", asdu); connection.sendConfirmation(asdu); final ASdu responseAsdu = this.iec60870AsduFactory.createInterrogationCommandResponseAsdu(); LOGGER.info("Processing interrogation command. Sending response ASDU: {}.", responseAsdu); connection.send(responseAsdu); final ASdu terminationAsdu = this.iec60870AsduFactory.createActivationTerminationResponseAsdu(); LOGGER.info("Finished processing interrogation command. Sending termination ASDU: {}", terminationAsdu); connection.send(terminationAsdu); } @Autowired  Iec60870InterrogationCommandAsduHandler(final Iec60870AsduFactory iec60870AsduFactory); @Override void handleAsdu(final Connection connection, final ASdu asdu);  }
@Test void testSendingOrder() throws IOException { doNothing().when(this.connection).sendConfirmation(any(ASdu.class)); final ASdu responseAsdu = this.getAsdu(ASduType.M_SP_NA_1, CauseOfTransmission.INTERROGATED_BY_STATION); when(this.iec60870AsduFactory.createInterrogationCommandResponseAsdu()).thenReturn(responseAsdu); final ASdu terminationAsdu = this.getAsdu(ASduType.C_IC_NA_1, CauseOfTransmission.ACTIVATION_TERMINATION); when(this.iec60870AsduFactory.createActivationTerminationResponseAsdu()).thenReturn(terminationAsdu); doNothing().when(this.connection).send(any(ASdu.class)); final InOrder inOrder = inOrder(this.connection); final Iec60870InterrogationCommandAsduHandler interrogationCommandHandler = new Iec60870InterrogationCommandAsduHandler( this.iec60870AsduFactory); interrogationCommandHandler.handleAsdu(this.connection, responseAsdu); inOrder.verify(this.connection).sendConfirmation(any(ASdu.class)); inOrder.verify(this.connection).send(argThat(new AsduTypeArgumentMatcher(ASduType.M_SP_NA_1))); inOrder.verify(this.connection) .send(argThat( new AsduTypeArgumentMatcher(ASduType.C_IC_NA_1, CauseOfTransmission.ACTIVATION_TERMINATION))); inOrder.verifyNoMoreInteractions(); }