### Question:
TransactionManager { boolean addTransactionAndGetReadyToSend(CoapTransaction transaction) throws TooManyRequestsForEndpointException { return addTransactionAndGetReadyToSend(transaction, false); }  void setMaximumEndpointQueueSize(int maximumEndpointQueueSize); @SuppressWarnings("PMD.PrematureDeclaration") //false positive boolean addTransactionAndGetReadyToSend(CoapTransaction transaction, boolean forceAdd); Optional<CoapTransaction> removeAndLock(CoapTransactionId transId); Optional<CoapTransaction> unlockOrRemoveAndGetNext(CoapTransactionId transId); int getNumberOfTransactions(); Optional<CoapTransaction> findMatchAndRemoveForSeparateResponse(CoapPacket req); Collection<CoapTransaction> findTimeoutTransactions(final long currentTime); void close();  }### Answer:
@Test public void test_findMatchForSeparateResponse() throws Exception { CoapPacket request = newCoapPacket(REMOTE_ADR).mid(1).con().get().token(123).uriPath("/test").build(); CoapPacket requestInactive = newCoapPacket(REMOTE_ADR).mid(2).con().get().token(456).uriPath("/test").build(); CoapTransaction activeTrans = new CoapTransaction(mock(RequestCallback.class), request, mock(CoapUdpMessaging.class), TransportContext.NULL, mock(Consumer.class)).makeActiveForTests(); assertTrue(transMgr.addTransactionAndGetReadyToSend(activeTrans)); CoapTransaction inactiveTrans = new CoapTransaction(mock(RequestCallback.class), requestInactive, mock(CoapUdpMessaging.class), TransportContext.NULL, mock(Consumer.class)); assertFalse(transMgr.addTransactionAndGetReadyToSend(inactiveTrans)); assertMatch(newCoapPacket(REMOTE_ADR).mid(12).con(Code.C205_CONTENT).token(123).build(), activeTrans); assertNoMatch(newCoapPacket(REMOTE_ADR).mid(12).non(Code.C205_CONTENT).token(123).build()); assertNoMatch(newCoapPacket(REMOTE_ADR).mid(13).con(Code.C205_CONTENT).token(456).build()); assertNoMatch(newCoapPacket(REMOTE_ADR).mid(12).ack(Code.C205_CONTENT).token(123).build()); assertNoMatch(newCoapPacket(REMOTE_ADR).mid(12).con(Code.C205_CONTENT).token(12).build()); assertNoMatch(newCoapPacket(InMemoryCoapTransport.createAddress(61616)).mid(12).con(Code.C205_CONTENT).token(123).build()); assertNoMatch(newCoapPacket(REMOTE_ADR).mid(12).con().get().token(123).build()); }
@Test public void test_findMatchForSeparateResponse_emptyToken() throws Exception { CoapPacket request = newCoapPacket(REMOTE_ADR).mid(1).con().get().uriPath("/test").build(); assertTrue(transMgr.addTransactionAndGetReadyToSend(new CoapTransaction(mock(RequestCallback.class), request, mock(CoapUdpMessaging.class), TransportContext.NULL, mock(Consumer.class)))); assertNoMatch(newCoapPacket(REMOTE_ADR).mid(12).con(Code.C205_CONTENT).build()); }