@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)); }
@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); }
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); } }
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); }
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); }
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);  }