Search in sources :

Example 1 with Links

use of io.jenkins.blueocean.rest.hal.Links in project blueocean-plugin by jenkinsci.

the class FreeStylePipelineTest method findNonNumericRun.

@Test
@Issue("JENKINS-51716")
public void findNonNumericRun() throws Exception {
    FreeStyleProject freestyle = Mockito.spy(j.createProject(FreeStyleProject.class, "freestyle"));
    FreeStyleBuild build1 = Mockito.mock(FreeStyleBuild.class);
    FreeStyleBuild build2 = Mockito.mock(FreeStyleBuild.class);
    Mockito.when(build1.getId()).thenReturn("build1");
    Mockito.when(build1.getParent()).thenReturn(freestyle);
    Mockito.when(build1.getNextBuild()).thenReturn(build2);
    Mockito.when(build2.getId()).thenReturn("build2");
    Mockito.when(build2.getParent()).thenReturn(freestyle);
    Mockito.when(build2.getPreviousBuild()).thenReturn(build1);
    RunList<FreeStyleBuild> runs = RunList.fromRuns(Arrays.asList(build1, build2));
    Mockito.doReturn(runs).when(freestyle).getBuilds();
    Mockito.doReturn(build2).when(freestyle).getLastBuild();
    FreeStylePipeline freeStylePipeline = (FreeStylePipeline) BluePipelineFactory.resolve(freestyle);
    assertNotNull(freeStylePipeline);
    BlueRun blueRun = freeStylePipeline.getLatestRun();
    assertNotNull(blueRun);
    Links links = blueRun.getLinks();
    assertNotNull(links);
    assertNotNull(links.get("self"));
}
Also used : BlueRun(io.jenkins.blueocean.rest.model.BlueRun) Links(io.jenkins.blueocean.rest.hal.Links) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with Links

use of io.jenkins.blueocean.rest.hal.Links in project blueocean-plugin by jenkinsci.

the class FreeStylePipelineTest method findModernRun.

@Test
public void findModernRun() throws Exception {
    FreeStyleProject freestyle = Mockito.spy(j.createProject(FreeStyleProject.class, "freestyle"));
    FreeStyleBuild build1 = Mockito.mock(FreeStyleBuild.class);
    FreeStyleBuild build2 = Mockito.mock(FreeStyleBuild.class);
    Mockito.when(build1.getParent()).thenReturn(freestyle);
    Mockito.when(build1.getNextBuild()).thenReturn(build2);
    Mockito.when(build2.getParent()).thenReturn(freestyle);
    Mockito.when(build2.getPreviousBuild()).thenReturn(build1);
    RunList<FreeStyleBuild> runs = RunList.fromRuns(Arrays.asList(build1, build2));
    Mockito.doReturn(runs).when(freestyle).getBuilds();
    Mockito.doReturn(build2).when(freestyle).getLastBuild();
    FreeStylePipeline freeStylePipeline = (FreeStylePipeline) BluePipelineFactory.resolve(freestyle);
    assertNotNull(freeStylePipeline);
    BlueRun blueRun = freeStylePipeline.getLatestRun();
    assertNotNull(blueRun);
    Links links = blueRun.getLinks();
    assertNotNull(links);
    assertNotNull(links.get("self"));
}
Also used : BlueRun(io.jenkins.blueocean.rest.model.BlueRun) Links(io.jenkins.blueocean.rest.hal.Links) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with Links

use of io.jenkins.blueocean.rest.hal.Links in project blueocean-plugin by jenkinsci.

the class AbstractRunImpl method getLinks.

@Override
public Links getLinks() {
    Links links = super.getLinks().add("parent", parent.getLink());
    Run nextRun = run.getNextBuild();
    Run prevRun = run.getPreviousBuild();
    if (nextRun != null) {
        Link nextRunLink = LinkResolver.resolveLink(nextRun);
        links.add("nextRun", nextRunLink);
    }
    if (prevRun != null) {
        Link prevRunLink = LinkResolver.resolveLink(prevRun);
        links.add("prevRun", prevRunLink);
    }
    return links;
}
Also used : Links(io.jenkins.blueocean.rest.hal.Links) BlueRun(io.jenkins.blueocean.rest.model.BlueRun) Run(hudson.model.Run) Link(io.jenkins.blueocean.rest.hal.Link)

Aggregations

Links (io.jenkins.blueocean.rest.hal.Links)3 BlueRun (io.jenkins.blueocean.rest.model.BlueRun)3 FreeStyleBuild (hudson.model.FreeStyleBuild)2 FreeStyleProject (hudson.model.FreeStyleProject)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Run (hudson.model.Run)1 Link (io.jenkins.blueocean.rest.hal.Link)1 Issue (org.jvnet.hudson.test.Issue)1