Search in sources :

Example 1 with JiraJobAction

use of hudson.plugins.jira.JiraJobAction in project blueocean-plugin by jenkinsci.

the class BlueJiraIssueTest method issuesForJobActionDoesNotHaveIssue.

@Test
public void issuesForJobActionDoesNotHaveIssue() throws Exception {
    Job job = mock(Job.class);
    mockStatic(JiraSite.class);
    JiraSite site = mock(JiraSite.class);
    when(JiraSite.get(job)).thenReturn(site);
    JiraJobAction action = new JiraJobAction(job, null);
    when(job.getAction(JiraJobAction.class)).thenReturn(action);
    // Should resolve no issues because there is no JiraJobAction
    Assert.assertTrue(BlueIssueFactory.resolve(job).isEmpty());
}
Also used : Job(hudson.model.Job) JiraJobAction(hudson.plugins.jira.JiraJobAction) JiraSite(hudson.plugins.jira.JiraSite) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with JiraJobAction

use of hudson.plugins.jira.JiraJobAction 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)2 JiraJobAction (hudson.plugins.jira.JiraJobAction)2 JiraSite (hudson.plugins.jira.JiraSite)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 JiraIssue (hudson.plugins.jira.model.JiraIssue)1 BlueIssue (io.jenkins.blueocean.rest.model.BlueIssue)1 URL (java.net.URL)1