### Question:
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; }### Answer:
@Test public void toScenarios_should_return_empty_list_when_items_is_null() { final List<NewmanScenario> newmanScenarios = cut.toScenarios(null, null, null); assertThat(newmanScenarios).isEmpty(); }
@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"); }
@Test public void toScenarios_should_append_executed_scenarios_to_newman_scenarios() { 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.getScenario().getName())) .containsExactly("parent", "parent \u25b6 request1", "parent \u25b6 request2"); }
@Test public void toScenarios_should_increment_lines() { Item[] items = new Item[] { new Item() .withName("parent") .withChildren(new Item[] { new Item().withName("request1"), new Item().withName("request2") }) }; AtomicInteger requestPosition = new AtomicInteger(5); final List<NewmanScenario> newmanScenarios = cut.toScenarios(items, requestPosition, null, NO_PARENT); assertThat(newmanScenarios.stream().map(n -> Integer.valueOf(n.getScenario().getLine()))) .containsExactly(Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8)); }