### Question:
MappingLogEventWriter extends BaseLogEventWriter implements XmlConfigurable { protected byte[] mapOutput(byte[] output) { if (outputMappers != null) { for (ByteArrayMapper mapper : outputMappers) { output = mapper.apply(output); } } return output; }  @Override void setPrintStream(PrintStream p); @Override synchronized void close(); @Override void write(LogEvent ev); @Override void setConfiguration(Element e);  }### Answer:
@Test void testMapOutputsShouldCallOutputMappersInOrderAndReturnFinalResult() { MappingLogEventWriter writer = new MappingLogEventWriter(); List<ByteArrayMapper> mappers = new ArrayList<>(); writer.outputMappers = mappers; mappers.add(b -> { byte[] temp = Arrays.copyOf(b, b.length + 1); temp[temp.length - 1] = '1'; return temp; }); mappers.add(b -> { byte[] temp = Arrays.copyOf(b, b.length + 1); temp[temp.length - 1] = '2'; return temp; }); byte[] b = {'0'}; byte[] r = writer.mapOutput(b); assertArrayEquals(new byte[]{'0','1','2'}, r); }
@Test void testMapOutputShouldNotThrowExceptionWhenOutputMappersIsNull() { MappingLogEventWriter writer = new MappingLogEventWriter(); assertDoesNotThrow(() -> writer.mapOutput(new byte[]{})); }