1 package it;
2
3 import com.atlassian.jira.nimblefunctests.annotation.Restore;
4 import com.atlassian.jira.rest.client.IssueRestClient;
5 import com.atlassian.jira.rest.client.domain.BasicResolution;
6 import com.atlassian.jira.rest.client.domain.BasicVotes;
7 import com.atlassian.jira.rest.client.domain.BasicWatchers;
8 import com.atlassian.jira.rest.client.domain.ChangelogGroup;
9 import com.atlassian.jira.rest.client.domain.Comment;
10 import com.atlassian.jira.rest.client.domain.Issue;
11 import com.atlassian.jira.rest.client.internal.json.TestConstants;
12 import com.google.common.collect.ImmutableList;
13 import com.google.common.collect.Iterables;
14 import org.codehaus.jettison.json.JSONException;
15 import org.junit.Test;
16 import samples.Example1;
17
18 import java.net.URISyntaxException;
19
20 import static org.junit.Assert.*;
21
22
23 @SuppressWarnings("ConstantConditions")
24 @Restore(TestConstants.DEFAULT_JIRA_DUMP_FILE)
25 public class ExamplesTest extends AbstractJerseyRestClientTest {
26
27 @Test
28 public void testExample1() throws URISyntaxException, JSONException {
29
30 Example1.main(new String[]{environmentData.getBaseUrl().toString(), "-q"});
31
32
33 final Issue issue = client.getIssueClient().getIssue("TST-7", ImmutableList.copyOf(IssueRestClient.Expandos.values()), pm);
34
35
36 final BasicVotes votes = issue.getVotes();
37 assertNotNull(votes);
38 assertEquals(1, votes.getVotes());
39 assertEquals(true, votes.hasVoted());
40
41
42 final BasicWatchers watchers = issue.getWatchers();
43 assertNotNull(watchers);
44 assertEquals(1, watchers.getNumWatchers());
45
46
47 final BasicResolution resolution = issue.getResolution();
48 assertNotNull(resolution);
49 assertEquals("Incomplete", resolution.getName());
50
51 if (isJira5xOrNewer()) {
52
53 final Iterable<ChangelogGroup> changelog = issue.getChangelog();
54 assertEquals(2, Iterables.size(changelog));
55 }
56
57
58 final Iterable<Comment> comments = issue.getComments();
59 assertNotNull(comments);
60 assertEquals(1, Iterables.size(comments));
61 final Comment comment = comments.iterator().next();
62 assertEquals("My comment", comment.getBody());
63 assertEquals("Administrator", comment.getAuthor().getDisplayName());
64 }
65
66 }