public void testGetMap() throws IOException { MetricsServlet servlet = new MetricsServlet(); Map<String, Map<String, List<TagsMetricsPair>>> m = servlet.makeMap(contexts); assertEquals("Map missing contexts", 2, m.size()); assertTrue(m.containsKey("test1")); Map<String, List<TagsMetricsPair>> m2 = m.get("test1"); assertEquals("Missing records", 1, m2.size()); assertTrue(m2.containsKey("testRecord")); assertEquals("Wrong number of tags-values pairs.", 1, m2.get("testRecord").size()); }
public void testPrintMap() throws IOException { StringWriter sw = new StringWriter(); PrintWriter out = new PrintWriter(sw); MetricsServlet servlet = new MetricsServlet(); servlet.printMap(out, servlet.makeMap(contexts)); String EXPECTED = "" + "test1\n" + " testRecord\n" + " {testTag1=testTagValue1,testTag2=testTagValue2}:\n" + " testMetric1=1\n" + " testMetric2=33\n" + "test2\n"; assertEquals(EXPECTED, sw.toString()); }