Skip to content

Commit bc16588

Browse files
committed
pr feedback and tests
1 parent e6d1c77 commit bc16588

File tree

2 files changed

+99
-3
lines changed

2 files changed

+99
-3
lines changed

src/main/java/org/zendesk/client/v2/Zendesk.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ public Iterable<Translation> getArticleTranslations(Long articleId) {
22422242
handleList(Translation.class, "translations"));
22432243
}
22442244

2245-
public Translation getArticleTranslation(long articleId, String locale) {
2245+
public Translation showArticleTranslation(long articleId, String locale) {
22462246
return complete(submit(req("GET",
22472247
tmpl("/help_center/articles/{articleId}/translations/{locale}.json")
22482248
.set("articleId", articleId).set("locale", locale)),
@@ -2341,7 +2341,7 @@ public Iterable<Translation> getCategoryTranslations(Long categoryId) {
23412341
handleList(Translation.class, "translations"));
23422342
}
23432343

2344-
public Translation getCategoryTranslation(long categoryId, String locale) {
2344+
public Translation showCategoryTranslation(long categoryId, String locale) {
23452345
return complete(submit(req("GET",
23462346
tmpl("/help_center/categories/{categoryId}/translations/{locale}.json")
23472347
.set("categoryId", categoryId).set("locale", locale)),
@@ -2400,7 +2400,7 @@ public Iterable<Translation> getSectionTranslations(Long sectionId) {
24002400
handleList(Translation.class, "translations"));
24012401
}
24022402

2403-
public Translation getSectionTranslation(long sectionId, String locale) {
2403+
public Translation showSectionTranslation(long sectionId, String locale) {
24042404
return complete(submit(req("GET",
24052405
tmpl("/help_center/sections/{sectionId}/translations/{locale}.json")
24062406
.set("sectionId", sectionId).set("locale", locale)),

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

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,38 @@ public void getArticleTranslations() throws Exception {
16141614
}
16151615
}
16161616

1617+
@Test
1618+
public void showArticleTranslation() throws Exception {
1619+
createClientWithTokenOrPassword();
1620+
List<String> locales = instance.getHelpCenterLocales();
1621+
1622+
int articleCount = 0;
1623+
1624+
for (Article article : instance.getArticles()) {
1625+
assertNotNull(article.getId());
1626+
1627+
if (++articleCount > 10) {
1628+
break;
1629+
}
1630+
1631+
int translationCount = 0;
1632+
1633+
for (String locale : locales) {
1634+
Translation translation = instance.showArticleTranslation(article.getId(), locale);
1635+
1636+
// if there is no translation for the given locale the endpoint will return null
1637+
if (translation != null) {
1638+
assertNotNull(translation.getId());
1639+
assertNotNull(translation.getTitle());
1640+
}
1641+
1642+
if (++translationCount > 3) {
1643+
break;
1644+
}
1645+
}
1646+
}
1647+
}
1648+
16171649
@Test
16181650
public void getSectionTranslations() throws Exception {
16191651
createClientWithTokenOrPassword();
@@ -1636,6 +1668,38 @@ public void getSectionTranslations() throws Exception {
16361668
}
16371669
}
16381670

1671+
@Test
1672+
public void showSectionTranslation() throws Exception {
1673+
createClientWithTokenOrPassword();
1674+
List<String> locales = instance.getHelpCenterLocales();
1675+
1676+
int sectionCount = 0;
1677+
1678+
for (Section section : instance.getSections()) {
1679+
assertNotNull(section.getId());
1680+
1681+
if (++sectionCount > 10) {
1682+
break;
1683+
}
1684+
1685+
int translationCount = 0;
1686+
1687+
for (String locale : locales) {
1688+
Translation translation = instance.showSectionTranslation(section.getId(), locale);
1689+
1690+
// if there is no translation for the given locale the endpoint will return null
1691+
if (translation != null) {
1692+
assertNotNull(translation.getId());
1693+
assertNotNull(translation.getTitle());
1694+
}
1695+
1696+
if (++translationCount > 3) {
1697+
break;
1698+
}
1699+
}
1700+
}
1701+
}
1702+
16391703
@Test
16401704
public void getCategoryTranslations() throws Exception {
16411705
createClientWithTokenOrPassword();
@@ -1658,6 +1722,38 @@ public void getCategoryTranslations() throws Exception {
16581722
}
16591723
}
16601724

1725+
@Test
1726+
public void showCategoryTranslation() throws Exception {
1727+
createClientWithTokenOrPassword();
1728+
List<String> locales = instance.getHelpCenterLocales();
1729+
1730+
int categoryCount = 0;
1731+
1732+
for (Category category : instance.getCategories()) {
1733+
assertNotNull(category.getId());
1734+
1735+
if (++categoryCount > 10) {
1736+
break;
1737+
}
1738+
1739+
int translationCount = 0;
1740+
1741+
for (String locale : locales) {
1742+
Translation translation = instance.showCategoryTranslation(category.getId(), locale);
1743+
1744+
// if there is no translation for the given locale the endpoint will return null
1745+
if (translation != null) {
1746+
assertNotNull(translation.getId());
1747+
assertNotNull(translation.getTitle());
1748+
}
1749+
1750+
if (++translationCount > 3) {
1751+
break;
1752+
}
1753+
}
1754+
}
1755+
}
1756+
16611757
@Test
16621758
public void getArticlesIncrementally() throws Exception {
16631759
createClientWithTokenOrPassword();

0 commit comments

Comments
 (0)