@Test public void serializeNumericResultWithPath() throws Exception { ResultSerializer resultSerializer = new DetailedResultSerializer(); Result result = numericResult(); result = new Result(result.getEpoch(), result.getAttributeName(), result.getClassName(), result.getObjDomain(), result.getKeyAlias(), result.getTypeName(), ImmutableList.<String>of("used"), result.getValue()); String message = resultSerializer.serialize(dummyServer(), dummyQuery(), result); JsonNode jsonNode = new ObjectMapper().readValue(message, JsonNode.class); assertThat(jsonNode.get("host").asText()).isEqualTo("host.example.net"); assertThat(jsonNode.get("source").asText()).isEqualTo("host.example.net"); assertThat(jsonNode.get("port").asInt()).isEqualTo(4321); assertThat(jsonNode.get("attributeName").asText()).isEqualTo("ObjectPendingFinalizationCount"); assertThat(jsonNode.get("className").asText()).isEqualTo("sun.management.MemoryImpl"); assertThat(jsonNode.get("objDomain").asText()).isEqualTo("ObjectDomainName"); assertThat(jsonNode.get("typeName").asText()).isEqualTo("type=Memory"); assertThat(jsonNode.get("typeNameMap").get("type").asText()).isEqualTo("Memory"); assertThat(jsonNode.get("typeNameMap")).hasSize(1); assertThat(jsonNode.get("valuePath").get(0).asText()).isEqualTo("used"); assertThat(jsonNode.get("value").asLong()).isEqualTo(10L); assertThat(jsonNode.get("epoch").asLong()).isEqualTo(0L); assertThat(jsonNode.get("keyAlias").asText()).isEqualTo("MemoryAlias"); }
@Override public String serialize(final Server server, final Query query, final Result result) throws IOException { return objectMapper.writeValueAsString(new KResult(server, result)); }
DetailedResultSerializer implements ResultSerializer { @Override public String serialize(final Server server, final Query query, final Result result) throws IOException { return objectMapper.writeValueAsString(new KResult(server, result)); } }
DetailedResultSerializer implements ResultSerializer { @Override public String serialize(final Server server, final Query query, final Result result) throws IOException { return objectMapper.writeValueAsString(new KResult(server, result)); } @JsonCreator  DetailedResultSerializer(); }
DetailedResultSerializer implements ResultSerializer { @Override public String serialize(final Server server, final Query query, final Result result) throws IOException { return objectMapper.writeValueAsString(new KResult(server, result)); } @JsonCreator  DetailedResultSerializer(); @Override String serialize(final Server server, final Query query, final Result result); }
DetailedResultSerializer implements ResultSerializer { @Override public String serialize(final Server server, final Query query, final Result result) throws IOException { return objectMapper.writeValueAsString(new KResult(server, result)); } @JsonCreator  DetailedResultSerializer(); @Override String serialize(final Server server, final Query query, final Result result);  }