@Test public void ignoreNonNumericValues() throws IOException { StatsDWriter2 writer = new StatsDWriter2(ImmutableList.<String>of(), "root", "c", false, 1L); StringWriter out = new StringWriter(); writer.write(out, dummyServer(), dummyQuery(), singleTrueResult()); assertThat(out.toString()).isEmpty(); }
@Test public void nonNumericValuesAsKey() throws IOException { StatsDWriter2 writer = new StatsDWriter2(ImmutableList.<String>of(), "root", "g", true, 1L); StringWriter out = new StringWriter(); writer.write(out, dummyServer(), dummyQuery(), singleTrueResult()); assertThat(out.toString()) .isEqualTo("root.host_example_net_4321.VerboseMemory.Verbose.true:1|g\n"); }
@Test public void writeNumericResult() throws IOException { StatsDWriter2 writer = new StatsDWriter2(ImmutableList.<String>of(), "root", "c", false, 1L); StringWriter out = new StringWriter(); writer.write(out, dummyServer(), dummyQuery(), singleNumericResult()); assertThat(out.toString()) .isEqualTo( "root.host_example_net_4321.ObjectPendingFinalizationCount.ObjectPendingFinalizationCount:10|c\n"); }
@Test public void multipleValuesAreSeparatedByNewLine() throws IOException { StatsDWriter2 writer = new StatsDWriter2(ImmutableList.<String>of(), "root", "g", true, 1L); StringWriter out = new StringWriter(); writer.write(out, dummyServer(), dummyQuery(), dummyResults()); assertThat(out.toString()) .isEqualTo( "root.host_example_net_4321.ObjectPendingFinalizationCount.ObjectPendingFinalizationCount:10|g\n" + "root.host_example_net_4321.VerboseMemory.Verbose.true:1|g\n" + "root.host_example_net_4321.VerboseMemory.Verbose.false:1|g\n"); }