@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 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 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 testResetStreamCounts() { counter.countUpStream(new ObjectId(), 100); counter.resetStreamCounts(); assertEquals(new HashMap<ObjectId, Integer>(), counter.getStreamCounts()); }