aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2014-06-11 20:17:43 +0200
committerBananeweizen <bananeweizen@gmx.de>2014-06-11 20:17:43 +0200
commit1e1ecc4c9514fbb2eb6fe273968ec9b57aa8f614 (patch)
treecab6a91076bb42aac6f037b24ea789939e3e1bb5 /tests/src/cgeo/geocaching
parente9283b50b4d3e15dffefe8a9b9eda7de5b7999e5 (diff)
downloadcgeo-1e1ecc4c9514fbb2eb6fe273968ec9b57aa8f614.zip
cgeo-1e1ecc4c9514fbb2eb6fe273968ec9b57aa8f614.tar.gz
cgeo-1e1ecc4c9514fbb2eb6fe273968ec9b57aa8f614.tar.bz2
refactoring: more assertj instead of junit assert
Diffstat (limited to 'tests/src/cgeo/geocaching')
-rw-r--r--tests/src/cgeo/geocaching/CgeoApplicationTest.java6
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java10
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java4
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java18
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java2
-rw-r--r--tests/src/cgeo/geocaching/geopoint/ViewportTest.java2
-rw-r--r--tests/src/cgeo/geocaching/twitter/TwitterTest.java12
-rw-r--r--tests/src/cgeo/geocaching/utils/TextUtilsTest.java6
8 files changed, 31 insertions, 29 deletions
diff --git a/tests/src/cgeo/geocaching/CgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
index bdde2b6..ae182d7 100644
--- a/tests/src/cgeo/geocaching/CgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
@@ -79,8 +79,8 @@ public class CgeoApplicationTest extends CGeoTestCase {
assertThat(tb.getIconUrl()).isEqualTo("http://www.geocaching.com/images/wpttypes/21.gif");
assertThat(tb.getName()).isEqualTo("blafoo's Children Music CD");
assertThat(tb.getType()).isEqualTo("Travel Bug Dog Tag");
- assertEquals(new GregorianCalendar(2009, 8 - 1, 24).getTime(), tb.getReleased());
- assertEquals("Niedersachsen, Germany", tb.getOrigin());
+ assertThat(tb.getReleased()).isEqualTo(new GregorianCalendar(2009, 8 - 1, 24).getTime());
+ assertThat(tb.getOrigin()).isEqualTo("Niedersachsen, Germany");
assertThat(tb.getOwner()).isEqualTo("blafoo");
assertThat(tb.getOwnerGuid()).isEqualTo("0564a940-8311-40ee-8e76-7e91b2cf6284");
assertThat(tb.getGoal()).isEqualTo("Kinder erfreuen.<br /><br />Make children happy.");
@@ -418,7 +418,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
*/
public static void testSearchByGeocodeSpecialties() {
final Geocache GCV2R9 = CgeoApplicationTest.testSearchByGeocode("GCV2R9");
- assertEquals("California, United States", GCV2R9.getLocation());
+ assertThat(GCV2R9.getLocation()).isEqualTo("California, United States");
final Geocache GC1ZXEZ = CgeoApplicationTest.testSearchByGeocode("GC1ZXEZ");
assertThat(GC1ZXEZ.getOwnerUserId()).isEqualTo("Ms.Marple/Mr.Stringer");
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 "&amp;"
final String page = "<span id=\"ctl00_ContentBody_lbHeading\">Schlauchen&amp;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/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&ouml;&szlig;er :-)", trackable.getDetails());
+ assertThat(trackable.getDetails()).isEqualTo("Der kleine Maulwurf in etwas gr&ouml;&szlig;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/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index a463dd8..1f97fa3 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -50,9 +50,9 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(cache.getSize()).isEqualTo(CacheSize.MICRO);
assertThat(cache.getDifficulty()).isEqualTo(1.0f);
assertThat(cache.getTerrain()).isEqualTo(5.0f);
- assertEquals("Baden-Württemberg, Germany", cache.getLocation());
- assertEquals("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel.\nA old dream of my childhood, a treasure on a lonely island.", cache.getShortDescription());
- assertEquals(new Geopoint(48.859683, 9.1874), cache.getCoords());
+ assertThat(cache.getLocation()).isEqualTo("Baden-Württemberg, Germany");
+ assertThat(cache.getShortDescription()).isEqualTo("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel.\nA old dream of my childhood, a treasure on a lonely island.");
+ assertThat(cache.getCoords()).isEqualTo(new Geopoint(48.859683, 9.1874));
return cache;
}
@@ -75,9 +75,9 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(cache.getSize()).isEqualTo(CacheSize.SMALL);
assertThat(cache.getDifficulty()).isEqualTo(1.0f);
assertThat(cache.getTerrain()).isEqualTo(4.0f);
- assertEquals("Baden-Württemberg, Germany", cache.getLocation());
- assertEquals("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel. A old dream of my childhood, a treasure on a lonely is", cache.getShortDescription());
- assertEquals(new Geopoint(48.85968, 9.18740), cache.getCoords());
+ assertThat(cache.getLocation()).isEqualTo("Baden-Württemberg, Germany");
+ assertThat(cache.getShortDescription()).isEqualTo("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel. A old dream of my childhood, a treasure on a lonely is");
+ assertThat(cache.getCoords()).isEqualTo(new Geopoint(48.85968, 9.18740));
assertThat(cache.isReliableLatLon()).isTrue();
}
@@ -174,7 +174,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(log.author).isEqualTo("Geoteufel");
assertThat(log.date).isEqualTo(parseTime("2011-09-11T07:00:00Z"));
assertThat(log.found).isEqualTo(-1);
- assertEquals("Sehr schöne Runde und wir haben wieder etwas Neues über Hockenheim gelernt. Super Tarnung.\nTFTC, Geoteufel", log.log);
+ assertThat(log.log).isEqualTo("Sehr schöne Runde und wir haben wieder etwas Neues über Hockenheim gelernt. Super Tarnung.\nTFTC, Geoteufel");
assertThat(log.isOwn()).isFalse();
assertThat(log.getDisplayText()).isEqualTo(log.log);
assertThat(log.daysSinceLog() > 700).isTrue();
@@ -209,7 +209,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(wp.getPrefix()).isEqualTo("S1");
assertThat(wp.getLookup()).isEqualTo("---");
assertThat(wp.getName()).isEqualTo("Station 1");
- assertEquals("Ein zweiter Wegpunkt, der nicht wirklich existiert sondern nur zum Testen gedacht ist.", wp.getNote());
+ assertThat(wp.getNote()).isEqualTo("Ein zweiter Wegpunkt, der nicht wirklich existiert sondern nur zum Testen gedacht ist.");
assertThat(wp.getWaypointType()).isEqualTo(WaypointType.STAGE);
assertEquals(49.317500, wp.getCoords().getLatitude(), 0.000001);
assertEquals(8.545100, wp.getCoords().getLongitude(), 0.000001);
@@ -345,7 +345,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(cache.getDifficulty()).isEqualTo(1.5f);
assertThat(cache.getTerrain()).isEqualTo(1.0f);
assertThat(cache.getDescription().startsWith("Dieses sind die Reste einer in Kornwestheim gefundenen")).isTrue();
- assertEquals(new Geopoint(48.8642167, 9.1836), cache.getCoords());
+ assertThat(cache.getCoords()).isEqualTo(new Geopoint(48.8642167, 9.1836));
assertThat(cache.isReliableLatLon()).isTrue();
assertThat(cache.getHint()).isEqualTo("Wasserleitung");
}
diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java
index 4b25247..4392705 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java
@@ -12,7 +12,7 @@ public class GeoPointFormatterTest extends AndroidTestCase {
// From issue #2624: coordinate is wrong near to a confluence point
final Geopoint point = new Geopoint(49.9999999999999, 5.0);
final String format = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECDEGREE_COMMA, point);
- assertEquals("50.000000,5.000000", format);
+ assertThat(format).isEqualTo("50.000000,5.000000");
final String formatMinute = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECMINUTE_RAW, point);
assertThat(formatMinute).isEqualTo("N 50° 00.000 E 005° 00.000");
final String formatSecond = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECSECOND, point).replaceAll(",", ".");
diff --git a/tests/src/cgeo/geocaching/geopoint/ViewportTest.java b/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
index ab59e79..e1b63fe 100644
--- a/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
@@ -66,7 +66,7 @@ public class ViewportTest extends AndroidTestCase {
try {
current = Locale.getDefault();
Locale.setDefault(Locale.FRENCH);
- assertEquals("1,0", String.format("%.2g", 1.0d)); // Control that we are in a locale with commma separator
+ assertThat(String.format("%.2g", 1.0d)).isEqualTo("1,0"); // Control that we are in a locale with comma separator
assertThat(vpRef.sqlWhere("t").toString()).isEqualTo("t.latitude >= -1.0 and t.latitude <= 3.0 and t.longitude >= -2.0 and t.longitude <= 4.0");
} finally {
Locale.setDefault(current);
diff --git a/tests/src/cgeo/geocaching/twitter/TwitterTest.java b/tests/src/cgeo/geocaching/twitter/TwitterTest.java
index 9de5e2f..a4df454 100644
--- a/tests/src/cgeo/geocaching/twitter/TwitterTest.java
+++ b/tests/src/cgeo/geocaching/twitter/TwitterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.twitter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import cgeo.geocaching.LogEntry;
import cgeo.geocaching.Trackable;
@@ -18,7 +20,7 @@ public class TwitterTest extends TestCase {
Trackable tb = new Trackable();
tb.setName("Travel bug");
tb.setGeocode("TB1234");
- assertEquals("I touched Travel bug (http://www.geocaching.com//track/details.aspx?tracker=TB1234). #cgeo #geocaching", Twitter.getStatusMessage(tb, null));
+ assertThat(Twitter.getStatusMessage(tb, null)).isEqualTo("I touched Travel bug (http://www.geocaching.com//track/details.aspx?tracker=TB1234). #cgeo #geocaching");
} finally {
TestSettings.setTrackableTwitterMessage(oldMessage);
}
@@ -31,7 +33,7 @@ public class TwitterTest extends TestCase {
Geocache cache = new Geocache();
cache.setGeocode("GC1234");
cache.setName("TwitterTest");
- assertEquals("I found TwitterTest (http://coord.info/GC1234). #cgeo #geocaching", Twitter.getStatusMessage(cache, null));
+ assertThat(Twitter.getStatusMessage(cache, null)).isEqualTo("I found TwitterTest (http://coord.info/GC1234). #cgeo #geocaching");
} finally {
TestSettings.setCacheTwitterMessage(oldMessage);
}
@@ -43,7 +45,7 @@ public class TwitterTest extends TestCase {
TestSettings.setCacheTwitterMessage("[LOG]");
Geocache cache = new Geocache();
LogEntry log = new LogEntry(0, LogType.FOUND_IT, "log text");
- assertEquals("log text #cgeo #geocaching", Twitter.getStatusMessage(cache, log));
+ assertThat(Twitter.getStatusMessage(cache, log)).isEqualTo("log text #cgeo #geocaching");
} finally {
TestSettings.setCacheTwitterMessage(oldMessage);
}
@@ -55,7 +57,7 @@ public class TwitterTest extends TestCase {
TestSettings.setTrackableTwitterMessage("[LOG]");
Trackable trackable = new Trackable();
LogEntry log = new LogEntry(0, LogType.FOUND_IT, "trackable log text");
- assertEquals("trackable log text #cgeo #geocaching", Twitter.getStatusMessage(trackable, log));
+ assertThat(Twitter.getStatusMessage(trackable, log)).isEqualTo("trackable log text #cgeo #geocaching");
} finally {
TestSettings.setTrackableTwitterMessage(oldMessage);
}
@@ -68,7 +70,7 @@ public class TwitterTest extends TestCase {
Geocache cache = new Geocache();
cache.setGeocode("GC1234");
cache.setName("TwitterTest");
- assertEquals("TwitterTest #cgeo #mytag #geocaching", Twitter.getStatusMessage(cache, null));
+ assertThat(Twitter.getStatusMessage(cache, null)).isEqualTo("TwitterTest #cgeo #mytag #geocaching");
} finally {
TestSettings.setCacheTwitterMessage(oldMessage);
}
diff --git a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
index d1dba84..29c4864 100644
--- a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
@@ -13,7 +13,7 @@ import java.util.regex.Pattern;
public class TextUtilsTest extends AndroidTestCase {
public static void testRegEx() {
final String page = MockedCache.readCachePage("GC2CJPF");
- assertEquals(GCConstantsTest.MOCK_LOGIN_NAME, TextUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???"));
+ assertThat(TextUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")).isEqualTo(GCConstantsTest.MOCK_LOGIN_NAME);
assertThat(page.contains("id=\"ctl00_hlRenew\"") || GCConstants.MEMBER_STATUS_PM.equals(TextUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???"))).isTrue();
}
@@ -23,7 +23,7 @@ public class TextUtilsTest extends AndroidTestCase {
public static void testControlCharactersCleanup() {
final Pattern patternAll = Pattern.compile("(.*)", Pattern.DOTALL);
- assertEquals("some control characters removed", TextUtils.getMatch("some" + "\u001C" + "control" + (char) 0x1D + "characters removed", patternAll, ""));
- assertEquals("newline also removed", TextUtils.getMatch("newline\nalso\nremoved", patternAll, ""));
+ assertThat(TextUtils.getMatch("some" + "\u001C" + "control" + (char) 0x1D + "characters removed", patternAll, "")).isEqualTo("some control characters removed");
+ assertThat(TextUtils.getMatch("newline\nalso\nremoved", patternAll, "")).isEqualTo("newline also removed");
}
}