diff options
Diffstat (limited to 'tests/src')
3 files changed, 37 insertions, 7 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java index 2897b54..1c64568 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java @@ -36,7 +36,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { private void assertUnpublished(final int cache) { final String page = getFileContent(cache); - final SearchResult result = GCParser.parseCacheFromText(page, null); + final SearchResult result = GCParser.parseAndSaveCacheFromText(page, null); assertThat(result).isNotNull(); assertThat(result.isEmpty()).isTrue(); assertThat(result.getError()).isEqualTo(StatusCode.UNPUBLISHED_CACHE); @@ -52,7 +52,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { private void assertPublishedCache(final int cachePage, final String cacheName) { final String page = getFileContent(cachePage); - final SearchResult result = GCParser.parseCacheFromText(page, null); + final SearchResult result = GCParser.parseAndSaveCacheFromText(page, null); assertThat(result).isNotNull(); assertThat(result.getCount()).isEqualTo(1); final Geocache cache = result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); @@ -79,7 +79,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { final SearchResult searchResult; try { Settings.setGcCustomDate(MockedCache.getDateFormat()); - searchResult = GCParser.parseCacheFromText(mockedCache.getData(), null); + searchResult = GCParser.parseAndSaveCacheFromText(mockedCache.getData(), null); } finally { Settings.setGcCustomDate(oldCustomDate); } @@ -103,7 +103,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { for (MockedCache mockedCache : RegExPerformanceTest.MOCKED_CACHES) { // to get the same results we have to use the date format used when the mocked data was created Settings.setGcCustomDate(MockedCache.getDateFormat()); - SearchResult searchResult = GCParser.parseCacheFromText(mockedCache.getData(), null); + SearchResult searchResult = GCParser.parseAndSaveCacheFromText(mockedCache.getData(), null); Geocache parsedCache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); assertThat(StringUtils.isNotBlank(mockedCache.getMockedDataUser())).isTrue(); Compare.assertCompareCaches(mockedCache, parsedCache, true); @@ -158,7 +158,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { GCParser.editModifiedCoordinates(cache, new Geopoint("N51 21.544", "E07 02.566")); cache.dropSynchronous(); final String page = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0"); - final Geocache cache2 = GCParser.parseCacheFromText(page, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY); + final Geocache cache2 = GCParser.parseAndSaveCacheFromText(page, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY); assertThat(cache2).isNotNull(); assert (cache2 != null); // eclipse bug assertThat(cache2.hasUserModifiedCoords()).isTrue(); @@ -167,7 +167,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { GCParser.deleteModifiedCoordinates(cache2); cache2.dropSynchronous(); final String page2 = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0"); - final Geocache cache3 = GCParser.parseCacheFromText(page2, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY); + final Geocache cache3 = GCParser.parseAndSaveCacheFromText(page2, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY); assertThat(cache3).isNotNull(); assert (cache3 != null); // eclipse bug assertThat(cache3.hasUserModifiedCoords()).isFalse(); @@ -210,7 +210,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { private Geocache parseCache(int resourceId) { final String page = getFileContent(resourceId); - final SearchResult result = GCParser.parseCacheFromText(page, null); + final SearchResult result = GCParser.parseAndSaveCacheFromText(page, null); assertThat(result).isNotNull(); assertThat(result.isEmpty()).isFalse(); return result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); diff --git a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java index 05d676b..2c1d06c 100644 --- a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java @@ -22,6 +22,8 @@ public class OkapiClientTest extends CGeoTestCase { assertThat(cache.getGeocode()).isEqualTo(geoCode); assertThat(cache.getName()).isEqualTo("Oshkosh Municipal Tank"); assertThat(cache.isDetailed()).isTrue(); + assertThat(cache.getOwnerDisplayName()).isNotEmpty(); + assertThat(cache.getOwnerUserId()).isEqualTo(cache.getOwnerDisplayName()); } public static void testOCSearchMustWorkWithoutOAuthAccessTokens() { diff --git a/tests/src/cgeo/geocaching/filter/StateNotFoundFilterTest.java b/tests/src/cgeo/geocaching/filter/StateNotFoundFilterTest.java new file mode 100644 index 0000000..2bf9d94 --- /dev/null +++ b/tests/src/cgeo/geocaching/filter/StateNotFoundFilterTest.java @@ -0,0 +1,28 @@ +package cgeo.geocaching.filter; + +import static org.assertj.core.api.Assertions.assertThat; + +import cgeo.CGeoTestCase; +import cgeo.geocaching.Geocache; +import cgeo.geocaching.filter.StateFilter.StateNotFoundFilter; + +public class StateNotFoundFilterTest extends CGeoTestCase { + + private StateFilter.StateNotFoundFilter notFoundFilter; + private Geocache foundCache; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + notFoundFilter = new StateNotFoundFilter(); + foundCache = new Geocache(); + foundCache.setFound(true); + } + + public void testAccepts() { + assertThat(notFoundFilter.accepts(foundCache)).isFalse(); + assertThat(notFoundFilter.accepts(new Geocache())).isTrue(); + } + +} |
