diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/connector')
4 files changed, 27 insertions, 15 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java index be0c4da..ef50709 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java @@ -16,9 +16,9 @@ public class GCConstantsTest extends AndroidTestCase { public static void testLocation() { // GC37GFJ - assertEquals("Bretagne, France", parseLocation(" <span id=\"ctl00_ContentBody_Location\">In Bretagne, France</span><br />")); + assertThat(parseLocation(" <span id=\"ctl00_ContentBody_Location\">In Bretagne, France</span><br />")).isEqualTo("Bretagne, France"); // GCV2R9 - assertEquals("California, United States", parseLocation("<span id=\"ctl00_ContentBody_Location\">In <a href=\"/map/beta/default.aspx?lat=37.4354&lng=-122.07745&z=16\" title=\"View Map\">California, United States</a></span><br />")); + assertThat(parseLocation("<span id=\"ctl00_ContentBody_Location\">In <a href=\"/map/beta/default.aspx?lat=37.4354&lng=-122.07745&z=16\" title=\"View Map\">California, United States</a></span><br />")).isEqualTo("California, United States"); } private static String parseLocation(final String html) { @@ -55,16 +55,16 @@ public class GCConstantsTest extends AndroidTestCase { public static void testConstants() { final String session = "userSession = new Groundspeak.Map.UserSession('aKWZ', userOptions:'XPTf', sessionToken:'123pNKwdktYGZL0xd-I7yqA6nm_JE1BDUtM4KcOkifin2TRCMutBd_PZE14Ohpffs2ZgkTnxTSnxYpBigK4hBA2', subscriberType: 3, enablePersonalization: true });"; - assertEquals("aKWZ", TextUtils.getMatch(session, GCConstants.PATTERN_USERSESSION, "")); + assertThat(TextUtils.getMatch(session, GCConstants.PATTERN_USERSESSION, "")).isEqualTo("aKWZ"); assertThat(TextUtils.getMatch(session, GCConstants.PATTERN_SESSIONTOKEN, "").startsWith("123pNK")).isTrue(); } public static void testTBWithSpecialChar() { // Incidentally, the site incorrectly escapes the "&" into "&" final String page = "<span id=\"ctl00_ContentBody_lbHeading\">Schlauchen&ravestorm</span>"; - assertEquals("Schlauchen&ravestorm", Html.fromHtml(TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_NAME, "")).toString()); + assertThat(Html.fromHtml(TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_NAME, "")).toString()).isEqualTo("Schlauchen&ravestorm"); // Test with the current incorrect form as well final String page2 = "<span id=\"ctl00_ContentBody_lbHeading\">Schlauchen&ravestorm</span>"; - assertEquals("Schlauchen&ravestorm", Html.fromHtml(TextUtils.getMatch(page2, GCConstants.PATTERN_TRACKABLE_NAME, "")).toString()); + assertThat(Html.fromHtml(TextUtils.getMatch(page2, GCConstants.PATTERN_TRACKABLE_NAME, "")).toString()).isEqualTo("Schlauchen&ravestorm"); } } 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/gc/TrackablesTest.java b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java index c45efd7..faaedbf 100644 --- a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java @@ -101,9 +101,9 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { assertThat(goal).isNotNull(); assertThat(goal.startsWith("Bei meinem Besitzer auf der Couch")).isTrue(); assertThat(goal.endsWith("Geocachern zusammen fotografieren.")).isTrue(); - assertEquals("Der kleine Maulwurf in etwas größer :-)", trackable.getDetails()); + assertThat(trackable.getDetails()).isEqualTo("Der kleine Maulwurf in etwas größer :-)"); assertThat(trackable.getGeocode()).isEqualTo("TB54VJJ"); - assertEquals("Nordrhein-Westfalen, Germany", trackable.getOrigin()); + assertThat(trackable.getOrigin()).isEqualTo("Nordrhein-Westfalen, Germany"); assertThat(trackable.getOwner()).isEqualTo("Lineflyer"); // the icon url is manipulated during compression assertThat(trackable.getIconUrl().endsWith("www.geocaching.com/images/wpttypes/21.gif")).isTrue(); diff --git a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java index 05d676b..04bb5ac 100644 --- a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java @@ -6,6 +6,7 @@ import cgeo.CGeoTestCase; import cgeo.geocaching.DataStore; import cgeo.geocaching.Geocache; import cgeo.geocaching.enumerations.LoadFlags; +import cgeo.geocaching.enumerations.LogType; public class OkapiClientTest extends CGeoTestCase { @@ -22,6 +23,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() { @@ -42,8 +45,17 @@ public class OkapiClientTest extends CGeoTestCase { assertThat(cache.getWaypoints()).hasSize(3); // load again - cache.refreshSynchronous(cache.getListId(), null); + cache.refreshSynchronous(null); assertThat(cache.getWaypoints()).hasSize(3); } + public static void testOCWillAttendLogs() { + final String geoCode = "OC10CB8"; + + removeCacheCompletely(geoCode); + Geocache cache = OkapiClient.getCache(geoCode); + assertThat(cache).as("Cache from OKAPI").isNotNull(); + assertThat(cache.getLogCounts().get(LogType.WILL_ATTEND)).isGreaterThan(0); + } + } |
