@Test public void testIncrementHost() { String hostname = "foobar"; counter.countUpHost(hostname, 10); counter.incrementHost(hostname); int res = counter.getHostCounts().get(Tools.encodeBase64(hostname)); assertEquals(11, res); }
@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()); }