| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.tools;
|
|---|
| 3 |
|
|---|
| 4 | import static org.junit.Assert.assertTrue;
|
|---|
| 5 |
|
|---|
| 6 | import org.junit.Rule;
|
|---|
| 7 | import org.junit.Test;
|
|---|
| 8 | import org.openstreetmap.josm.data.coor.LatLon;
|
|---|
| 9 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
|---|
| 10 |
|
|---|
| 11 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|---|
| 12 | import net.trajano.commons.testing.UtilityClassTestUtil;
|
|---|
| 13 |
|
|---|
| 14 | /**
|
|---|
| 15 | * Unit tests of {@link Territories} class.
|
|---|
| 16 | */
|
|---|
| 17 | public class TerritoriesTest {
|
|---|
| 18 | /**
|
|---|
| 19 | * Test rules.
|
|---|
| 20 | */
|
|---|
| 21 | @Rule
|
|---|
| 22 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
|---|
| 23 | public JOSMTestRules rules = new JOSMTestRules().platform().projection().territories();
|
|---|
| 24 |
|
|---|
| 25 | /**
|
|---|
| 26 | * Tests that {@code Territories} satisfies utility class criterias.
|
|---|
| 27 | * @throws ReflectiveOperationException if an error occurs
|
|---|
| 28 | */
|
|---|
| 29 | @Test
|
|---|
| 30 | public void testUtilityClass() throws ReflectiveOperationException {
|
|---|
| 31 | UtilityClassTestUtil.assertUtilityClassWellDefined(Territories.class);
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | /**
|
|---|
| 35 | * Test of {@link Territories#isIso3166Code} method.
|
|---|
| 36 | */
|
|---|
| 37 | @Test
|
|---|
| 38 | public void testIsIso3166Code() {
|
|---|
| 39 | check("Paris", new LatLon(48.8567, 2.3508), "EU", "FR", "FX");
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | private static void check(String name, LatLon ll, String ... expectedCodes) {
|
|---|
| 43 | for (String e : expectedCodes) {
|
|---|
| 44 | assertTrue(name + " " + e, Territories.isIso3166Code(e, ll));
|
|---|
| 45 | }
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|