@Test public void testGetIssueWithAnonymouslyCreatedAttachment() { setAnonymousMode(); final Issue issue = client.getIssueClient().getIssue("ANONEDIT-1").claim(); final Iterator<Attachment> attachmentIterator = issue.getAttachments().iterator(); assertTrue(attachmentIterator.hasNext()); assertNull(attachmentIterator.next().getAuthor()); }
@Test public void testGetIssue() throws Exception { final Issue issue = client.getIssueClient().getIssue("TST-1").claim(); assertEquals("TST-1", issue.getKey()); assertEquals(Long.valueOf(10000), issue.getId()); assertTrue(issue.getSelf().toString().startsWith(jiraUri.toString())); assertEqualsNoUri(IntegrationTestUtil.USER_ADMIN, issue.getReporter()); assertEqualsNoUri(IntegrationTestUtil.USER_ADMIN, issue.getAssignee()); assertThat(issue.getLabels(), containsInAnyOrder("a", "bcds")); assertEquals(3, Iterables.size(issue.getComments())); final Iterable<String> expectedExpandos = getExpectedExpands(); assertThat( ImmutableList.copyOf(issue.getExpandos()), containsInAnyOrder(toArray(expectedExpandos, String.class))); assertEquals(new TimeTracking(null, 0, 190), issue.getTimeTracking()); assertTrue(Iterables.size(issue.getFields()) > 0); assertEquals( IntegrationTestUtil.START_PROGRESS_TRANSITION_ID, Iterables.size(issue.getAttachments())); final Iterable<Attachment> items = issue.getAttachments(); assertNotNull(items); Attachment attachment1 = new Attachment( IntegrationTestUtil.concat( IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ? UriBuilder.fromUri(jiraUri).path("/rest/api/2/").build() : jiraRestRootUri, "/attachment/10040"), "dla Paw\u0142a.txt", IntegrationTestUtil.USER_ADMIN, dateTime, 643, "text/plain", IntegrationTestUtil.concat(jiraUri, "/secure/attachment/10040/dla+Paw%C5%82a.txt"), null); assertEquals(attachment1, items.iterator().next()); // test for changelog assertNull(issue.getChangelog()); final Issue issueWithChangelogAndOperations = client.getIssueClient().getIssue("TST-2", EnumSet.of(CHANGELOG, OPERATIONS)).claim(); final Iterable<ChangelogGroup> changelog = issueWithChangelogAndOperations.getChangelog(); if (isJira5xOrNewer()) { assertNotNull(changelog); final ChangelogGroup chg1 = Iterables.get(changelog, 18); assertEquals("admin", chg1.getAuthor().getName()); assertEquals("Administrator", chg1.getAuthor().getDisplayName()); assertEquals( new DateTime(2010, 8, 17, 16, 40, 34, 924).toInstant(), chg1.getCreated().toInstant()); assertEquals( Collections.singletonList( new ChangelogItem(FieldType.JIRA, "status", "1", "Open", "3", "In Progress")), chg1.getItems()); final ChangelogGroup chg2 = Iterables.get(changelog, 20); assertEquals("admin", chg2.getAuthor().getName()); assertEquals("Administrator", chg2.getAuthor().getDisplayName()); assertEquals( new DateTime(2010, 8, 24, 16, 10, 23, 468).toInstant(), chg2.getCreated().toInstant()); final List<ChangelogItem> expected = ImmutableList.of( new ChangelogItem(FieldType.JIRA, "timeoriginalestimate", null, null, "0", "0"), new ChangelogItem(FieldType.CUSTOM, "My Radio buttons", null, null, null, "Another"), new ChangelogItem(FieldType.CUSTOM, "project3", null, null, "10000", "Test Project"), new ChangelogItem(FieldType.CUSTOM, "My Number Field New", null, null, null, "1.45")); assertEquals(expected, chg2.getItems()); } final Operations operations = issueWithChangelogAndOperations.getOperations(); if (isJira5xOrNewer()) { assertThat(operations, notNullValue()); assertThat( operations.getOperationById("log-work"), allOf(instanceOf(OperationLink.class), hasProperty("id", is("log-work")))); } }