Skip to content

Commit df14857

Browse files
committed
Add unit tests for List Locales operation
1 parent c98eaf2 commit df14857

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

src/test/java/org/zendesk/client/v2/RealSmokeTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import org.zendesk.client.v2.model.Identity;
7070
import org.zendesk.client.v2.model.JobResult;
7171
import org.zendesk.client.v2.model.JobStatus;
72+
import org.zendesk.client.v2.model.Locale;
7273
import org.zendesk.client.v2.model.Organization;
7374
import org.zendesk.client.v2.model.OrganizationMembership;
7475
import org.zendesk.client.v2.model.Priority;
@@ -2479,6 +2480,22 @@ public void getViewReturnsTheUnresolvedView() throws Exception {
24792480
assertTrue(maybeView.isPresent());
24802481
}
24812482

2483+
@Test
2484+
public void getLocalesReturnsLocales() throws Exception {
2485+
createClientWithTokenOrPassword();
2486+
Iterable<Locale> locales = instance.getLocales();
2487+
assertThat(locales, notNullValue());
2488+
2489+
int numLocales = 0;
2490+
boolean defaultLocaleIsPresent = false;
2491+
for (Locale locale : locales) {
2492+
defaultLocaleIsPresent |= locale.isDefault();
2493+
++numLocales;
2494+
}
2495+
assertThat(numLocales, greaterThan(0));
2496+
assertThat(defaultLocaleIsPresent, is(true));
2497+
}
2498+
24822499
// UTILITIES
24832500

24842501
/**
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.zendesk.client.v2.model;
2+
3+
import static org.hamcrest.CoreMatchers.is;
4+
import static org.hamcrest.MatcherAssert.assertThat;
5+
6+
import org.junit.Test;
7+
import org.zendesk.client.v2.Zendesk;
8+
9+
public class LocaleTest {
10+
@Test
11+
public void testLocaleDeserialization() throws Exception {
12+
String json =
13+
"{"
14+
+ "\"url\": \"https://acme.zendesk.com/api/v2/locales/en-US.json\","
15+
+ "\"id\": 1,"
16+
+ "\"locale\": \"en-US\","
17+
+ "\"name\": \"English\","
18+
+ "\"native_name\": \"English (United States)\","
19+
+ "\"presentation_name\": \"English (United States)\","
20+
+ "\"rtl\": false,"
21+
+ "\"created_at\": \"2023-08-13T19:23:16Z\","
22+
+ "\"updated_at\": \"2023-09-21T19:23:16Z\","
23+
+ "\"default\": true"
24+
+ "}";
25+
26+
Locale locale = Zendesk.createMapper().readValue(json, Locale.class);
27+
28+
assertThat(locale.getUrl(), is("https://acme.zendesk.com/api/v2/locales/en-US.json"));
29+
assertThat(locale.getId(), is(1L));
30+
assertThat(locale.getLocale(), is("en-US"));
31+
assertThat(locale.getName(), is("English"));
32+
assertThat(locale.getNativeName(), is("English (United States)"));
33+
assertThat(locale.getPresentationName(), is("English (United States)"));
34+
assertThat(locale.getRtl(), is(false));
35+
assertThat(locale.getCreatedAt().getTime(), is(1691954596000L));
36+
assertThat(locale.getUpdatedAt().getTime(), is(1695324196000L));
37+
assertThat(locale.isDefault(), is(true));
38+
}
39+
}

0 commit comments

Comments
 (0)