Search in sources :

Example 16 with JiraBean

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

the class TestJiraConnector method testCreateIssueWrongPriority.

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

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

the class TestJiraBean method testBeanCreation.

@Test(groups = "ut")
public void testBeanCreation() {
    Map<String, String> customFieldsValues = new HashMap<>();
    new JiraBean("summary", "description", "P1", "Bug", "testName", null, "assignee", "reporter", new ArrayList<>(), new File(""), customFieldsValues, Arrays.asList("comp1", "comp2"));
}
Also used : HashMap(java.util.HashMap) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 18 with JiraBean

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

the class TestJiraBean method testBeanCreationNoIssueType.

@Test(groups = "ut", expectedExceptions = ConfigurationException.class)
public void testBeanCreationNoIssueType() {
    Map<String, String> customFieldsValues = new HashMap<>();
    new JiraBean("summary", "description", "P1", null, "testName", null, "assignee", "reporter", new ArrayList<>(), new File(""), customFieldsValues, Arrays.asList("comp1", "comp2"));
}
Also used : HashMap(java.util.HashMap) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 19 with JiraBean

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

the class TestJiraConnector method testCreateIssueWithMinimalFields.

/**
 * Test issue creation without fields, components, screenshots, ...
 * @throws URISyntaxException
 */
@Test(groups = { "ut" })
public void testCreateIssueWithMinimalFields() throws URISyntaxException {
    ArgumentCaptor<IssueInput> issueArgument = ArgumentCaptor.forClass(IssueInput.class);
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", "P1", "Bug", null, null, null, null, new ArrayList<>(), null, new HashMap<>(), new ArrayList<>());
    jiraConnector.createIssue(jiraBean);
    verify(issueRestClient).createIssue(issueArgument.capture());
    // check issue has only mandatory fields
    IssueInput issueInput = ((IssueInput) issueArgument.getValue());
    Assert.assertEquals(issueInput.getField("summary").getValue(), "issue 1");
    Assert.assertEquals(issueInput.getField("description").getValue(), "issue 1 descr");
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("issuetype").getValue())).getValuesMap().get("id"), "1");
    Assert.assertEquals(ImmutableList.copyOf(((Iterable<ComplexIssueInputFieldValue>) (issueInput.getField("components").getValue()))).size(), 0);
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("project").getValue())).getValuesMap().get("key"), PROJECT_KEY);
    Assert.assertNull(issueInput.getField("reporter"));
    Assert.assertNull(issueInput.getField("assignee"));
    // check attachments have been added (screenshot + detailed results)
    verify(issueRestClient, never()).addAttachments(eq(new URI("http://foo/bar/i/1/attachments")), any(File.class));
}
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) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) URI(java.net.URI) File(java.io.File) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 20 with JiraBean

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

the class TestJiraConnector method testCreateIssueWithMinimalFieldsOtherEmpty.

/**
 * Test issue creation without fields, components, screenshots, ...
 * @throws URISyntaxException
 */
@Test(groups = { "ut" })
public void testCreateIssueWithMinimalFieldsOtherEmpty() throws URISyntaxException {
    ArgumentCaptor<IssueInput> issueArgument = ArgumentCaptor.forClass(IssueInput.class);
    JiraConnector jiraConnector = new JiraConnector("http://foo/bar", PROJECT_KEY, "user", "password", jiraOptions);
    JiraBean jiraBean = new JiraBean(null, "issue 1", "issue 1 descr", "", "Bug", "", null, "", "", new ArrayList<>(), null, new HashMap<>(), new ArrayList<>());
    jiraConnector.createIssue(jiraBean);
    verify(issueRestClient).createIssue(issueArgument.capture());
    // check issue has only mandatory fields
    IssueInput issueInput = ((IssueInput) issueArgument.getValue());
    Assert.assertEquals(issueInput.getField("summary").getValue(), "issue 1");
    Assert.assertEquals(issueInput.getField("description").getValue(), "issue 1 descr");
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("issuetype").getValue())).getValuesMap().get("id"), "1");
    Assert.assertEquals(ImmutableList.copyOf(((Iterable<ComplexIssueInputFieldValue>) (issueInput.getField("components").getValue()))).size(), 0);
    Assert.assertEquals(((ComplexIssueInputFieldValue) (issueInput.getField("project").getValue())).getValuesMap().get("key"), PROJECT_KEY);
    Assert.assertNull(issueInput.getField("reporter"));
    Assert.assertNull(issueInput.getField("assignee"));
    Assert.assertNull(issueInput.getField("priority"));
    // check attachments have been added (screenshot + detailed results)
    verify(issueRestClient, never()).addAttachments(eq(new URI("http://foo/bar/i/1/attachments")), any(File.class));
}
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) JiraBean(com.seleniumtests.connectors.bugtracker.jira.JiraBean) JiraConnector(com.seleniumtests.connectors.bugtracker.jira.JiraConnector) URI(java.net.URI) File(java.io.File) 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