1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.api.domain;
18
19 import org.junit.Test;
20
21 import java.util.Collections;
22
23 import static com.atlassian.jira.rest.client.TestUtil.EMPTY_GROUPS;
24 import static com.atlassian.jira.rest.client.TestUtil.EMPTY_LINKS;
25 import static org.hamcrest.Matchers.allOf;
26 import static org.hamcrest.Matchers.hasProperty;
27 import static org.hamcrest.Matchers.instanceOf;
28 import static org.hamcrest.Matchers.is;
29 import static org.junit.Assert.assertThat;
30
31 public class OperationsTest {
32
33 @Test
34 public void testGetLinkById() throws Exception {
35 Operations operations = new Operations(Collections.singleton(new OperationGroup(
36 null,
37 Collections.singleton(new OperationLink("action_id_4", null, "Start", null, "/start", null, null)),
38 EMPTY_GROUPS,
39 null,
40 null
41 )));
42
43 Operation operation = operations.getOperationById("action_id_4");
44
45 assertThat(operation, allOf(
46 instanceOf(OperationLink.class),
47 hasProperty("id", is("action_id_4"))
48 )
49 );
50 }
51
52 @Test
53 public void testGetSelfGroupById() throws Exception {
54 Operations operations = new Operations(Collections.singleton(new OperationGroup(
55 "group_self",
56 EMPTY_LINKS,
57 EMPTY_GROUPS,
58 null,
59 null
60 )));
61
62 Operation operation = operations.getOperationById("group_self");
63
64 assertThat(operation, allOf(
65 instanceOf(OperationGroup.class),
66 hasProperty("id", is("group_self"))
67 )
68 );
69 }
70
71 @Test
72 public void testGetGroupById() throws Exception {
73 Operations operations = new Operations(Collections.singleton(new OperationGroup(
74 null,
75 EMPTY_LINKS,
76 Collections.singleton(new OperationGroup("group_5", EMPTY_LINKS, EMPTY_GROUPS, null, null)),
77 null,
78 null
79 )));
80
81 Operation operation = operations.getOperationById("group_5");
82
83 assertThat(operation, allOf(
84 instanceOf(OperationGroup.class),
85 hasProperty("id", is("group_5"))
86 )
87 );
88 }
89
90 @Test
91 public void testGetHeaderById() throws Exception {
92 Operations operations = new Operations(Collections.singleton(new OperationGroup(
93 null,
94 EMPTY_LINKS,
95 EMPTY_GROUPS,
96 new OperationHeader("header_6", "header_6", null, null),
97 null
98 )));
99
100 Operation operation = operations.getOperationById("header_6");
101
102 assertThat(operation, allOf(
103 instanceOf(OperationHeader.class),
104 hasProperty("id", is("header_6"))
105 )
106 );
107 }
108 }