CompactingXmlBodyFilter implements BodyFilter { @Override public String filter(@Nullable final String contentType, final String body) { return XML.test(contentType) && shouldCompact(body) ? compact(body) : body; }  @Override String filter(@Nullable final String contentType, final String body);  }
@Test void shouldIgnoreInvalidContent() { final String invalidBody = "<?xml>\n<invalid>"; assertThat(unit.filter("application/xml", invalidBody), is(invalidBody)); }
@Test void shouldIgnoreInvalidContentType() { final String filtered = unit.filter("text/plain", prettifiedXml); assertThat(filtered, is(prettifiedXml)); }
@Test void shouldTransformValidXmlRequestWithSimpleContentType() { final String filtered = unit.filter("application/xml", prettifiedXml); assertThat(filtered, is(minimisedXml)); }
@Test void shouldTransformValidXmlRequestWithCompatibleContentType() { final String filtered = unit.filter("application/custom+xml", prettifiedXml); assertThat(filtered, is(minimisedXml)); }
@Test void shouldIgnoreEmptyBody() { final String filtered = unit.filter("application/xml", ""); assertThat(filtered, is("")); }