@Test
  public void testCountUpStream() {
    ObjectId streamId = new ObjectId();
    counter.countUpStream(streamId, 100);
    counter.countUpStream(streamId, 150);

    int res = counter.getStreamCounts().get(streamId.toString());
    assertEquals(250, res);
  }
  @Test
  public void testIncrementStream() {
    ObjectId streamId = new ObjectId();
    counter.countUpStream(streamId, 100);
    counter.incrementStream(streamId);

    int res = counter.getStreamCounts().get(streamId.toString());
    assertEquals(101, res);
  }
  @Test
  public void testGetStreamCounts() {
    ObjectId stream1 = new ObjectId();
    ObjectId stream2 = new ObjectId();
    ObjectId stream3 = new ObjectId();

    Map expected = new HashMap<String, Integer>();
    expected.put(stream1.toString(), 1);
    expected.put(stream2.toString(), 5);
    expected.put(stream3.toString(), 2);

    counter.countUpStream(stream1, 1);
    counter.countUpStream(stream2, 3);
    counter.countUpStream(stream2, 2);
    counter.countUpStream(stream3, 1);
    counter.incrementStream(stream3);

    assertEquals(expected, counter.getStreamCounts());
  }
  @Test
  public void testResetAllCounts() {
    counter.countUpTotal(100);
    counter.countUpHost("foo.example.org", 9001);
    counter.countUpStream(new ObjectId(), 5);

    assertEquals(100, counter.getTotalCount()); // Just to make sure.

    counter.resetAllCounts();

    assertEquals(0, counter.getTotalCount());
    assertEquals(0, counter.getHostCounts().size());
    assertEquals(0, counter.getStreamCounts().size());
  }
  @Test
  public void testGetHostCounts() {
    String host1 = "example.org";
    String host2 = "foo.example.org";
    String host3 = "example.com";

    Map expected = new HashMap<String, Integer>();
    expected.put(Tools.encodeBase64(host1), 5);
    expected.put(Tools.encodeBase64(host2), 1);
    expected.put(Tools.encodeBase64(host3), 3);

    counter.countUpStream(new ObjectId(), 5); // Add a stream count for complexity.
    counter.countUpHost(host1, 4);
    counter.countUpHost(host1, 1);
    counter.incrementHost(host2);
    counter.countUpHost(host3, 3);

    assertEquals(expected, counter.getHostCounts());
  }
 @Test
 public void testResetStreamCounts() {
   counter.countUpStream(new ObjectId(), 100);
   counter.resetStreamCounts();
   assertEquals(new HashMap<ObjectId, Integer>(), counter.getStreamCounts());
 }