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