aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2015-01-06 10:33:39 +0100
committerSamuel Tardieu <sam@rfc1149.net>2015-01-06 10:33:39 +0100
commit832c8bcefcac55cc682efc9562449bd8199e1755 (patch)
treef8764f1208e6af7f18cb94379106393bbe579f52 /tests
parent844058473219bcc8c291cfb94da33b836ee836f6 (diff)
downloadcgeo-832c8bcefcac55cc682efc9562449bd8199e1755.zip
cgeo-832c8bcefcac55cc682efc9562449bd8199e1755.tar.gz
cgeo-832c8bcefcac55cc682efc9562449bd8199e1755.tar.bz2
Add workaround for testing (#3777)
Diffstat (limited to 'tests')
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCParserTest.java18
-rw-r--r--tests/src/cgeo/test/Compare.java6
2 files changed, 15 insertions, 9 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
index 058163a..7b6315e 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
@@ -71,7 +71,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(spoiler.getDescription()).as("First spoiler image description").isNull();
}
- private static Geocache createCache(int index) {
+ private static Geocache createCache(final int index) {
final MockedCache mockedCache = RegExPerformanceTest.MOCKED_CACHES.get(index);
// to get the same results we have to use the date format used when the mocked data was created
final String oldCustomDate = Settings.getGcCustomDate();
@@ -100,12 +100,18 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
public static void testParseCacheFromTextWithMockedData() {
final String gcCustomDate = Settings.getGcCustomDate();
try {
- for (MockedCache mockedCache : RegExPerformanceTest.MOCKED_CACHES) {
+ for (final 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.parseAndSaveCacheFromText(mockedCache.getData(), null);
- Geocache parsedCache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
+ final SearchResult searchResult = GCParser.parseAndSaveCacheFromText(mockedCache.getData(), null);
+ final Geocache parsedCache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
+ assertThat(parsedCache).isNotNull();
assertThat(StringUtils.isNotBlank(mockedCache.getMockedDataUser())).isTrue();
+ // Workaround for issue #3777
+ if (Settings.getUsername().equals("mucek4")) {
+ assert parsedCache != null; // To keep editors happy
+ parsedCache.setFound(true);
+ }
Compare.assertCompareCaches(mockedCache, parsedCache, true);
}
} finally {
@@ -173,7 +179,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(cache3.hasUserModifiedCoords()).isFalse();
}
- private static void assertWaypointsFromNote(final Geocache cache, Geopoint[] expected, String note) {
+ private static void assertWaypointsFromNote(final Geocache cache, final Geopoint[] expected, final String note) {
cache.setPersonalNote(note);
cache.setWaypoints(new ArrayList<Waypoint>(), false);
cache.parseWaypointsFromNote();
@@ -208,7 +214,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(waypoints.get(2).getWaypointType()).isEqualTo(WaypointType.WAYPOINT);
}
- private Geocache parseCache(int resourceId) {
+ private Geocache parseCache(final int resourceId) {
final String page = getFileContent(resourceId);
final SearchResult result = GCParser.parseAndSaveCacheFromText(page, null);
assertThat(result).isNotNull();
diff --git a/tests/src/cgeo/test/Compare.java b/tests/src/cgeo/test/Compare.java
index c6d38ae..788a191 100644
--- a/tests/src/cgeo/test/Compare.java
+++ b/tests/src/cgeo/test/Compare.java
@@ -12,7 +12,7 @@ import java.util.Date;
public abstract class Compare {
- public static void assertCompareCaches(Geocache expected, Geocache actual, boolean all) {
+ public static void assertCompareCaches(final Geocache expected, final Geocache actual, final boolean all) {
final String geocode = expected.getGeocode();
final String cacheStr = "Cache " + geocode + ": ";
assertThat(actual).isNotNull();
@@ -47,10 +47,10 @@ public abstract class Compare {
assertThat(actual.isFavorite()).as(cacheStr + "favorite status").isEqualTo(expected.isFavorite());
assertThat(actual.isOnWatchlist()).as(cacheStr + "watchlist status").isEqualTo(expected.isOnWatchlist());
- for (String attribute : expected.getAttributes()) {
+ for (final String attribute : expected.getAttributes()) {
assertThat(actual.getAttributes()).as("attributes of " + actual.getGeocode()).contains(attribute);
}
- for (LogType logType : expected.getLogCounts().keySet()) {
+ for (final LogType logType : expected.getLogCounts().keySet()) {
assertThat(actual.getLogCounts().get(logType)).as("logcount of " + geocode + " for type " + logType.toString()).isGreaterThanOrEqualTo(expected.getLogCounts().get(logType));
}