### Question:
MappingLogEventWriter extends BaseLogEventWriter implements XmlConfigurable { @Override public void setConfiguration(Element e) throws ConfigurationException { configureEventMappers(e); configureOutputMappers(e); }  @Override void setPrintStream(PrintStream p); @Override synchronized void close(); @Override void write(LogEvent ev); @Override void setConfiguration(Element e);  }### Answer:
@Test void testConfigureEventMappersShouldThrowExceptionWhenFailOnNewInstance() { Element root = new Element("root"); Element em = new Element("event-mapper"); em.setAttribute("class", "i.dont.Exist"); root.addContent(em); MappingLogEventWriter writer = new MappingLogEventWriter(); assertThrows(ConfigurationException.class, () -> writer.setConfiguration(root)); }
@Test void testConfigureOutputMappersShouldThrowExceptionWhenFailOnNewInstance() { Element root = new Element("root"); Element om = new Element("output-mapper"); om.setAttribute("class", "i.dont.Exist"); root.addContent(om); MappingLogEventWriter writer = new MappingLogEventWriter(); assertThrows(ConfigurationException.class, () -> writer.setConfiguration(root)); }
@Test void testShouldAddEventMapperWhenConfigured() throws ConfigurationException { Element root = new Element("root"); Element em = new Element("event-mapper"); em.setAttribute("class", "org.jpos.util.function.TestLogEventMapper"); root.addContent(em); MappingLogEventWriter writer = new MappingLogEventWriter(); assertNull(writer.eventMappers); writer.setConfiguration(root); assertNotNull(writer.eventMappers); assertEquals(1, writer.eventMappers.size()); assertTrue(writer.eventMappers.get(0) instanceof TestLogEventMapper); }
@Test void testShouldAddOutputMapperWhenConfigured() throws ConfigurationException { Element root = new Element("root"); Element om = new Element("output-mapper"); om.setAttribute("class", "org.jpos.util.function.RemoveNewLinesMapper"); root.addContent(om); MappingLogEventWriter writer = new MappingLogEventWriter(); assertNull(writer.outputMappers); writer.setConfiguration(root); assertNotNull(writer.outputMappers); assertEquals(1, writer.outputMappers.size()); assertTrue(writer.outputMappers.get(0) instanceof RemoveNewLinesMapper); }