use of com.googlecode.jmxtrans.model.OutputWriterFactory in project jmxtrans by jmxtrans.
the class JmxProcessingTests method querySimpleAttribute.
@Test
public void querySimpleAttribute() throws Exception {
OutputWriterFactory outputWriterFactory = mock(OutputWriterFactory.class);
OutputWriter outputWriter = mock(OutputWriter.class);
when(outputWriterFactory.create()).thenReturn(outputWriter);
Query query = Query.builder().setObj(MBEAN_NAME).addAttr("DummyValue").addOutputWriterFactory(outputWriterFactory).build();
Server server = localServer();
Iterable<Result> results1 = server.execute(query);
query.runOutputWritersForQuery(server, results1);
verify(outputWriter).doWrite(any(Server.class), queryCaptor.capture(), resultsCaptor.capture());
assertThat(queryCaptor.getValue()).isEqualTo(query);
List<Result> results = resultsCaptor.getValue();
assertThat(results).hasSize(1);
Result result = results.get(0);
assertThat(result.getValues().get("DummyValue")).isEqualTo(123);
}
Aggregations