Search in sources :

Example 11 with IssueBean

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

the class TestJiraConnector method testCreateJiraBean.

/**
 * Create a new jira bean with all parameters
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCreateJiraBean() 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");
    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, step2, stepEnd), jiraOptions);
    Assert.assertTrue(issueBean instanceof JiraBean);
    JiraBean jiraBean = (JiraBean) issueBean;
    Assert.assertEquals(jiraBean.getAssignee(), "me");
    // check only step2 is seen as a failed step
    Assert.assertEquals(jiraBean.getDescription(), "*Test:* testCreateJiraBean\n" + "*Description:* some description\n" + "*Error step #1 (step 2):* *{color:#de350b}java.lang.NullPointerException: Error clicking{color}*\n" + "h2. Steps in error\n" + "* *Step 1: step 2*\n" + "{code:java}Step step 2\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" + "\n" + "\n" + "For more details, see attached .zip file");
    Assert.assertEquals(jiraBean.getSummary(), "[Selenium][selenium][DEV][ngName] test myTest KO");
    Assert.assertEquals(jiraBean.getReporter(), "you");
    Assert.assertEquals(jiraBean.getTestName(), "testCreateJiraBean");
    // screenshots from the last step
    Assert.assertEquals(jiraBean.getScreenShots(), Arrays.asList(screenshot, screenshot));
    Assert.assertEquals(jiraBean.getTestStep(), step2);
    Assert.assertEquals(jiraBean.getDateTime().getDayOfMonth(), ZonedDateTime.now().plusHours(3).getDayOfMonth());
    Assert.assertEquals(jiraBean.getComponents(), Arrays.asList("comp1", "comp2"));
    Assert.assertEquals(jiraBean.getIssueType(), "Bug");
    Assert.assertEquals(jiraBean.getPriority(), "P1");
    Assert.assertEquals(jiraBean.getCustomFields().get("foo"), "bar");
    Assert.assertTrue(jiraBean.getDetailedResult().isFile());
    Assert.assertTrue(jiraBean.getDetailedResult().length() > 1000);
    // not initialized by default
    Assert.assertNull(jiraBean.getId());
}
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 12 with IssueBean

use of com.seleniumtests.connectors.bugtracker.IssueBean 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 13 with IssueBean

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

the class TestJiraConnector method testCreateJiraBeanNoFailedSteps.

@Test(groups = { "ut" })
public void testCreateJiraBeanNoFailedSteps() 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");
    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, stepEnd), jiraOptions);
    // that when no failed step exist, (this should not happen), this is not a problem for connector
    Assert.assertNull(issueBean);
}
Also used : IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with IssueBean

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

the class TestBugTracker method testCreateIssueBeanNoStep.

/**
 * If no steps are available, do not create IssueBean
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCreateIssueBeanNoStep() throws Exception {
    FakeBugTracker fbt = spy(new FakeBugTracker());
    PowerMockito.whenNew(FakeBugTracker.class).withAnyArguments().thenReturn(fbt);
    BugTracker bugtracker = BugTracker.getInstance("fake", "http://foo/bar", "selenium", "user", "password", new HashMap<>());
    IssueBean issueBean = bugtracker.createIssueBean("[Selenium][selenium][DEV][ngName] test myTest KO", "myTest", "some description", new ArrayList<>(), issueOptions);
    Assert.assertNull(issueBean);
}
Also used : FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) 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 15 with IssueBean

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

the class TestBugTracker method testDoNotUpdateIssue.

/**
 * Do not update existing issue as we fail on the same step
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testDoNotUpdateIssue() throws Exception {
    FakeBugTracker fbt = spy(new FakeBugTracker());
    PowerMockito.whenNew(FakeBugTracker.class).withAnyArguments().thenReturn(fbt);
    when(fbt.issueAlreadyExists(any(IssueBean.class))).thenReturn(new IssueBean("ISSUE-1", "[Selenium][app][env][ng] test Test1 KO", String.format(BugTracker.STEP_KO_PATTERN, 1)));
    BugTracker bugtracker = BugTracker.getInstance("fake", "http://foo/bar", "selenium", "user", "password", new HashMap<>());
    bugtracker.createIssue("selenium", "DEV", "ngName", "testDoNotUpdateIssue", "some description", Arrays.asList(step1, step2, stepEnd), issueOptions);
    // check that we check if the issue already exists
    verify(fbt).issueAlreadyExists(any(IssueBean.class));
    // check that issue is not created
    verify(fbt, never()).createIssue(any(IssueBean.class));
    verify(fbt, never()).updateIssue(eq("ISSUE-1"), anyString(), anyList(), eq(step2));
}
Also used : FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) 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)

Aggregations

IssueBean (com.seleniumtests.connectors.bugtracker.IssueBean)18 MockitoTest (com.seleniumtests.MockitoTest)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)16 Test (org.testng.annotations.Test)16 BugTracker (com.seleniumtests.connectors.bugtracker.BugTracker)9 JiraConnector (com.seleniumtests.connectors.bugtracker.jira.JiraConnector)9 FakeBugTracker (com.seleniumtests.connectors.bugtracker.FakeBugTracker)7 JiraBean (com.seleniumtests.connectors.bugtracker.jira.JiraBean)6 SearchResult (com.atlassian.jira.rest.client.api.domain.SearchResult)3 TestStep (com.seleniumtests.reporter.logger.TestStep)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IssueRestClient (com.atlassian.jira.rest.client.api.IssueRestClient)1 JiraRestClient (com.atlassian.jira.rest.client.api.JiraRestClient)1 RestClientException (com.atlassian.jira.rest.client.api.RestClientException)1 SearchRestClient (com.atlassian.jira.rest.client.api.SearchRestClient)1 BasicComponent (com.atlassian.jira.rest.client.api.domain.BasicComponent)1 BasicIssue (com.atlassian.jira.rest.client.api.domain.BasicIssue)1 BasicPriority (com.atlassian.jira.rest.client.api.domain.BasicPriority)1 BasicProject (com.atlassian.jira.rest.client.api.domain.BasicProject)1