1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.internal.json.gen;
18
19 import com.atlassian.jira.rest.client.api.domain.Comment;
20 import com.atlassian.jira.rest.client.api.domain.ServerInfo;
21 import com.atlassian.jira.rest.client.api.domain.input.LinkIssuesInput;
22 import com.atlassian.jira.rest.client.internal.ServerVersionConstants;
23 import com.atlassian.jira.rest.client.internal.json.ResourceUtil;
24 import com.atlassian.jira.rest.client.test.matchers.JSONObjectMatcher;
25 import org.junit.Assert;
26 import org.junit.Test;
27
28 public class LinkIssuesInputGeneratorTest {
29
30 private final ServerInfo serverInfo = new ServerInfo(null, "1.2.3", ServerVersionConstants.BN_JIRA_4_3, null, null, null, null);
31 private final LinkIssuesInputGenerator inputGenerator = new LinkIssuesInputGenerator(serverInfo);
32
33 @Test
34 public void testGenerateWithoutComment() throws Exception {
35 LinkIssuesInput input1 = new LinkIssuesInput("TST-1", "TST-2", "MyLinkType");
36 Assert.assertThat(inputGenerator.generate(input1), JSONObjectMatcher.isEqual(ResourceUtil
37 .getJsonObjectFromResource("/json/issueLinkInput/no-comment.json")));
38 }
39
40 @Test
41 public void testGenerate() throws Exception {
42 LinkIssuesInput input1 = new LinkIssuesInput("TST-1", "TST-2", "MyLinkType", Comment.valueOf("simple comment"));
43 Assert.assertThat(inputGenerator.generate(input1), JSONObjectMatcher.isEqual(ResourceUtil
44 .getJsonObjectFromResource("/json/issueLinkInput/simple.json")));
45 }
46
47 @Test
48 public void testGenerateWithRoleLevel() throws Exception {
49 LinkIssuesInput input1 = new LinkIssuesInput("TST-1", "TST-2", "MyLinkType", Comment
50 .createWithRoleLevel("simple comment", "Users"));
51 Assert.assertThat(inputGenerator.generate(input1), JSONObjectMatcher.isEqual(ResourceUtil
52 .getJsonObjectFromResource("/json/issueLinkInput/with-project-role.json")));
53 }
54
55 @Test
56 public void testGenerateWithGroupLevel() throws Exception {
57 LinkIssuesInput input1 = new LinkIssuesInput("TST-1", "TST-2", "MyLinkType", Comment
58 .createWithGroupLevel("simple comment", "jira-users"));
59 Assert.assertThat(inputGenerator.generate(input1), JSONObjectMatcher.isEqual(ResourceUtil
60 .getJsonObjectFromResource("/json/issueLinkInput/with-user-group.json")));
61 }
62
63 }