PropertyLink { public JsonObject toJson() { JsonObject result = new JsonObject(); result.addProperty("text", text); result.addProperty("url", url); result.addProperty("relevance", relevance); return result; } PropertyLink(String text, String url, int relevance); String getText(); String getUrl(); int getRelevance(); JsonObject toJson();  }
@Test public void toJson() { assertThat( new PropertyLink("foobar", "http: is(GSON.fromJson( "{\"text\":\"foobar\",\"url\":\"http: JsonObject.class))); }