@Test public void testParseWithNullBuilder_fails() { thrown.expect(NullPointerException.class); xPathSet.parseMessage((Builder) null, Mockito.mock(SOAPMessage.class)); }
public ResponseInfo.Builder parseMessage(ResponseInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); if (soapMessage == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { soapMessage.writeTo(outputStream); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (SOAPException | IOException e) { builder.withPayload("Unable to read response due to exception: " + e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); String responseTimeString = nodeExtractor.extractNodeValue(soapHeader, responseTimeXPath); String operationsString = nodeExtractor.extractNodeValue(soapHeader, operationsCountXPath); builder .withRequestId(nodeExtractor.extractNodeValue(soapHeader, requestIdXPath)) .withResponseTimeMillis(Longs.tryParse(Strings.nullToEmpty(responseTimeString))) .withOperationsCount(Longs.tryParse(Strings.nullToEmpty(operationsString))); } catch (SOAPException e) { builder.withRequestId("Unable to extract the requestId due to exception: " + e); } return builder; }
ResponseInfoXPathSet { public ResponseInfo.Builder parseMessage(ResponseInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); if (soapMessage == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { soapMessage.writeTo(outputStream); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (SOAPException | IOException e) { builder.withPayload("Unable to read response due to exception: " + e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); String responseTimeString = nodeExtractor.extractNodeValue(soapHeader, responseTimeXPath); String operationsString = nodeExtractor.extractNodeValue(soapHeader, operationsCountXPath); builder .withRequestId(nodeExtractor.extractNodeValue(soapHeader, requestIdXPath)) .withResponseTimeMillis(Longs.tryParse(Strings.nullToEmpty(responseTimeString))) .withOperationsCount(Longs.tryParse(Strings.nullToEmpty(operationsString))); } catch (SOAPException e) { builder.withRequestId("Unable to extract the requestId due to exception: " + e); } return builder; } }
ResponseInfoXPathSet { public ResponseInfo.Builder parseMessage(ResponseInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); if (soapMessage == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { soapMessage.writeTo(outputStream); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (SOAPException | IOException e) { builder.withPayload("Unable to read response due to exception: " + e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); String responseTimeString = nodeExtractor.extractNodeValue(soapHeader, responseTimeXPath); String operationsString = nodeExtractor.extractNodeValue(soapHeader, operationsCountXPath); builder .withRequestId(nodeExtractor.extractNodeValue(soapHeader, requestIdXPath)) .withResponseTimeMillis(Longs.tryParse(Strings.nullToEmpty(responseTimeString))) .withOperationsCount(Longs.tryParse(Strings.nullToEmpty(operationsString))); } catch (SOAPException e) { builder.withRequestId("Unable to extract the requestId due to exception: " + e); } return builder; } @Inject  ResponseInfoXPathSet(AdsApiConfiguration apiConfig, NodeExtractor nodeExtractor); }
ResponseInfoXPathSet { public ResponseInfo.Builder parseMessage(ResponseInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); if (soapMessage == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { soapMessage.writeTo(outputStream); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (SOAPException | IOException e) { builder.withPayload("Unable to read response due to exception: " + e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); String responseTimeString = nodeExtractor.extractNodeValue(soapHeader, responseTimeXPath); String operationsString = nodeExtractor.extractNodeValue(soapHeader, operationsCountXPath); builder .withRequestId(nodeExtractor.extractNodeValue(soapHeader, requestIdXPath)) .withResponseTimeMillis(Longs.tryParse(Strings.nullToEmpty(responseTimeString))) .withOperationsCount(Longs.tryParse(Strings.nullToEmpty(operationsString))); } catch (SOAPException e) { builder.withRequestId("Unable to extract the requestId due to exception: " + e); } return builder; } @Inject  ResponseInfoXPathSet(AdsApiConfiguration apiConfig, NodeExtractor nodeExtractor); IterableXPath getRequestIdXPath(); IterableXPath getResponseTimeXPath(); IterableXPath getOperationsCountXPath(); @Override String toString(); ResponseInfo.Builder parseMessage(ResponseInfo.Builder builder, SOAPMessage soapMessage); }
ResponseInfoXPathSet { public ResponseInfo.Builder parseMessage(ResponseInfo.Builder builder, SOAPMessage soapMessage) { Preconditions.checkNotNull(builder, "Null builder"); if (soapMessage == null) { return builder; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { soapMessage.writeTo(outputStream); builder.withPayload(outputStream.toString(StandardCharsets.UTF_8.name())); } catch (SOAPException | IOException e) { builder.withPayload("Unable to read response due to exception: " + e); } try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); String responseTimeString = nodeExtractor.extractNodeValue(soapHeader, responseTimeXPath); String operationsString = nodeExtractor.extractNodeValue(soapHeader, operationsCountXPath); builder .withRequestId(nodeExtractor.extractNodeValue(soapHeader, requestIdXPath)) .withResponseTimeMillis(Longs.tryParse(Strings.nullToEmpty(responseTimeString))) .withOperationsCount(Longs.tryParse(Strings.nullToEmpty(operationsString))); } catch (SOAPException e) { builder.withRequestId("Unable to extract the requestId due to exception: " + e); } return builder; } @Inject  ResponseInfoXPathSet(AdsApiConfiguration apiConfig, NodeExtractor nodeExtractor); IterableXPath getRequestIdXPath(); IterableXPath getResponseTimeXPath(); IterableXPath getOperationsCountXPath(); @Override String toString(); ResponseInfo.Builder parseMessage(ResponseInfo.Builder builder, SOAPMessage soapMessage);  }