Search in sources :

Example 26 with JiraConnector

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

the class TestBugTracker method testJiraBugtracker.

@Test(groups = { "ut" })
public void testJiraBugtracker() throws Exception {
    PowerMockito.whenNew(JiraConnector.class).withAnyArguments().thenReturn(jiraConnector);
    BugTracker bugtracker = BugTracker.getInstance("jira", "http://foo/bar", "selenium", "user", "password", new HashMap<>());
    Assert.assertTrue(bugtracker instanceof JiraConnector);
}
Also used : JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) BugTracker(com.seleniumtests.connectors.bugtracker.BugTracker) FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 27 with JiraConnector

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

the class TestJiraConnector method testCreateIssueWithMinimalFields.

/**
 * Test issue creation without fields, components, screenshots, ...
 * @throws URISyntaxException
 */
@Test(groups = { "ut" })
public void testCreateIssueWithMinimalFields() throws URISyntaxException {
    ArgumentCaptor<IssueInput> issueArgument = ArgumentCaptor.forClass(IssueInput.class);
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", "P1", "Bug", null, null, null, null, new ArrayList<>(), null, new HashMap<>(), new ArrayList<>());
    jiraConnector.createIssue(jiraBean);
    verify(issueRestClient).createIssue(issueArgument.capture());
    // check issue has only mandatory fields
    IssueInput issueInput = ((IssueInput) issueArgument.getValue());
    Assert.assertEquals(issueInput.getField("summary").getValue(), "issue 1");
    Assert.assertEquals(issueInput.getField("description").getValue(), "issue 1 descr");
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("issuetype").getValue())).getValuesMap().get("id"), "1");
    Assert.assertEquals(ImmutableList.copyOf(((Iterable<ComplexIssueInputFieldValue>) (issueInput.getField("components").getValue()))).size(), 0);
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("project").getValue())).getValuesMap().get("key"), PROJECT_KEY);
    Assert.assertNull(issueInput.getField("reporter"));
    Assert.assertNull(issueInput.getField("assignee"));
    // check attachments have been added (screenshot + detailed results)
    verify(issueRestClient, never()).addAttachments(eq(new URI("http://foo/bar/i/1/attachments")), any(File.class));
}
Also used : IssueInput(com.atlassian.jira.rest.client.api.domain.input.IssueInput) ComplexIssueInputFieldValue(com.atlassian.jira.rest.client.api.domain.input.ComplexIssueInputFieldValue) OptionalIterable(com.atlassian.jira.rest.client.api.OptionalIterable) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) URI(java.net.URI) File(java.io.File) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 28 with JiraConnector

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

the class TestJiraConnector method testCreateIssueWithMinimalFieldsOtherEmpty.

/**
 * Test issue creation without fields, components, screenshots, ...
 * @throws URISyntaxException
 */
@Test(groups = { "ut" })
public void testCreateIssueWithMinimalFieldsOtherEmpty() throws URISyntaxException {
    ArgumentCaptor<IssueInput> issueArgument = ArgumentCaptor.forClass(IssueInput.class);
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", "", "Bug", "", null, "", "", new ArrayList<>(), null, new HashMap<>(), new ArrayList<>());
    jiraConnector.createIssue(jiraBean);
    verify(issueRestClient).createIssue(issueArgument.capture());
    // check issue has only mandatory fields
    IssueInput issueInput = ((IssueInput) issueArgument.getValue());
    Assert.assertEquals(issueInput.getField("summary").getValue(), "issue 1");
    Assert.assertEquals(issueInput.getField("description").getValue(), "issue 1 descr");
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("issuetype").getValue())).getValuesMap().get("id"), "1");
    Assert.assertEquals(ImmutableList.copyOf(((Iterable<ComplexIssueInputFieldValue>) (issueInput.getField("components").getValue()))).size(), 0);
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("project").getValue())).getValuesMap().get("key"), PROJECT_KEY);
    Assert.assertNull(issueInput.getField("reporter"));
    Assert.assertNull(issueInput.getField("assignee"));
    Assert.assertNull(issueInput.getField("priority"));
    // check attachments have been added (screenshot + detailed results)
    verify(issueRestClient, never()).addAttachments(eq(new URI("http://foo/bar/i/1/attachments")), any(File.class));
}
Also used : IssueInput(com.atlassian.jira.rest.client.api.domain.input.IssueInput) ComplexIssueInputFieldValue(com.atlassian.jira.rest.client.api.domain.input.ComplexIssueInputFieldValue) OptionalIterable(com.atlassian.jira.rest.client.api.OptionalIterable) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) URI(java.net.URI) File(java.io.File) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 29 with JiraConnector

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

the class TestJiraConnector method testCreateJiraBeanWithErrorCauseAndDetails.

@Test(groups = { "ut" })
public void testCreateJiraBeanWithErrorCauseAndDetails() throws Exception {
    jiraOptions.put("priority", "P1");
    jiraOptions.put("assignee", "me");
    jiraOptions.put("reporter", "you");
    jiraOptions.put("jira.issueType", "Bug");
    jiraOptions.put("jira.components", "comp1,comp2");
    jiraOptions.put("jira.field.foo", "bar");
    SeleniumTestsContextManager.getThreadContext().setStartedBy("http://foo/bar/job/1");
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    IssueBean issueBean = jiraConnector.createIssueBean("[Selenium][selenium][DEV][ngName] test myTest KO", "testCreateJiraBean", "some description", Arrays.asList(step1, stepWithErrorCauseAndDetails, stepEnd), jiraOptions);
    Assert.assertTrue(issueBean instanceof JiraBean);
    JiraBean jiraBean = (JiraBean) issueBean;
    // check only step2 is seen as a failed step
    // detailed result is not provided because 'startedBy' is set
    Assert.assertEquals(jiraBean.getDescription(), "*Test:* testCreateJiraBean\n" + "*Description:* some description\n" + "*Started by:* http://foo/bar/job/1\n" + "*Error step #1 (step 3):* *{color:#de350b}java.lang.NullPointerException: Error clicking{color}*\n" + "h2. Steps in error\n" + "* *Step 1: step 3*\n" + "+Possible cause:+ REGRESSION => Check  your script\n" + "{code:java}Step step 3\n" + "  - action1\n" + "  - action2{code}\n" + "\n" + "h2. Last logs\n" + "{code:java}Step Test end{code}\n" + "\n" + "h2. Associated screenshots\n" + "!N-A_0-2_Test_end--123456.png|thumbnail!\n" + "!N-A_0-2_Test_end--123456.png|thumbnail!\n");
}
Also used : IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 30 with JiraConnector

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

the class TestJiraConnector method testCreateIssueUnknownFieldValue.

/**
 * Test issue creation with field value. No error should be raised (but issue may not be created if field is mandatory)
 * @throws URISyntaxException
 */
@Test(groups = { "ut" })
public void testCreateIssueUnknownFieldValue() {
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    Map<String, String> fields = new HashMap<>();
    // field allowed by jira
    fields.put("step", "step3");
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", "P1", "Bug", null, null, null, null, new ArrayList<>(), null, fields, new ArrayList<>());
    jiraConnector.createIssue(jiraBean);
}
Also used : HashMap(java.util.HashMap) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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