Search in sources :

Example 11 with JiraConnector

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

the class TestJiraConnector method testCreateJiraBeanNoFinalStep.

@Test(groups = { "ut" })
public void testCreateJiraBeanNoFinalStep() 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), jiraOptions);
    // issue bean is not created when "Test end" is not present
    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 12 with JiraConnector

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

the class TestJiraConnector method testJira.

@Test(groups = "no-ti", enabled = true)
public void testJira() {
    Map<String, String> jiraOptions = new HashMap<>();
    jiraOptions.put("jira.openStates", "Open,To Do");
    jiraOptions.put("jira.closeTransition", "Prêt/Démarrer/Livrer/A valider/Validation effectuée/Clore");
    jiraOptions.put("jira.issueType", "Bogue");
    jiraOptions.put("priority", "Important");
    JiraConnector jiraConnector = new JiraConnector(System.getProperty("server"), "FFC", System.getProperty("user"), System.getProperty("password"), jiraOptions);
    jiraConnector.createIssue(null, null, "core", "testJira", "testng  http://confluence.covea.priv/display/portailSM/Selenium+-+Descriptions+des+scenarios", Arrays.asList(step1, step2, stepEnd), jiraOptions);
    // jiraConnector.issueAlreadyExists(new JiraBean(null, "[Selenium][core][DEV][testng] test myTest KO", "", "Bogue"));
    // jiraConnector.updateIssue("FFC-573", "commentaire", Arrays.asList(screenshot));
    jiraConnector.closeIssue("FFC-837", "Terminé");
}
Also used : HashMap(java.util.HashMap) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 13 with JiraConnector

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

the class TestJiraConnector method testIssueDoesNotExist.

/**
 * The issue does not exist on jira, we return null
 */
@Test(groups = { "ut" })
public void testIssueDoesNotExist() {
    when(promiseSearch.claim()).thenReturn(new SearchResult(0, 2, 2, Arrays.asList()));
    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 has not been found
    Assert.assertNull(newJiraBean);
}
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) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with JiraConnector

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

the class TestJiraConnector method testCreateJiraBeanWithErrorCauseNoDetails.

@Test(groups = { "ut" })
public void testCreateJiraBeanWithErrorCauseNoDetails() 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, stepWithErrorCause, 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 4):* *{color:#de350b}java.lang.NullPointerException: Error clicking{color}*\n" + "h2. Steps in error\n" + "* *Step 1: step 4*\n" + "+Possible cause:+ REGRESSION\n" + "{code:java}Step step 4\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 15 with JiraConnector

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

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