Search in sources :

Example 21 with Link

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());
}
Also used : Reachable(io.jenkins.blueocean.rest.Reachable) Link(io.jenkins.blueocean.rest.hal.Link) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) WithoutJenkins(org.jvnet.hudson.test.WithoutJenkins)

Example 22 with Link

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);
}
Also used : Link(io.jenkins.blueocean.rest.hal.Link) Test(org.junit.Test)

Example 23 with Link

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);
}
Also used : BlueRun(io.jenkins.blueocean.rest.model.BlueRun) BlueRun(io.jenkins.blueocean.rest.model.BlueRun) Run(hudson.model.Run) Link(io.jenkins.blueocean.rest.hal.Link) Test(org.junit.Test)

Example 24 with Link

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.");
    }
}
Also used : BlueQueueItem(io.jenkins.blueocean.rest.model.BlueQueueItem) BuildableItem(hudson.model.BuildableItem) BuildableItem(hudson.model.BuildableItem) ArrayList(java.util.ArrayList) BluePipeline(io.jenkins.blueocean.rest.model.BluePipeline) BlueQueueItem(io.jenkins.blueocean.rest.model.BlueQueueItem) Link(io.jenkins.blueocean.rest.hal.Link)

Example 25 with Link

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;
}
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

Link (io.jenkins.blueocean.rest.hal.Link)30 Test (org.junit.Test)12 BlueRun (io.jenkins.blueocean.rest.model.BlueRun)8 Run (hudson.model.Run)7 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)7 Reachable (io.jenkins.blueocean.rest.Reachable)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 BlueOrganization (io.jenkins.blueocean.rest.model.BlueOrganization)5 BluePipelineNode (io.jenkins.blueocean.rest.model.BluePipelineNode)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)4 Job (hudson.model.Job)3 ServiceException (io.jenkins.blueocean.commons.ServiceException)3 BluePipelineStep (io.jenkins.blueocean.rest.model.BluePipelineStep)3 BlueQueueItem (io.jenkins.blueocean.rest.model.BlueQueueItem)3