aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo')
-rw-r--r--tests/src/cgeo/geocaching/CgeoApplicationTest.java3
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCParserTest.java14
-rw-r--r--tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java2
-rw-r--r--tests/src/cgeo/geocaching/export/ExportTest.java4
-rw-r--r--tests/src/cgeo/geocaching/files/InvalidXMLCharacterFilterReaderTest.java1
-rw-r--r--tests/src/cgeo/geocaching/filter/StateNotFoundFilterTest.java28
-rw-r--r--tests/src/cgeo/geocaching/test/mock/MockedCache.java1
7 files changed, 42 insertions, 11 deletions
diff --git a/tests/src/cgeo/geocaching/CgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
index 3e63481..bdde2b6 100644
--- a/tests/src/cgeo/geocaching/CgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
@@ -158,6 +158,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
public static void testSearchByGeocodeNotLoggedIn() {
withMockedLoginDo(new Runnable() {
+ @Override
public void run() {
// non premium cache
MockedCache cache = new GC2CJPF();
@@ -193,6 +194,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
public static void testSearchErrorOccured() {
withMockedLoginDo(new Runnable() {
+ @Override
public void run() {
// non premium cache
final MockedCache cache = new GC1ZXX2();
@@ -342,6 +344,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
public static void testSearchByViewportNotLoggedIn() {
withMockedLoginDo(new Runnable() {
+ @Override
public void run() {
final Strategy strategy = Settings.getLiveMapStrategy();
final Strategy testStrategy = Strategy.FAST; // FASTEST, FAST or DETAILED for tests
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/export/ExportTest.java b/tests/src/cgeo/geocaching/export/ExportTest.java
index a9fceec..848a1f7 100644
--- a/tests/src/cgeo/geocaching/export/ExportTest.java
+++ b/tests/src/cgeo/geocaching/export/ExportTest.java
@@ -52,10 +52,6 @@ public class ExportTest extends CGeoTestCase {
private static class GpxExportTester extends GpxExport {
- protected GpxExportTester() {
- super();
- }
-
public File testExportSync(List<Geocache> caches) throws InterruptedException, ExecutionException {
final ArrayList<String> geocodes = new ArrayList<String>(caches.size());
for (final Geocache cache : caches) {
diff --git a/tests/src/cgeo/geocaching/files/InvalidXMLCharacterFilterReaderTest.java b/tests/src/cgeo/geocaching/files/InvalidXMLCharacterFilterReaderTest.java
index 0641b5d..515d8a6 100644
--- a/tests/src/cgeo/geocaching/files/InvalidXMLCharacterFilterReaderTest.java
+++ b/tests/src/cgeo/geocaching/files/InvalidXMLCharacterFilterReaderTest.java
@@ -17,6 +17,7 @@ public class InvalidXMLCharacterFilterReaderTest extends AndroidTestCase {
final AtomicReference<String> description = new AtomicReference<String>();
root.setEndTextElementListener(new EndTextElementListener() {
+ @Override
public void end(String body) {
description.set(body);
}
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();
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/test/mock/MockedCache.java b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
index d06e715..cd482f8 100644
--- a/tests/src/cgeo/geocaching/test/mock/MockedCache.java
+++ b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
@@ -150,6 +150,7 @@ public abstract class MockedCache implements ICache {
return getName();
}
+ @Override
public Geopoint getCoords() {
return coords;
}