### Question:
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);  }### Answer:
@Test public void testParseWithNullBuilder_fails() { thrown.expect(NullPointerException.class); xPathSet.parseMessage((Builder) null, Mockito.mock(SOAPMessage.class)); }
@Test public void testParseWithNullMessage() { Builder builder = Mockito.mock(Builder.class); assertSame( "parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, null)); verifyZeroInteractions(builder); }
@Test public void testParseWithNullSoapPart() { Builder builder = Mockito.mock(Builder.class); SOAPMessage message = Mockito.mock(SOAPMessage.class); when(message.getSOAPPart()).thenReturn(null); assertSame( "parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message)); verifyZeroInteractions(builder); }
@Test public void testParseTransformException() throws TransformerException { Builder builder = Mockito.mock(Builder.class); SOAPMessage message = Mockito.mock(SOAPMessage.class); doThrow(TransformerException.class) .when(transformer).transform(any(Source.class), any(Result.class)); assertSame( "parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message) ); }
@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); }