diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/connector/oc')
3 files changed, 34 insertions, 2 deletions
diff --git a/tests/src/cgeo/geocaching/connector/oc/OCCZConnectorTest.java b/tests/src/cgeo/geocaching/connector/oc/OCCZConnectorTest.java new file mode 100644 index 0000000..52fc5c8 --- /dev/null +++ b/tests/src/cgeo/geocaching/connector/oc/OCCZConnectorTest.java @@ -0,0 +1,14 @@ +package cgeo.geocaching.connector.oc; + +import static org.assertj.core.api.Assertions.assertThat; +import junit.framework.TestCase; + +public class OCCZConnectorTest extends TestCase { + + public static void testGetGeocodeFromUrl() throws Exception { + final OCCZConnector connector = new OCCZConnector(); + assertThat(connector.getGeocodeFromUrl("http://opencaching.cz/viewcache.php?cacheid=610")).isEqualTo("OZ0262"); + assertThat(connector.getGeocodeFromUrl("http://www.opencaching.de/viewcache.php?cacheid=151223")).isNull(); + } + +} diff --git a/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java b/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java index 0aad3aa..697b8d8 100644 --- a/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java @@ -24,4 +24,15 @@ public class OCConnectorTest extends TestCase { return ocConnector; } + public static void testGetGeocodeFromUrlDe() throws Exception { + final IConnector connector = ConnectorFactory.getConnector("OC0028"); + assertThat(connector.getGeocodeFromUrl("http://opencaching.de/OC0028")).isEqualTo("OC0028"); + assertThat(connector.getGeocodeFromUrl("http://www.opencaching.de/OC0028")).isEqualTo("OC0028"); + } + + public static void testGetGeocodeFromUrlUs() throws Exception { + final IConnector connector = ConnectorFactory.getConnector("OU07A0"); + assertThat(connector.getGeocodeFromUrl("http://www.opencaching.us/viewcache.php?wp=OU07A0")).isEqualTo("OU07A0"); + } + } diff --git a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java index aa66ac9..22b2dbe 100644 --- a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java @@ -30,7 +30,7 @@ public class OkapiClientTest extends CGeoTestCase { public static void testOCSearchMustWorkWithoutOAuthAccessTokens() { final String geoCode = "OC1234"; - Geocache cache = OkapiClient.getCache(geoCode); + final Geocache cache = OkapiClient.getCache(geoCode); assertThat(cache).overridingErrorMessage("You must have a valid OKAPI key installed for running this test (but you do not need to set credentials in the app).").isNotNull(); assertThat(cache.getName()).isEqualTo("Wupper-Schein"); } @@ -55,9 +55,16 @@ public class OkapiClientTest extends CGeoTestCase { final String geoCode = "OC6465"; removeCacheCompletely(geoCode); - Geocache cache = OkapiClient.getCache(geoCode); + final Geocache cache = OkapiClient.getCache(geoCode); assertThat(cache).as("Cache from OKAPI").isNotNull(); assertThat(cache.getLogCounts().get(LogType.WILL_ATTEND)).isGreaterThan(0); } + public static void testGetAllLogs() { + final String geoCode = "OC10CB8"; + final Geocache cache = OkapiClient.getCache(geoCode); + final int defaultLogCount = 10; + assertThat(cache.getLogs().size()).isGreaterThan(defaultLogCount); + } + } |
