public abstract DataWriter createDataWriter(Object bean, Writer w, ExportConfig config) throws IOException; }
public abstract DataWriter createDataWriter(Object bean, Writer w, ExportConfig config) throws IOException; }
@SuppressWarnings({"unchecked", "rawtypes"}) // API design flaw prevents this from type-checking public void serveExposedBean(StaplerRequest req, Object exposedBean, Flavor flavor) throws ServletException, IOException { serveExposedBean(req, exposedBean, new ExportConfig().withFlavor(flavor).withPrettyPrint(req.hasParameter("pretty"))); }
@SuppressWarnings({"unchecked", "rawtypes"}) // API design flaw prevents this from type-checking public void serveExposedBean(StaplerRequest req, Object exposedBean, Flavor flavor) throws ServletException, IOException { serveExposedBean(req, exposedBean, new ExportConfig().withFlavor(flavor).withPrettyPrint(req.hasParameter("pretty"))); }
@Test public void testNotExportedBean() throws IOException { ExportConfig config = new ExportConfig().withFlavor(Flavor.JSON).withExportInterceptor(new ExportInterceptor1()).withSkipIfFail(true); StringWriter writer = new StringWriter(); ExportableBean b = new ExportableBean(); builder.get(ExportableBean.class).writeTo(b,Flavor.JSON.createDataWriter(b, writer, config)); Assert.assertEquals("{\"_class\":\""+ExportableBean.class.getName()+"\",\"name\":\"property1\",\"notExportedBean\":{},\"shouldBeNull\":null}", writer.toString()); }
@Test(expected = IOException.class) public void testNotExportedBeanFailing() throws IOException { ExportConfig config = new ExportConfig().withFlavor(Flavor.JSON).withExportInterceptor(new ExportInterceptor2()).withSkipIfFail(true); StringWriter writer = new StringWriter(); ExportableBean b = new ExportableBean(); builder.get(ExportableBean.class).writeTo(b,Flavor.JSON.createDataWriter(b, writer, config)); }