JsonHelper { static String toJson(Object value) { try { return JSON.writeValueAsString(value); } catch (IOException e) { throw new AssertionError(e); } }    }
@Test public void testToJson() { Foo foo = foo(1, "Hello World"); assertEquals("{\"bar\":1,\"baz\":\"Hello World\"}", JsonHelper.toJson(foo)); }