View Javadoc

1   /*
2    * Copyright (C) 2014 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.jira.rest.client.internal.json;
18  
19  import com.atlassian.jira.rest.client.api.domain.OperationGroup;
20  import com.atlassian.jira.rest.client.api.domain.OperationHeader;
21  import com.atlassian.jira.rest.client.api.domain.OperationLink;
22  import com.atlassian.jira.rest.client.api.domain.Operations;
23  import org.junit.Test;
24  
25  import java.util.Collections;
26  
27  import static org.hamcrest.Matchers.is;
28  import static org.junit.Assert.assertThat;
29  
30  public class OperationsJsonParserTest {
31      @Test
32      public void testParse() throws Exception {
33          OperationsJsonParser parser = new OperationsJsonParser();
34          Operations actual = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/operations/valid.json"));
35          assertThat(actual, is(new Operations(Collections.singleton(new OperationGroup(
36                  "opsbar-transitions",
37                  Collections.singleton(new OperationLink("action_id_4", "issueaction-workflow-transition",
38                          "Start Progress", "Start work on the issue", "/secure/WorkflowUIDispatcher.jspa?id=93813&action=4&atl_token=",
39                          10, null)),
40                  Collections.singleton(new OperationGroup(
41                          null,
42                          Collections.<OperationLink>emptyList(),
43                          Collections.<OperationGroup>emptyList(),
44                          new OperationHeader("opsbar-transitions_more", "Workflow", null, null),
45                          null)),
46                  null,
47                  20
48          )))));
49      }
50  }