Search in sources :

Example 21 with JiraBean

use of com.seleniumtests.connectors.bugtracker.jira.JiraBean 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 22 with JiraBean

use of com.seleniumtests.connectors.bugtracker.jira.JiraBean 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)

Example 23 with JiraBean

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

the class TestJiraConnector method testCreateIssue.

/**
 * Test issue creation with all fields
 * @throws URISyntaxException
 */
@Test(groups = { "ut" })
public void testCreateIssue() throws URISyntaxException {
    ArgumentCaptor<IssueInput> issueArgument = ArgumentCaptor.forClass(IssueInput.class);
    ArgumentCaptor<File> screenshotCaptor = ArgumentCaptor.forClass(File.class);
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    Map<String, String> fields = new HashMap<>();
    // field allowed by jira
    fields.put("application", "myApp");
    // field allowed by jira
    fields.put("step", "step2");
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", "P1", "Bug", "myTest", null, "me", "you", Arrays.asList(screenshot), detailedResult, fields, Arrays.asList("comp1"));
    jiraConnector.createIssue(jiraBean);
    Assert.assertEquals(jiraBean.getId(), "ISSUE-1");
    verify(issueRestClient).createIssue(issueArgument.capture());
    // check issue has all data defined in jiraBean
    IssueInput issueInput = ((IssueInput) issueArgument.getValue());
    Assert.assertEquals(issueInput.getField("summary").getValue(), "issue 1");
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("issuetype").getValue())).getValuesMap().get("id"), "1");
    Assert.assertEquals(ImmutableList.copyOf(((Iterable<ComplexIssueInputFieldValue>) (issueInput.getField("components").getValue()))).size(), 1);
    Assert.assertEquals(ImmutableList.copyOf(((Iterable<ComplexIssueInputFieldValue>) (issueInput.getField("components").getValue()))).get(0).getValuesMap().get("name"), "comp1");
    // Assert.assertEquals(issueInput.getField("duedate").getValue().toString().split("-")[0], Integer.toString(LocalDateTime.now().getYear()));
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("project").getValue())).getValuesMap().get("key"), PROJECT_KEY);
    Assert.assertEquals(issueInput.getField("description").getValue(), "issue 1 descr");
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("reporter").getValue())).getValuesMap().get("name"), "you");
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("assignee").getValue())).getValuesMap().get("name"), "user1");
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("priority").getValue())).getValuesMap().get("id"), "1");
    // custom field
    Assert.assertEquals(issueInput.getField("13").getValue(), "myApp");
    // custom field
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("33").getValue())).getValuesMap().get("value"), "step2");
    // check attachments have been added (screenshot + detailed results)
    verify(issueRestClient, times(2)).addAttachments(eq(new URI("http://foo/bar/i/1/attachments")), screenshotCaptor.capture());
    Assert.assertTrue(((File) screenshotCaptor.getAllValues().get(0)).getName().endsWith(".png"));
    Assert.assertTrue(((File) screenshotCaptor.getAllValues().get(1)).getName().endsWith(".zip"));
}
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) HashMap(java.util.HashMap) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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 24 with JiraBean

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

the class TestJiraConnector method testCreateIssueWrongIssueType.

/**
 * Test issue creation with wrong issue type, unknown from jira
 * @throws URISyntaxException
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testCreateIssueWrongIssueType() {
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", null, "BigBug", null, null, "", null, new ArrayList<>(), null, new HashMap<>(), new ArrayList<>());
    jiraConnector.createIssue(jiraBean);
}
Also used : 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)

Aggregations

JiraBean (com.seleniumtests.connectors.bugtracker.jira.JiraBean)24 Test (org.testng.annotations.Test)23 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)20 JiraConnector (com.seleniumtests.connectors.bugtracker.jira.JiraConnector)19 MockitoTest (com.seleniumtests.MockitoTest)18 File (java.io.File)8 IssueBean (com.seleniumtests.connectors.bugtracker.IssueBean)6 HashMap (java.util.HashMap)6 URI (java.net.URI)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 OptionalIterable (com.atlassian.jira.rest.client.api.OptionalIterable)4 IssueInput (com.atlassian.jira.rest.client.api.domain.input.IssueInput)4 ComplexIssueInputFieldValue (com.atlassian.jira.rest.client.api.domain.input.ComplexIssueInputFieldValue)3 GenericTest (com.seleniumtests.GenericTest)3 ZonedDateTime (java.time.ZonedDateTime)3 SearchResult (com.atlassian.jira.rest.client.api.domain.SearchResult)2 DateTime (org.joda.time.DateTime)1