class PostmanScenarioIndexerService {

    Scenario toScenario(ItemWithScripts item, Source source, AtomicInteger requestPosition, String severity, List<Assertion> assertions, String... path) {
        final String countryCodes;
        if (source.isPostmanCountryRootFolders()) {
            countryCodes = extractCountryCodes(path);
        } else {
            countryCodes = Tag.COUNTRY_ALL;
        }

        final Assertion[] assertionsArray = assertions.toArray(new Assertion[0]);

        String content = postmanService.buildScenarioContent(item.getRequest(), null, assertionsArray, null, true);

        Scenario scenario = new Scenario();
        scenario.setSource(source);
        scenario.setTags(StringUtils.isEmpty(severity) ? null : Tag.SEVERITY_PREFIX + severity);
        scenario.setCountryCodes(countryCodes);
        scenario.setSeverity(severity);
        scenario.setName(String.join(PostmanService.FOLDER_DELIMITER, path));
        scenario.setLine(requestPosition.incrementAndGet());
        scenario.setContent(content);
        return scenario;
    }

}