GenericAllureStoryReporter implements StoryReporter { @VisibleForTesting protected static Set<Map<String, String>> minimize() { Set<?> videos = Sets.newHashSet(config().getList("webdriver.videos", Lists.newArrayList())); List<Map<String, String>> videosData = Lists.newArrayList(); Set<Map<String, String>> result = Sets.newTreeSet(new Comparator<Map<String, String>>() { @Override public int compare(Map<String, String> o1, Map<String, String> o2) { String key1 = o1.keySet().iterator().next(); String key2 = o2.keySet().iterator().next(); return key1.compareTo(key2); } }); Set<String> titles = Sets.newTreeSet(new Comparator<String>() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } }); for (Object video : videos) { @SuppressWarnings("unchecked") Map.Entry<String, String> videoData = ((Map<String, String>) video).entrySet().iterator().next(); closeSession(videoData.getValue().replaceAll(".*/download_video/", "").replaceAll(".mp4", "").replaceAll(" titles.add(videoData.getKey().split("->")[0]); videosData.add(Collections.singletonMap(videoData.getKey(), videoData.getValue())); } if (titles.size() != videos.size()) { for (final String title : titles) { FluentIterable<Map<String, String>> videosForScenario = FluentIterable.from(videosData).filter(new Predicate<Map<String, String>>() { @Override public boolean apply(Map<String, String> input) { return input.keySet().iterator().next().contains(title + "->"); } }); if (videosForScenario.size() == 1) { result.add(Collections.singletonMap(title + "::", videosForScenario.first().get().values().iterator().next())); } else { result.addAll(videosForScenario.toList()); } } } LOG.info("Preparing to download videos for:\n{}", Joiner.on("\n").join(result)); return result; } GenericAllureStoryReporter(); static String storyName(); static void populateVideos(Properties initial); @VisibleForTesting static void populateVideo(Properties initial, String link, String title); static Properties environment(); static Optional<File> getResultsDir(); static File getReportDir(); static void cleanPreviousReport(); static void generateReport(); static String scenarioName(); void beforeStory(String name, String description, String path); void afterStory(); void beforeScenario(String scenarioTitle); void scenarioMeta(Properties meta); void afterScenario(); void example(Map<String, String> tableRow); void beforeStep(String step); void successful(String step); void ignorable(String step); void pending(String step); void notPerformed(String step); void failed(String step, Throwable cause); @Override void start(); @Override void finish(); void attach(byte[] attachment, String title, String mimeType); String name(); int order(); static final ThreadLocal<String> currentScenario; }
@SuppressWarnings("unchecked") @Test public void should_makeTheTheListMinimal() { List<Map<String, String>> data = Lists.newArrayList(); Map<String, String> first = Collections.singletonMap("Feature1 ->scenario1|sss|::", "empty"); Map<String, String> second = Collections.singletonMap("Feature1 ->scenario2|aaa|::", "empty"); Map<String, String> third = Collections.singletonMap("Feature1 2->scenario1::", "empty"); Map<String, String> augmented = Collections.singletonMap("Feature1 2::", "empty"); data.add(first); data.add(first); data.add(second); data.add(second); data.add(second); data.add(third); data.add(third); data.add(second); ConfigLoader.config().addProperty("webdriver.videos", data); assertThat(GenericAllureStoryReporter.minimize().size(), is(3)); assertThat(GenericAllureStoryReporter.minimize(), contains(first, second, augmented)); assertThat(GenericAllureStoryReporter.minimize(), not(contains(third))); }