@Test @RunAsClient @InSequence(19) public void testApplicationMetadataItems() { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).options("/metrics/application").jsonPath(); Map<String, Object> elements = jsonPath.getMap("."); List<String> missing = new ArrayList<>(); Map<String, MiniMeta> names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.APPLICATION); for (String item : names.keySet()) { if (!elements.containsKey(item)) { missing.add(item); } } assertTrue("Following application items are missing: " + Arrays.toString(missing.toArray()), missing.isEmpty()); }
@Test @RunAsClient @InSequence(8) public void testBaseSingularMetricsPresent() { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).get("/metrics/base").jsonPath(); Map<String, Object> elements = jsonPath.getMap("."); List<String> missing = new ArrayList<>(); Map<String, MiniMeta> baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); for (String item : baseNames.keySet()) { if (item.startsWith("gc.")) { continue; } if (!elements.containsKey(item) && !baseNames.get(item).optional) { missing.add(item); } } assertTrue("Following base items are missing: " + Arrays.toString(missing.toArray()), missing.isEmpty()); }
@Test @RunAsClient @InSequence(11) public void testBaseMetadataSingluarItems() { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath(); Map<String, Object> elements = jsonPath.getMap("."); List<String> missing = new ArrayList<>(); Map<String, MiniMeta> baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); for (String item : baseNames.keySet()) { if (item.startsWith("gc.") || baseNames.get(item).optional) { continue; } if (!elements.containsKey(item)) { missing.add(item); } } assertTrue("Following base items are missing: " + Arrays.toString(missing.toArray()), missing.isEmpty()); }
@Test @RunAsClient @InSequence(15) public void testBaseMetadataGarbageCollection() throws Exception { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath(); int count = 0; Map<String, Object> elements = jsonPath.getMap("."); for (String name : elements.keySet()) { if (name.startsWith("gc.")) { assertTrue(name.endsWith(".count") || name.endsWith(".time")); count++; } } assertThat(count, greaterThan(0)); }
@Test @RunAsClient @InSequence(31) public void testOptionalBaseMetrics() { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath(); Map<String, Object> elements = jsonPath.getMap("."); Map<String, MiniMeta> names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); for (String item : names.keySet()) { if (elements.containsKey(item) && names.get(item).optional) { String prefix = names.get(item).name; String type = "\""+prefix+"\""+".type"; String unit= "\""+prefix+"\""+".unit"; given().header(wantJson).options("/metrics/base/"+prefix).then().statusCode(200) .body(type, equalTo(names.get(item).type)) .body(unit, equalTo(names.get(item).unit)); } } }
@Test @RunAsClient @InSequence(20) public void testApplicationMetadataTypeAndUnit() { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).options("/metrics/application").jsonPath(); Map<String, Map<String, Object>> elements = jsonPath.getMap("."); Map<String, MiniMeta> expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.APPLICATION); checkMetadataPresent(elements, expectedMetadata); }
@Test @RunAsClient @InSequence(12) public void testBaseMetadataTypeAndUnit() { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath(); Map<String, Map<String, Object>> elements = jsonPath.getMap("."); Map<String, MiniMeta> expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); checkMetadataPresent(elements, expectedMetadata); }