diff options
Diffstat (limited to 'tests/src')
5 files changed, 28 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/CgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java index c00f549..beb33cd 100644 --- a/tests/src/cgeo/geocaching/CgeoApplicationTest.java +++ b/tests/src/cgeo/geocaching/CgeoApplicationTest.java @@ -312,6 +312,8 @@ public class CgeoApplicationTest extends CGeoTestCase { assertThat(search).isNotNull(); assertThat(search.getGeocodes().contains(mockedCache.getGeocode())).isTrue(); Geocache parsedCache = DataStore.loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB); + assert (parsedCache != null); + assertThat(parsedCache).isNotNull(); assertThat(mockedCache.getCoords().equals(parsedCache.getCoords())).isEqualTo(Settings.isGCPremiumMember()); assertThat(parsedCache.isReliableLatLon()).isEqualTo(Settings.isGCPremiumMember()); @@ -324,6 +326,8 @@ public class CgeoApplicationTest extends CGeoTestCase { assertThat(search).isNotNull(); assertThat(search.getGeocodes().contains(mockedCache.getGeocode())).isTrue(); parsedCache = DataStore.loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB); + assert (parsedCache != null); + assertThat(parsedCache).isNotNull(); assertThat(mockedCache.getCoords().equals(parsedCache.getCoords())).isEqualTo(Settings.isGCPremiumMember()); assertThat(parsedCache.isReliableLatLon()).isEqualTo(Settings.isGCPremiumMember()); @@ -366,6 +370,8 @@ public class CgeoApplicationTest extends CGeoTestCase { assertThat(search.getGeocodes().contains(cache.getGeocode())).isTrue(); // coords differ final Geocache cacheFromViewport = DataStore.loadCache(cache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB); + assert (cacheFromViewport != null); + assertThat(cacheFromViewport).isNotNull(); Log.d("cgeoApplicationTest.testSearchByViewportNotLoggedIn: Coords expected = " + cache.getCoords()); Log.d("cgeoApplicationTest.testSearchByViewportNotLoggedIn: Coords actual = " + cacheFromViewport.getCoords()); assertThat(cache.getCoords().distanceTo(cacheFromViewport.getCoords()) <= 1e-3).isFalse(); diff --git a/tests/src/cgeo/geocaching/DataStoreTest.java b/tests/src/cgeo/geocaching/DataStoreTest.java index 03713ac..36bfe47 100644 --- a/tests/src/cgeo/geocaching/DataStoreTest.java +++ b/tests/src/cgeo/geocaching/DataStoreTest.java @@ -59,6 +59,8 @@ public class DataStoreTest extends CGeoTestCase { // get list final StoredList list1 = DataStore.getList(listId1); + assert (list1 != null); + assertThat(list1).isNotNull(); assertThat(list1.title).isEqualTo("DataStore Test (renamed)"); // move to list (cache1=listId2, cache2=listId2) @@ -123,6 +125,8 @@ public class DataStoreTest extends CGeoTestCase { try { DataStore.saveCache(cache, EnumSet.of(SaveFlag.DB)); final Geocache loadedCache = DataStore.loadCache(GEOCODE_CACHE, LoadFlags.LOAD_ALL_DB_ONLY); + assert (loadedCache != null); + assertThat(loadedCache).isNotNull(); assertThat(loadedCache).overridingErrorMessage("Cache was not saved.").isNotNull(); assertThat(loadedCache.getInventory()).hasSize(1); } finally { diff --git a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java index 20a51b8..7b011f3 100644 --- a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java @@ -19,6 +19,7 @@ public class OkapiClientTest extends CGeoTestCase { assertThat(cache.isDetailed()).isTrue(); // cache should be stored to DB (to listID 0) when loaded above cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY); + assert (cache != null); assertThat(cache).isNotNull(); assertThat(cache.getGeocode()).isEqualTo(geoCode); assertThat(cache.getName()).isEqualTo("Oshkosh Municipal Tank"); @@ -41,6 +42,7 @@ public class OkapiClientTest extends CGeoTestCase { assertThat(cache).as("Cache from OKAPI").isNotNull(); // cache should be stored to DB (to listID 0) when loaded above cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY); + assert (cache != null); assertThat(cache).isNotNull(); assertThat(cache.getWaypoints()).hasSize(3); diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java index f72cf4a..7b9d9ac 100644 --- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java +++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java @@ -78,6 +78,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode)); final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + assert (cache != null); + assertThat(cache).isNotNull(); assertCacheProperties(cache); assertThat(cache.getWaypoints().isEmpty()).isTrue(); @@ -101,6 +103,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode)); final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + assert (cache != null); + assertThat(cache).isNotNull(); assertCacheProperties(cache); assertThat(cache.getWaypoints()).as("Number of imported waypoints").hasSize(4); @@ -128,6 +132,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList("GC31J2H")); final Geocache cache = DataStore.loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB); + assert (cache != null); + assertThat(cache).isNotNull(); assertCacheProperties(cache); assertThat(cache.getWaypoints()).hasSize(2); } @@ -141,6 +147,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); final Geocache cache = DataStore.loadCache("AID1", LoadFlags.LOAD_CACHE_OR_DB); + assert (cache != null); + assertThat(cache).isNotNull(); assertCacheProperties(cache); assertThat(cache.getName()).isEqualTo("First Aid Station #1"); } @@ -205,6 +213,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode)); final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + assert (cache != null); + assertThat(cache).isNotNull(); assertCacheProperties(cache); assertThat(cache.getWaypoints().isEmpty()).isTrue(); @@ -223,6 +233,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode)); final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + assert (cache != null); + assertThat(cache).isNotNull(); assertCacheProperties(cache); assertThat(cache.getWaypoints()).hasSize(1); // this is the original pocket query result without test waypoint } @@ -249,6 +261,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode)); final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + assert (cache != null); + assertThat(cache).isNotNull(); assertCacheProperties(cache); assertThat(cache.getWaypoints()).hasSize(1); // this is the original pocket query result without test waypoint } diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java index 74694bd..43fda22 100644 --- a/tests/src/cgeo/geocaching/files/GPXParserTest.java +++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java @@ -286,6 +286,8 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase { DataStore.removeAllFromCache(); // load only the minimum cache, it has several members missing final Geocache minimalCache = DataStore.loadCache(geocode, EnumSet.of(LoadFlag.DB_MINIMAL)); + assert (minimalCache != null); + assertThat(minimalCache).isNotNull(); // now check that we load lazy members on demand assertThat(minimalCache.getAttributes()).isNotEmpty(); |
