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