All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.otto.jlineup.report.ReportGenerator Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
package de.otto.jlineup.report;

import java.util.*;

public class ReportGenerator {

    public Report generateReport(List screenshotComparisonResultList) {
        final double differenceSum = screenshotComparisonResultList.stream().mapToDouble(scr -> scr.difference).sum();
        final OptionalDouble differenceMax = screenshotComparisonResultList.stream().mapToDouble(scr -> scr.difference).max();
        final Summary summary = new Summary(differenceSum > 0, differenceSum, differenceMax.orElseGet(() -> 0));

        Map> resultsPerUrl = new HashMap<>();

        for (ScreenshotComparisonResult screenshotComparisonResult : screenshotComparisonResultList) {
            List resultListForUrl = resultsPerUrl.getOrDefault(screenshotComparisonResult.url, new ArrayList<>());
            resultListForUrl.add(screenshotComparisonResult);
            resultsPerUrl.putIfAbsent(screenshotComparisonResult.url, resultListForUrl);
        }

        return new Report(summary, resultsPerUrl);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy