package cgeo.geocaching.connector.oc;

import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.DataStore;
import cgeo.geocaching.enumerations.LoadFlags;

public class OkapiClientTest extends CGeoTestCase {

    public static void testGetOCCache() {
        final String geoCode = "OU0331";
        Geocache cache = OkapiClient.getCache(geoCode);
        assertNotNull("Did not get cache from OKAPI", cache);
        assertEquals("Unexpected geo code", geoCode, cache.getGeocode());
        assertEquals("Oshkosh Municipal Tank", cache.getName());
        assertTrue(cache.isDetailed());
        // cache should be stored to DB (to listID 0) when loaded above
        cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
        assertNotNull(cache);
        assertEquals(geoCode, cache.getGeocode());
        assertEquals("Oshkosh Municipal Tank", cache.getName());
        assertTrue(cache.isDetailed());
    }

    public static void testOCSearchMustWorkWithoutOAuthAccessTokens() {
        final String geoCode = "OC1234";
        Geocache cache = OkapiClient.getCache(geoCode);
        assertNotNull("You must have a valid OKAPI key installed for running this test (but you do not need to set credentials in the app).", cache);
        assertEquals("Wupper-Schein", cache.getName());
    }
}

@@ -81,23 +81,24 @@
 caching.
-Geocach
+DataStor
 e;%0Aimpor
@@ -111,32 +111,31 @@
 .geocaching.
-DataStor
+Geocach
 e;%0Aimport cg
@@ -1326,10 +1326,624 @@
 ;%0A    %7D%0A
+%0A    public static void testOCCacheWithWaypoints() %7B%0A        final String geoCode = %22OCDDD2%22;%0A        removeCacheCompletely(geoCode);%0A        Geocache cache = OkapiClient.getCache(geoCode);%0A        assertNotNull(%22Did not get cache from OKAPI%22, cache);%0A        // cache should be stored to DB (to listID 0) when loaded above%0A        cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);%0A        assertNotNull(cache);%0A        assertEquals(3, cache.getWaypoints().size());%0A%0A        // load again%0A        cache.refresh(cache.getListId(), null);%0A        assertEquals(3, cache.getWaypoints().size());%0A    %7D%0A%0A
 %7D%0A

add test for okapi loading