Search in sources :

Example 6 with BlueIssue

use of io.jenkins.blueocean.rest.model.BlueIssue in project blueocean-plugin by jenkinsci.

the class BlueJiraIssueTest method issuesForJob.

@Test
public void issuesForJob() throws Exception {
    Job job = mock(Job.class);
    mockStatic(JiraSite.class);
    JiraSite site = mock(JiraSite.class);
    when(JiraSite.get(job)).thenReturn(site);
    // Should resolve no issues because there is no JiraJobAction
    Assert.assertTrue(BlueIssueFactory.resolve(job).isEmpty());
    // Setup a job with a JiraJobAction
    JiraIssue jiraIssue = new JiraIssue("FOO-123", "A cool issue");
    when(site.getUrl(jiraIssue)).thenReturn(new URL("http://jira.example.com/browse/FOO-123"));
    JiraJobAction action = new JiraJobAction(job, jiraIssue);
    when(job.getAction(JiraJobAction.class)).thenReturn(action);
    // Expect a single issue
    Collection<BlueIssue> issues = BlueIssueFactory.resolve(job);
    Assert.assertEquals(1, issues.size());
    BlueIssue issue = issues.iterator().next();
    Assert.assertEquals("FOO-123", issue.getId());
    Assert.assertEquals("http://jira.example.com/browse/FOO-123", issue.getURL());
}
Also used : JiraIssue(hudson.plugins.jira.model.JiraIssue) Job(hudson.model.Job) JiraJobAction(hudson.plugins.jira.JiraJobAction) JiraSite(hudson.plugins.jira.JiraSite) URL(java.net.URL) BlueIssue(io.jenkins.blueocean.rest.model.BlueIssue) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Job (hudson.model.Job)6 BlueIssue (io.jenkins.blueocean.rest.model.BlueIssue)6 Test (org.junit.Test)6 Run (hudson.model.Run)4 ChangeLogSet (hudson.scm.ChangeLogSet)4 DescribableList (hudson.util.DescribableList)3 JiraSite (hudson.plugins.jira.JiraSite)2 JiraIssue (hudson.plugins.jira.model.JiraIssue)2 URL (java.net.URL)2 MultiBranchProject (jenkins.branch.MultiBranchProject)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 AbstractFolder (com.cloudbees.hudson.plugins.folder.AbstractFolder)1 JiraBuildAction (hudson.plugins.jira.JiraBuildAction)1 JiraJobAction (hudson.plugins.jira.JiraJobAction)1 GitSCMSource (jenkins.plugins.git.GitSCMSource)1 GitHubSCMSource (org.jenkinsci.plugins.github_branch_source.GitHubSCMSource)1