X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=tests%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FTestCountryCode.java;fp=tests%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FTestCountryCode.java;h=0000000000000000000000000000000000000000;hb=bccd4cc0dba0f89aa045b113bac46eb8cc1dab4e;hp=7f82909c75cc1dc5763f8b210271c760029c2332;hpb=c9ed09f0007fc2c813815be927a5a24b23dab83c;p=gigi.git diff --git a/tests/org/cacert/gigi/dbObjects/TestCountryCode.java b/tests/org/cacert/gigi/dbObjects/TestCountryCode.java deleted file mode 100644 index 7f82909c..00000000 --- a/tests/org/cacert/gigi/dbObjects/TestCountryCode.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.cacert.gigi.dbObjects; - -import static org.junit.Assert.*; - -import java.util.Arrays; -import java.util.List; - -import org.cacert.gigi.GigiApiException; -import org.cacert.gigi.dbObjects.Country.CountryCodeType; -import org.cacert.gigi.testUtils.BusinessTest; -import org.hamcrest.BaseMatcher; -import org.hamcrest.CoreMatchers; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -@RunWith(Parameterized.class) -public class TestCountryCode extends BusinessTest { - - @Parameter(0) - public CountryCodeType type; - - @Parameters(name = "Type: {0}") - public static Iterable getParameters() { - return Arrays.asList(new Object[] { - CountryCodeType.CODE_2_CHARS - }, new Object[] { - CountryCodeType.CODE_3_CHARS - }); - } - - @Test - public void testList() throws GigiApiException { - List ccs = Country.getCountries(); - for (Country cc : ccs) { - assertThat(cc.getCode(type), stringLength(type.getLen())); - } - } - - @Test - public void testFetch() throws GigiApiException { - String ref = type == CountryCodeType.CODE_2_CHARS ? "DE" : "DEU"; - Country cc = Country.getCountryByCode(ref, type); - assertEquals(ref, cc.getCode(type)); - assertEquals("Germany", cc.getName()); - } - - @Test - public void testCheck() throws GigiApiException { - String ref = type == CountryCodeType.CODE_2_CHARS ? "DE" : "DEU"; - String reff = type == CountryCodeType.CODE_2_CHARS ? "DF" : "DFU"; - - Country.checkCountryCode(ref, type); - try { - Country.checkCountryCode(reff, type); - } catch (GigiApiException e) { - assertThat(e.getMessage(), CoreMatchers.containsString("was wrong")); - } - - Country.getCountryByCode(ref, type); - try { - Country.getCountryByCode(reff, type); - } catch (GigiApiException e) { - assertThat(e.getMessage(), CoreMatchers.containsString("was wrong")); - } - } - - @Test - public void testSingleInstance() throws GigiApiException { - String ref = type == CountryCodeType.CODE_2_CHARS ? "DE" : "DEU"; - assertSame(Country.getCountryByCode(ref, type), Country.getCountryByCode(ref, type)); - } - - private Matcher stringLength(final int len) { - return new BaseMatcher() { - - @Override - public boolean matches(Object s) { - if (s instanceof String) { - return ((String) s).length() == len; - } - return false; - } - - @Override - public void describeTo(Description arg0) { - arg0.appendText("String of length " + len); - } - - }; - } - -}