### Question:
Response { @Override public String toString() { Gson gson = new Gson(); return gson.toJson(this); } Response(String elementId, boolean success);  Response(String elementId, boolean success, String optionalMessage); Boolean isSuccess(); String getElementId(); String getOptionalMessage(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void toStringWithMessageTest() { Response resp = new Response("id", true); String result = resp.toString(); assertEquals("{\"success\":true,\"elementId\":\"id\",\"optionalMessage\":\"\"}", result); }
@Test public void toStringWithoutMessageTest() { Response resp = new Response("id", false, "error"); String result = resp.toString(); assertEquals("{\"success\":false,\"elementId\":\"id\",\"optionalMessage\":\"error\"}", result); }