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"));
}
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"));
}
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;
}
Aggregations