@Test public void testWriteInternal() throws Exception { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); PojoView pojoView = new PojoView(new SampleClass("John", "Doe", "25", "john.doe@opentides.com"), SearchView.class); converter.writeInternal(pojoView, outputMessage); assertEquals("{\"name\":\"John\"}", outputMessage.getBodyAsString()); pojoView = new PojoView(new SampleClass("John", "Doe", "25", "john.doe@opentides.com"), FormView.class); outputMessage = new MockHttpOutputMessage(); converter.writeInternal(pojoView, outputMessage); assertEquals("{\"name\":\"John\",\"lastName\":\"Doe\"}", outputMessage.getBodyAsString()); pojoView = new PojoView(new SampleClass("John", "Doe", "25", "john.doe@opentides.com"), DisplayView.class); outputMessage = new MockHttpOutputMessage(); converter.writeInternal(pojoView, outputMessage); assertEquals("{\"name\":\"John\",\"lastName\":\"Doe\",\"age\":\"25\"}", outputMessage.getBodyAsString()); pojoView = new PojoView(new SampleClass("John", "Doe", "25", "john.doe@opentides.com"), FullView.class); outputMessage = new MockHttpOutputMessage(); converter.writeInternal(pojoView, outputMessage); assertEquals("{\"name\":\"John\",\"lastName\":\"Doe\",\"age\":\"25\",\"email\":\"john.doe@opentides.com\"}", outputMessage.getBodyAsString()); }
@Override protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { try { if (object instanceof DataView && ((DataView) object).hasView()) { writeView((DataView) object, outputMessage); } else { super.writeInternal(object, outputMessage); } } catch (Exception e) { _log.error("Failed to convert object to json.", e); throw e; } }
ViewAwareJsonMessageConverter extends
		MappingJackson2HttpMessageConverter implements InitializingBean { @Override protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { try { if (object instanceof DataView && ((DataView) object).hasView()) { writeView((DataView) object, outputMessage); } else { super.writeInternal(object, outputMessage); } } catch (Exception e) { _log.error("Failed to convert object to json.", e); throw e; } } }
ViewAwareJsonMessageConverter extends
		MappingJackson2HttpMessageConverter implements InitializingBean { @Override protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { try { if (object instanceof DataView && ((DataView) object).hasView()) { writeView((DataView) object, outputMessage); } else { super.writeInternal(object, outputMessage); } } catch (Exception e) { _log.error("Failed to convert object to json.", e); throw e; } }  }
ViewAwareJsonMessageConverter extends
		MappingJackson2HttpMessageConverter implements InitializingBean { @Override protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { try { if (object instanceof DataView && ((DataView) object).hasView()) { writeView((DataView) object, outputMessage); } else { super.writeInternal(object, outputMessage); } } catch (Exception e) { _log.error("Failed to convert object to json.", e); throw e; } }  final void setPrefixJson(boolean prefixJson); @Override void afterPropertiesSet(); }
ViewAwareJsonMessageConverter extends
		MappingJackson2HttpMessageConverter implements InitializingBean { @Override protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { try { if (object instanceof DataView && ((DataView) object).hasView()) { writeView((DataView) object, outputMessage); } else { super.writeInternal(object, outputMessage); } } catch (Exception e) { _log.error("Failed to convert object to json.", e); throw e; } }  final void setPrefixJson(boolean prefixJson); @Override void afterPropertiesSet();  }