GsonJsonObjectMarshaller implements JsonObjectMarshaller<T> { @Override public String marshal(T item) { return gson.toJson(item); }  void setGson(Gson gson); @Override String marshal(T item);  }
@Test public void testJsonMarshalling() { GsonJsonObjectMarshaller<Foo> jsonObjectMarshaller = new GsonJsonObjectMarshaller<>(); String foo = jsonObjectMarshaller.marshal(new Foo(1, "foo")); Assert.assertEquals("{\"id\":1,\"name\":\"foo\"}", foo); }