ClientConnectionService { public synchronized void close(final ClientConnection connection) { final String deviceIdentification = connection.getConnectionParameters().getDeviceIdentification(); if (connection instanceof DeviceConnection) { this.iec60870Client.disconnect(connection); this.connectionCache.removeConnection(deviceIdentification); } else { LOGGER.warn("No connection found for deviceIdentification {}", deviceIdentification); } }  ClientConnection getConnection(final RequestMetadata requestMetadata); void closeConnection(final String deviceIdentification); synchronized void close(final ClientConnection connection); @PreDestroy void closeAllConnections();  }
@Test void testDisconnectByClientConnection() throws Exception { final String deviceIdentification = "DA_DVC_1"; final ClientConnection clientConnection = ClientConnectionFactory.forDevice(deviceIdentification); this.connectionCache.addConnection(deviceIdentification, clientConnection); this.clientConnectionService.close(clientConnection); verify(this.iec60870Client).disconnect(clientConnection); verify(this.connectionCache).removeConnection(deviceIdentification); }