### Question:
JsonExceptionSerializer { public String end() { return json.append("}").toString(); } JsonExceptionSerializer(Throwable exception); String end(); JsonExceptionSerializer appendAttribute(final String name, final Object value);  }### Answer:
@Test public void testWeCanConvertExceptionWithoutMessage() throws Exception { HttpException exception = new HttpException(); JsonExceptionSerializer serializer = new JsonExceptionSerializer(exception); String json = serializer.end(); assertEquals(exception, json); }
@Test public void testWeCanConvertExceptionWithMessageToJson() throws Exception { HttpException exception = new HttpException("message"); JsonExceptionSerializer serializer = new JsonExceptionSerializer(exception); String json = serializer.end(); assertEquals(exception, json); }
@Test public void testJsonContainsInternationalizedMessageWhenLocalIsSet() throws Exception { APIException exception = new APIException(new _("message")); fakeI18n.setL10n("localization"); exception.setLocale(LOCALE.en); JsonExceptionSerializer serializer = new JsonExceptionSerializer(exception); String json = serializer.end(); assertThat(json, equalTo( "{\"exception\":\"" + exception.getClass().toString() + "\"," + "\"message\":\"localization\"" + "}")); }