use of io.jenkins.blueocean.rest.hal.Link in project blueocean-plugin by jenkinsci.
the class OrganizationFolderTest method testOrgFolderRun.
@Test
@WithoutJenkins
public void testOrgFolderRun() {
OrganizationFolderPipelineImpl organizationFolder = new OrganizationFolderPipelineImpl(mockOrganization(), orgFolder, new Link("/a/b/")) {
};
OrganizationFolderRunImpl organizationFolderRun = new OrganizationFolderRunImpl(organizationFolder, new Reachable() {
@Override
public Link getLink() {
return new Link("/a/b/");
}
});
assertEquals(orgFolder.getName(), organizationFolderRun.getPipeline());
assertEquals(organization.getName(), organizationFolderRun.getOrganization());
assertNotNull(organizationFolder.getRuns());
}
use of io.jenkins.blueocean.rest.hal.Link in project blueocean-plugin by jenkinsci.
the class NodeDownstreamBuildActionTest method appeaseCoverageMonster.
// FIXME: How do I get rid of this? POJO test cases make Baby Jesus cry.
@Test
public void appeaseCoverageMonster() {
NodeDownstreamBuildAction a = new NodeDownstreamBuildAction(new Link("/nuts"), "right");
assertNotNull(a);
}
use of io.jenkins.blueocean.rest.hal.Link in project blueocean-plugin by jenkinsci.
the class DefaultRunImplTest method unknownRunTypeResolvesToDefaultRunImpl.
@Test
public void unknownRunTypeResolvesToDefaultRunImpl() throws Exception {
Run run = mock(Run.class);
when(run.getParent()).thenReturn(j.createFreeStyleProject());
BlueRun blueRun = BlueRunFactory.getRun(run, () -> new Link("foo"));
Assert.assertNotNull(blueRun);
Assert.assertTrue(blueRun instanceof DefaultRunImpl);
}
use of io.jenkins.blueocean.rest.hal.Link in project blueocean-plugin by jenkinsci.
the class QueueUtil method getQueuedItems.
/**
* This function gets gets a list of all queued items if the job is a buildable item.
*
* Note the estimated build number calculation is a guess - job types need not return
* sequential build numbers.
*
* @return List of items newest first
*/
public static List<BlueQueueItem> getQueuedItems(BlueOrganization organization, Job job) {
BluePipeline pipeline = (BluePipeline) BluePipelineFactory.resolve(job);
if (job instanceof BuildableItem && pipeline != null) {
BuildableItem task = (BuildableItem) job;
List<hudson.model.Queue.Item> items = Jenkins.get().getQueue().getItems(task);
List<BlueQueueItem> items2 = new ArrayList<>();
for (int i = 0; i < items.size(); i++) {
Link self = pipeline.getLink().rel("queue").rel(Long.toString(items.get(i).getId()));
QueueItemImpl queueItem = new QueueItemImpl(organization, items.get(i), pipeline, (items.size() == 1 ? job.getNextBuildNumber() : job.getNextBuildNumber() + i), self, pipeline.getLink());
items2.add(0, queueItem);
}
return items2;
} else {
throw new ServiceException.UnexpectedErrorException("This pipeline is not buildable and therefore does not have a queue.");
}
}
use of io.jenkins.blueocean.rest.hal.Link 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