Search in sources :

Example 1 with JiraConnector

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

the class BugTracker method closeIssue.

/**
 * Close issue if it exists
 * @param application
 * @param environment
 * @param testNgName
 * @param testName
 */
public void closeIssue(String application, String environment, String testNgName, String testName) {
    String summary = createIssueSummary(application, environment, testNgName, testName);
    IssueBean issueBean;
    if (this instanceof JiraConnector) {
        issueBean = new JiraBean("", summary, "", "", "");
    } else {
        issueBean = new IssueBean(summary, "", "", null, null, null, null, null);
    }
    // Close issue if it exists
    IssueBean currentIssue = issueAlreadyExists(issueBean);
    if (currentIssue != null) {
        closeIssue(currentIssue.getId(), "Test is now OK");
    }
}
Also used : JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector)

Example 2 with JiraConnector

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

the class TestJiraConnector method testIssueAlreadyExistsIssueBean.

/**
 * Test JiraConnector only accepts JiraBean instances
 */
@Test(groups = { "ut" }, expectedExceptions = ClassCastException.class)
public void testIssueAlreadyExistsIssueBean() {
    when(promiseSearch.claim()).thenReturn(new SearchResult(0, 2, 2, Arrays.asList(issue1, issue2)));
    IssueBean jiraBean = new IssueBean(null, "issue 1", "issue 1");
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    jiraConnector.issueAlreadyExists(jiraBean);
}
Also used : IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) SearchResult(com.atlassian.jira.rest.client.api.domain.SearchResult) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with JiraConnector

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

the class TestJiraConnector method testCreateIssueNoIssueType.

/**
 * Test issue creation without issue type
 * @throws URISyntaxException
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testCreateIssueNoIssueType() {
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", null, null, 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)

Example 4 with JiraConnector

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

the class TestJiraConnector method testCreateIssueUnknownField.

/**
 * Test issue creation with wrong field. No error should be raised (but issue may not be created if field is mandatory)
 * @throws URISyntaxException
 */
@Test(groups = { "ut" })
public void testCreateIssueUnknownField() {
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    Map<String, String> fields = new HashMap<>();
    // field not allowed by jira
    fields.put("myfield", "myApp");
    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 5 with JiraConnector

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

the class TestJiraConnector method testCreateIssueMissingScreenshotFile.

/**
 * Test the case where the attachment file (file of snapshot is not present)
 * @throws URISyntaxException
 */
@Test(groups = { "ut" })
public void testCreateIssueMissingScreenshotFile() throws URISyntaxException {
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    // simulate screenshot file not present
    new File(screenshot.getFullImagePath()).delete();
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", "P1", "Bug", null, null, null, null, Arrays.asList(screenshot), null, new HashMap<>(), new ArrayList<>());
    jiraConnector.createIssue(jiraBean);
    // check attachments (screenshots) have not been added  because screenshot file was not available
    verify(issueRestClient, never()).addAttachments(eq(new URI("http://foo/bar/i/1/attachments")), any(File.class));
}
Also used : JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) File(java.io.File) URI(java.net.URI) 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