1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.internal.jersey;
18
19 import com.atlassian.jira.rest.client.IterableMatcher;
20 import com.atlassian.jira.rest.client.internal.json.ResourceUtil;
21 import org.codehaus.jettison.json.JSONException;
22 import org.junit.Assert;
23 import org.junit.Test;
24
25 import java.util.Collection;
26
27 public class AbstractJerseyRestClientTest {
28 @Test
29 public void testExtractErrors() throws JSONException {
30 final String str = ResourceUtil.getStringFromResource("/json/error/valid.json");
31 final Collection<String> stringCollection = AbstractJerseyRestClient.extractErrors(str);
32 Assert.assertThat(stringCollection, IterableMatcher.hasOnlyElements("abcfsd"));
33 }
34
35 @Test
36 public void testExtractErrors2() throws JSONException {
37 final String str = ResourceUtil.getStringFromResource("/json/error/valid2.json");
38 final Collection<String> stringCollection = AbstractJerseyRestClient.extractErrors(str);
39 Assert.assertThat(stringCollection, IterableMatcher.hasOnlyElements("a", "b", "xxx"));
40 }
41
42 @Test
43 public void testExtractErrors3() throws JSONException {
44 final String str = ResourceUtil.getStringFromResource("/json/error/valid3.json");
45 final Collection<String> stringCollection = AbstractJerseyRestClient.extractErrors(str);
46 Assert.assertThat(stringCollection, IterableMatcher.hasOnlyElements("aa", "bb"));
47 }
48
49 @Test
50 public void testExtractErrors4() throws JSONException {
51 final String str = ResourceUtil.getStringFromResource("/json/error/valid4.json");
52 final Collection<String> stringCollection = AbstractJerseyRestClient.extractErrors(str);
53 Assert.assertThat(stringCollection, IterableMatcher.hasOnlyElements("a", "b", "y", "z"));
54 }
55
56 }