XmlRecordCompactor extends RecordCompactor { @Override protected String compact(final String payload) { if (payload == null) { return null; } if (payload.trim().isEmpty()) { return EMPTY_STRING; } return payload .replaceAll(LINE_SEPARATOR, "") .replaceAll("\t", "") .replaceAll(">( *?)<", "><"); }    }
@Test public void testFlattenXmlRecord() { String expectedPayload = "<foo><bar><baz name='baz'/></bar></foo>"; String payload = "<foo>" + LINE_SEPARATOR + "<bar>" + LINE_SEPARATOR + "<baz name='baz'/>" + LINE_SEPARATOR + "</bar>" + LINE_SEPARATOR + "</foo>"; String compactRecord = xmlRecordCompactor.compact(payload); assertThat(compactRecord).isNotNull().isEqualTo(expectedPayload); }