use of io.jenkins.blueocean.rest.model.BlueTestResult in project blueocean-plugin by jenkinsci.
the class BlueTestResultContainerImplTest method testGetTestNotFound.
@Test
public void testGetTestNotFound() throws Exception {
String id = "io.jenkins.blueocean.service.embedded.BlueTestResultContainerImplTest$FactoryImpl$BlueTestResultImpl:test_1";
BlueTestResult result = container.get(id);
assertNotNull(result);
assertEquals(id, result.getId());
}
use of io.jenkins.blueocean.rest.model.BlueTestResult in project blueocean-plugin by jenkinsci.
the class BlueTestResultContainerImplTest method testsFilteredByStatus.
@Test
public void testsFilteredByStatus() throws Exception {
List<BlueTestResult> allResults = IteratorUtils.toList(container.iterator());
List<BlueTestResult> allSkipped = IteratorUtils.toList(container.getBlueTestResultIterator(allResults, Status.SKIPPED.name(), null, null));
assertEquals(2, allSkipped.size());
for (BlueTestResult tr : allSkipped) {
assertEquals(Status.SKIPPED, tr.getStatus());
}
}
use of io.jenkins.blueocean.rest.model.BlueTestResult in project blueocean-plugin by jenkinsci.
the class BlueTestResultFactory method resolve.
public static Result resolve(Run<?, ?> run, Reachable parent) {
Iterable<BlueTestResult> results = new ArrayList<>(0);
BlueTestSummary summary = new //
BlueTestSummary(//
0, //
0, //
0, //
0, //
0, //
0, //
0, parent == null ? null : parent.getLink());
for (BlueTestResultFactory factory : allFactories()) {
Result result = factory.getBlueTestResults(run, parent);
if (result != null && result.results != null && result.summary != null) {
results = IterableUtils.chainedIterable(result.results, results);
summary = summary.tally(result.summary);
}
}
return getResult(results, summary);
}
use of io.jenkins.blueocean.rest.model.BlueTestResult 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();
}
use of io.jenkins.blueocean.rest.model.BlueTestResult 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