use of io.jenkins.blueocean.rest.model.BlueTestResult.Status in project blueocean-plugin by jenkinsci.
the class BlueTestResultContainerImpl method filterByStatus.
@VisibleForTesting
public static Iterator<BlueTestResult> filterByStatus(Iterable<BlueTestResult> results, String status) {
String[] statusAtoms = StringUtils.split(status, ',');
Predicate<BlueTestResult> predicate = Predicates.alwaysFalse();
if (statusAtoms == null || statusAtoms.length == 0) {
throw new BadRequestException("status not provided");
}
for (String statusString : statusAtoms) {
Status queryStatus;
try {
queryStatus = Status.valueOf(statusString.toUpperCase());
} catch (IllegalArgumentException e) {
throw new BadRequestException("bad status " + status, e);
}
predicate = Predicates.or(predicate, new StatusPredicate(queryStatus));
}
return Iterables.filter(results, predicate).iterator();
}
use of io.jenkins.blueocean.rest.model.BlueTestResult.Status in project blueocean-plugin by jenkinsci.
the class BlueTestResultContainerImpl method filterByStatus.
// for testing purpose
public static Predicate<BlueTestResult> filterByStatus(String status) {
String[] statusAtoms = StringUtils.split(status, ',');
Predicate<BlueTestResult> predicate = blueTestResult -> false;
if (statusAtoms == null || statusAtoms.length == 0) {
throw new BadRequestException("status not provided");
}
for (String statusString : statusAtoms) {
Predicate<BlueTestResult> statusPredicate;
try {
if (statusString.startsWith("!")) {
StatusPredicate tmp = new StatusPredicate(Status.valueOf(statusString.toUpperCase().substring(1)));
statusPredicate = blueTestResult -> !tmp.test(blueTestResult);
} else {
statusPredicate = new StatusPredicate(Status.valueOf(statusString.toUpperCase()));
}
} catch (IllegalArgumentException e) {
throw new BadRequestException("bad status " + status, e);
}
predicate = predicate.or(statusPredicate);
}
return predicate;
}
Aggregations