AsyncBroker { public NoticeableFuture<V> take(K key) { return _defaultNoticeableFutures.remove(key); }  Map<K, NoticeableFuture<V>> getOpenBids(); NoticeableFuture<V> post(K key); NoticeableFuture<V> post(K key, boolean[] newMarker); NoticeableFuture<V> take(K key); boolean takeWithException(K key, Throwable throwable); boolean takeWithResult(K key, V result);  }
@Test public void testTake() { AsyncBroker<String, String> asyncBroker = new AsyncBroker<>(); Map<String, DefaultNoticeableFuture<String>> defaultNoticeableFutures = ReflectionTestUtil.getFieldValue( asyncBroker, "_defaultNoticeableFutures"); Assert.assertTrue( defaultNoticeableFutures.toString(), defaultNoticeableFutures.isEmpty()); Assert.assertNull(asyncBroker.take(_KEY)); NoticeableFuture<String> noticeableFuture = asyncBroker.post(_KEY); Assert.assertEquals( defaultNoticeableFutures.toString(), 1, defaultNoticeableFutures.size()); Assert.assertSame(noticeableFuture, defaultNoticeableFutures.get(_KEY)); Assert.assertSame(noticeableFuture, asyncBroker.take(_KEY)); Assert.assertTrue( defaultNoticeableFutures.toString(), defaultNoticeableFutures.isEmpty()); Assert.assertNull(asyncBroker.take(_KEY)); Assert.assertTrue(noticeableFuture.cancel(true)); }