### Question:
DatadogHttpClient { public static String serialize(Object obj) throws JsonProcessingException { return MAPPER.writeValueAsString(obj); } DatadogHttpClient(String dgApiKey, String dgProxyHost, int dgProxyPort); void send(DatadogHttpReporter.DatadogHttpRequest request); static String serialize(Object obj); void close();  }### Answer:
@Test public void serializeGauge() throws JsonProcessingException { DGauge g = new DGauge(new Gauge<Number>() { @Override public Number getValue() { return 1; } }, "testCounter", "localhost", tags); assertEquals( "{\"metric\":\"testCounter\",\"type\":\"gauge\",\"host\":\"localhost\",\"tags\":[\"tag1\",\"tag2\"],\"points\":[[123,1]]}", DatadogHttpClient.serialize(g)); }
@Test public void serializeGaugeWithoutHost() throws JsonProcessingException { DGauge g = new DGauge(new Gauge<Number>() { @Override public Number getValue() { return 1; } }, "testCounter", null, tags); assertEquals( "{\"metric\":\"testCounter\",\"type\":\"gauge\",\"tags\":[\"tag1\",\"tag2\"],\"points\":[[123,1]]}", DatadogHttpClient.serialize(g)); }
@Test public void serializeCounter() throws JsonProcessingException { DCounter c = new DCounter(new Counter() { @Override public void inc() {} @Override public void inc(long n) {} @Override public void dec() {} @Override public void dec(long n) {} @Override public long getCount() { return 1; } }, "testCounter", "localhost", tags); assertEquals( "{\"metric\":\"testCounter\",\"type\":\"counter\",\"host\":\"localhost\",\"tags\":[\"tag1\",\"tag2\"],\"points\":[[123,1]]}", DatadogHttpClient.serialize(c)); }
@Test public void serializeCounterWithoutHost() throws JsonProcessingException { DCounter c = new DCounter(new Counter() { @Override public void inc() {} @Override public void inc(long n) {} @Override public void dec() {} @Override public void dec(long n) {} @Override public long getCount() { return 1; } }, "testCounter", null, tags); assertEquals( "{\"metric\":\"testCounter\",\"type\":\"counter\",\"tags\":[\"tag1\",\"tag2\"],\"points\":[[123,1]]}", DatadogHttpClient.serialize(c)); }
@Test public void serializeMeter() throws JsonProcessingException { DMeter m = new DMeter(new Meter() { @Override public void markEvent() {} @Override public void markEvent(long n) {} @Override public double getRate() { return 1; } @Override public long getCount() { return 0; } }, "testMeter", "localhost", tags); assertEquals( "{\"metric\":\"testMeter\",\"type\":\"gauge\",\"host\":\"localhost\",\"tags\":[\"tag1\",\"tag2\"],\"points\":[[123,1.0]]}", DatadogHttpClient.serialize(m)); }
@Test public void serializeMeterWithoutHost() throws JsonProcessingException { DMeter m = new DMeter(new Meter() { @Override public void markEvent() {} @Override public void markEvent(long n) {} @Override public double getRate() { return 1; } @Override public long getCount() { return 0; } }, "testMeter", null, tags); assertEquals( "{\"metric\":\"testMeter\",\"type\":\"gauge\",\"tags\":[\"tag1\",\"tag2\"],\"points\":[[123,1.0]]}", DatadogHttpClient.serialize(m)); }