### Question:
VarsJsonHandler { @VisibleForTesting String getBody(boolean pretty) { Map<String, Object> vars = Maps.newLinkedHashMap(); for (Stat<?> var : statSupplier.get()) { vars.put(var.getName(), var.read()); } return getGson(pretty).toJson(vars); } @Inject  VarsJsonHandler(Supplier<Iterable<Stat<?>>> statSupplier); @GET @Produces(MediaType.APPLICATION_JSON) String getVars(@QueryParam("pretty") boolean pretty);  }### Answer:
@Test public void testGetEmpty() { expectVarScrape(ImmutableMap.<String, Object>of()); control.replay(); assertEquals("{}", varsJson.getBody(false)); }
@Test public void testGet() { expectVarScrape(ImmutableMap.<String, Object>of( "str", "foobar", "int", 5, "float", 4.16126 )); control.replay(); assertEquals("{\"str\":\"foobar\",\"int\":5,\"float\":4.16126}", varsJson.getBody(false)); }
@Test public void testGetPretty() { expectVarScrape(ImmutableMap.<String, Object>of( "str", "foobar", "int", 5, "float", 4.16126 )); control.replay(); assertEquals("{\n" + " \"str\": \"foobar\",\n" + " \"int\": 5,\n" + " \"float\": 4.16126\n" + "}", varsJson.getBody(true)); }