public final void testGetBlockListForFile() {
    HeaderBlock hBlock = tracker.getLatestHeaderBlockForFile(FILENAME);
    assertNotNull(hBlock);
    assertEquals(hBlock1.getBlockId(), hBlock.getBlockId());

    LinkedList<Long> blocksIds = hBlock.getAssociatedDataBlockId();
    assertEquals(2, blocksIds.size());
    assertEquals(dBlock1.getBlockId(), blocksIds.getLast().longValue());
    assertEquals(dBlock2.getBlockId(), blocksIds.getFirst().longValue());
    MetaDataBlock metaBlock = hBlock.getMetaDataForDataBlock(blocksIds.getFirst());
  }
  public void setUp() {
    tracker = new BlockTracker(1, new MockNetwork());
    hBlock1.registerDataBlock(dBlock1, 0, 0);
    hBlock1.registerDataBlock(dBlock2, 100, 0);

    hBlock2.registerDataBlock(dBlock2, 0, 0);
    hBlock2.registerDataBlock(dBlock3, 100, 0);

    tracker.addHeaderBlock(hBlock1);

    tBlock1.addHeaderBlockToTransaction(hBlock1);
    tracker.addTransaction(tBlock1);

    tBlock2.addHeaderBlockToTransaction(hBlock2);
    // We do not add the second transaction yet.
  }
  public final void testGetDeleteableBlocks() {
    // HeaderBlock hBlock =
    TransactionBlock latestTransBlock = tracker.getLatestTransactionBlock(DATANAME1);
    assertEquals(tBlock1.getBlockId(), latestTransBlock.getBlockId());

    tracker.addTransaction(tBlock2);
    latestTransBlock = tracker.getLatestTransactionBlock(DATANAME1);
    assertEquals(tBlock2.getBlockId(), latestTransBlock.getBlockId());

    Vector<Long> blocksToDelete = tracker.getBlocksOnlyReferencedBy(tBlock1);
    assertEquals(2, blocksToDelete.size());
    assertEquals(hBlock1.getBlockId(), blocksToDelete.get(0).longValue());
    assertEquals(dBlock1.getBlockId(), blocksToDelete.get(1).longValue());
  }
  public final void testGetLatestBlock() {
    assertSame(tBlock1, tracker.getLatestTransactionBlock(DATANAME1));
    assertSame(hBlock1, tracker.getLatestHeaderBlockForFile(FILENAME));

    tracker.addHeaderBlock(hBlock2);
    tracker.addTransaction(tBlock2);
    assertSame(tBlock2, tracker.getLatestTransactionBlock(DATANAME1));
    assertSame(hBlock2, tracker.getLatestHeaderBlockForFile(FILENAME));

    Vector<Long> blocksOfT1 = tracker.getBlocksOnlyReferencedBy(tBlock1);
    assertEquals(2, blocksOfT1.size());
    assertEquals(hBlock1.getBlockId(), blocksOfT1.get(0).longValue());
    assertEquals(dBlock1.getBlockId(), blocksOfT1.get(1).longValue());
  }