|
14 | 14 | import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource; |
15 | 15 | import static org.hamcrest.CoreMatchers.is; |
16 | 16 | import static org.hamcrest.CoreMatchers.notNullValue; |
| 17 | +import static org.hamcrest.CoreMatchers.nullValue; |
17 | 18 | import static org.hamcrest.MatcherAssert.assertThat; |
18 | 19 | import static org.hamcrest.text.MatchesPattern.matchesPattern; |
19 | 20 |
|
20 | 21 | public class Zendesk4SettingsTest { |
21 | 22 |
|
22 | 23 | @Test |
23 | 24 | public void shouldSerialize() throws Exception { |
24 | | - final Zendesk4Settings settings = new Zendesk4Settings("https://foo.com", plus.name(), "12am", "America/Los_Angeles"); |
| 25 | + final Zendesk4Settings settings = new Zendesk4Settings("https://foo.com", "zopim.com", "testAccount", |
| 26 | + plus.name(), "12am", "America/Los_Angeles"); |
25 | 27 | assertThat(settings, jsonEquals(resource("connector/settings-zendesk4.json"))); |
26 | 28 | } |
27 | 29 |
|
| 30 | + @Test |
| 31 | + public void shouldSerialize_beforeTemplate26() throws Exception { |
| 32 | + final Zendesk4Settings settings = new Zendesk4Settings("https://foo.com", null, null, |
| 33 | + plus.name(), "12am", "America/Los_Angeles"); |
| 34 | + assertThat(settings, jsonEquals(resource("connector/settings-zendesk4-before-template26.json"))); |
| 35 | + } |
| 36 | + |
28 | 37 | @Test |
29 | 38 | public void shouldDeserialize() throws Exception { |
30 | 39 | final Zendesk4Settings settings = readObjectFromResource("/connector/settings-zendesk4.json", Zendesk4Settings.class); |
31 | 40 |
|
32 | 41 | assertThat(settings, is(notNullValue())); |
33 | 42 | assertThat(settings.getApiUrl(), is("https://foo.com")); |
| 43 | + assertThat(settings.getZopimUrl(), is("zopim.com")); |
| 44 | + assertThat(settings.getAccount(), is("testAccount")); |
| 45 | + assertThat(settings.getType(), is(plus.name())); |
| 46 | + assertThat(settings.getSyncTime(), is("12am")); |
| 47 | + assertThat(settings.getSyncTimeZone(), is("America/Los_Angeles")); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void shouldDeserialize_beforeTemplate26() throws Exception { |
| 52 | + final Zendesk4Settings settings = readObjectFromResource("/connector/settings-zendesk4-before-template26.json", Zendesk4Settings.class); |
| 53 | + |
| 54 | + assertThat(settings, is(notNullValue())); |
| 55 | + assertThat(settings.getApiUrl(), is("https://foo.com")); |
| 56 | + assertThat(settings.getZopimUrl(), is(nullValue())); |
| 57 | + assertThat(settings.getAccount(), is(nullValue())); |
34 | 58 | assertThat(settings.getType(), is(plus.name())); |
35 | 59 | assertThat(settings.getSyncTime(), is("12am")); |
36 | 60 | assertThat(settings.getSyncTimeZone(), is("America/Los_Angeles")); |
@@ -60,6 +84,20 @@ public void testSetApiUrl() throws Exception { |
60 | 84 | assertThat(settings.getApiUrl(), is("new url")); |
61 | 85 | } |
62 | 86 |
|
| 87 | + @Test |
| 88 | + public void testSetZopimUrl() throws Exception { |
| 89 | + final Zendesk4Settings settings = new Zendesk4Settings("api url"); |
| 90 | + settings.setZopimUrl("zopim url"); |
| 91 | + assertThat(settings.getZopimUrl(), is("zopim url")); |
| 92 | + } |
| 93 | + |
| 94 | + @Test |
| 95 | + public void testSetAccount() throws Exception { |
| 96 | + final Zendesk4Settings settings = new Zendesk4Settings("api url"); |
| 97 | + settings.setAccount("test account"); |
| 98 | + assertThat(settings.getAccount(), is("test account")); |
| 99 | + } |
| 100 | + |
63 | 101 | @Test |
64 | 102 | public void testToStringFormat() { |
65 | 103 | final Zendesk4Settings settings = new Zendesk4Settings("old url"); |
|
0 commit comments