@Test public void HandleTerminateKeyEstablishment() { System.out.println("--- " + Thread.currentThread().getStackTrace()[1].getMethodName()); SmartEnergyClient seClient = Mockito.mock(SmartEnergyClient.class); ZclKeyEstablishmentCluster keCluster = Mockito.mock(ZclKeyEstablishmentCluster.class); IeeeAddress ieeeAddress = Mockito.mock(IeeeAddress.class); ZclKeyEstablishmentClient keClient = new ZclKeyEstablishmentClient(ieeeAddress, seClient, keCluster); TerminateKeyEstablishment command = new TerminateKeyEstablishment( KeyEstablishmentStatusEnum.BAD_MESSAGE.getKey(), 1, 1); command.setCommandDirection(ZclCommandDirection.SERVER_TO_CLIENT); assertTrue(keClient.commandReceived(command)); command = new TerminateKeyEstablishment(KeyEstablishmentStatusEnum.UNKNOWN_ISSUER.getKey(), 1, 1); command.setCommandDirection(ZclCommandDirection.SERVER_TO_CLIENT); assertTrue(keClient.commandReceived(command)); command.setCommandDirection(ZclCommandDirection.CLIENT_TO_SERVER); assertFalse(keClient.commandReceived(command)); }
@Override public boolean commandReceived(ZclCommand command) { Runnable handler = null; if (command.getCommandDirection() != ZclCommandDirection.SERVER_TO_CLIENT) { return false; } if (command instanceof InitiateKeyEstablishmentResponse) { handler = new HandleInitiateKeyEstablishmentResponse((InitiateKeyEstablishmentResponse) command); } if (command instanceof EphemeralDataResponse) { handler = new HandleEphemeralDataResponse((EphemeralDataResponse) command); } if (command instanceof ConfirmKeyResponse) { handler = new HandleConfirmKeyResponse((ConfirmKeyResponse) command); } if (command instanceof TerminateKeyEstablishment) { handler = new HandleTerminateKeyEstablishment((TerminateKeyEstablishment) command); } if (handler != null) { executorService.submit(handler); return true; } return false; }
ZclKeyEstablishmentClient implements ZclCommandListener { @Override public boolean commandReceived(ZclCommand command) { Runnable handler = null; if (command.getCommandDirection() != ZclCommandDirection.SERVER_TO_CLIENT) { return false; } if (command instanceof InitiateKeyEstablishmentResponse) { handler = new HandleInitiateKeyEstablishmentResponse((InitiateKeyEstablishmentResponse) command); } if (command instanceof EphemeralDataResponse) { handler = new HandleEphemeralDataResponse((EphemeralDataResponse) command); } if (command instanceof ConfirmKeyResponse) { handler = new HandleConfirmKeyResponse((ConfirmKeyResponse) command); } if (command instanceof TerminateKeyEstablishment) { handler = new HandleTerminateKeyEstablishment((TerminateKeyEstablishment) command); } if (handler != null) { executorService.submit(handler); return true; } return false; } }
ZclKeyEstablishmentClient implements ZclCommandListener { @Override public boolean commandReceived(ZclCommand command) { Runnable handler = null; if (command.getCommandDirection() != ZclCommandDirection.SERVER_TO_CLIENT) { return false; } if (command instanceof InitiateKeyEstablishmentResponse) { handler = new HandleInitiateKeyEstablishmentResponse((InitiateKeyEstablishmentResponse) command); } if (command instanceof EphemeralDataResponse) { handler = new HandleEphemeralDataResponse((EphemeralDataResponse) command); } if (command instanceof ConfirmKeyResponse) { handler = new HandleConfirmKeyResponse((ConfirmKeyResponse) command); } if (command instanceof TerminateKeyEstablishment) { handler = new HandleTerminateKeyEstablishment((TerminateKeyEstablishment) command); } if (handler != null) { executorService.submit(handler); return true; } return false; } ZclKeyEstablishmentClient(IeeeAddress ieeeAddress, SmartEnergyClient smartEnergyClient,
            ZclKeyEstablishmentCluster keCluster); }
ZclKeyEstablishmentClient implements ZclCommandListener { @Override public boolean commandReceived(ZclCommand command) { Runnable handler = null; if (command.getCommandDirection() != ZclCommandDirection.SERVER_TO_CLIENT) { return false; } if (command instanceof InitiateKeyEstablishmentResponse) { handler = new HandleInitiateKeyEstablishmentResponse((InitiateKeyEstablishmentResponse) command); } if (command instanceof EphemeralDataResponse) { handler = new HandleEphemeralDataResponse((EphemeralDataResponse) command); } if (command instanceof ConfirmKeyResponse) { handler = new HandleConfirmKeyResponse((ConfirmKeyResponse) command); } if (command instanceof TerminateKeyEstablishment) { handler = new HandleTerminateKeyEstablishment((TerminateKeyEstablishment) command); } if (handler != null) { executorService.submit(handler); return true; } return false; } ZclKeyEstablishmentClient(IeeeAddress ieeeAddress, SmartEnergyClient smartEnergyClient,
            ZclKeyEstablishmentCluster keCluster); void setCbkeProvider(ZigBeeCbkeProvider cbkeProvider); boolean setCryptoSuite(ZigBeeCryptoSuites requestedCryptoSuite); ZigBeeCryptoSuites getCryptoSuite(); boolean start(); void shutdown(); void stop(); @Override boolean commandReceived(ZclCommand command); }
ZclKeyEstablishmentClient implements ZclCommandListener { @Override public boolean commandReceived(ZclCommand command) { Runnable handler = null; if (command.getCommandDirection() != ZclCommandDirection.SERVER_TO_CLIENT) { return false; } if (command instanceof InitiateKeyEstablishmentResponse) { handler = new HandleInitiateKeyEstablishmentResponse((InitiateKeyEstablishmentResponse) command); } if (command instanceof EphemeralDataResponse) { handler = new HandleEphemeralDataResponse((EphemeralDataResponse) command); } if (command instanceof ConfirmKeyResponse) { handler = new HandleConfirmKeyResponse((ConfirmKeyResponse) command); } if (command instanceof TerminateKeyEstablishment) { handler = new HandleTerminateKeyEstablishment((TerminateKeyEstablishment) command); } if (handler != null) { executorService.submit(handler); return true; } return false; } ZclKeyEstablishmentClient(IeeeAddress ieeeAddress, SmartEnergyClient smartEnergyClient,
            ZclKeyEstablishmentCluster keCluster); void setCbkeProvider(ZigBeeCbkeProvider cbkeProvider); boolean setCryptoSuite(ZigBeeCryptoSuites requestedCryptoSuite); ZigBeeCryptoSuites getCryptoSuite(); boolean start(); void shutdown(); void stop(); @Override boolean commandReceived(ZclCommand command);  }