Search in sources :

Example 1 with Result

use of io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result 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 Result

use of io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result 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 Result

use of io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result in project blueocean-plugin by jenkinsci.

the class BlueTestResultFactoryTest method testFactoryReturnsZeroTestsForNode.

@Test
public void testFactoryReturnsZeroTestsForNode() {
    testsToReturn = 0;
    Run<?, ?> run = mock(Run.class);
    BluePipelineNode node = mock(BluePipelineNode.class);
    Result resolved = BlueTestResultFactory.resolve(run, node);
    assertNull(resolved.summary);
    assertNull(resolved.results);
}
Also used : BluePipelineNode(io.jenkins.blueocean.rest.model.BluePipelineNode) BlueTestResult(io.jenkins.blueocean.rest.model.BlueTestResult) Result(io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result) Test(org.junit.Test)

Example 4 with Result

use of io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result in project blueocean-plugin by jenkinsci.

the class BlueTestResultFactoryTest method testFactoryReturnsZeroTests.

@Test
public void testFactoryReturnsZeroTests() {
    testsToReturn = 0;
    Run<?, ?> run = mock(Run.class);
    Result resolved = BlueTestResultFactory.resolve(run, null);
    assertNull(resolved.summary);
    assertNull(resolved.results);
}
Also used : BlueTestResult(io.jenkins.blueocean.rest.model.BlueTestResult) Result(io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result) Test(org.junit.Test)

Example 5 with Result

use of io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result in project blueocean-plugin by jenkinsci.

the class BlueTestResultFactoryTest method testFactory.

@Test
public void testFactory() {
    Run<?, ?> run = mock(Run.class);
    Result resolved = BlueTestResultFactory.resolve(run, null);
    assertNotNull(resolved.summary);
    assertEquals(12, resolved.summary.getTotal());
    assertEquals(6, resolved.summary.getPassedTotal());
    assertEquals(2, resolved.summary.getSkippedTotal());
    assertEquals(4, resolved.summary.getFailedTotal());
    assertEquals(2, resolved.summary.getRegressionsTotal());
    assertEquals(2, resolved.summary.getFixedTotal());
    assertEquals(2, resolved.summary.getExistingFailedTotal());
}
Also used : BlueTestResult(io.jenkins.blueocean.rest.model.BlueTestResult) Result(io.jenkins.blueocean.rest.factory.BlueTestResultFactory.Result) Test(org.junit.Test)

Aggregations

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