public static Statistic randomStatistic() { return new Statistic() .setFailed(current().nextLong(10)) .setBroken(current().nextLong(10)) .setPassed(current().nextLong(10)) .setSkipped(current().nextLong(10)) .setUnknown(current().nextLong(10)); }
public void merge(final Statistic other) { if (Objects.isNull(other)) { return; } setFailed(getFailed() + other.getFailed()); setBroken(getBroken() + other.getBroken()); setPassed(getPassed() + other.getPassed()); setSkipped(getSkipped() + other.getSkipped()); setUnknown(getUnknown() + other.getUnknown()); }
public static Statistic updateStatistic(final Statistic statistic, final TreeNode treeNode) { if (treeNode instanceof TestResultTreeGroup) { final Statistic byLeafs = calculateStatisticByLeafs((TestResultTreeGroup) treeNode); statistic.update(byLeafs.getStatus()); } else if (treeNode instanceof TestResultTreeLeaf) { statistic.update(((TestResultTreeLeaf) treeNode).getStatus()); } return statistic; }
public static Statistic calculateStatisticByLeafs(final TestResultTreeGroup group) { return group.getChildren().stream() .reduce( new Statistic(), TreeUtils::updateStatisticRecursive, TreeUtils::mergeStatistic ); }
public static Statistic updateStatisticRecursive(final Statistic statistic, final TreeNode treeNode) { if (treeNode instanceof TestResultTreeGroup) { statistic.merge(calculateStatisticByLeafs((TestResultTreeGroup) treeNode)); } else if (treeNode instanceof TestResultTreeLeaf) { statistic.update(((TestResultTreeLeaf) treeNode).getStatus()); } return statistic; }
public void update(final Statusable statusable) { if (Objects.isNull(statusable)) { return; } update(statusable.getStatus()); }
@Override protected List<CsvExportCategory> getData(final List<LaunchResults> launchesResults) { final List<CsvExportCategory> exportLabels = new ArrayList<>(); final Tree<TestResult> data = CategoriesPlugin.getData(launchesResults); final List<TreeWidgetItem> items = data.getChildren().stream() .filter(TestResultTreeGroup.class::isInstance) .map(TestResultTreeGroup.class::cast) .map(CategoriesPlugin::toWidgetItem) .sorted(Comparator.comparing(TreeWidgetItem::getStatistic, comparator()).reversed()) .collect(Collectors.toList()); items.forEach(item -> exportLabels.add(new CsvExportCategory(item))); return exportLabels; } }
public void update(final Status status) { if (Objects.isNull(status)) { return; } switch (status) { case FAILED: setFailed(getFailed() + 1); break; case BROKEN: setBroken(getBroken() + 1); break; case PASSED: setPassed(getPassed() + 1); break; case SKIPPED: setSkipped(getSkipped() + 1); break; default: setUnknown(getUnknown() + 1); break; } }
public static Statistic calculateStatisticByChildren(final TestResultTreeGroup group) { return group.getChildren().stream() .reduce( new Statistic(), TreeUtils::updateStatistic, TreeUtils::mergeStatistic ); }
public static Statistic updateStatisticRecursive(final Statistic statistic, final TreeNode treeNode) { if (treeNode instanceof TestResultTreeGroup) { statistic.merge(calculateStatisticByLeafs((TestResultTreeGroup) treeNode)); } else if (treeNode instanceof TestResultTreeLeaf) { statistic.update(((TestResultTreeLeaf) treeNode).getStatus()); } return statistic; }
public static Statistic updateStatistic(final Statistic statistic, final TreeNode treeNode) { if (treeNode instanceof TestResultTreeGroup) { final Statistic byLeafs = calculateStatisticByLeafs((TestResultTreeGroup) treeNode); statistic.update(byLeafs.getStatus()); } else if (treeNode instanceof TestResultTreeLeaf) { statistic.update(((TestResultTreeLeaf) treeNode).getStatus()); } return statistic; }
@Override public void update(final TestResult testResult) { if (testResult.isRetry()) { return; } statistic.update(testResult); }
@Override protected Object getData(final List<LaunchResults> launches) { final Tree<TestResult> data = SuitesPlugin.getData(launches); final List<TreeWidgetItem> items = data.getChildren().stream() .filter(TestResultTreeGroup.class::isInstance) .map(TestResultTreeGroup.class::cast) .map(WidgetAggregator::toWidgetItem) .sorted(Comparator.comparing(TreeWidgetItem::getStatistic, comparator()).reversed()) .limit(10) .collect(Collectors.toList()); return new TreeWidgetData().setItems(items).setTotal(data.getChildren().size()); }
default void updateStatistic(Statistic other) { getStatistic().setFailed(other.getFailed() + getStatistic().getFailed()); getStatistic().setBroken(other.getBroken() + getStatistic().getBroken()); getStatistic().setPassed(other.getPassed() + getStatistic().getPassed()); getStatistic().setSkipped(other.getSkipped() + getStatistic().getSkipped()); getStatistic().setUnknown(other.getUnknown() + getStatistic().getUnknown()); }
@Test public void shouldGetStatusForStatistic() throws Exception { final Statistic first = new Statistic().setFailed(2L).setPassed(1L); final Statistic second = new Statistic().setPassed(4L).setBroken(1L); final Statistic third = new Statistic().setPassed(1L).setSkipped(4L); assertThat(Arrays.asList(first, second, third)) .extracting(Statistic::getStatus) .containsExactly( Status.FAILED, Status.BROKEN, Status.PASSED ); }
@Override protected SummaryData getData(final List<LaunchResults> launches) { final SummaryData data = new SummaryData() .setStatistic(new Statistic()) .setTime(new GroupTime()) .setReportName("Allure Report"); launches.stream() .flatMap(launch -> launch.getResults().stream()) .forEach(result -> { data.getStatistic().update(result); data.getTime().update(result); }); return data; } }
private Optional<LaunchInfo> updateLaunchInfo(final LaunchResults results) { final Optional<LaunchInfo> extra = results.getExtra(LAUNCH_BLOCK_NAME); extra.map(launchInfo -> { final Statistic statistic = new Statistic(); launchInfo.setStatistic(statistic); results.getResults().forEach(statistic::update); return launchInfo; }); return extra; } }