@Test public void testParseWithNullTransformer() { Builder builder = Mockito.mock(Builder.class); when(transformerSupplier.get()).thenReturn(null); SOAPMessage message = Mockito.mock(SOAPMessage.class); when(message.getSOAPPart()).thenReturn(Mockito.mock(SOAPPart.class)); assertSame( "parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message)); verifyZeroInteractions(builder); }
public RequestInfo.Builder parseMessage(RequestInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); Transformer transformer = transformerSupplier.get(); if (soapMessage == null || soapMessage.getSOAPPart() == null || transformer == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { transformer.transform(soapMessage.getSOAPPart().getContent(), new StreamResult(outputStream)); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (TransformerException | SOAPException | IOException e) { builder.withPayload("Unable to read request content due to exception: " + e); libLogger.warn("Unable to read request content due to exception.", e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); builder.withContext(contextName, nodeExtractor.extractNodeValue(soapHeader, contextXPath)); } catch (SOAPException e) { builder.withContext( contextName, "Unable to extract " + contextName + " from request due to exception: " + e); } return builder; }
RequestInfoXPathSet { public RequestInfo.Builder parseMessage(RequestInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); Transformer transformer = transformerSupplier.get(); if (soapMessage == null || soapMessage.getSOAPPart() == null || transformer == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { transformer.transform(soapMessage.getSOAPPart().getContent(), new StreamResult(outputStream)); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (TransformerException | SOAPException | IOException e) { builder.withPayload("Unable to read request content due to exception: " + e); libLogger.warn("Unable to read request content due to exception.", e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); builder.withContext(contextName, nodeExtractor.extractNodeValue(soapHeader, contextXPath)); } catch (SOAPException e) { builder.withContext( contextName, "Unable to extract " + contextName + " from request due to exception: " + e); } return builder; } }
RequestInfoXPathSet { public RequestInfo.Builder parseMessage(RequestInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); Transformer transformer = transformerSupplier.get(); if (soapMessage == null || soapMessage.getSOAPPart() == null || transformer == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { transformer.transform(soapMessage.getSOAPPart().getContent(), new StreamResult(outputStream)); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (TransformerException | SOAPException | IOException e) { builder.withPayload("Unable to read request content due to exception: " + e); libLogger.warn("Unable to read request content due to exception.", e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); builder.withContext(contextName, nodeExtractor.extractNodeValue(soapHeader, contextXPath)); } catch (SOAPException e) { builder.withContext( contextName, "Unable to extract " + contextName + " from request due to exception: " + e); } return builder; } @Inject  RequestInfoXPathSet(
      AdsApiConfiguration apiConfig,
      NodeExtractor nodeExtractor,
      Supplier<Transformer> transformerSupplier,
      @Named("libLogger") Logger libLogger); }
RequestInfoXPathSet { public RequestInfo.Builder parseMessage(RequestInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); Transformer transformer = transformerSupplier.get(); if (soapMessage == null || soapMessage.getSOAPPart() == null || transformer == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { transformer.transform(soapMessage.getSOAPPart().getContent(), new StreamResult(outputStream)); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (TransformerException | SOAPException | IOException e) { builder.withPayload("Unable to read request content due to exception: " + e); libLogger.warn("Unable to read request content due to exception.", e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); builder.withContext(contextName, nodeExtractor.extractNodeValue(soapHeader, contextXPath)); } catch (SOAPException e) { builder.withContext( contextName, "Unable to extract " + contextName + " from request due to exception: " + e); } return builder; } @Inject  RequestInfoXPathSet(
      AdsApiConfiguration apiConfig,
      NodeExtractor nodeExtractor,
      Supplier<Transformer> transformerSupplier,
      @Named("libLogger") Logger libLogger); IterableXPath getContextXPath(); String getContextName(); @Override String toString(); RequestInfo.Builder parseMessage(RequestInfo.Builder builder, SOAPMessage soapMessage); }
RequestInfoXPathSet { public RequestInfo.Builder parseMessage(RequestInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); Transformer transformer = transformerSupplier.get(); if (soapMessage == null || soapMessage.getSOAPPart() == null || transformer == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { transformer.transform(soapMessage.getSOAPPart().getContent(), new StreamResult(outputStream)); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (TransformerException | SOAPException | IOException e) { builder.withPayload("Unable to read request content due to exception: " + e); libLogger.warn("Unable to read request content due to exception.", e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); builder.withContext(contextName, nodeExtractor.extractNodeValue(soapHeader, contextXPath)); } catch (SOAPException e) { builder.withContext( contextName, "Unable to extract " + contextName + " from request due to exception: " + e); } return builder; } @Inject  RequestInfoXPathSet(
      AdsApiConfiguration apiConfig,
      NodeExtractor nodeExtractor,
      Supplier<Transformer> transformerSupplier,
      @Named("libLogger") Logger libLogger); IterableXPath getContextXPath(); String getContextName(); @Override String toString(); RequestInfo.Builder parseMessage(RequestInfo.Builder builder, SOAPMessage soapMessage);  }