@Test public void testGet() { assertNotNull(blockQueueProvider); assertEquals(0, blockQueueProvider.size()); if(downloadService.isDownloadSuccess().isSuccess()) { downloadService.setDownloadSuccess(false); } Block block = new Block(); boolean result = blockQueueProvider.put(new BlockContainer(block, BlockContainerStatus.RECEIVED)); assertTrue(result); assertEquals(1, blockQueueProvider.size()); BlockContainer blockContainer = blockQueueProvider.get(); assertNull(blockContainer); downloadService.setDownloadSuccess(true); blockContainer = blockQueueProvider.get(); assertNotNull(blockContainer); assertEquals(blockContainer.getBlock(), block); assertEquals(blockContainer.getStatus(), BlockContainerStatus.DOWNLOADING); assertEquals(0, blockQueueProvider.size()); block = new Block(); result = blockQueueProvider.put(new BlockContainer(block, BlockContainerStatus.RECEIVED)); assertTrue(result); blockContainer = blockQueueProvider.get(); assertNotNull(blockContainer); assertEquals(blockContainer.getBlock(), block); assertEquals(blockContainer.getStatus(), BlockContainerStatus.RECEIVED); }
public BlockContainer get() { BlockContainer blockContainer = null; if (!downloadBlockQueueHasDestory) { blockContainer = downloadBlockQueue.poll(); } checkDownloadService(); boolean hasDownloadSuccess = downloadService.isDownloadSuccess().isSuccess(); if (blockContainer == null && hasDownloadSuccess && !downloadBlockQueueHasDestory) { downloadBlockQueueHasDestory = true; if (blockContainer == null) { blockContainer = blockQueue.poll(); } } else if (hasDownloadSuccess && blockContainer == null) { blockContainer = blockQueue.poll(); } return blockContainer; }
BlockQueueProvider { public BlockContainer get() { BlockContainer blockContainer = null; if (!downloadBlockQueueHasDestory) { blockContainer = downloadBlockQueue.poll(); } checkDownloadService(); boolean hasDownloadSuccess = downloadService.isDownloadSuccess().isSuccess(); if (blockContainer == null && hasDownloadSuccess && !downloadBlockQueueHasDestory) { downloadBlockQueueHasDestory = true; if (blockContainer == null) { blockContainer = blockQueue.poll(); } } else if (hasDownloadSuccess && blockContainer == null) { blockContainer = blockQueue.poll(); } return blockContainer; } }
BlockQueueProvider { public BlockContainer get() { BlockContainer blockContainer = null; if (!downloadBlockQueueHasDestory) { blockContainer = downloadBlockQueue.poll(); } checkDownloadService(); boolean hasDownloadSuccess = downloadService.isDownloadSuccess().isSuccess(); if (blockContainer == null && hasDownloadSuccess && !downloadBlockQueueHasDestory) { downloadBlockQueueHasDestory = true; if (blockContainer == null) { blockContainer = blockQueue.poll(); } } else if (hasDownloadSuccess && blockContainer == null) { blockContainer = blockQueue.poll(); } return blockContainer; } private  BlockQueueProvider(); }
BlockQueueProvider { public BlockContainer get() { BlockContainer blockContainer = null; if (!downloadBlockQueueHasDestory) { blockContainer = downloadBlockQueue.poll(); } checkDownloadService(); boolean hasDownloadSuccess = downloadService.isDownloadSuccess().isSuccess(); if (blockContainer == null && hasDownloadSuccess && !downloadBlockQueueHasDestory) { downloadBlockQueueHasDestory = true; if (blockContainer == null) { blockContainer = blockQueue.poll(); } } else if (hasDownloadSuccess && blockContainer == null) { blockContainer = blockQueue.poll(); } return blockContainer; } private  BlockQueueProvider(); static BlockQueueProvider getInstance(); boolean put(BlockContainer blockContainer); BlockContainer get(); long size(); void clear(); }
BlockQueueProvider { public BlockContainer get() { BlockContainer blockContainer = null; if (!downloadBlockQueueHasDestory) { blockContainer = downloadBlockQueue.poll(); } checkDownloadService(); boolean hasDownloadSuccess = downloadService.isDownloadSuccess().isSuccess(); if (blockContainer == null && hasDownloadSuccess && !downloadBlockQueueHasDestory) { downloadBlockQueueHasDestory = true; if (blockContainer == null) { blockContainer = blockQueue.poll(); } } else if (hasDownloadSuccess && blockContainer == null) { blockContainer = blockQueue.poll(); } return blockContainer; } private  BlockQueueProvider(); static BlockQueueProvider getInstance(); boolean put(BlockContainer blockContainer); BlockContainer get(); long size(); void clear();  }