@Test public void commandReceived() { ZigBeeTransactionManager transactionManager = Mockito.mock(ZigBeeTransactionManager.class); ZigBeeCommand command = createCommand(false); ZigBeeTransactionFuture transactionFuture = new ZigBeeTransactionFuture(Mockito.mock(ZigBeeTransaction.class)); ZigBeeCommand matchRequest = createCommand(false); ZigBeeCommand nomatchRequest = createCommand(false); ZigBeeTransactionMatcher matcher = Mockito.mock(ZigBeeTransactionMatcher.class); Mockito.when(matcher.isTransactionMatch(command, matchRequest)).thenReturn(true); Mockito.when(matcher.isTransactionMatch(command, nomatchRequest)).thenReturn(false); ZigBeeTransaction transaction = new ZigBeeTransaction(transactionManager, command, matcher); transaction.setFuture(transactionFuture); assertEquals(transactionFuture, transaction.getFuture()); transaction.commandReceived(nomatchRequest); assertFalse(transactionFuture.isDone()); assertFalse(transactionFuture.isCancelled()); transaction.commandReceived(matchRequest); assertTrue(transactionFuture.isDone()); assertFalse(transactionFuture.isCancelled()); }
public void commandReceived(ZigBeeCommand receivedCommand) { if (responseMatcher == null) { return; } synchronized (command) { if (Objects.equals(command.getTransactionId(), receivedCommand.getTransactionId()) && responseMatcher.isTransactionMatch(command, receivedCommand)) { if (state == TransactionState.TRANSMITTED) { state = TransactionState.RESPONDED; completionCommand = receivedCommand; logger.debug("Transaction response received - waiting TX_ACK: {}", this); } else { completeTransaction(receivedCommand); } } } }
ZigBeeTransaction { public void commandReceived(ZigBeeCommand receivedCommand) { if (responseMatcher == null) { return; } synchronized (command) { if (Objects.equals(command.getTransactionId(), receivedCommand.getTransactionId()) && responseMatcher.isTransactionMatch(command, receivedCommand)) { if (state == TransactionState.TRANSMITTED) { state = TransactionState.RESPONDED; completionCommand = receivedCommand; logger.debug("Transaction response received - waiting TX_ACK: {}", this); } else { completeTransaction(receivedCommand); } } } } }
ZigBeeTransaction { public void commandReceived(ZigBeeCommand receivedCommand) { if (responseMatcher == null) { return; } synchronized (command) { if (Objects.equals(command.getTransactionId(), receivedCommand.getTransactionId()) && responseMatcher.isTransactionMatch(command, receivedCommand)) { if (state == TransactionState.TRANSMITTED) { state = TransactionState.RESPONDED; completionCommand = receivedCommand; logger.debug("Transaction response received - waiting TX_ACK: {}", this); } else { completeTransaction(receivedCommand); } } } } ZigBeeTransaction(ZigBeeTransactionManager transactionManager, final ZigBeeCommand command,
            final ZigBeeTransactionMatcher responseMatcher); }
ZigBeeTransaction { public void commandReceived(ZigBeeCommand receivedCommand) { if (responseMatcher == null) { return; } synchronized (command) { if (Objects.equals(command.getTransactionId(), receivedCommand.getTransactionId()) && responseMatcher.isTransactionMatch(command, receivedCommand)) { if (state == TransactionState.TRANSMITTED) { state = TransactionState.RESPONDED; completionCommand = receivedCommand; logger.debug("Transaction response received - waiting TX_ACK: {}", this); } else { completeTransaction(receivedCommand); } } } } ZigBeeTransaction(ZigBeeTransactionManager transactionManager, final ZigBeeCommand command,
            final ZigBeeTransactionMatcher responseMatcher); void setTransactionId(int transactionId); Integer getTransactionId(); int getTimerPeriod1(); void setTimerPeriod1(int timeout); int getTimerPeriod2(); void setTimerPeriod2(int timeout); IeeeAddress getIeeeAddress(); void setIeeeAddress(IeeeAddress ieeeAddress); void commandReceived(ZigBeeCommand receivedCommand); void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId); @Override String toString(); }
ZigBeeTransaction { public void commandReceived(ZigBeeCommand receivedCommand) { if (responseMatcher == null) { return; } synchronized (command) { if (Objects.equals(command.getTransactionId(), receivedCommand.getTransactionId()) && responseMatcher.isTransactionMatch(command, receivedCommand)) { if (state == TransactionState.TRANSMITTED) { state = TransactionState.RESPONDED; completionCommand = receivedCommand; logger.debug("Transaction response received - waiting TX_ACK: {}", this); } else { completeTransaction(receivedCommand); } } } } ZigBeeTransaction(ZigBeeTransactionManager transactionManager, final ZigBeeCommand command,
            final ZigBeeTransactionMatcher responseMatcher); void setTransactionId(int transactionId); Integer getTransactionId(); int getTimerPeriod1(); void setTimerPeriod1(int timeout); int getTimerPeriod2(); void setTimerPeriod2(int timeout); IeeeAddress getIeeeAddress(); void setIeeeAddress(IeeeAddress ieeeAddress); void commandReceived(ZigBeeCommand receivedCommand); void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId); @Override String toString();  }