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.JSONObjectMatcher;
20 import com.atlassian.jira.rest.client.domain.Comment;
21 import com.atlassian.jira.rest.client.domain.ServerInfo;
22 import com.atlassian.jira.rest.client.domain.input.LinkIssuesInput;
23 import com.atlassian.jira.rest.client.internal.ServerVersionConstants;
24 import com.atlassian.jira.rest.client.internal.json.ResourceUtil;
25 import org.junit.Test;
26
27 import static org.junit.Assert.assertThat;
28
29 public class LinkIssuesInputGeneratorTest {
30
31 private final ServerInfo serverInfo = new ServerInfo(null, "1.2.3", ServerVersionConstants.BN_JIRA_4_3, null, null, null, null);
32 private final LinkIssuesInputGenerator inputGenerator = new LinkIssuesInputGenerator(serverInfo);
33
34 @Test
35 public void testGenerateWithoutComment() throws Exception {
36 LinkIssuesInput input1 = new LinkIssuesInput("TST-1", "TST-2", "MyLinkType");
37 assertThat(inputGenerator.generate(input1), JSONObjectMatcher.isEqual(ResourceUtil.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 assertThat(inputGenerator.generate(input1), JSONObjectMatcher.isEqual(ResourceUtil.getJsonObjectFromResource("/json/issueLinkInput/simple.json")));
44 }
45
46 @Test
47 public void testGenerateWithRoleLevel() throws Exception {
48 LinkIssuesInput input1 = new LinkIssuesInput("TST-1", "TST-2", "MyLinkType", Comment.createWithRoleLevel("simple comment", "Users"));
49 assertThat(inputGenerator.generate(input1), JSONObjectMatcher.isEqual(ResourceUtil.getJsonObjectFromResource("/json/issueLinkInput/with-project-role.json")));
50 }
51
52 @Test
53 public void testGenerateWithGroupLevel() throws Exception {
54 LinkIssuesInput input1 = new LinkIssuesInput("TST-1", "TST-2", "MyLinkType", Comment.createWithGroupLevel("simple comment", "jira-users"));
55 assertThat(inputGenerator.generate(input1), JSONObjectMatcher.isEqual(ResourceUtil.getJsonObjectFromResource("/json/issueLinkInput/with-user-group.json")));
56 }
57
58 }