Search in sources :

Example 16 with JiraConnector

use of com.seleniumtests.connectors.bugtracker.jira.JiraConnector in project seleniumRobot by bhecquet.

the class TestJiraConnector method testCloseUnknownIssue.

/**
 * Error raised when not
 * @throws URISyntaxException
 */
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testCloseUnknownIssue() {
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    jiraConnector.closeIssue("ISSUE-2", "closed");
}
Also used : JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 17 with JiraConnector

use of com.seleniumtests.connectors.bugtracker.jira.JiraConnector in project seleniumRobot by bhecquet.

the class TestJiraConnector method testUpdateUnknownIssue.

@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testUpdateUnknownIssue() throws URISyntaxException {
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    jiraConnector.updateIssue("ISSUE-2", "update", Arrays.asList(screenshot));
}
Also used : JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 18 with JiraConnector

use of com.seleniumtests.connectors.bugtracker.jira.JiraConnector in project seleniumRobot by bhecquet.

the class TestJiraConnector method testIssueAlreadyExists.

/**
 * The issue already exists on Jira
 */
@Test(groups = { "ut" })
public void testIssueAlreadyExists() {
    when(promiseSearch.claim()).thenReturn(new SearchResult(0, 2, 2, Arrays.asList(issue1, issue2)));
    DateTime issueDate = DateTime.now().minusDays(1);
    when(issue1.getCreationDate()).thenReturn(issueDate);
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1", "Bug", "P1");
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    IssueBean newJiraBean = jiraConnector.issueAlreadyExists(jiraBean);
    // check issue exists and has been updated with the first found issue
    Assert.assertNotNull(newJiraBean);
    Assert.assertEquals(newJiraBean.getId(), "ISSUE-1");
    Assert.assertEquals(newJiraBean.getSummary(), jiraBean.getSummary());
    Assert.assertEquals(newJiraBean.getDescription(), "jira issue 1");
    Assert.assertEquals(newJiraBean.getDate(), issueDate.toString("yyyy-MM-dd'T'HH:mmZZ"));
}
Also used : IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) SearchResult(com.atlassian.jira.rest.client.api.domain.SearchResult) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 19 with JiraConnector

use of com.seleniumtests.connectors.bugtracker.jira.JiraConnector in project seleniumRobot by bhecquet.

the class TestJiraConnector method testUpdateIssue.

@Test(groups = { "ut" })
public void testUpdateIssue() throws URISyntaxException {
    ArgumentCaptor<Comment> commentArgument = ArgumentCaptor.forClass(Comment.class);
    ArgumentCaptor<File> screenshotCaptor = ArgumentCaptor.forClass(File.class);
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    jiraConnector.updateIssue("ISSUE-1", "update", Arrays.asList(screenshot));
    verify(issueRestClient).addComment(any(URI.class), commentArgument.capture());
    Assert.assertEquals(commentArgument.getValue().getBody(), "update\n" + "!N-A_0-2_Test_end--123456.png|thumbnail!\n");
    // check attachments have been added (screenshot)
    verify(issueRestClient).addAttachments(eq(new URI("http://foo/bar/i/1/attachments")), screenshotCaptor.capture());
    Assert.assertTrue(((File) screenshotCaptor.getAllValues().get(0)).getName().endsWith(".png"));
}
Also used : Comment(com.atlassian.jira.rest.client.api.domain.Comment) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) File(java.io.File) URI(java.net.URI) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 20 with JiraConnector

use of com.seleniumtests.connectors.bugtracker.jira.JiraConnector in project seleniumRobot by bhecquet.

the class TestJiraConnector method testCloseIssueMultipleTransitionsSlow.

/**
 * issue #470: When closing issue with multiple transition, check the case where jira do not update the transitions of the issue immediately
 * We need to retry
 */
@Test(groups = { "ut" })
public void testCloseIssueMultipleTransitionsSlow() {
    // initial state
    when(promiseTransitions.claim()).thenReturn(Arrays.asList(transition3)).thenReturn(// state not updated
    Arrays.asList(transition3)).thenReturn(// state updated
    Arrays.asList(transition1, transition2));
    jiraOptions.put("jira.closeTransition", "review/close");
    ArgumentCaptor<TransitionInput> transitionArgument = ArgumentCaptor.forClass(TransitionInput.class);
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    jiraConnector.closeIssue("ISSUE-1", "closed");
    verify(issueRestClient, times(2)).transition(eq(issue1), transitionArgument.capture());
    // transition to review state
    Assert.assertEquals(transitionArgument.getAllValues().get(0).getId(), 3);
    // transition to closed state
    Assert.assertEquals(transitionArgument.getAllValues().get(1).getId(), 1);
}
Also used : TransitionInput(com.atlassian.jira.rest.client.api.domain.input.TransitionInput) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

JiraConnector (com.seleniumtests.connectors.bugtracker.jira.JiraConnector)33 Test (org.testng.annotations.Test)32 MockitoTest (com.seleniumtests.MockitoTest)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)31 JiraBean (com.seleniumtests.connectors.bugtracker.jira.JiraBean)19 IssueBean (com.seleniumtests.connectors.bugtracker.IssueBean)9 File (java.io.File)6 URI (java.net.URI)6 TransitionInput (com.atlassian.jira.rest.client.api.domain.input.TransitionInput)5 OptionalIterable (com.atlassian.jira.rest.client.api.OptionalIterable)4 IssueInput (com.atlassian.jira.rest.client.api.domain.input.IssueInput)4 HashMap (java.util.HashMap)4 SearchResult (com.atlassian.jira.rest.client.api.domain.SearchResult)3 ComplexIssueInputFieldValue (com.atlassian.jira.rest.client.api.domain.input.ComplexIssueInputFieldValue)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Comment (com.atlassian.jira.rest.client.api.domain.Comment)1 GenericTest (com.seleniumtests.GenericTest)1 BugTracker (com.seleniumtests.connectors.bugtracker.BugTracker)1 FakeBugTracker (com.seleniumtests.connectors.bugtracker.FakeBugTracker)1 ZonedDateTime (java.time.ZonedDateTime)1