Search in sources :

Example 11 with ObjectMetadataAction

use of jenkins.scm.api.metadata.ObjectMetadataAction in project blueocean-plugin by jenkinsci.

the class CachesTest method testBranchCacheLoaderWithNoPrimaryInstanceMetadataAction.

@Test
public void testBranchCacheLoaderWithNoPrimaryInstanceMetadataAction() throws Exception {
    ObjectMetadataAction metadataAction = new ObjectMetadataAction("A cool branch", "A very cool change", "http://example.com/branches/cool-branch");
    when(job.getAction(ObjectMetadataAction.class)).thenReturn(metadataAction);
    when(job.getFullName()).thenReturn("cool-branch");
    Caches.BranchCacheLoader loader = new Caches.BranchCacheLoader(jenkins);
    BranchImpl.Branch branch = loader.load(job.getFullName());
    assertNotNull(branch);
    assertFalse(branch.isPrimary());
    assertEquals("http://example.com/branches/cool-branch", branch.getUrl());
}
Also used : ObjectMetadataAction(jenkins.scm.api.metadata.ObjectMetadataAction) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with ObjectMetadataAction

use of jenkins.scm.api.metadata.ObjectMetadataAction in project blueocean-plugin by jenkinsci.

the class BranchMetadataTest method testBranchInfo.

@Test
public void testBranchInfo() {
    assertNull(branch.getBranch());
    ObjectMetadataAction oma = new ObjectMetadataAction("My Branch", "A feature branch", "https://path/to/branch");
    when(job.getAction(ObjectMetadataAction.class)).thenReturn(oma);
    when(job.getAction(PrimaryInstanceMetadataAction.class)).thenReturn(new PrimaryInstanceMetadataAction());
    Caches.BRANCH_METADATA.invalidateAll();
    assertEquals("https://path/to/branch", branch.getBranch().getUrl());
    assertTrue(branch.getBranch().isPrimary());
}
Also used : ObjectMetadataAction(jenkins.scm.api.metadata.ObjectMetadataAction) PrimaryInstanceMetadataAction(jenkins.scm.api.metadata.PrimaryInstanceMetadataAction) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with ObjectMetadataAction

use of jenkins.scm.api.metadata.ObjectMetadataAction in project blueocean-plugin by jenkinsci.

the class BranchMetadataTest method testGetURL.

@Test
public void testGetURL() {
    assertNull(branch.getBranch());
    ObjectMetadataAction oma = new ObjectMetadataAction("My Branch", "A feature branch", "https://path/to/branch");
    when(job.getAction(ObjectMetadataAction.class)).thenReturn(oma);
    Caches.BRANCH_METADATA.invalidateAll();
    assertNotNull(branch.getBranch());
    assertFalse(branch.getBranch().isPrimary());
    assertEquals("https://path/to/branch", branch.getBranch().getUrl());
}
Also used : ObjectMetadataAction(jenkins.scm.api.metadata.ObjectMetadataAction) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

ObjectMetadataAction (jenkins.scm.api.metadata.ObjectMetadataAction)13 Test (org.junit.Test)8 PrimaryInstanceMetadataAction (jenkins.scm.api.metadata.PrimaryInstanceMetadataAction)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 NonNull (edu.umd.cs.findbugs.annotations.NonNull)3 Action (hudson.model.Action)3 ArrayList (java.util.ArrayList)3 SCMHead (jenkins.scm.api.SCMHead)3 ContributorMetadataAction (jenkins.scm.api.metadata.ContributorMetadataAction)3 NamedArrayList (jenkins.scm.impl.form.NamedArrayList)3 GiteaConnection (org.jenkinsci.plugin.gitea.client.api.GiteaConnection)3 Job (hudson.model.Job)2 Link (io.jenkins.blueocean.rest.hal.Link)2 MockChangeRequestSCMHead (jenkins.scm.impl.mock.MockChangeRequestSCMHead)2 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)2 Exported (org.kohsuke.stapler.export.Exported)2 ChangeRequestSCMHead (jenkins.scm.api.mixin.ChangeRequestSCMHead)1 GiteaOrganization (org.jenkinsci.plugin.gitea.client.api.GiteaOrganization)1