DefaultStatus implements Status { public void badRequest(String message) { sendError(HttpServletResponse.SC_BAD_REQUEST, message); } DefaultStatus(HttpServletResponse response, Result result, Configuration config,
			Proxifier proxifier, Router router); void notFound(); void header(String key, String value); void created(); void created(String location); void ok(); void conflict(); void methodNotAllowed(EnumSet<HttpMethod> allowedMethods); void movedPermanentlyTo(String location); T movedPermanentlyTo(final Class<T> controller); void unsupportedMediaType(String message); void badRequest(String message); void badRequest(List<?> errors); void forbidden(String message); void noContent(); void notAcceptable(); void accepted(); void notModified();  }
@Test public void shouldSerializeErrorMessages() throws Exception { Message normal = new ValidationMessage("The message", "category"); I18nMessage i18ned = new I18nMessage("category", "message"); i18ned.setBundle(new SingletonResourceBundle("message", "Something else")); MockSerializationResult result = new MockSerializationResult(XStreamBuilderImpl.cleanInstance(new MessageConverter())); DefaultStatus status = new DefaultStatus(response, result, config, new JavassistProxifier(new ObjenesisInstanceCreator()), router); status.badRequest(Lists.newArrayList(normal, i18ned)); String serialized = result.serializedResult(); assertThat(serialized, containsString("<message>The message</message>")); assertThat(serialized, containsString("<category>category</category>")); assertThat(serialized, containsString("<message>Something else</message>")); assertThat(serialized, not(containsString("<validationMessage>"))); assertThat(serialized, not(containsString("<i18nMessage>"))); }
@Test public void shouldSerializeErrorMessagesInJSON() throws Exception { Message normal = new ValidationMessage("The message", "category"); I18nMessage i18ned = new I18nMessage("category", "message"); i18ned.setBundle(new SingletonResourceBundle("message", "Something else")); MockSerializationResult result = new MockSerializationResult(XStreamBuilderImpl.cleanInstance(new MessageConverter())) { @Override public <T extends View> T use(Class<T> view) { return view.cast(new DefaultRepresentationResult(new FormatResolver() { public String getAcceptFormat() { return "json"; } }, this, Arrays.<Serialization>asList(super.use(JSONSerialization.class)), null)); } }; DefaultStatus status = new DefaultStatus(response, result, config, new JavassistProxifier(new ObjenesisInstanceCreator()), router); status.badRequest(Lists.newArrayList(normal, i18ned)); String serialized = result.serializedResult(); assertThat(serialized, containsString("\"message\": \"The message\"")); assertThat(serialized, containsString("\"category\": \"category\"")); assertThat(serialized, containsString("\"message\": \"Something else\"")); assertThat(serialized, not(containsString("\"validationMessage\""))); assertThat(serialized, not(containsString("\"i18nMessage\""))); }