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");
}
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);
}
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"));
}
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);
}
Aggregations