Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Refactoring translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Fayder Florez committed Mar 5, 2017
1 parent ffd3c53 commit 1984221
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/main/java/fayder/restcountries/domain/BaseCountry.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class BaseCountry {

private String subregion;

private CountryTranslations translations;

private Integer population;

private List<Double> latlng;
Expand Down Expand Up @@ -126,14 +124,6 @@ public void setSubregion(String subregion) {
this.subregion = subregion;
}

public CountryTranslations getTranslations() {
return translations;
}

public void setTranslations(CountryTranslations translations) {
this.translations = translations;
}

public Integer getPopulation() {
return population;
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/fayder/restcountries/v1/domain/Country.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Country extends BaseCountry {

private List<String> currencies;
private List<String> languages;
private CountryTranslations translations;

public List<String> getCurrencies() {
return currencies;
Expand All @@ -28,4 +29,12 @@ public List<String> getLanguages() {
public void setLanguages(List<String> languages) {
this.languages = languages;
}

public CountryTranslations getTranslations() {
return translations;
}

public void setTranslations(CountryTranslations translations) {
this.translations = translations;
}
}
5 changes: 5 additions & 0 deletions src/main/java/fayder/restcountries/v2/domain/Country.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Country extends BaseCountry {

private List<Currency> currencies;
private List<Language> languages;
private Translations translations;

public List<Currency> getCurrencies() {
return currencies;
Expand Down Expand Up @@ -40,4 +41,8 @@ public String getRelevance() {
public String getSubregion() {
return super.getSubregion();
}

public Translations getTranslations() {
return translations;
}
}
20 changes: 20 additions & 0 deletions src/main/java/fayder/restcountries/v2/domain/Translations.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package fayder.restcountries.v2.domain;

import fayder.restcountries.v1.domain.CountryTranslations;

/**
* Created by fayder on 05/03/2017.
*/
public class Translations extends CountryTranslations {

private String br;
private String pt;

public String getBr() {
return br;
}

public String getPt() {
return pt;
}
}
15 changes: 15 additions & 0 deletions src/test/java/fayder/restcountries/v2/CountryServiceTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fayder.restcountries.v2;

import fayder.restcountries.v2.domain.Country;
import fayder.restcountries.v2.domain.Translations;
import fayder.restcountries.v2.rest.CountryService;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -153,4 +154,18 @@ public void getByDemonym() throws Exception {
Assert.assertEquals("french", country.getDemonym().toLowerCase());
}
}

@Test
public void translations() throws Exception {
Country country = CountryService.getInstance().getByAlpha("COL");
Assert.assertNotNull(country);
Translations translations = country.getTranslations();
Assert.assertEquals("Kolumbien", translations.getDe());
Assert.assertEquals("Colombia", translations.getEs());
Assert.assertEquals("Colombie", translations.getFr());
Assert.assertEquals("コロンビア", translations.getJa());
Assert.assertEquals("Colombia", translations.getIt());
Assert.assertEquals("Colômbia", translations.getBr());
Assert.assertEquals("Colômbia", translations.getPt());
}
}

0 comments on commit 1984221

Please sign in to comment.