@Override
public Integer getValue() {
class UnitTestComparator implements Comparator<Build> {
@Override
public int compare(Build o1, Build o2) {
Action test1 = getTestReport(o1);
Action test2 = getTestReport(o2);
if (test1 == null && test2 == null)
return 0;
if (test1 == null)
return 1;
if (test2 == null)
return -1;
return test1.getTotalCount() - test2.getTotalCount();
}
}
List<Build> builds = service.getBuilds(project);
if (builds.isEmpty())
return null;
Build buildWithMaxUnitTests = Collections.max(builds,
new UnitTestComparator());
Action testReport = getTestReport(buildWithMaxUnitTests);
return testReport == null ? null : testReport.getTotalCount();
}