@Test public void toScenarios_should_wrap_item_tree_into_newman_scenario_list() { Item[] items = new Item[] { new Item() .withName("parent") .withChildren(new Item[] { new Item().withName("request1"), new Item().withName("request2") }) }; final List<NewmanScenario> newmanScenarios = cut.toScenarios(items, new AtomicInteger(-42), null, NO_PARENT); assertThat(newmanScenarios.stream().map(n -> n.getItem().getName())) .containsExactly("parent", "request1", "request2"); }
List<NewmanScenario> toScenarios(Item[] items, AtomicInteger requestPosition, String parentSeverity, String... parentFolders) { List<NewmanScenario> newmanScenarios = new ArrayList<>(); if (items != null) { for (Item item : items) { String severity = getSeverity(ArrayUtils.addAll(parentFolders, item.getName())); if (StringUtils.isEmpty(severity)) { severity = parentSeverity; } String nameWithoutTag = removeSeverityTag(item.getName()); String[] path = ArrayUtils.addAll(parentFolders, nameWithoutTag); ExecutedScenario executedScenario = new ExecutedScenario(); executedScenario.setName(String.join(FOLDER_DELIMITER, path)); executedScenario.setLine(requestPosition.incrementAndGet()); executedScenario.setCucumberId(toCucumberId(path)); executedScenario.setSeverity(severity); executedScenario.setTags(StringUtils.isEmpty(severity) ? null : Tag.SEVERITY_PREFIX + severity); NewmanScenario newmanScenario = new NewmanScenario(); newmanScenario.setScenario(executedScenario); newmanScenario.setItem(item); newmanScenarios.add(newmanScenario); newmanScenarios.addAll(toScenarios(item.getChildren(), requestPosition, severity, path)); } } return newmanScenarios; }
PostmanService { List<NewmanScenario> toScenarios(Item[] items, AtomicInteger requestPosition, String parentSeverity, String... parentFolders) { List<NewmanScenario> newmanScenarios = new ArrayList<>(); if (items != null) { for (Item item : items) { String severity = getSeverity(ArrayUtils.addAll(parentFolders, item.getName())); if (StringUtils.isEmpty(severity)) { severity = parentSeverity; } String nameWithoutTag = removeSeverityTag(item.getName()); String[] path = ArrayUtils.addAll(parentFolders, nameWithoutTag); ExecutedScenario executedScenario = new ExecutedScenario(); executedScenario.setName(String.join(FOLDER_DELIMITER, path)); executedScenario.setLine(requestPosition.incrementAndGet()); executedScenario.setCucumberId(toCucumberId(path)); executedScenario.setSeverity(severity); executedScenario.setTags(StringUtils.isEmpty(severity) ? null : Tag.SEVERITY_PREFIX + severity); NewmanScenario newmanScenario = new NewmanScenario(); newmanScenario.setScenario(executedScenario); newmanScenario.setItem(item); newmanScenarios.add(newmanScenario); newmanScenarios.addAll(toScenarios(item.getChildren(), requestPosition, severity, path)); } } return newmanScenarios; } }
PostmanService { List<NewmanScenario> toScenarios(Item[] items, AtomicInteger requestPosition, String parentSeverity, String... parentFolders) { List<NewmanScenario> newmanScenarios = new ArrayList<>(); if (items != null) { for (Item item : items) { String severity = getSeverity(ArrayUtils.addAll(parentFolders, item.getName())); if (StringUtils.isEmpty(severity)) { severity = parentSeverity; } String nameWithoutTag = removeSeverityTag(item.getName()); String[] path = ArrayUtils.addAll(parentFolders, nameWithoutTag); ExecutedScenario executedScenario = new ExecutedScenario(); executedScenario.setName(String.join(FOLDER_DELIMITER, path)); executedScenario.setLine(requestPosition.incrementAndGet()); executedScenario.setCucumberId(toCucumberId(path)); executedScenario.setSeverity(severity); executedScenario.setTags(StringUtils.isEmpty(severity) ? null : Tag.SEVERITY_PREFIX + severity); NewmanScenario newmanScenario = new NewmanScenario(); newmanScenario.setScenario(executedScenario); newmanScenario.setItem(item); newmanScenarios.add(newmanScenario); newmanScenarios.addAll(toScenarios(item.getChildren(), requestPosition, severity, path)); } } return newmanScenarios; }  }
PostmanService { List<NewmanScenario> toScenarios(Item[] items, AtomicInteger requestPosition, String parentSeverity, String... parentFolders) { List<NewmanScenario> newmanScenarios = new ArrayList<>(); if (items != null) { for (Item item : items) { String severity = getSeverity(ArrayUtils.addAll(parentFolders, item.getName())); if (StringUtils.isEmpty(severity)) { severity = parentSeverity; } String nameWithoutTag = removeSeverityTag(item.getName()); String[] path = ArrayUtils.addAll(parentFolders, nameWithoutTag); ExecutedScenario executedScenario = new ExecutedScenario(); executedScenario.setName(String.join(FOLDER_DELIMITER, path)); executedScenario.setLine(requestPosition.incrementAndGet()); executedScenario.setCucumberId(toCucumberId(path)); executedScenario.setSeverity(severity); executedScenario.setTags(StringUtils.isEmpty(severity) ? null : Tag.SEVERITY_PREFIX + severity); NewmanScenario newmanScenario = new NewmanScenario(); newmanScenario.setScenario(executedScenario); newmanScenario.setItem(item); newmanScenarios.add(newmanScenario); newmanScenarios.addAll(toScenarios(item.getChildren(), requestPosition, severity, path)); } } return newmanScenarios; }  void parse(JsonParser parser, NewmanParsingResult result); List<ExecutedScenario> postProcess(Run run, NewmanParsingResult result, String newmanReportPath, AtomicInteger requestPosition); void deleteTempFiles(NewmanParsingResult newmanParsingResult); }
PostmanService { List<NewmanScenario> toScenarios(Item[] items, AtomicInteger requestPosition, String parentSeverity, String... parentFolders) { List<NewmanScenario> newmanScenarios = new ArrayList<>(); if (items != null) { for (Item item : items) { String severity = getSeverity(ArrayUtils.addAll(parentFolders, item.getName())); if (StringUtils.isEmpty(severity)) { severity = parentSeverity; } String nameWithoutTag = removeSeverityTag(item.getName()); String[] path = ArrayUtils.addAll(parentFolders, nameWithoutTag); ExecutedScenario executedScenario = new ExecutedScenario(); executedScenario.setName(String.join(FOLDER_DELIMITER, path)); executedScenario.setLine(requestPosition.incrementAndGet()); executedScenario.setCucumberId(toCucumberId(path)); executedScenario.setSeverity(severity); executedScenario.setTags(StringUtils.isEmpty(severity) ? null : Tag.SEVERITY_PREFIX + severity); NewmanScenario newmanScenario = new NewmanScenario(); newmanScenario.setScenario(executedScenario); newmanScenario.setItem(item); newmanScenarios.add(newmanScenario); newmanScenarios.addAll(toScenarios(item.getChildren(), requestPosition, severity, path)); } } return newmanScenarios; }  void parse(JsonParser parser, NewmanParsingResult result); List<ExecutedScenario> postProcess(Run run, NewmanParsingResult result, String newmanReportPath, AtomicInteger requestPosition); void deleteTempFiles(NewmanParsingResult newmanParsingResult); static final String FOLDER_DELIMITER; }