use of io.jenkins.blueocean.rest.model.BlueIssue in project blueocean-plugin by jenkinsci.
the class GithubIssueTest method changeSetEntryIsNotGithub.
@Test
public void changeSetEntryIsNotGithub() throws Exception {
MultiBranchProject project = mock(MultiBranchProject.class);
Job job = mock(Job.class);
Run run = mock(Run.class);
ChangeLogSet logSet = mock(ChangeLogSet.class);
ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
when(project.getProperties()).thenReturn(new DescribableList(project));
when(entry.getParent()).thenReturn(logSet);
when(logSet.getRun()).thenReturn(run);
when(run.getParent()).thenReturn(job);
when(job.getParent()).thenReturn(project);
when(entry.getMsg()).thenReturn("Closed #123 #124");
when(project.getSCMSources()).thenReturn(Lists.newArrayList(new GitSCMSource("http://example.com/repo.git")));
Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
Assert.assertEquals(0, resolved.size());
}
use of io.jenkins.blueocean.rest.model.BlueIssue in project blueocean-plugin by jenkinsci.
the class BlueJiraIssueTest method issuesForChangeSetItem.
@Test
public void issuesForChangeSetItem() throws Exception {
Job job = mock(Job.class);
Run run = mock(Run.class);
ChangeLogSet logSet = mock(ChangeLogSet.class);
ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
when(entry.getParent()).thenReturn(logSet);
when(logSet.getRun()).thenReturn(run);
when(run.getParent()).thenReturn(job);
mockStatic(JiraSite.class);
JiraSite site = mock(JiraSite.class);
when(site.getIssuePattern()).thenReturn(JiraSite.DEFAULT_ISSUE_PATTERN);
when(JiraSite.get(job)).thenReturn(site);
when(entry.getMsg()).thenReturn("TEST-123");
// Should resolve no issues because there is no JiraJobAction
Assert.assertTrue(BlueIssueFactory.resolve(entry).isEmpty());
// Setup a job with a JiraJobAction
JiraIssue jiraIssue1 = new JiraIssue("FOO-123", "A cool issue");
JiraIssue jiraIssue2 = new JiraIssue("FOO-124", "A cool issue");
when(site.getUrl(jiraIssue1)).thenReturn(new URL("http://jira.example.com/browse/FOO-123"));
when(site.getUrl(jiraIssue2)).thenReturn(new URL("http://jira.example.com/browse/FOO-124"));
JiraBuildAction action = new JiraBuildAction(run, Sets.newLinkedHashSet(ImmutableSet.of(jiraIssue1, jiraIssue2)));
when(run.getAction(JiraBuildAction.class)).thenReturn(action);
// Expect two issues
when(entry.getMsg()).thenReturn("something FOO-123 vivek FOO-124 #ace");
List<BlueIssue> issues = Lists.newLinkedList(BlueIssueFactory.resolve(entry));
Assert.assertEquals(2, issues.size());
BlueIssue issue1 = issues.get(0);
Assert.assertEquals("FOO-123", issue1.getId());
Assert.assertEquals("http://jira.example.com/browse/FOO-123", issue1.getURL());
BlueIssue issue2 = issues.get(1);
Assert.assertEquals("FOO-124", issue2.getId());
Assert.assertEquals("http://jira.example.com/browse/FOO-124", issue2.getURL());
}
use of io.jenkins.blueocean.rest.model.BlueIssue in project blueocean-plugin by jenkinsci.
the class GithubIssueTest method jobNotImplemented.
@Test
public void jobNotImplemented() throws Exception {
Job job = mock(Job.class);
Collection<BlueIssue> resolved = BlueIssueFactory.resolve(job);
Assert.assertTrue(resolved.isEmpty());
}
use of io.jenkins.blueocean.rest.model.BlueIssue in project blueocean-plugin by jenkinsci.
the class GithubIssueTest method changeSetJobParentNotMultibranch.
@Test
public void changeSetJobParentNotMultibranch() throws Exception {
AbstractFolder project = mock(AbstractFolder.class);
Job job = mock(Job.class);
Run run = mock(Run.class);
ChangeLogSet logSet = mock(ChangeLogSet.class);
ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
when(project.getProperties()).thenReturn(new DescribableList(project));
when(entry.getParent()).thenReturn(logSet);
when(logSet.getRun()).thenReturn(run);
when(run.getParent()).thenReturn(job);
when(job.getParent()).thenReturn(project);
when(entry.getMsg()).thenReturn("Closed #123 #124");
Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
Assert.assertEquals(0, resolved.size());
}
use of io.jenkins.blueocean.rest.model.BlueIssue in project blueocean-plugin by jenkinsci.
the class GithubIssueTest method changeSetEntry.
@Test
public void changeSetEntry() throws Exception {
MultiBranchProject project = mock(MultiBranchProject.class);
Job job = mock(Job.class);
Run run = mock(Run.class);
ChangeLogSet logSet = mock(ChangeLogSet.class);
ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
when(project.getProperties()).thenReturn(new DescribableList(project));
when(entry.getParent()).thenReturn(logSet);
when(logSet.getRun()).thenReturn(run);
when(run.getParent()).thenReturn(job);
when(job.getParent()).thenReturn(project);
GitHubSCMSource source = new GitHubSCMSource("foo", null, null, null, "example", "repo");
when(project.getSCMSources()).thenReturn(Lists.newArrayList(source));
when(entry.getMsg()).thenReturn("Closed #123 #124");
Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
Assert.assertEquals(2, resolved.size());
Map<String, BlueIssue> issueMap = Maps.uniqueIndex(resolved, new Function<BlueIssue, String>() {
@Override
public String apply(BlueIssue input) {
return input.getId();
}
});
BlueIssue issue123 = issueMap.get("#123");
Assert.assertEquals("https://github.com/example/repo/issues/123", issue123.getURL());
BlueIssue issue124 = issueMap.get("#124");
Assert.assertEquals("https://github.com/example/repo/issues/124", issue124.getURL());
}
Aggregations