@Test public void shouldAddXmlProcessingLines() { XmlBodyVerificationBuilder builder = new XmlBodyVerificationBuilder(new Contract(), Optional.of(";")); BlockBuilder blockBuilder = new BlockBuilder(" "); BodyMatchers matchers = new BodyMatchers(); builder.addXmlResponseBodyCheck(blockBuilder, xml, matchers, xml, true); String test = blockBuilder.toString(); assertThat(test).contains("DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();") .contains("builderFactory.setNamespaceAware(true);") .contains("DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();") .contains("Document parsedXml = documentBuilder.parse(new InputSource(new StringReader(").contains(xml); }
void addXmlResponseBodyCheck(BlockBuilder blockBuilder, Object responseBody, BodyMatchers bodyMatchers, String responseString, boolean shouldCommentOutBDDBlocks) { addXmlProcessingLines(blockBuilder, responseString); Object processedBody = XmlToXPathsConverter.removeMatchingXPaths(responseBody, bodyMatchers); List<BodyMatcher> matchers = new XmlToXPathsConverter().mapToMatchers(processedBody); if (bodyMatchers != null && bodyMatchers.hasMatchers()) { matchers.addAll(bodyMatchers.matchers()); } addBodyMatchingBlock(matchers, blockBuilder, responseBody, shouldCommentOutBDDBlocks); }
XmlBodyVerificationBuilder implements BodyMethodGeneration { void addXmlResponseBodyCheck(BlockBuilder blockBuilder, Object responseBody, BodyMatchers bodyMatchers, String responseString, boolean shouldCommentOutBDDBlocks) { addXmlProcessingLines(blockBuilder, responseString); Object processedBody = XmlToXPathsConverter.removeMatchingXPaths(responseBody, bodyMatchers); List<BodyMatcher> matchers = new XmlToXPathsConverter().mapToMatchers(processedBody); if (bodyMatchers != null && bodyMatchers.hasMatchers()) { matchers.addAll(bodyMatchers.matchers()); } addBodyMatchingBlock(matchers, blockBuilder, responseBody, shouldCommentOutBDDBlocks); } }
XmlBodyVerificationBuilder implements BodyMethodGeneration { void addXmlResponseBodyCheck(BlockBuilder blockBuilder, Object responseBody, BodyMatchers bodyMatchers, String responseString, boolean shouldCommentOutBDDBlocks) { addXmlProcessingLines(blockBuilder, responseString); Object processedBody = XmlToXPathsConverter.removeMatchingXPaths(responseBody, bodyMatchers); List<BodyMatcher> matchers = new XmlToXPathsConverter().mapToMatchers(processedBody); if (bodyMatchers != null && bodyMatchers.hasMatchers()) { matchers.addAll(bodyMatchers.matchers()); } addBodyMatchingBlock(matchers, blockBuilder, responseBody, shouldCommentOutBDDBlocks); } XmlBodyVerificationBuilder(Contract contract, Optional<String> lineSuffix); }
XmlBodyVerificationBuilder implements BodyMethodGeneration { void addXmlResponseBodyCheck(BlockBuilder blockBuilder, Object responseBody, BodyMatchers bodyMatchers, String responseString, boolean shouldCommentOutBDDBlocks) { addXmlProcessingLines(blockBuilder, responseString); Object processedBody = XmlToXPathsConverter.removeMatchingXPaths(responseBody, bodyMatchers); List<BodyMatcher> matchers = new XmlToXPathsConverter().mapToMatchers(processedBody); if (bodyMatchers != null && bodyMatchers.hasMatchers()) { matchers.addAll(bodyMatchers.matchers()); } addBodyMatchingBlock(matchers, blockBuilder, responseBody, shouldCommentOutBDDBlocks); } XmlBodyVerificationBuilder(Contract contract, Optional<String> lineSuffix); @Override void methodForNullCheck(BodyMatcher bodyMatcher, BlockBuilder bb); @Override void methodForEqualityCheck(BodyMatcher bodyMatcher, BlockBuilder bb, Object body); @Override void methodForCommandExecution(BodyMatcher bodyMatcher, BlockBuilder bb, Object body); @Override void methodForTypeCheck(BodyMatcher bodyMatcher, BlockBuilder bb, Object copiedBody); }
XmlBodyVerificationBuilder implements BodyMethodGeneration { void addXmlResponseBodyCheck(BlockBuilder blockBuilder, Object responseBody, BodyMatchers bodyMatchers, String responseString, boolean shouldCommentOutBDDBlocks) { addXmlProcessingLines(blockBuilder, responseString); Object processedBody = XmlToXPathsConverter.removeMatchingXPaths(responseBody, bodyMatchers); List<BodyMatcher> matchers = new XmlToXPathsConverter().mapToMatchers(processedBody); if (bodyMatchers != null && bodyMatchers.hasMatchers()) { matchers.addAll(bodyMatchers.matchers()); } addBodyMatchingBlock(matchers, blockBuilder, responseBody, shouldCommentOutBDDBlocks); } XmlBodyVerificationBuilder(Contract contract, Optional<String> lineSuffix); @Override void methodForNullCheck(BodyMatcher bodyMatcher, BlockBuilder bb); @Override void methodForEqualityCheck(BodyMatcher bodyMatcher, BlockBuilder bb, Object body); @Override void methodForCommandExecution(BodyMatcher bodyMatcher, BlockBuilder bb, Object body); @Override void methodForTypeCheck(BodyMatcher bodyMatcher, BlockBuilder bb, Object copiedBody);  }