### Question:
JacksonJsonLayout extends AbstractLayout<ItemSource> implements ItemSourceLayout, LifeCycle { @Override public final ItemSource toSerializable(LogEvent event) { return serialize(event); } protected  JacksonJsonLayout(Configuration config, ObjectWriter configuredWriter, ItemSourceFactory itemSourceFactory); @Override String getContentType(); @Override byte[] toByteArray(LogEvent event); @Override final ItemSource toSerializable(LogEvent event); @Override final ItemSource serialize(LogEvent event); @Override final ItemSource serialize(Message message); @PluginBuilderFactory static JacksonJsonLayout.Builder newBuilder(); @Override void start(); @Override void stop(); @Override boolean isStarted(); @Override boolean isStopped(); static final String PLUGIN_NAME; }### Answer:
@Test public void builderBuildsLayoutWithDefaultItemSourceFactoryIfNotConfigured() { JacksonJsonLayout.Builder builder = spy(createDefaultTestBuilder()); JacksonJsonLayout layout = builder.build(); LogEvent logEvent = new Log4jLogEvent(); ItemSource itemSource = layout.toSerializable(logEvent); assertEquals(StringItemSource.class, itemSource.getClass()); }
@Test public void builderBuildsLayoutWithProvidedItemSourceFactoryIfConfigured() { JacksonJsonLayout.Builder builder = spy(createDefaultTestBuilder()); builder.withItemSourceFactory(new LayoutTestItemSourceFactory()); JacksonJsonLayout layout = builder.build(); LogEvent logEvent = new Log4jLogEvent(); ItemSource itemSource = layout.toSerializable(logEvent); assertEquals(LayoutTestItemSource.class, itemSource.getClass()); }
@Test public void logEventSerializationDelegatesToItemSourceFactory() { JacksonJsonLayout.Builder builder = spy(createDefaultTestBuilder()); LayoutTestItemSourceFactory itemSourceFactory = spy(new LayoutTestItemSourceFactory()); builder.withItemSourceFactory(itemSourceFactory); JacksonJsonLayout layout = builder.build(); LogEvent logEvent = new Log4jLogEvent(); layout.toSerializable(logEvent); verify(itemSourceFactory).create(eq(logEvent), any(ObjectWriter.class)); }