@Test public void testTransformerSupplierReturnsNull() { when(transformerSupplier.get()).thenReturn(null); String prettyPrintedXml = createPrettyPrinter().prettyPrint(TEST_XML); assertSame( "XML should not be formatted if Supplier<Transformer>.get returns null", TEST_XML, prettyPrintedXml); }
@Override public String prettyPrint(String xml) { if (xml == null) { return xml; } Source xmlSource = sanitizeXml(xml); if (xmlSource == null) { xmlSource = new StreamSource(new StringReader(xml)); } String formattedXml = formatXml(xmlSource); return formattedXml != null ? formattedXml : xml; }
PrettyPrinter implements PrettyPrinterInterface { @Override public String prettyPrint(String xml) { if (xml == null) { return xml; } Source xmlSource = sanitizeXml(xml); if (xmlSource == null) { xmlSource = new StreamSource(new StringReader(xml)); } String formattedXml = formatXml(xmlSource); return formattedXml != null ? formattedXml : xml; } }
PrettyPrinter implements PrettyPrinterInterface { @Override public String prettyPrint(String xml) { if (xml == null) { return xml; } Source xmlSource = sanitizeXml(xml); if (xmlSource == null) { xmlSource = new StreamSource(new StringReader(xml)); } String formattedXml = formatXml(xmlSource); return formattedXml != null ? formattedXml : xml; } @Inject  PrettyPrinter(
      AdsApiConfiguration adsApiConfiguration,
      @Named("libLogger") Logger libLogger,
      Supplier<XPath> xpathSupplier,
      Supplier<Transformer> transformerSupplier,
      Supplier<DocumentBuilder> documentBuilderSupplier); }
PrettyPrinter implements PrettyPrinterInterface { @Override public String prettyPrint(String xml) { if (xml == null) { return xml; } Source xmlSource = sanitizeXml(xml); if (xmlSource == null) { xmlSource = new StreamSource(new StringReader(xml)); } String formattedXml = formatXml(xmlSource); return formattedXml != null ? formattedXml : xml; } @Inject  PrettyPrinter(
      AdsApiConfiguration adsApiConfiguration,
      @Named("libLogger") Logger libLogger,
      Supplier<XPath> xpathSupplier,
      Supplier<Transformer> transformerSupplier,
      Supplier<DocumentBuilder> documentBuilderSupplier); @Override String prettyPrint(String xml); }
PrettyPrinter implements PrettyPrinterInterface { @Override public String prettyPrint(String xml) { if (xml == null) { return xml; } Source xmlSource = sanitizeXml(xml); if (xmlSource == null) { xmlSource = new StreamSource(new StringReader(xml)); } String formattedXml = formatXml(xmlSource); return formattedXml != null ? formattedXml : xml; } @Inject  PrettyPrinter(
      AdsApiConfiguration adsApiConfiguration,
      @Named("libLogger") Logger libLogger,
      Supplier<XPath> xpathSupplier,
      Supplier<Transformer> transformerSupplier,
      Supplier<DocumentBuilder> documentBuilderSupplier); @Override String prettyPrint(String xml);  }