Search in sources :

Example 1 with NotFoundException

use of io.jenkins.blueocean.commons.ServiceException.NotFoundException in project blueocean-plugin by jenkinsci.

the class BlueTestResultContainerImpl method get.

@Override
public BlueTestResult get(final String name) {
    Result resolved = resolve();
    if (resolved.summary == null || resolved.results == null) {
        throw new NotFoundException("no tests");
    }
    BlueTestResult testResult = IterableUtils.find(resolved.results, blueTestResult -> blueTestResult != null && blueTestResult.getId().equals(name), null);
    if (testResult == null) {
        throw new NotFoundException("not found");
    }
    return testResult;
}
Also used : NotFoundException(io.jenkins.blueocean.commons.ServiceException.NotFoundException) BlueTestResult(io.jenkins.blueocean.rest.model.BlueTestResult) BlueTestResult(io.jenkins.blueocean.rest.model.BlueTestResult) Result(io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result)

Example 2 with NotFoundException

use of io.jenkins.blueocean.commons.ServiceException.NotFoundException in project blueocean-plugin by jenkinsci.

the class BlueTestResultContainerImpl method iterator.

@NonNull
@Override
public Iterator<BlueTestResult> iterator() {
    Result resolved = resolve();
    if (resolved.summary == null || resolved.results == null) {
        throw new NotFoundException("no tests");
    }
    StaplerRequest request = Stapler.getCurrentRequest();
    if (request != null) {
        String status = request.getParameter("status");
        String state = request.getParameter("state");
        String age = request.getParameter("age");
        return getBlueTestResultIterator(resolved.results, status, state, age);
    }
    return resolved.results.iterator();
}
Also used : StaplerRequest(org.kohsuke.stapler.StaplerRequest) NotFoundException(io.jenkins.blueocean.commons.ServiceException.NotFoundException) BlueTestResult(io.jenkins.blueocean.rest.model.BlueTestResult) Result(io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Example 3 with NotFoundException

use of io.jenkins.blueocean.commons.ServiceException.NotFoundException in project blueocean-plugin by jenkinsci.

the class RunContainerImpl method get.

@Override
public BlueRun get(String name) {
    RunList<? extends hudson.model.Run> runList = job.getBuilds();
    if (name == null) {
        return BlueRunFactory.getRun(runList.getLastBuild(), pipeline);
    }
    for (hudson.model.Run r : runList) {
        if (r.getId().equals(name)) {
            return BlueRunFactory.getRun(r, pipeline);
        }
    }
    int number;
    try {
        number = Integer.parseInt(name);
    } catch (NumberFormatException e) {
        throw new NotFoundException(String.format("Run %s not found in organization %s and pipeline %s", name, pipeline.getOrganizationName(), job.getName()));
    }
    for (BlueQueueItem item : QueueUtil.getQueuedItems(pipeline.getOrganization(), job)) {
        if (item.getExpectedBuildNumber() == number) {
            return item.toRun();
        }
    }
    throw new NotFoundException(String.format("Run %s not found in organization %s and pipeline %s", name, pipeline.getOrganizationName(), job.getName()));
}
Also used : NotFoundException(io.jenkins.blueocean.commons.ServiceException.NotFoundException) BlueQueueItem(io.jenkins.blueocean.rest.model.BlueQueueItem)

Aggregations

NotFoundException (io.jenkins.blueocean.commons.ServiceException.NotFoundException)3 Result (io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result)2 BlueTestResult (io.jenkins.blueocean.rest.model.BlueTestResult)2 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1 BlueQueueItem (io.jenkins.blueocean.rest.model.BlueQueueItem)1 StaplerRequest (org.kohsuke.stapler.StaplerRequest)1