aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorMichael Keppler <michael.keppler@gmx.de>2014-04-22 17:30:51 +0200
committerMichael Keppler <michael.keppler@gmx.de>2014-04-22 21:44:00 +0200
commitcc9aa8b1d2b9ec24f2c41e4a523c69edcf8c8ac0 (patch)
treefca2712f72bb2759ef4e39c0235a8a5054f27013 /tests/src
parent825b779844b280ba7c1effdd4185cc856eccdf5b (diff)
downloadcgeo-cc9aa8b1d2b9ec24f2c41e4a523c69edcf8c8ac0.zip
cgeo-cc9aa8b1d2b9ec24f2c41e4a523c69edcf8c8ac0.tar.gz
cgeo-cc9aa8b1d2b9ec24f2c41e4a523c69edcf8c8ac0.tar.bz2
#2414 convert junit statements to assertj
This conversion is not complete, but the remaining statements are hard to catch with regular expressions automatically.
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/cgeo/geocaching/CgeoApplicationTest.java129
-rw-r--r--tests/src/cgeo/geocaching/DataStoreTest.java49
-rw-r--r--tests/src/cgeo/geocaching/DestinationTest.java12
-rw-r--r--tests/src/cgeo/geocaching/GeocacheTest.java56
-rw-r--r--tests/src/cgeo/geocaching/GpxFileListActivityTest.java6
-rw-r--r--tests/src/cgeo/geocaching/ImageUtilsTest.java8
-rw-r--r--tests/src/cgeo/geocaching/LazyInitialilzedListTest.java30
-rw-r--r--tests/src/cgeo/geocaching/ParametersTest.java16
-rw-r--r--tests/src/cgeo/geocaching/PersonalNoteTest.java18
-rw-r--r--tests/src/cgeo/geocaching/SearchResultTest.java34
-rw-r--r--tests/src/cgeo/geocaching/SettingsTest.java8
-rw-r--r--tests/src/cgeo/geocaching/StaticMapsProviderTest.java16
-rw-r--r--tests/src/cgeo/geocaching/TrackableTest.java14
-rw-r--r--tests/src/cgeo/geocaching/WaypointTest.java22
-rw-r--r--tests/src/cgeo/geocaching/activity/ProgressTest.java12
-rw-r--r--tests/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactoryTest.java4
-rw-r--r--tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java94
-rw-r--r--tests/src/cgeo/geocaching/connector/ec/ECApiTest.java5
-rw-r--r--tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java14
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java24
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java40
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java6
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCParserTest.java66
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java106
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java110
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java11
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java8
-rw-r--r--tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java8
-rw-r--r--tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java28
-rw-r--r--tests/src/cgeo/geocaching/connector/ox/OXConnectorTest.java9
-rw-r--r--tests/src/cgeo/geocaching/connector/trackable/GeokretyConnectorTest.java17
-rw-r--r--tests/src/cgeo/geocaching/connector/trackable/GeokretyParserTest.java12
-rw-r--r--tests/src/cgeo/geocaching/connector/trackable/TravelBugConnectorTest.java40
-rw-r--r--tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java26
-rw-r--r--tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java28
-rw-r--r--tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java36
-rw-r--r--tests/src/cgeo/geocaching/enumerations/LogTypeTest.java20
-rw-r--r--tests/src/cgeo/geocaching/enumerations/LogTypeTrackableTest.java4
-rw-r--r--tests/src/cgeo/geocaching/enumerations/WaypointTypeTest.java4
-rw-r--r--tests/src/cgeo/geocaching/export/ExportTest.java4
-rw-r--r--tests/src/cgeo/geocaching/export/GpxSerializerTest.java19
-rw-r--r--tests/src/cgeo/geocaching/files/GPXImporterTest.java72
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java236
-rw-r--r--tests/src/cgeo/geocaching/files/LocParserTest.java48
-rw-r--r--tests/src/cgeo/geocaching/files/LocalStorageTest.java12
-rw-r--r--tests/src/cgeo/geocaching/files/ProgressInputStreamTest.java8
-rw-r--r--tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java14
-rw-r--r--tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java8
-rw-r--r--tests/src/cgeo/geocaching/filter/SizeFilterTest.java12
-rw-r--r--tests/src/cgeo/geocaching/filter/StateArchivedFilterTest.java6
-rw-r--r--tests/src/cgeo/geocaching/filter/StateDisabledFilterTest.java6
-rw-r--r--tests/src/cgeo/geocaching/filter/StateFoundFilterTest.java6
-rw-r--r--tests/src/cgeo/geocaching/filter/StateNonPremiumFilterTest.java6
-rw-r--r--tests/src/cgeo/geocaching/filter/StatePremiumFilterTest.java6
-rw-r--r--tests/src/cgeo/geocaching/filter/StateStoredFilterTest.java6
-rw-r--r--tests/src/cgeo/geocaching/filter/TerrainFilterTest.java8
-rw-r--r--tests/src/cgeo/geocaching/filter/TypeFilterTest.java16
-rw-r--r--tests/src/cgeo/geocaching/geopoint/DistanceParserTest.java20
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java4
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java26
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeopointTest.java101
-rw-r--r--tests/src/cgeo/geocaching/geopoint/UnitsTest.java6
-rw-r--r--tests/src/cgeo/geocaching/geopoint/ViewportTest.java48
-rw-r--r--tests/src/cgeo/geocaching/list/PseudoListTest.java5
-rw-r--r--tests/src/cgeo/geocaching/list/StoredListTest.java10
-rw-r--r--tests/src/cgeo/geocaching/network/NetworkTest.java7
-rw-r--r--tests/src/cgeo/geocaching/network/OAuthTest.java8
-rw-r--r--tests/src/cgeo/geocaching/network/ParametersTest.java16
-rw-r--r--tests/src/cgeo/geocaching/sensors/SensorsTest.java6
-rw-r--r--tests/src/cgeo/geocaching/sorting/NameComparatorTest.java10
-rw-r--r--tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java12
-rw-r--r--tests/src/cgeo/geocaching/test/EmulatorStateTest.java4
-rw-r--r--tests/src/cgeo/geocaching/test/RegExPerformanceTest.java4
-rw-r--r--tests/src/cgeo/geocaching/test/WhitespaceTest.java18
-rw-r--r--tests/src/cgeo/geocaching/test/mock/MockedCache.java6
-rw-r--r--tests/src/cgeo/geocaching/ui/FormatterTest.java6
-rw-r--r--tests/src/cgeo/geocaching/utils/AngleUtilsTest.java16
-rw-r--r--tests/src/cgeo/geocaching/utils/CryptUtilsTest.java26
-rw-r--r--tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java10
-rw-r--r--tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java14
-rw-r--r--tests/src/cgeo/geocaching/utils/LeastRecentlyUsedMapTest.java42
-rw-r--r--tests/src/cgeo/geocaching/utils/LeastRecentlyUsedSetTest.java32
-rw-r--r--tests/src/cgeo/geocaching/utils/LogTemplateProviderTest.java4
-rw-r--r--tests/src/cgeo/geocaching/utils/MiscUtilsTest.java6
-rw-r--r--tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java9
-rw-r--r--tests/src/cgeo/geocaching/utils/TextUtilsTest.java6
-rw-r--r--tests/src/cgeo/geocaching/utils/XmlUtilsTest.java4
-rw-r--r--tests/src/cgeo/test/Compare.java65
88 files changed, 1166 insertions, 1028 deletions
diff --git a/tests/src/cgeo/geocaching/CgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
index 91971ca..3e63481 100644
--- a/tests/src/cgeo/geocaching/CgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.gc.GCLogin;
@@ -26,7 +28,6 @@ import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.Log;
import cgeo.test.Compare;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import android.test.suitebuilder.annotation.MediumTest;
@@ -34,8 +35,6 @@ import android.test.suitebuilder.annotation.SmallTest;
import java.util.GregorianCalendar;
-import junit.framework.Assert;
-
/**
* The c:geo application test. It can be used for tests that require an
* application and/or context.
@@ -63,7 +62,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
@MediumTest
public static void testSearchTrackableNotExisting() {
final Trackable tb = GCParser.searchTrackable("123456", null, null);
- assertNull(tb);
+ assertThat(tb).isNull();
}
/**
@@ -72,37 +71,37 @@ public class CgeoApplicationTest extends CGeoTestCase {
@MediumTest
public static void testSearchTrackable() {
final Trackable tb = GCParser.searchTrackable("TB2J1VZ", null, null);
- assertNotNull(tb);
+ assertThat(tb).isNotNull();
assert (tb != null); // eclipse bug
// fix data
- assertEquals("aefffb86-099f-444f-b132-605436163aa8", tb.getGuid());
- assertEquals("TB2J1VZ", tb.getGeocode());
- assertEquals("http://www.geocaching.com/images/wpttypes/21.gif", tb.getIconUrl());
- assertEquals("blafoo's Children Music CD", tb.getName());
- assertEquals("Travel Bug Dog Tag", tb.getType());
+ assertThat(tb.getGuid()).isEqualTo("aefffb86-099f-444f-b132-605436163aa8");
+ assertThat(tb.getGeocode()).isEqualTo("TB2J1VZ");
+ 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());
- assertEquals("blafoo", tb.getOwner());
- assertEquals("0564a940-8311-40ee-8e76-7e91b2cf6284", tb.getOwnerGuid());
- assertEquals("Kinder erfreuen.<br /><br />Make children happy.", tb.getGoal());
- assertTrue(tb.getDetails().startsWith("Auf der CD sind"));
- assertEquals("http://imgcdn.geocaching.com/track/display/38382780-87a7-4393-8393-78841678ee8c.jpg", tb.getImage());
+ 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.");
+ assertThat(tb.getDetails()).startsWith("Auf der CD sind");
+ assertThat(tb.getImage()).isEqualTo("http://imgcdn.geocaching.com/track/display/38382780-87a7-4393-8393-78841678ee8c.jpg");
// Following data can change over time
- assertTrue(tb.getDistance() >= 10617.8f);
- assertTrue(tb.getLogs().size() >= 10);
- assertTrue(Trackable.SPOTTED_CACHE == tb.getSpottedType() || Trackable.SPOTTED_USER == tb.getSpottedType() || Trackable.SPOTTED_UNKNOWN == tb.getSpottedType());
- // no assumption possible: assertEquals("faa2d47d-19ea-422f-bec8-318fc82c8063", tb.getSpottedGuid());
- // no assumption possible: assertEquals("Nice place for a break cache", tb.getSpottedName());
+ assertThat(tb.getDistance()).isGreaterThanOrEqualTo(10617.8f);
+ assertThat(tb.getLogs().size()).isGreaterThanOrEqualTo(10);
+ assertThat(Trackable.SPOTTED_CACHE == tb.getSpottedType() || Trackable.SPOTTED_USER == tb.getSpottedType() || Trackable.SPOTTED_UNKNOWN == tb.getSpottedType()).isTrue();
+ // no assumption possible: assertThat(tb.getSpottedGuid()).isEqualTo("faa2d47d-19ea-422f-bec8-318fc82c8063");
+ // no assumption possible: assertThat(tb.getSpottedName()).isEqualTo("Nice place for a break cache");
// we can't check specifics in the log entries since they change, but we can verify data was parsed
for (LogEntry log : tb.getLogs()) {
- assertTrue(log.date > 0);
- assertTrue(StringUtils.isNotEmpty(log.author));
+ assertThat(log.date).isGreaterThan(0);
+ assertThat(log.author).isNotEmpty();
if (log.type == LogType.PLACED_IT || log.type == LogType.RETRIEVED_IT) {
- assertTrue(StringUtils.isNotEmpty(log.cacheName));
- assertTrue(StringUtils.isNotEmpty(log.cacheGuid));
+ assertThat(log.cacheName).isNotEmpty();
+ assertThat(log.cacheGuid).isNotEmpty();
} else {
- assertTrue(log.type != LogType.UNKNOWN);
+ assertThat(log.type).isNotEqualTo(LogType.UNKNOWN);
}
}
}
@@ -113,13 +112,13 @@ public class CgeoApplicationTest extends CGeoTestCase {
@MediumTest
public static Geocache testSearchByGeocode(final String geocode) {
final SearchResult search = Geocache.searchByGeocode(geocode, null, 0, true, null);
- assertNotNull(search);
+ assertThat(search).isNotNull();
if (Settings.isGCPremiumMember() || search.getError() == null) {
- assertEquals(1, search.getGeocodes().size());
- assertTrue(search.getGeocodes().contains(geocode));
+ assertThat(search.getGeocodes()).hasSize(1);
+ assertThat(search.getGeocodes()).contains(geocode);
return DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
}
- assertEquals(0, search.getGeocodes().size());
+ assertThat(search.getGeocodes()).isEmpty();
return null;
}
@@ -129,8 +128,8 @@ public class CgeoApplicationTest extends CGeoTestCase {
@MediumTest
public static void testSearchByGeocodeNotExisting() {
final SearchResult search = Geocache.searchByGeocode("GC123456", null, 0, true, null);
- assertNotNull(search);
- assertEquals(StatusCode.COMMUNICATION_ERROR, search.getError());
+ assertThat(search).isNotNull();
+ assertThat(search.getError()).isEqualTo(StatusCode.COMMUNICATION_ERROR);
}
/**
@@ -166,14 +165,14 @@ public class CgeoApplicationTest extends CGeoTestCase {
deleteCacheFromDBAndLogout(cache.getGeocode());
SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null);
- assertNotNull(search);
- assertEquals(1, search.getGeocodes().size());
- assertTrue(search.getGeocodes().contains(cache.getGeocode()));
+ assertThat(search).isNotNull();
+ assertThat(search.getGeocodes()).hasSize(1);
+ assertThat(search.getGeocodes().contains(cache.getGeocode())).isTrue();
final Geocache searchedCache = search.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
// coords must be null if the user is not logged in
- assertNotNull(searchedCache);
+ assertThat(searchedCache).isNotNull();
assert (searchedCache != null); // eclipse bug
- assertNull(searchedCache.getCoords());
+ assertThat(searchedCache.getCoords()).isNull();
// premium cache. Not visible to guests
cache = new GC2JVEH();
@@ -181,8 +180,8 @@ public class CgeoApplicationTest extends CGeoTestCase {
deleteCacheFromDBAndLogout(cache.getGeocode());
search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null);
- assertNotNull(search);
- assertEquals(0, search.getGeocodes().size());
+ assertThat(search).isNotNull();
+ assertThat(search.getGeocodes()).isEmpty();
}
});
}
@@ -201,8 +200,8 @@ public class CgeoApplicationTest extends CGeoTestCase {
deleteCacheFromDBAndLogout(cache.getGeocode());
final SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null);
- assertNotNull(search);
- assertEquals(0, search.getGeocodes().size());
+ assertThat(search).isNotNull();
+ assertThat(search.getGeocodes()).isEmpty();
}
});
}
@@ -240,9 +239,9 @@ public class CgeoApplicationTest extends CGeoTestCase {
@Override
public void run() {
final SearchResult search = GCParser.searchByCoords(new Geopoint("N 50° 06.654 E 008° 39.777"), CacheType.MYSTERY, false, null);
- assertNotNull(search);
- assertTrue(20 <= search.getGeocodes().size());
- assertTrue(search.getGeocodes().contains("GC1HBMY"));
+ assertThat(search).isNotNull();
+ assertThat(20 <= search.getGeocodes().size()).isTrue();
+ assertThat(search.getGeocodes().contains("GC1HBMY")).isTrue();
}
});
}
@@ -257,9 +256,9 @@ public class CgeoApplicationTest extends CGeoTestCase {
@Override
public void run() {
final SearchResult search = GCParser.searchByOwner("blafoo", CacheType.MYSTERY, false, null);
- assertNotNull(search);
- assertEquals(3, search.getGeocodes().size());
- assertTrue(search.getGeocodes().contains("GC36RT6"));
+ assertThat(search).isNotNull();
+ assertThat(search.getGeocodes()).hasSize(3);
+ assertThat(search.getGeocodes().contains("GC36RT6")).isTrue();
}
});
}
@@ -274,9 +273,9 @@ public class CgeoApplicationTest extends CGeoTestCase {
@Override
public void run() {
final SearchResult search = GCParser.searchByUsername("blafoo", CacheType.WEBCAM, false, null);
- assertNotNull(search);
- assertEquals(4, search.getTotalCountGC());
- assertTrue(search.getGeocodes().contains("GCP0A9"));
+ assertThat(search).isNotNull();
+ assertThat(search.getTotalCountGC()).isEqualTo(4);
+ assertThat(search.getGeocodes().contains("GCP0A9")).isTrue();
}
});
}
@@ -308,24 +307,24 @@ public class CgeoApplicationTest extends CGeoTestCase {
// check coords for DETAILED
Settings.setLiveMapStrategy(Strategy.DETAILED);
SearchResult search = ConnectorFactory.searchByViewport(viewport, tokens);
- assertNotNull(search);
- assertTrue(search.getGeocodes().contains(mockedCache.getGeocode()));
+ assertThat(search).isNotNull();
+ assertThat(search.getGeocodes().contains(mockedCache.getGeocode())).isTrue();
Geocache parsedCache = DataStore.loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
- assertEquals(Settings.isGCPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
- assertEquals(Settings.isGCPremiumMember(), parsedCache.isReliableLatLon());
+ assertThat(mockedCache.getCoords().equals(parsedCache.getCoords())).isEqualTo(Settings.isGCPremiumMember());
+ assertThat(parsedCache.isReliableLatLon()).isEqualTo(Settings.isGCPremiumMember());
// check update after switch strategy to FAST
Settings.setLiveMapStrategy(Strategy.FAST);
Tile.cache.removeFromTileCache(mockedCache);
search = ConnectorFactory.searchByViewport(viewport, tokens);
- assertNotNull(search);
- assertTrue(search.getGeocodes().contains(mockedCache.getGeocode()));
+ assertThat(search).isNotNull();
+ assertThat(search.getGeocodes().contains(mockedCache.getGeocode())).isTrue();
parsedCache = DataStore.loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
- assertEquals(Settings.isGCPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
- assertEquals(Settings.isGCPremiumMember(), parsedCache.isReliableLatLon());
+ assertThat(mockedCache.getCoords().equals(parsedCache.getCoords())).isEqualTo(Settings.isGCPremiumMember());
+ assertThat(parsedCache.isReliableLatLon()).isEqualTo(Settings.isGCPremiumMember());
} finally {
// restore user settings
@@ -360,15 +359,15 @@ public class CgeoApplicationTest extends CGeoTestCase {
Viewport viewport = new Viewport(cache, 0.003, 0.003);
SearchResult search = ConnectorFactory.searchByViewport(viewport, INVALID_TOKEN);
- assertNotNull(search);
- assertTrue(search.getGeocodes().contains(cache.getGeocode()));
+ assertThat(search).isNotNull();
+ assertThat(search.getGeocodes().contains(cache.getGeocode())).isTrue();
// coords differ
final Geocache cacheFromViewport = DataStore.loadCache(cache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
Log.d("cgeoApplicationTest.testSearchByViewportNotLoggedIn: Coords expected = " + cache.getCoords());
Log.d("cgeoApplicationTest.testSearchByViewportNotLoggedIn: Coords actual = " + cacheFromViewport.getCoords());
- assertFalse(cache.getCoords().distanceTo(cacheFromViewport.getCoords()) <= 1e-3);
+ assertThat(cache.getCoords().distanceTo(cacheFromViewport.getCoords()) <= 1e-3).isFalse();
// depending on the chosen strategy the coords can be reliable or not
- assertEquals(testStrategy == Strategy.DETAILED, cacheFromViewport.isReliableLatLon());
+ assertThat(cacheFromViewport.isReliableLatLon()).isEqualTo(testStrategy == Strategy.DETAILED);
// premium cache
cache = new GC2JVEH();
@@ -377,9 +376,9 @@ public class CgeoApplicationTest extends CGeoTestCase {
viewport = new Viewport(cache, 0.003, 0.003);
search = ConnectorFactory.searchByViewport(viewport, INVALID_TOKEN);
- assertNotNull(search);
+ assertThat(search).isNotNull();
// In the meantime, premium-member caches are also shown on map when not logged in
- assertTrue(search.getGeocodes().contains(cache.getGeocode()));
+ assertThat(search.getGeocodes().contains(cache.getGeocode())).isTrue();
} finally {
Settings.setLiveMapStrategy(strategy);
@@ -416,10 +415,10 @@ public class CgeoApplicationTest extends CGeoTestCase {
*/
public static void testSearchByGeocodeSpecialties() {
final Geocache GCV2R9 = CgeoApplicationTest.testSearchByGeocode("GCV2R9");
- Assert.assertEquals("California, United States", GCV2R9.getLocation());
+ assertEquals("California, United States", GCV2R9.getLocation());
final Geocache GC1ZXEZ = CgeoApplicationTest.testSearchByGeocode("GC1ZXEZ");
- Assert.assertEquals("Ms.Marple/Mr.Stringer", GC1ZXEZ.getOwnerUserId());
+ assertThat(GC1ZXEZ.getOwnerUserId()).isEqualTo("Ms.Marple/Mr.Stringer");
}
/** Remove cache from DB and cache to ensure that the cache is not loaded from the database */
diff --git a/tests/src/cgeo/geocaching/DataStoreTest.java b/tests/src/cgeo/geocaching/DataStoreTest.java
index 7dc3016..93d76a1 100644
--- a/tests/src/cgeo/geocaching/DataStoreTest.java
+++ b/tests/src/cgeo/geocaching/DataStoreTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.connector.gc.GCConnector;
import cgeo.geocaching.connector.gc.Tile;
@@ -31,16 +33,16 @@ public class DataStoreTest extends CGeoTestCase {
cache1.setGeocode("Cache 1");
final Geocache cache2 = new Geocache();
cache2.setGeocode("Cache 2");
- assertNotNull(cache2);
+ assertThat(cache2).isNotNull();
try {
// create lists
listId1 = DataStore.createList("DataStore Test");
- assertTrue(listId1 > StoredList.STANDARD_LIST_ID);
+ assertThat(listId1 > StoredList.STANDARD_LIST_ID).isTrue();
listId2 = DataStore.createList("DataStoreTest");
- assertTrue(listId2 > StoredList.STANDARD_LIST_ID);
- assertTrue(DataStore.getLists().size() >= 2);
+ assertThat(listId2 > StoredList.STANDARD_LIST_ID).isTrue();
+ assertThat(DataStore.getLists().size() >= 2).isTrue();
cache1.setDetailed(true);
cache1.setListId(listId1);
@@ -50,21 +52,21 @@ public class DataStoreTest extends CGeoTestCase {
// save caches to DB (cache1=listId1, cache2=listId1)
DataStore.saveCache(cache1, LoadFlags.SAVE_ALL);
DataStore.saveCache(cache2, LoadFlags.SAVE_ALL);
- assertTrue(DataStore.getAllCachesCount() >= 2);
+ assertThat(DataStore.getAllCachesCount() >= 2).isTrue();
// rename list (cache1=listId1, cache2=listId1)
assertEquals(1, DataStore.renameList(listId1, "DataStore Test (renamed)"));
// get list
final StoredList list1 = DataStore.getList(listId1);
- assertEquals("DataStore Test (renamed)", list1.title);
+ assertThat(list1.title).isEqualTo("DataStore Test (renamed)");
// move to list (cache1=listId2, cache2=listId2)
DataStore.moveToList(Collections.singletonList(cache1), listId2);
assertEquals(1, DataStore.getAllStoredCachesCount(CacheType.ALL, listId2));
// remove list (cache1=listId2, cache2=listId2)
- assertTrue(DataStore.removeList(listId1));
+ assertThat(DataStore.removeList(listId1)).isTrue();
// mark dropped (cache1=1, cache2=0)
DataStore.markDropped(Collections.singletonList(cache2));
@@ -121,8 +123,8 @@ public class DataStoreTest extends CGeoTestCase {
try {
DataStore.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
final Geocache loadedCache = DataStore.loadCache(GEOCODE_CACHE, LoadFlags.LOAD_ALL_DB_ONLY);
- assertNotNull("Cache was not saved!", loadedCache);
- assertEquals(1, loadedCache.getInventory().size());
+ assertThat(loadedCache).overridingErrorMessage("Cache was not saved.").isNotNull();
+ assertThat(loadedCache.getInventory()).hasSize(1);
} finally {
DataStore.removeCache(GEOCODE_CACHE, LoadFlags.REMOVE_ALL);
}
@@ -134,7 +136,7 @@ public class DataStoreTest extends CGeoTestCase {
final String GEOCODE_CACHE = "TEST";
final String upperCase = GEOCODE_CACHE;
final String lowerCase = StringUtils.lowerCase(upperCase);
- assertFalse(upperCase.equals(lowerCase));
+ assertThat(upperCase.equals(lowerCase)).isFalse();
// create cache and trackable
final Geocache cache = new Geocache();
@@ -143,14 +145,14 @@ public class DataStoreTest extends CGeoTestCase {
try {
final Geocache oldCache = DataStore.loadCache(upperCase, LoadFlags.LOAD_ALL_DB_ONLY);
- assertNull("Database contained old cache!", oldCache);
+ assertThat(oldCache).as("Old cache").isNull();
DataStore.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
final Geocache cacheWithOriginalCode = DataStore.loadCache(upperCase, LoadFlags.LOAD_ALL_DB_ONLY);
- assertNotNull("Cache was not saved correctly!", cacheWithOriginalCode);
+ assertThat(cacheWithOriginalCode).overridingErrorMessage("Cache was not saved correctly!").isNotNull();
final Geocache cacheLowerCase = DataStore.loadCache(lowerCase, LoadFlags.LOAD_ALL_DB_ONLY);
- assertNotNull("Could not find cache by case insensitive geocode", cacheLowerCase);
+ assertThat(cacheLowerCase).overridingErrorMessage("Could not find cache by case insensitive geocode").isNotNull();
} finally {
DataStore.removeCache(upperCase, LoadFlags.REMOVE_ALL);
@@ -159,11 +161,10 @@ public class DataStoreTest extends CGeoTestCase {
// Loading logs for an empty geocode should return an empty list, not null!
public static void testLoadLogsFromEmptyGeocode() {
-
final List<LogEntry> logs = DataStore.loadLogs("");
- assertNotNull("Logs must not be null", logs);
- assertEquals("Logs from empty geocode must be empty", 0, logs.size());
+ assertThat(logs).as("Logs for empty geocode").isNotNull();
+ assertThat(logs).as("Logs for empty geocode").isEmpty();
}
public static void testLoadCacheHistory() {
@@ -171,7 +172,7 @@ public class DataStoreTest extends CGeoTestCase {
int allCaches = 0;
for (CacheType cacheType : CacheType.values()) {
SearchResult historyOfType = DataStore.getHistoryOfCaches(false, cacheType);
- assertNotNull(historyOfType);
+ assertThat(historyOfType).isNotNull();
if (cacheType != CacheType.ALL) {
sumCaches += historyOfType.getCount();
} else {
@@ -179,9 +180,9 @@ public class DataStoreTest extends CGeoTestCase {
}
}
// check that sum of types equals 'all'
- assertEquals(sumCaches, allCaches);
+ assertThat(allCaches).isEqualTo(sumCaches);
// check that two different routines behave the same
- assertEquals(DataStore.getAllHistoryCachesCount(), sumCaches);
+ assertThat(sumCaches).isEqualTo(DataStore.getAllHistoryCachesCount());
}
public static void testCachedMissing() {
@@ -219,11 +220,11 @@ public class DataStoreTest extends CGeoTestCase {
Set<String> filteredGeoCodes = DataStore.getCachedMissingFromSearch(search, tiles, GCConnector.getInstance(), Tile.ZOOMLEVEL_MIN_PERSONALIZED - 1);
- assertTrue(filteredGeoCodes.contains(inTileLowZoom.getGeocode()));
- assertFalse(filteredGeoCodes.contains(inTileHighZoom.getGeocode()));
- assertFalse(filteredGeoCodes.contains(otherConnector.getGeocode()));
- assertFalse(filteredGeoCodes.contains(outTile.getGeocode()));
- assertFalse(filteredGeoCodes.contains(main.getGeocode()));
+ assertThat(filteredGeoCodes.contains(inTileLowZoom.getGeocode())).isTrue();
+ assertThat(filteredGeoCodes.contains(inTileHighZoom.getGeocode())).isFalse();
+ assertThat(filteredGeoCodes.contains(otherConnector.getGeocode())).isFalse();
+ assertThat(filteredGeoCodes.contains(outTile.getGeocode())).isFalse();
+ assertThat(filteredGeoCodes.contains(main.getGeocode())).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/DestinationTest.java b/tests/src/cgeo/geocaching/DestinationTest.java
index 26caacd..00249c4 100644
--- a/tests/src/cgeo/geocaching/DestinationTest.java
+++ b/tests/src/cgeo/geocaching/DestinationTest.java
@@ -1,11 +1,11 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.geopoint.Geopoint;
import android.test.AndroidTestCase;
-import junit.framework.Assert;
-
public class DestinationTest extends AndroidTestCase {
private Destination dest = null;
@@ -17,9 +17,9 @@ public class DestinationTest extends AndroidTestCase {
}
public void testSomething() {
- Assert.assertEquals(1, dest.getId());
- Assert.assertEquals(10000, dest.getDate());
- Assert.assertEquals(52.5, dest.getCoords().getLatitude());
- Assert.assertEquals(9.33, dest.getCoords().getLongitude());
+ assertThat(dest.getId()).isEqualTo(1);
+ assertThat(dest.getDate()).isEqualTo(10000);
+ assertThat(dest.getCoords().getLatitude()).isEqualTo(52.5);
+ assertThat(dest.getCoords().getLongitude()).isEqualTo(9.33);
}
} \ No newline at end of file
diff --git a/tests/src/cgeo/geocaching/GeocacheTest.java b/tests/src/cgeo/geocaching/GeocacheTest.java
index 020cf6c..b3ec6be 100644
--- a/tests/src/cgeo/geocaching/GeocacheTest.java
+++ b/tests/src/cgeo/geocaching/GeocacheTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
@@ -25,11 +27,11 @@ public class GeocacheTest extends CGeoTestCase {
public static void testCanBeAddedToCalendar() {
final Date today = new Date();
final Geocache cacheToday = new MockedEventCache(today);
- assertTrue(cacheToday.canBeAddedToCalendar());
+ assertThat(cacheToday.canBeAddedToCalendar()).isTrue();
final Date yesterday = new Date(today.getTime() - 86400 * 1000);
final MockedEventCache cacheYesterday = new MockedEventCache(yesterday);
- assertFalse(cacheYesterday.canBeAddedToCalendar());
+ assertThat(cacheYesterday.canBeAddedToCalendar()).isFalse();
}
public static void testEquality() {
@@ -37,22 +39,22 @@ public class GeocacheTest extends CGeoTestCase {
final Geocache two = new Geocache();
// identity
- assertTrue(one.equals(one));
+ assertThat(one.equals(one)).isTrue();
// different objects without geocode shall not be equal
- assertFalse(one.equals(two));
+ assertThat(one.equals(two)).isFalse();
one.setGeocode("geocode");
two.setGeocode("geocode");
// different objects with same geocode shall be equal
- assertTrue(one.equals(two));
+ assertThat(one.equals(two)).isTrue();
}
public static void testGeocodeUppercase() {
final Geocache cache = new Geocache();
cache.setGeocode("gc1234");
- assertEquals("GC1234", cache.getGeocode());
+ assertThat(cache.getGeocode()).isEqualTo("GC1234");
}
public final void testUpdateWaypointFromNote() {
@@ -78,12 +80,12 @@ public class GeocacheTest extends CGeoTestCase {
cache.setPersonalNote(note);
cache.parseWaypointsFromNote();
final List<Waypoint> waypoints = cache.getWaypoints();
- assertNotNull(waypoints);
- assertEquals(expectedWaypoints, waypoints.size());
+ assertThat(waypoints).isNotNull();
+ assertThat(waypoints).hasSize(expectedWaypoints);
final Waypoint waypoint = waypoints.get(0);
- assertEquals(new Geopoint("N51 13.888 E007 03.444"), waypoint.getCoords());
- // assertEquals("Test", waypoint.getNote());
- assertEquals(CgeoApplication.getInstance().getString(R.string.cache_personal_note) + " 1", waypoint.getName());
+ assertThat(waypoint.getCoords()).isEqualTo(new Geopoint("N51 13.888 E007 03.444"));
+ // assertThat(waypoint.getNote()).isEqualTo("Test");
+ assertThat(waypoint.getName()).isEqualTo(CgeoApplication.getInstance().getString(R.string.cache_personal_note) + " 1");
cache.store(StoredList.TEMPORARY_LIST_ID, null);
}
removeCacheCompletely(geocode);
@@ -117,8 +119,8 @@ public class GeocacheTest extends CGeoTestCase {
download.gatherMissingFrom(stored);
- assertTrue("Detailed not merged correctly", download.isDetailed());
- assertFalse("Disabled not merged correctly", download.isDisabled());
+ assertThat(download.isDetailed()).as("merged detailed").isTrue();
+ assertThat(download.isDisabled()).as("merged disabled").isFalse();
assertEquals("Type not merged correctly", CacheType.MULTI, download.getType());
assertEquals("Longitude not merged correctly", 9.0, download.getCoords().getLongitude(), 0.1);
assertEquals("Latitude not merged correctly", 41.0, download.getCoords().getLatitude(), 0.1);
@@ -144,8 +146,8 @@ public class GeocacheTest extends CGeoTestCase {
livemap.gatherMissingFrom(stored);
- assertTrue("Detailed not merged correctly", livemap.isDetailed());
- assertTrue("Disabled not merged correctly", livemap.isDisabled());
+ assertThat(livemap.isDetailed()).as("merged detailed").isTrue();
+ assertThat(livemap.isDisabled()).as("merged disabled").isTrue();
assertEquals("Type not merged correctly", CacheType.TRADITIONAL, livemap.getType());
assertEquals("Longitude not merged correctly", 8.0, livemap.getCoords().getLongitude(), 0.1);
assertEquals("Latitude not merged correctly", 40.0, livemap.getCoords().getLatitude(), 0.1);
@@ -208,7 +210,7 @@ public class GeocacheTest extends CGeoTestCase {
assertEquals("Type not merged correctly", CacheType.MULTI, popup.getType());
assertEquals("Longitude not merged correctly", 8.0, popup.getCoords().getLongitude(), 0.1);
assertEquals("Latitude not merged correctly", 40.0, popup.getCoords().getLatitude(), 0.1);
- assertTrue("Found not merged correctly", popup.isFound());
+ assertThat(popup.isFound()).overridingErrorMessage("Found not merged correctly").isTrue();
assertEquals("Zoomlevel not merged correctly", 12, popup.getCoordZoomLevel());
}
@@ -231,7 +233,7 @@ public class GeocacheTest extends CGeoTestCase {
public static void testNameForSorting() {
Geocache cache = new Geocache();
cache.setName("GR8 01-01");
- assertEquals("GR000008 000001-000001", cache.getNameForSorting());
+ assertThat(cache.getNameForSorting()).isEqualTo("GR000008 000001-000001");
}
public static void testGuessEventTime() {
@@ -255,7 +257,7 @@ public class GeocacheTest extends CGeoTestCase {
cache.setType(CacheType.EVENT);
cache.setDescription(StringUtils.EMPTY);
cache.setShortDescription("text 14:20 text");
- assertEquals(String.valueOf(14 * 60 + 20), cache.guessEventTimeMinutes());
+ assertThat(cache.guessEventTimeMinutes()).isEqualTo(String.valueOf(14 * 60 + 20));
}
private static void assertTime(final String description, final int hours, final int minutes) {
@@ -263,45 +265,45 @@ public class GeocacheTest extends CGeoTestCase {
cache.setDescription(description);
cache.setType(CacheType.EVENT);
final int minutesAfterMidnight = hours * 60 + minutes;
- assertEquals(String.valueOf(minutesAfterMidnight), cache.guessEventTimeMinutes());
+ assertThat(cache.guessEventTimeMinutes()).isEqualTo(String.valueOf(minutesAfterMidnight));
}
private static void assertNoTime(final String description) {
final Geocache cache = new Geocache();
cache.setDescription(description);
cache.setType(CacheType.EVENT);
- assertNull(cache.guessEventTimeMinutes());
+ assertThat(cache.guessEventTimeMinutes()).isNull();
}
public static void testGetPossibleLogTypes() throws Exception {
Geocache gcCache = new Geocache();
gcCache.setGeocode("GC123");
gcCache.setType(CacheType.WEBCAM);
- assertTrue(gcCache.getPossibleLogTypes().contains(LogType.WEBCAM_PHOTO_TAKEN));
- assertTrue("GC caches can have maintenance logs", gcCache.getPossibleLogTypes().contains(LogType.NEEDS_MAINTENANCE));
+ assertThat(gcCache.getPossibleLogTypes()).as("possible GC cache log types").contains(LogType.WEBCAM_PHOTO_TAKEN);
+ assertThat(gcCache.getPossibleLogTypes()).as("possible GC cache log types").contains(LogType.NEEDS_MAINTENANCE);
Geocache ocCache = new Geocache();
ocCache.setGeocode("OC1234");
ocCache.setType(CacheType.TRADITIONAL);
- assertFalse("A traditional cache cannot have a webcam log", ocCache.getPossibleLogTypes().contains(LogType.WEBCAM_PHOTO_TAKEN));
- assertFalse("OC caches have no maintenance log type", ocCache.getPossibleLogTypes().contains(LogType.NEEDS_MAINTENANCE));
+ assertThat(ocCache.getPossibleLogTypes()).as("traditional cache possible log types").doesNotContain(LogType.WEBCAM_PHOTO_TAKEN);
+ assertThat(ocCache.getPossibleLogTypes()).as("OC cache possible log types").doesNotContain(LogType.NEEDS_MAINTENANCE);
}
public static void testLogTypeEventPast() throws Exception {
Calendar today = Calendar.getInstance();
today.add(Calendar.DAY_OF_MONTH, -1);
- assertEquals(LogType.ATTENDED, createEventCache(today).getDefaultLogType());
+ assertThat(createEventCache(today).getDefaultLogType()).isEqualTo(LogType.ATTENDED);
}
public static void testLogTypeEventToday() throws Exception {
Calendar today = Calendar.getInstance();
- assertEquals(LogType.ATTENDED, createEventCache(today).getDefaultLogType());
+ assertThat(createEventCache(today).getDefaultLogType()).isEqualTo(LogType.ATTENDED);
}
public static void testLogTypeEventFuture() throws Exception {
Calendar today = Calendar.getInstance();
today.add(Calendar.DAY_OF_MONTH, 1);
- assertEquals(LogType.WILL_ATTEND, createEventCache(today).getDefaultLogType());
+ assertThat(createEventCache(today).getDefaultLogType()).isEqualTo(LogType.WILL_ATTEND);
}
private static Geocache createEventCache(Calendar calendar) {
diff --git a/tests/src/cgeo/geocaching/GpxFileListActivityTest.java b/tests/src/cgeo/geocaching/GpxFileListActivityTest.java
index 2923bfc..1dbed80 100644
--- a/tests/src/cgeo/geocaching/GpxFileListActivityTest.java
+++ b/tests/src/cgeo/geocaching/GpxFileListActivityTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.annotation.TargetApi;
import android.test.ActivityInstrumentationTestCase2;
@@ -61,10 +63,10 @@ public class GpxFileListActivityTest extends ActivityInstrumentationTestCase2<Gp
}
private void assertImport(String fileName) {
- assertTrue(importGpxActivity.filenameBelongsToList(fileName));
+ assertThat(importGpxActivity.filenameBelongsToList(fileName)).isTrue();
}
private void denyImport(String fileName) {
- assertFalse(importGpxActivity.filenameBelongsToList(fileName));
+ assertThat(importGpxActivity.filenameBelongsToList(fileName)).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/ImageUtilsTest.java b/tests/src/cgeo/geocaching/ImageUtilsTest.java
index c67d340..7f6c7e5 100644
--- a/tests/src/cgeo/geocaching/ImageUtilsTest.java
+++ b/tests/src/cgeo/geocaching/ImageUtilsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
import cgeo.geocaching.test.R;
import cgeo.geocaching.utils.ImageUtils;
@@ -7,7 +9,6 @@ import cgeo.geocaching.utils.ImageUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Arrays;
public class ImageUtilsTest extends AbstractResourceInstrumentationTestCase {
@@ -18,13 +19,12 @@ public class ImageUtilsTest extends AbstractResourceInstrumentationTestCase {
ImageUtils.decodeBase64ToStream(icon64, outputStream);
final byte[] decodedImage = outputStream.toByteArray();
outputStream.close();
- assertEquals("decoded image has the right size", 409, decodedImage.length);
+ assertThat(decodedImage.length).as("decoded image size").isEqualTo(409);
final InputStream originalStream = getResourceStream(R.raw.small_file);
final byte[] originalImage = new byte[409];
assertEquals("original image has the right size (consistency check)", 409, originalStream.read(originalImage));
originalStream.close();
- assertTrue("decoded base64 image is similar to original file data",
- Arrays.equals(originalImage, decodedImage));
+ assertThat(decodedImage).as("decoded base64 image").isEqualTo(originalImage);
}
}
diff --git a/tests/src/cgeo/geocaching/LazyInitialilzedListTest.java b/tests/src/cgeo/geocaching/LazyInitialilzedListTest.java
index d129838..ec1f593 100644
--- a/tests/src/cgeo/geocaching/LazyInitialilzedListTest.java
+++ b/tests/src/cgeo/geocaching/LazyInitialilzedListTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.utils.LazyInitializedList;
import android.test.AndroidTestCase;
@@ -43,32 +45,32 @@ public class LazyInitialilzedListTest extends AndroidTestCase {
}
public static void testCallOnce() {
- final MyList l = new MyList(0);
- assertEquals("call() must not be called prematurely", 0, l.getCounter());
- l.size();
- assertEquals("call() must be called when needed", 1, l.getCounter());
- l.size();
- assertEquals("call() must be called only once", 1, l.getCounter());
+ final MyList list = new MyList(0);
+ assertThat(list.getCounter()).overridingErrorMessage("call() must not be called prematurely").isEqualTo(0);
+ list.size();
+ assertThat(list.getCounter()).overridingErrorMessage("call() must be called when needed").isEqualTo(1);
+ list.size();
+ assertThat(list.getCounter()).overridingErrorMessage("call() must be called only once").isEqualTo(1);
}
public static void testSize() {
- final MyList l = new MyList(3);
- assertEquals("completed size must be identical to call() result", 3, l.size());
+ final MyList list = new MyList(3);
+ assertThat(list).overridingErrorMessage("completed size must be identical to call() result").hasSize(3);
}
public static void testValue() {
- final MyList l = new MyList(1);
- assertEquals("value must be identical to call() result", Integer.valueOf(1), l.get(0));
+ final MyList list = new MyList(1);
+ assertThat(list.get(0)).overridingErrorMessage("value must be identical to call() result").isEqualTo(1);
}
public static void testNull() {
- final MyList l = new MyList(MAKE_NULL);
- assertEquals("null returned by call() must create an empty list", 0, l.size());
+ final MyList list = new MyList(MAKE_NULL);
+ assertThat(list).overridingErrorMessage("null returned by call() must create an empty list").isEmpty();
}
public static void testException() {
- final MyList l = new MyList(MAKE_EXCEPTION);
- assertEquals("exception in call() must create an empty list", 0, l.size());
+ final MyList list = new MyList(MAKE_EXCEPTION);
+ assertThat(list).overridingErrorMessage("exception in call() must create an empty list").isEmpty();
}
}
diff --git a/tests/src/cgeo/geocaching/ParametersTest.java b/tests/src/cgeo/geocaching/ParametersTest.java
index f1d2638..75c045c 100644
--- a/tests/src/cgeo/geocaching/ParametersTest.java
+++ b/tests/src/cgeo/geocaching/ParametersTest.java
@@ -1,27 +1,27 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.network.Parameters;
import android.test.AndroidTestCase;
import java.security.InvalidParameterException;
-import junit.framework.Assert;
-
public class ParametersTest extends AndroidTestCase {
public static void testException() {
try {
final Parameters params = new Parameters("aaa", "AAA", "bbb");
params.clear(); // this will never be invoked, but suppresses warnings about unused objects
- Assert.fail("Exception not raised");
+ fail("Exception not raised");
} catch (InvalidParameterException e) {
// Ok
}
try {
final Parameters params = new Parameters("aaa", "AAA");
params.put("bbb", "BBB", "ccc");
- Assert.fail("Exception not raised");
+ fail("Exception not raised");
} catch (InvalidParameterException e) {
// Ok
}
@@ -30,7 +30,7 @@ public class ParametersTest extends AndroidTestCase {
public static void testMultipleValues() {
final Parameters params = new Parameters("aaa", "AAA", "bbb", "BBB");
params.put("ccc", "CCC", "ddd", "DDD");
- Assert.assertEquals("aaa=AAA&bbb=BBB&ccc=CCC&ddd=DDD", params.toString());
+ assertThat(params.toString()).isEqualTo("aaa=AAA&bbb=BBB&ccc=CCC&ddd=DDD");
}
public static void testSort() {
@@ -38,16 +38,16 @@ public class ParametersTest extends AndroidTestCase {
params.put("aaa", "AAA");
params.put("ccc", "CCC");
params.put("bbb", "BBB");
- Assert.assertEquals("aaa=AAA&ccc=CCC&bbb=BBB", params.toString());
+ assertThat(params.toString()).isEqualTo("aaa=AAA&ccc=CCC&bbb=BBB");
params.sort();
- Assert.assertEquals("aaa=AAA&bbb=BBB&ccc=CCC", params.toString());
+ assertThat(params.toString()).isEqualTo("aaa=AAA&bbb=BBB&ccc=CCC");
}
public static void testToString() {
final Parameters params = new Parameters();
params.put("name", "foo&bar");
params.put("type", "moving");
- Assert.assertEquals("name=foo%26bar&type=moving", params.toString());
+ assertThat(params.toString()).isEqualTo("name=foo%26bar&type=moving");
}
}
diff --git a/tests/src/cgeo/geocaching/PersonalNoteTest.java b/tests/src/cgeo/geocaching/PersonalNoteTest.java
index 74e1bab..f715d2c 100644
--- a/tests/src/cgeo/geocaching/PersonalNoteTest.java
+++ b/tests/src/cgeo/geocaching/PersonalNoteTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.list.StoredList;
@@ -14,7 +16,7 @@ public class PersonalNoteTest extends TestCase {
Geocache cache = new Geocache();
cache.setPersonalNote(testString);
PersonalNote parsedNote = new PersonalNote(cache);
- assertEquals(testString, parsedNote.toString());
+ assertThat(parsedNote.toString()).isEqualTo(testString);
assertPersonalNote(parsedNote, "Simple cgeo note", "Simple provider note");
}
@@ -24,7 +26,7 @@ public class PersonalNoteTest extends TestCase {
Geocache cache = new Geocache();
cache.setPersonalNote(testString);
PersonalNote parsedNote = new PersonalNote(cache);
- assertEquals(testString, parsedNote.toString());
+ assertThat(parsedNote.toString()).isEqualTo(testString);
assertPersonalNote(parsedNote, null, "Simple provider note");
}
@@ -47,7 +49,7 @@ public class PersonalNoteTest extends TestCase {
Geocache cache = new Geocache();
cache.setPersonalNote(testString);
PersonalNote parsedNote = new PersonalNote(cache);
- assertEquals("Simple cgeo note", parsedNote.toString());
+ assertThat(parsedNote.toString()).isEqualTo("Simple cgeo note");
assertPersonalNote(parsedNote, null, "Simple cgeo note");
}
@@ -60,7 +62,7 @@ public class PersonalNoteTest extends TestCase {
cache2.setPersonalNote("cgeo note\n--\nProvider note");
PersonalNote otherNote = new PersonalNote(cache2);
PersonalNote result = myNote.mergeWith(otherNote);
- assertEquals("cgeo note\n--\nSimple provider note", result.toString());
+ assertThat(result.toString()).isEqualTo("cgeo note\n--\nSimple provider note");
assertPersonalNote(result, "cgeo note", "Simple provider note");
}
@@ -73,15 +75,15 @@ public class PersonalNoteTest extends TestCase {
cache2.setPersonalNote("Provider note");
PersonalNote otherNote = new PersonalNote(cache2);
PersonalNote result = myNote.mergeWith(otherNote);
- assertEquals("Simple cgeo note\n--\nSimple provider note", result.toString());
+ assertThat(result.toString()).isEqualTo("Simple cgeo note\n--\nSimple provider note");
assertPersonalNote(result, "Simple cgeo note", "Simple provider note");
result = otherNote.mergeWith(myNote);
- assertEquals("Simple cgeo note\n--\nProvider note", result.toString());
+ assertThat(result.toString()).isEqualTo("Simple cgeo note\n--\nProvider note");
assertPersonalNote(result, "Simple cgeo note", "Provider note");
}
private static void assertPersonalNote(final PersonalNote note, final String cgeoNote, final String providerNote) {
- assertEquals(cgeoNote, note.getCgeoNote());
- assertEquals(providerNote, note.getProviderNote());
+ assertThat(note.getCgeoNote()).isEqualTo(cgeoNote);
+ assertThat(note.getProviderNote()).isEqualTo(providerNote);
}
}
diff --git a/tests/src/cgeo/geocaching/SearchResultTest.java b/tests/src/cgeo/geocaching/SearchResultTest.java
index 3f9f07f..ffc024d 100644
--- a/tests/src/cgeo/geocaching/SearchResultTest.java
+++ b/tests/src/cgeo/geocaching/SearchResultTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.os.Parcel;
import android.test.AndroidTestCase;
@@ -12,9 +14,9 @@ public class SearchResultTest extends AndroidTestCase {
geocodes.add("GC12345");
geocodes.add("GC23456");
final SearchResult searchResult = new SearchResult(geocodes);
- assertEquals(2, searchResult.getCount());
- assertEquals(2, searchResult.getTotalCountGC());
- assertTrue(searchResult.getGeocodes().contains("GC12345"));
+ assertThat(searchResult.getCount()).isEqualTo(2);
+ assertThat(searchResult.getTotalCountGC()).isEqualTo(2);
+ assertThat(searchResult.getGeocodes().contains("GC12345")).isTrue();
}
public static void testParcel() {
@@ -37,14 +39,14 @@ public class SearchResultTest extends AndroidTestCase {
parcel.recycle();
- assertEquals(3, receive.getCount());
- assertEquals(2, receive.getFilteredGeocodes().size());
+ assertThat(receive.getCount()).isEqualTo(3);
+ assertThat(receive.getFilteredGeocodes()).hasSize(2);
- assertTrue(receive.getGeocodes().contains("GC12345"));
- assertFalse(receive.getGeocodes().contains("GC45678"));
+ assertThat(receive.getGeocodes().contains("GC12345")).isTrue();
+ assertThat(receive.getGeocodes().contains("GC45678")).isFalse();
- assertFalse(receive.getFilteredGeocodes().contains("GC12345"));
- assertTrue(receive.getFilteredGeocodes().contains("GC45678"));
+ assertThat(receive.getFilteredGeocodes().contains("GC12345")).isFalse();
+ assertThat(receive.getFilteredGeocodes().contains("GC45678")).isTrue();
}
public static void testAddSearchResult() {
@@ -62,14 +64,14 @@ public class SearchResultTest extends AndroidTestCase {
newSearch.addGeocode("GC01234");
newSearch.addSearchResult(search);
- assertEquals(4, newSearch.getCount());
- assertEquals(2, newSearch.getFilteredGeocodes().size());
+ assertThat(newSearch.getCount()).isEqualTo(4);
+ assertThat(newSearch.getFilteredGeocodes()).hasSize(2);
- assertTrue(newSearch.getGeocodes().contains("GC12345"));
- assertTrue(newSearch.getGeocodes().contains("GC01234"));
- assertFalse(newSearch.getGeocodes().contains("GC45678"));
+ assertThat(newSearch.getGeocodes().contains("GC12345")).isTrue();
+ assertThat(newSearch.getGeocodes().contains("GC01234")).isTrue();
+ assertThat(newSearch.getGeocodes().contains("GC45678")).isFalse();
- assertFalse(newSearch.getFilteredGeocodes().contains("GC12345"));
- assertTrue(newSearch.getFilteredGeocodes().contains("GC45678"));
+ assertThat(newSearch.getFilteredGeocodes().contains("GC12345")).isFalse();
+ assertThat(newSearch.getFilteredGeocodes().contains("GC45678")).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/SettingsTest.java b/tests/src/cgeo/geocaching/SettingsTest.java
index 90a0209..4c342b3 100644
--- a/tests/src/cgeo/geocaching/SettingsTest.java
+++ b/tests/src/cgeo/geocaching/SettingsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.maps.mapsforge.MapsforgeMapProvider;
import cgeo.geocaching.settings.Settings;
@@ -22,16 +24,16 @@ public class SettingsTest extends ActivityInstrumentationTestCase2<MainActivity>
final String mapFile = Settings.getMapFile();
// We just want to ensure that it does not throw any exception but we do not know anything about the result
MapsforgeMapProvider.isValidMapFile(mapFile);
- assertTrue(true);
+ assertThat(true).isTrue();
}
public static void testSettings() {
// unfortunately, several other tests depend on being a premium member and will fail if run by a basic member
- assertEquals(GCConstants.MEMBER_STATUS_PM, Settings.getGCMemberStatus());
+ assertThat(Settings.getGCMemberStatus()).isEqualTo(GCConstants.MEMBER_STATUS_PM);
}
public static void testDeviceHasNormalLogin() {
// if the unit tests were interrupted in a previous run, the device might still have the "temporary" login data from the last tests
- assertFalse("c:geo".equals(Settings.getUsername()));
+ assertThat("c:geo".equals(Settings.getUsername())).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/StaticMapsProviderTest.java b/tests/src/cgeo/geocaching/StaticMapsProviderTest.java
index 2b11976..02c6660 100644
--- a/tests/src/cgeo/geocaching/StaticMapsProviderTest.java
+++ b/tests/src/cgeo/geocaching/StaticMapsProviderTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.files.LocalStorage;
import cgeo.geocaching.geopoint.Geopoint;
@@ -45,9 +47,9 @@ public class StaticMapsProviderTest extends TestCase {
// make sure we don't have stale downloads
deleteCacheDirectory(geocode);
- assertFalse(StaticMapsProvider.hasStaticMap(cache));
- assertFalse(StaticMapsProvider.hasStaticMapForWaypoint(geocode, theFinal));
- assertFalse(StaticMapsProvider.hasStaticMapForWaypoint(geocode, trailhead));
+ assertThat(StaticMapsProvider.hasStaticMap(cache)).isFalse();
+ assertThat(StaticMapsProvider.hasStaticMapForWaypoint(geocode, theFinal)).isFalse();
+ assertThat(StaticMapsProvider.hasStaticMapForWaypoint(geocode, trailhead)).isFalse();
// download
StaticMapsProvider.downloadMaps(cache);
@@ -59,13 +61,13 @@ public class StaticMapsProviderTest extends TestCase {
}
// check download
- assertTrue(StaticMapsProvider.hasStaticMap(cache));
- assertTrue(StaticMapsProvider.hasStaticMapForWaypoint(geocode, theFinal));
- assertTrue(StaticMapsProvider.hasStaticMapForWaypoint(geocode, trailhead));
+ assertThat(StaticMapsProvider.hasStaticMap(cache)).isTrue();
+ assertThat(StaticMapsProvider.hasStaticMapForWaypoint(geocode, theFinal)).isTrue();
+ assertThat(StaticMapsProvider.hasStaticMapForWaypoint(geocode, trailhead)).isTrue();
// waypoint static maps hashcode dependent
trailhead.setCoords(new Geopoint(lat + 0.24d + 2, lon + 0.25d + 2));
- assertFalse(StaticMapsProvider.hasStaticMapForWaypoint(geocode, trailhead));
+ assertThat(StaticMapsProvider.hasStaticMapForWaypoint(geocode, trailhead)).isFalse();
} finally {
TestSettings.setStoreOfflineWpMaps(backupStoreWP);
TestSettings.setStoreOfflineMaps(backupStore);
diff --git a/tests/src/cgeo/geocaching/TrackableTest.java b/tests/src/cgeo/geocaching/TrackableTest.java
index 7d3fd5c..2d9c773 100644
--- a/tests/src/cgeo/geocaching/TrackableTest.java
+++ b/tests/src/cgeo/geocaching/TrackableTest.java
@@ -1,33 +1,35 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.test.AndroidTestCase;
public class TrackableTest extends AndroidTestCase {
public static void testGetGeocode() {
final Trackable trackable = createTrackable("tb1234");
- assertEquals("TB1234", trackable.getGeocode());
+ assertThat(trackable.getGeocode()).isEqualTo("TB1234");
}
public static void testSetLogsNull() {
final Trackable trackable = new Trackable();
trackable.setLogs(null);
- assertNotNull("Trackable logs must not be null!", trackable.getLogs());
+ assertThat(trackable.getLogs()).as("Trackable logs").isNotNull();
}
public static void testTrackableUrl() {
final Trackable trackable = createTrackable("TB1234");
- assertEquals("http://www.geocaching.com//track/details.aspx?tracker=TB1234", trackable.getUrl());
+ assertThat(trackable.getUrl()).isEqualTo("http://www.geocaching.com//track/details.aspx?tracker=TB1234");
}
public static void testGeokretUrl() {
Trackable geokret = createTrackable("GK82A2");
- assertEquals("http://geokrety.org/konkret.php?id=33442", geokret.getUrl());
+ assertThat(geokret.getUrl()).isEqualTo("http://geokrety.org/konkret.php?id=33442");
}
public static void testLoggable() {
- assertTrue(createTrackable("TB1234").isLoggable());
- assertFalse(createTrackable("GK1234").isLoggable());
+ assertThat(createTrackable("TB1234").isLoggable()).isTrue();
+ assertThat(createTrackable("GK1234").isLoggable()).isFalse();
}
private static Trackable createTrackable(String geocode) {
diff --git a/tests/src/cgeo/geocaching/WaypointTest.java b/tests/src/cgeo/geocaching/WaypointTest.java
index 9868f81..a3dabbf 100644
--- a/tests/src/cgeo/geocaching/WaypointTest.java
+++ b/tests/src/cgeo/geocaching/WaypointTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
@@ -37,13 +39,13 @@ public class WaypointTest extends AndroidTestCase {
}
private static void assertOrdered(Waypoint first, Waypoint second) {
- assertTrue(Waypoint.WAYPOINT_COMPARATOR.compare(first, second) < 0);
+ assertThat(Waypoint.WAYPOINT_COMPARATOR.compare(first, second) < 0).isTrue();
}
public static void testGeocode() {
final Waypoint waypoint = new Waypoint("Test waypoint", WaypointType.PARKING, false);
waypoint.setGeocode("p1");
- assertEquals("P1", waypoint.getGeocode());
+ assertThat(waypoint.getGeocode()).isEqualTo("P1");
}
public static void testParseNoWaypointFromNote() {
@@ -59,21 +61,21 @@ public class WaypointTest extends AndroidTestCase {
"M 7\n" +
"N 5\n" +
"5 IFG 257";
- assertTrue(Waypoint.parseWaypointsFromNote(note).isEmpty());
+ assertThat(Waypoint.parseWaypointsFromNote(note).isEmpty()).isTrue();
}
public static void testParseWaypointFromNote() {
final String note = "Dummy note\nn 45° 3.5 e 27° 7.5\nNothing else";
final Collection<Waypoint> waypoints = Waypoint.parseWaypointsFromNote(note);
- assertEquals(1, waypoints.size());
+ assertThat(waypoints).hasSize(1);
final Geopoint coords = waypoints.iterator().next().getCoords();
- assertEquals(45, coords.getLatDeg());
- assertEquals(3.5, coords.getLatMinRaw());
- assertEquals(27, coords.getLonDeg());
- assertEquals(7.5, coords.getLonMinRaw());
+ assertThat(coords.getLatDeg()).isEqualTo(45);
+ assertThat(coords.getLatMinRaw()).isEqualTo(3.5);
+ assertThat(coords.getLonDeg()).isEqualTo(27);
+ assertThat(coords.getLonMinRaw()).isEqualTo(7.5);
final String note2 = "Waypoint on two lines\nN 45°3.5\nE 27°7.5\nNothing else";
final Collection<Waypoint> waypoints2 = Waypoint.parseWaypointsFromNote(note2);
- assertEquals(1, waypoints2.size());
- assertEquals(coords, waypoints2.iterator().next().getCoords());
+ assertThat(waypoints2).hasSize(1);
+ assertThat(waypoints2.iterator().next().getCoords()).isEqualTo(coords);
}
}
diff --git a/tests/src/cgeo/geocaching/activity/ProgressTest.java b/tests/src/cgeo/geocaching/activity/ProgressTest.java
index 9dab166..db2b9d9 100644
--- a/tests/src/cgeo/geocaching/activity/ProgressTest.java
+++ b/tests/src/cgeo/geocaching/activity/ProgressTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.activity;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.AboutActivity;
import android.annotation.TargetApi;
@@ -7,7 +9,7 @@ import android.test.ActivityInstrumentationTestCase2;
/**
* This test uses the about activity to avoid side effects like network and GPS being triggered by the main activity.
- *
+ *
*/
@TargetApi(8)
public class ProgressTest extends ActivityInstrumentationTestCase2<AboutActivity> {
@@ -18,17 +20,17 @@ public class ProgressTest extends ActivityInstrumentationTestCase2<AboutActivity
public void testProgressWrapper() {
final Progress progress = new Progress();
- assertFalse(progress.isShowing()); // nothing shown initially
+ assertThat(progress.isShowing()).isFalse(); // nothing shown initially
progress.show(getActivity(), "Title", "Message", true, null);
- assertTrue(progress.isShowing());
+ assertThat(progress.isShowing()).isTrue();
progress.setMessage("Test");
- assertTrue(progress.isShowing());
+ assertThat(progress.isShowing()).isTrue();
for (int i = 0; i < 2; i++) { // fault tolerant when dismissing to often
progress.dismiss();
- assertFalse(progress.isShowing());
+ assertThat(progress.isShowing()).isFalse();
}
}
}
diff --git a/tests/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactoryTest.java b/tests/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactoryTest.java
index 2d510ab..894d028 100644
--- a/tests/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactoryTest.java
+++ b/tests/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactoryTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory.NavigationAppsEnum;
import java.util.HashSet;
@@ -13,7 +15,7 @@ public class NavigationAppFactoryTest extends TestCase {
for (NavigationAppsEnum navigationApp : NavigationAppsEnum.values()) {
idSet.add(navigationApp.id);
}
- assertEquals("Duplicate id in " + NavigationAppsEnum.class.getSimpleName(), NavigationAppsEnum.values().length, idSet.size());
+ assertThat(idSet).doesNotHaveDuplicates();
}
}
diff --git a/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java b/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java
index 725f718..efa0b00 100644
--- a/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java
+++ b/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.connector.gc.GCConnector;
import cgeo.geocaching.connector.oc.OCConnector;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
@@ -11,84 +13,84 @@ public class ConnectorFactoryTest extends AbstractResourceInstrumentationTestCas
public static void testGetConnectors() {
final Collection<IConnector> connectors = ConnectorFactory.getConnectors();
- assertNotNull(connectors);
- assertFalse(connectors.isEmpty()); // unknown connector must exist
+ assertThat(connectors).isNotNull();
+ assertThat(connectors.isEmpty()).isFalse(); // unknown connector must exist
}
public static void testCanHandle() {
- assertFalse(ConnectorFactory.canHandle(""));
- assertTrue(ConnectorFactory.canHandle("GC12345"));
- assertTrue(ConnectorFactory.canHandle("some string")); // using unknown connector
- assertFalse(ConnectorFactory.canHandle("[/start with special char"));
+ assertThat(ConnectorFactory.canHandle("")).isFalse();
+ assertThat(ConnectorFactory.canHandle("GC12345")).isTrue();
+ assertThat(ConnectorFactory.canHandle("some string")).isTrue(); // using unknown connector
+ assertThat(ConnectorFactory.canHandle("[/start with special char")).isFalse();
}
public static void testGeocodeOpenCaching() {
- assertTrue(ConnectorFactory.getConnector("OZ12345") instanceof OCConnector); // opencaching CZ
- assertTrue(ConnectorFactory.getConnector("OC12345") instanceof OCConnector); // opencaching DE
- assertTrue(ConnectorFactory.getConnector("OU12345") instanceof OCConnector); // opencaching US
- assertTrue(ConnectorFactory.getConnector("OK12345") instanceof OCConnector); // opencaching UK
- assertTrue(ConnectorFactory.getConnector("OJ12345") instanceof OCConnector); // opencaching JP
- assertTrue(ConnectorFactory.getConnector("OS12345") instanceof OCConnector); // opencaching NO
- assertTrue(ConnectorFactory.getConnector("OB12345") instanceof OCConnector); // opencaching NL
- assertTrue(ConnectorFactory.getConnector("OP12345") instanceof OCConnector); // opencaching PL
+ assertThat(ConnectorFactory.getConnector("OZ12345") instanceof OCConnector).isTrue(); // opencaching CZ
+ assertThat(ConnectorFactory.getConnector("OC12345") instanceof OCConnector).isTrue(); // opencaching DE
+ assertThat(ConnectorFactory.getConnector("OU12345") instanceof OCConnector).isTrue(); // opencaching US
+ assertThat(ConnectorFactory.getConnector("OK12345") instanceof OCConnector).isTrue(); // opencaching UK
+ assertThat(ConnectorFactory.getConnector("OJ12345") instanceof OCConnector).isTrue(); // opencaching JP
+ assertThat(ConnectorFactory.getConnector("OS12345") instanceof OCConnector).isTrue(); // opencaching NO
+ assertThat(ConnectorFactory.getConnector("OB12345") instanceof OCConnector).isTrue(); // opencaching NL
+ assertThat(ConnectorFactory.getConnector("OP12345") instanceof OCConnector).isTrue(); // opencaching PL
}
public static void testGeocodeInvalidFormat() {
// all codes are invalid
- assertTrue(ConnectorFactory.getConnector("GC") instanceof UnknownConnector);
- assertTrue(ConnectorFactory.getConnector("OC") instanceof UnknownConnector);
- assertTrue(ConnectorFactory.getConnector("OX") instanceof UnknownConnector);
- assertTrue(ConnectorFactory.getConnector("GC 1234") instanceof UnknownConnector);
- assertTrue(ConnectorFactory.getConnector("OC 1234") instanceof UnknownConnector);
- assertTrue(ConnectorFactory.getConnector("OX 1234") instanceof UnknownConnector);
- assertTrue(ConnectorFactory.getConnector("GC-1234") instanceof UnknownConnector);
- assertTrue(ConnectorFactory.getConnector("OC-1234") instanceof UnknownConnector);
- assertTrue(ConnectorFactory.getConnector("OX-1234") instanceof UnknownConnector);
+ assertThat(ConnectorFactory.getConnector("GC") instanceof UnknownConnector).isTrue();
+ assertThat(ConnectorFactory.getConnector("OC") instanceof UnknownConnector).isTrue();
+ assertThat(ConnectorFactory.getConnector("OX") instanceof UnknownConnector).isTrue();
+ assertThat(ConnectorFactory.getConnector("GC 1234") instanceof UnknownConnector).isTrue();
+ assertThat(ConnectorFactory.getConnector("OC 1234") instanceof UnknownConnector).isTrue();
+ assertThat(ConnectorFactory.getConnector("OX 1234") instanceof UnknownConnector).isTrue();
+ assertThat(ConnectorFactory.getConnector("GC-1234") instanceof UnknownConnector).isTrue();
+ assertThat(ConnectorFactory.getConnector("OC-1234") instanceof UnknownConnector).isTrue();
+ assertThat(ConnectorFactory.getConnector("OX-1234") instanceof UnknownConnector).isTrue();
}
public static void testGetConnectorCgCache() {
- assertEquals(GCConnector.getInstance(), ConnectorFactory.getConnector(new GC1ZXX2()));
+ assertThat(ConnectorFactory.getConnector(new GC1ZXX2())).isEqualTo(GCConnector.getInstance());
}
public static void testGetConnectorString() {
final IConnector connector = ConnectorFactory.getConnector("GC12345");
- assertNotNull(connector);
- assertEquals(GCConnector.getInstance().getName(), connector.getName());
+ assertThat(connector).isNotNull();
+ assertThat(connector.getName()).isEqualTo(GCConnector.getInstance().getName());
}
public static void testTrim() {
- assertTrue(ConnectorFactory.getConnector(" OZ12345 ") instanceof OCConnector); // opencaching CZ
- assertTrue(ConnectorFactory.getConnector(" OZ 12345 ") instanceof UnknownConnector);
+ assertThat(ConnectorFactory.getConnector(" OZ12345 ") instanceof OCConnector).isTrue(); // opencaching CZ
+ assertThat(ConnectorFactory.getConnector(" OZ 12345 ") instanceof UnknownConnector).isTrue();
}
public static void testGetGeocodeFromUrl() {
- assertEquals("GC34PLO", ConnectorFactory.getGeocodeFromURL("http://coord.info/GC34PLO"));
- assertEquals("GC34PLO", ConnectorFactory.getGeocodeFromURL("http://www.coord.info/GC34PLO"));
- assertEquals("OX1234", ConnectorFactory.getGeocodeFromURL("http://www.opencaching.com/#!geocache/OX1234"));
+ assertThat(ConnectorFactory.getGeocodeFromURL("http://coord.info/GC34PLO")).isEqualTo("GC34PLO");
+ assertThat(ConnectorFactory.getGeocodeFromURL("http://www.coord.info/GC34PLO")).isEqualTo("GC34PLO");
+ assertThat(ConnectorFactory.getGeocodeFromURL("http://www.opencaching.com/#!geocache/OX1234")).isEqualTo("OX1234");
- assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/GC12ABC"));
- assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/GC12ABC"));
- assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://www.geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau"));
- assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau"));
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/GC12ABC")).isEqualTo("GC12ABC");
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/GC12ABC")).isEqualTo("GC12ABC");
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://www.geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau")).isEqualTo("GC12ABC");
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau")).isEqualTo("GC12ABC");
// trackable URLs
- assertNull(GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/TB1234"));
- assertNull(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/TB1234"));
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/TB1234")).isNull();
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/TB1234")).isNull();
// make sure that a mixture of different connector and geocode is recognized as invalid
- assertNull(ConnectorFactory.getGeocodeFromURL("http://www.opencaching.com/#!geocache/" + "GC12345"));
+ assertThat(ConnectorFactory.getGeocodeFromURL("http://www.opencaching.com/#!geocache/" + "GC12345")).isNull();
}
public static void testGetTrackableFromURL() throws Exception {
- assertEquals("GK78FA", ConnectorFactory.getTrackableFromURL("http://www.geokrety.org/konkret.php?id=30970"));
- assertEquals("GK78FA", ConnectorFactory.getTrackableFromURL("http://geokrety.org/konkret.php?id=30970"));
- assertEquals("TB1234", ConnectorFactory.getTrackableFromURL("http://coord.info/TB1234"));
- assertEquals("TB1234", ConnectorFactory.getTrackableFromURL("http://www.coord.info/TB1234"));
- assertEquals("TB1234", ConnectorFactory.getTrackableFromURL("http://geocaching.com/track/details.aspx?tracker=TB1234"));
- assertEquals("TB1234", ConnectorFactory.getTrackableFromURL("http://www.geocaching.com/track/details.aspx?tracker=TB1234"));
+ assertThat(ConnectorFactory.getTrackableFromURL("http://www.geokrety.org/konkret.php?id=30970")).isEqualTo("GK78FA");
+ assertThat(ConnectorFactory.getTrackableFromURL("http://geokrety.org/konkret.php?id=30970")).isEqualTo("GK78FA");
+ assertThat(ConnectorFactory.getTrackableFromURL("http://coord.info/TB1234")).isEqualTo("TB1234");
+ assertThat(ConnectorFactory.getTrackableFromURL("http://www.coord.info/TB1234")).isEqualTo("TB1234");
+ assertThat(ConnectorFactory.getTrackableFromURL("http://geocaching.com/track/details.aspx?tracker=TB1234")).isEqualTo("TB1234");
+ assertThat(ConnectorFactory.getTrackableFromURL("http://www.geocaching.com/track/details.aspx?tracker=TB1234")).isEqualTo("TB1234");
// cache URLs
- assertNull(ConnectorFactory.getTrackableFromURL("http://coord.info/GC1234"));
- assertNull(ConnectorFactory.getTrackableFromURL("http://www.coord.info/GC1234"));
+ assertThat(ConnectorFactory.getTrackableFromURL("http://coord.info/GC1234")).isNull();
+ assertThat(ConnectorFactory.getTrackableFromURL("http://www.coord.info/GC1234")).isNull();
}
}
diff --git a/tests/src/cgeo/geocaching/connector/ec/ECApiTest.java b/tests/src/cgeo/geocaching/connector/ec/ECApiTest.java
index 9f9e99c..6525d22 100644
--- a/tests/src/cgeo/geocaching/connector/ec/ECApiTest.java
+++ b/tests/src/cgeo/geocaching/connector/ec/ECApiTest.java
@@ -1,12 +1,13 @@
package cgeo.geocaching.connector.ec;
+import static org.assertj.core.api.Assertions.assertThat;
import junit.framework.TestCase;
public class ECApiTest extends TestCase {
public static void testGetIdFromGeocode() throws Exception {
- assertEquals("242", ECApi.getIdFromGeocode("EC242"));
- assertEquals("242", ECApi.getIdFromGeocode("ec242"));
+ assertThat(ECApi.getIdFromGeocode("EC242")).isEqualTo("242");
+ assertThat(ECApi.getIdFromGeocode("ec242")).isEqualTo("242");
}
}
diff --git a/tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java b/tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java
index 4b9ae37..aa6a185 100644
--- a/tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.ec;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
@@ -11,16 +13,16 @@ import junit.framework.TestCase;
public class ECConnectorTest extends TestCase {
public static void testCanHandle() throws Exception {
- assertTrue(ECConnector.getInstance().canHandle("EC380"));
- assertFalse(ECConnector.getInstance().canHandle("GC380"));
- assertFalse("faked EC codes must be handled during the import, otherwise GCECxxxx codes belong to 2 connectors", ECConnector.getInstance().canHandle("GCEC380"));
+ assertThat(ECConnector.getInstance().canHandle("EC380")).isTrue();
+ assertThat(ECConnector.getInstance().canHandle("GC380")).isFalse();
+ assertThat(ECConnector.getInstance().canHandle("GCEC380")).overridingErrorMessage("faked EC codes must be handled during the import, otherwise GCECxxxx codes belong to 2 connectors").isFalse();
}
public static void testGetPossibleLogTypes() throws Exception {
final List<LogType> possibleLogTypes = ECConnector.getInstance().getPossibleLogTypes(createCache());
- assertNotNull(possibleLogTypes);
- assertFalse(possibleLogTypes.isEmpty());
- assertTrue(possibleLogTypes.contains(LogType.FOUND_IT));
+ assertThat(possibleLogTypes).isNotNull();
+ assertThat(possibleLogTypes).isNotEmpty();
+ assertThat(possibleLogTypes).contains(LogType.FOUND_IT);
}
private static Geocache createCache() {
diff --git a/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java b/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java
index 708e328..63924ab 100644
--- a/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.gc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.Viewport;
@@ -15,13 +17,13 @@ public class AutoZoomTest extends TestCase {
int zoom = Tile.calcZoomLat(bottomLeft, topRight, 2);
- assertTrue(Math.abs(new Tile(bottomLeft, zoom).getY() - new Tile(topRight, zoom).getY()) == 1);
- assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getY() - new Tile(topRight, zoom + 1).getY()) > 1);
+ assertThat(Math.abs(new Tile(bottomLeft, zoom).getY() - new Tile(topRight, zoom).getY()) == 1).isTrue();
+ assertThat(Math.abs(new Tile(bottomLeft, zoom + 1).getY() - new Tile(topRight, zoom + 1).getY()) > 1).isTrue();
zoom = Tile.calcZoomLon(bottomLeft, topRight, 2);
- assertTrue(new Tile(bottomLeft, zoom).getX() + 1 == new Tile(topRight, zoom).getX());
- assertTrue(new Tile(bottomLeft, zoom + 1).getX() + 1 < new Tile(topRight, zoom + 1).getX());
+ assertThat(new Tile(bottomLeft, zoom).getX() + 1 == new Tile(topRight, zoom).getX()).isTrue();
+ assertThat(new Tile(bottomLeft, zoom + 1).getX() + 1 < new Tile(topRight, zoom + 1).getX()).isTrue();
}
@@ -31,13 +33,13 @@ public class AutoZoomTest extends TestCase {
int zoom = Tile.calcZoomLat(bottomLeft, topRight, 3);
- assertTrue(Math.abs(new Tile(bottomLeft, zoom).getY() - new Tile(topRight, zoom).getY()) >= 2);
- assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getY() - new Tile(topRight, zoom + 1).getY()) > 2);
+ assertThat(Math.abs(new Tile(bottomLeft, zoom).getY() - new Tile(topRight, zoom).getY()) >= 2).isTrue();
+ assertThat(Math.abs(new Tile(bottomLeft, zoom + 1).getY() - new Tile(topRight, zoom + 1).getY()) > 2).isTrue();
zoom = Tile.calcZoomLon(bottomLeft, topRight, 3);
- assertTrue(Math.abs(new Tile(bottomLeft, zoom).getX() - new Tile(topRight, zoom).getX()) >= 2);
- assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getX() - new Tile(topRight, zoom + 1).getX()) > 2);
+ assertThat(Math.abs(new Tile(bottomLeft, zoom).getX() - new Tile(topRight, zoom).getX()) >= 2).isTrue();
+ assertThat(Math.abs(new Tile(bottomLeft, zoom + 1).getX() - new Tile(topRight, zoom + 1).getX()) > 2).isTrue();
}
@@ -47,7 +49,7 @@ public class AutoZoomTest extends TestCase {
final Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight));
- assertEquals(2, tiles.size());
+ assertThat(tiles).hasSize(2);
}
public static void testTiles2x3() {
@@ -56,7 +58,7 @@ public class AutoZoomTest extends TestCase {
final Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, Tile.ZOOMLEVEL_MIN);
- assertEquals(6, tiles.size());
+ assertThat(tiles).hasSize(6);
}
public static void testTilesZoom13() {
@@ -65,6 +67,6 @@ public class AutoZoomTest extends TestCase {
final Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, 13);
- assertEquals(16, tiles.size());
+ assertThat(tiles).hasSize(16);
}
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
index 4a81231..811c0e4 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.gc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.trackable.TravelBugConnector;
@@ -27,17 +29,17 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
{
final Viewport viewport = new Viewport(new Geopoint("N 52° 25.369 E 9° 35.499"), new Geopoint("N 52° 25.600 E 9° 36.200"));
final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens);
- assertNotNull(searchResult);
- assertFalse(searchResult.isEmpty());
- assertTrue(searchResult.getGeocodes().contains("GC4ER5H"));
+ assertThat(searchResult).isNotNull();
+ assertThat(searchResult.isEmpty()).isFalse();
+ assertThat(searchResult.getGeocodes().contains("GC4ER5H")).isTrue();
// 22.10.13: Changed from GC211WG (archived) to GC4ER5H in same area
}
{
final Viewport viewport = new Viewport(new Geopoint("N 52° 24.000 E 9° 34.500"), new Geopoint("N 52° 26.000 E 9° 38.500"));
final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens);
- assertNotNull(searchResult);
- assertTrue(searchResult.getGeocodes().contains("GC4ER5H"));
+ assertThat(searchResult).isNotNull();
+ assertThat(searchResult.getGeocodes().contains("GC4ER5H")).isTrue();
}
} finally {
// restore user settings
@@ -47,19 +49,19 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
}
public static void testCanHandle() {
- assertTrue(GCConnector.getInstance().canHandle("GC2MEGA"));
- assertFalse(GCConnector.getInstance().canHandle("OXZZZZZ"));
+ assertThat(GCConnector.getInstance().canHandle("GC2MEGA")).isTrue();
+ assertThat(GCConnector.getInstance().canHandle("OXZZZZZ")).isFalse();
}
/**
* functionality moved to {@link TravelBugConnector}
*/
public static void testCanNotHandleTrackablesAnymore() {
- assertFalse(GCConnector.getInstance().canHandle("TB3F651"));
+ assertThat(GCConnector.getInstance().canHandle("TB3F651")).isFalse();
}
public static void testBaseCodings() {
- assertEquals(2045702, GCConstants.gccodeToGCId("GC2MEGA"));
+ assertThat(GCConstants.gccodeToGCId("GC2MEGA")).isEqualTo(2045702);
}
/** Tile computation with different zoom levels */
@@ -81,18 +83,18 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
}
private static void assertTileAt(int x, int y, final Tile tile) {
- assertEquals(x, tile.getX());
- assertEquals(y, tile.getY());
+ assertThat(tile.getX()).isEqualTo(x);
+ assertThat(tile.getY()).isEqualTo(y);
}
public static void testGetGeocodeFromUrl() {
- assertNull(GCConnector.getInstance().getGeocodeFromUrl("some string"));
- assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/GC12ABC"));
- assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/GC12ABC"));
- assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://www.geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau"));
- assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau"));
-
- assertNull(GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/TB1234"));
- assertNull(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/TB1234"));
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("some string")).isNull();
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/GC12ABC")).isEqualTo("GC12ABC");
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/GC12ABC")).isEqualTo("GC12ABC");
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://www.geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau")).isEqualTo("GC12ABC");
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau")).isEqualTo("GC12ABC");
+
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/TB1234")).isNull();
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/TB1234")).isNull();
}
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
index 8f6b960..be0c4da 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.gc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.test.mock.MockedCache;
import cgeo.geocaching.utils.TextUtils;
@@ -48,13 +50,13 @@ public class GCConstantsTest extends AndroidTestCase {
GCLogin.getInstance().logout();
GCLogin.getInstance().setActualCachesFound(0);
GCLogin.getInstance().login();
- assertTrue(GCLogin.getInstance().getActualCachesFound() > 0);
+ assertThat(GCLogin.getInstance().getActualCachesFound() > 0).isTrue();
}
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, ""));
- assertTrue(TextUtils.getMatch(session, GCConstants.PATTERN_SESSIONTOKEN, "").startsWith("123pNK"));
+ assertThat(TextUtils.getMatch(session, GCConstants.PATTERN_SESSIONTOKEN, "").startsWith("123pNK")).isTrue();
}
public static void testTBWithSpecialChar() {
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
index e6fed94..2897b54 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.gc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.Image;
@@ -18,7 +20,6 @@ import cgeo.geocaching.test.mock.MockedCache;
import cgeo.geocaching.utils.CancellableHandler;
import cgeo.test.Compare;
-import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import android.test.suitebuilder.annotation.MediumTest;
@@ -36,9 +37,9 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
private void assertUnpublished(final int cache) {
final String page = getFileContent(cache);
final SearchResult result = GCParser.parseCacheFromText(page, null);
- assertNotNull(result);
- assertTrue(result.isEmpty());
- assertEquals(StatusCode.UNPUBLISHED_CACHE, result.getError());
+ assertThat(result).isNotNull();
+ assertThat(result.isEmpty()).isTrue();
+ assertThat(result.getError()).isEqualTo(StatusCode.UNPUBLISHED_CACHE);
}
public void testPublishedCacheWithUnpublishedInDescription1() {
@@ -52,23 +53,22 @@ 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);
- assertNotNull(result);
- assertEquals(1, result.getCount());
+ assertThat(result).isNotNull();
+ assertThat(result.getCount()).isEqualTo(1);
final Geocache cache = result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
- assertNotNull(cache);
+ assertThat(cache).isNotNull();
assert (cache != null); // eclipse bug
- assertEquals(cacheName, cache.getName());
+ assertThat(cache.getName()).isEqualTo(cacheName);
}
public void testOwnCache() {
final Geocache cache = parseCache(R.raw.own_cache);
- assertNotNull("Cache not parsed!", cache);
- assertTrue("No spoilers found!", CollectionUtils.isNotEmpty(cache.getSpoilers()));
- assertEquals("Wrong number of spoilers", 2, cache.getSpoilers().size());
+ assertThat(cache).isNotNull();
+ assertThat(cache.getSpoilers()).as("spoilers").hasSize(2);
final Image spoiler = cache.getSpoilers().get(1);
assertEquals("First spoiler image url wrong", "http://imgcdn.geocaching.com/cache/large/6ddbbe82-8762-46ad-8f4c-57d03f4b0564.jpeg", spoiler.getUrl());
assertEquals("First spoiler image text wrong", "SPOILER", spoiler.getTitle());
- assertNull("First spoiler image description not empty", spoiler.getDescription());
+ assertThat(spoiler.getDescription()).as("First spoiler image description").isNull();
}
private static Geocache createCache(int index) {
@@ -84,11 +84,11 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
Settings.setGcCustomDate(oldCustomDate);
}
- assertNotNull(searchResult);
- assertEquals(1, searchResult.getCount());
+ assertThat(searchResult).isNotNull();
+ assertThat(searchResult.getCount()).isEqualTo(1);
final Geocache cache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
- assertNotNull(cache);
+ assertThat(cache).isNotNull();
return cache;
}
@@ -105,7 +105,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
Settings.setGcCustomDate(MockedCache.getDateFormat());
SearchResult searchResult = GCParser.parseCacheFromText(mockedCache.getData(), null);
Geocache parsedCache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
- assertTrue(StringUtils.isNotBlank(mockedCache.getMockedDataUser()));
+ assertThat(StringUtils.isNotBlank(mockedCache.getMockedDataUser())).isTrue();
Compare.assertCompareCaches(mockedCache, parsedCache, true);
}
} finally {
@@ -159,18 +159,18 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
cache.dropSynchronous();
final String page = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0");
final Geocache cache2 = GCParser.parseCacheFromText(page, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY);
- assertNotNull(cache2);
+ assertThat(cache2).isNotNull();
assert (cache2 != null); // eclipse bug
- assertTrue(cache2.hasUserModifiedCoords());
+ assertThat(cache2.hasUserModifiedCoords()).isTrue();
assertEquals(new Geopoint("N51 21.544", "E07 02.566"), cache2.getCoords());
// delete coordinates
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);
- assertNotNull(cache3);
+ assertThat(cache3).isNotNull();
assert (cache3 != null); // eclipse bug
- assertFalse(cache3.hasUserModifiedCoords());
+ assertThat(cache3.hasUserModifiedCoords()).isFalse();
}
private static void assertWaypointsFromNote(final Geocache cache, Geopoint[] expected, String note) {
@@ -178,18 +178,18 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
cache.setWaypoints(new ArrayList<Waypoint>(), false);
cache.parseWaypointsFromNote();
final List<Waypoint> waypoints = cache.getWaypoints();
- assertEquals(expected.length, waypoints.size());
+ assertThat(waypoints).hasSize(expected.length);
for (int i = 0; i < expected.length; i++) {
- assertTrue(expected[i].equals(waypoints.get(i).getCoords()));
+ assertThat(expected[i].equals(waypoints.get(i).getCoords())).isTrue();
}
}
public void testWaypointParsing() {
Geocache cache = parseCache(R.raw.gc366bq);
- assertEquals(13, cache.getWaypoints().size());
+ assertThat(cache.getWaypoints()).hasSize(13);
//make sure that waypoints are not duplicated
cache = parseCache(R.raw.gc366bq);
- assertEquals(13, cache.getWaypoints().size());
+ assertThat(cache.getWaypoints()).hasSize(13);
}
public static void testNoteParsingWaypointTypes() {
@@ -202,26 +202,26 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
cache.parseWaypointsFromNote();
final List<Waypoint> waypoints = cache.getWaypoints();
- assertEquals(3, waypoints.size());
- assertEquals(WaypointType.PARKING, waypoints.get(0).getWaypointType());
- assertEquals(WaypointType.FINAL, waypoints.get(1).getWaypointType());
- assertEquals(WaypointType.WAYPOINT, waypoints.get(2).getWaypointType());
+ assertThat(waypoints).hasSize(3);
+ assertThat(waypoints.get(0).getWaypointType()).isEqualTo(WaypointType.PARKING);
+ assertThat(waypoints.get(1).getWaypointType()).isEqualTo(WaypointType.FINAL);
+ assertThat(waypoints.get(2).getWaypointType()).isEqualTo(WaypointType.WAYPOINT);
}
private Geocache parseCache(int resourceId) {
final String page = getFileContent(resourceId);
final SearchResult result = GCParser.parseCacheFromText(page, null);
- assertNotNull(result);
- assertFalse(result.isEmpty());
+ assertThat(result).isNotNull();
+ assertThat(result.isEmpty()).isFalse();
return result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
}
public void testTrackableNotActivated() {
final String page = getFileContent(R.raw.tb123e_html);
final Trackable trackable = GCParser.parseTrackable(page, "TB123E");
- assertNotNull(trackable);
- assertEquals("TB123E", trackable.getGeocode());
+ assertThat(trackable).isNotNull();
+ assertThat(trackable.getGeocode()).isEqualTo("TB123E");
final String expectedDetails = CgeoApplication.getInstance().getString(cgeo.geocaching.R.string.trackable_not_activated);
- assertEquals(expectedDetails, trackable.getDetails());
+ assertThat(trackable.getDetails()).isEqualTo(expectedDetails);
}
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java b/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
index 42028d8..22f8536 100644
--- a/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.gc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
@@ -18,7 +20,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 88, 124, 14).getType());
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 228, 104, 14).getType());
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 52, 92, 14).getType());
- assertTrue(parseMapPNG(bitmap, 108, 112, 14).isFound());
+ assertThat(parseMapPNG(bitmap, 108, 112, 14).isFound()).isTrue();
}
private Bitmap getBitmap(int resourceId) {
@@ -80,52 +82,52 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
found = parseMapPNG(bitmap, 240, 140, 12).isFound() ? found + 1 : found;
found = parseMapPNG(bitmap, 211, 127, 12).isFound() ? found + 1 : found;
- assertEquals(7, multi);
- assertEquals(7, mystery);
- assertEquals(7, tradi);
- assertEquals(4, found);
+ assertThat(multi).isEqualTo(7);
+ assertThat(mystery).isEqualTo(7);
+ assertThat(tradi).isEqualTo(7);
+ assertThat(found).isEqualTo(4);
}
public void testParseExtraMap1() {
final Bitmap bitmap = getBitmap(R.raw.map1);
- assertTrue(parseMapPNG(bitmap, 128, 168, 12).isFound()); // GC3AT8B
+ assertThat(parseMapPNG(bitmap, 128, 168, 12).isFound()).isTrue(); // GC3AT8B
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 172, 164, 12).getType()); // GC39EXB
- assertTrue(parseMapPNG(bitmap, 164, 156, 12).isFound()); // GC30M7M
+ assertThat(parseMapPNG(bitmap, 164, 156, 12).isFound()).isTrue(); // GC30M7M
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 204, 72, 12).getType()); // GC3AN5Z
- assertTrue(parseMapPNG(bitmap, 188, 92, 12).isFound()); // GC37T3R
- assertTrue(parseMapPNG(bitmap, 164, 132, 12).isFound()); // GC34JME
+ assertThat(parseMapPNG(bitmap, 188, 92, 12).isFound()).isTrue(); // GC37T3R
+ assertThat(parseMapPNG(bitmap, 164, 132, 12).isFound()).isTrue(); // GC34JME
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 176, 148, 12).getType()); // GC37TCY
assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 180, 136, 12).getType()); // GC3947Z
- assertTrue(parseMapPNG(bitmap, 164, 100, 12).isFound()); // GC2ZY3X
- assertTrue(parseMapPNG(bitmap, 52, 104, 12).isFound()); // GC29RCW
- assertTrue(parseMapPNG(bitmap, 168, 88, 12).isFound()); // GC264JZ
- assertTrue(parseMapPNG(bitmap, 168, 140, 12).isFound()); // GC37RRV
+ assertThat(parseMapPNG(bitmap, 164, 100, 12).isFound()).isTrue(); // GC2ZY3X
+ assertThat(parseMapPNG(bitmap, 52, 104, 12).isFound()).isTrue(); // GC29RCW
+ assertThat(parseMapPNG(bitmap, 168, 88, 12).isFound()).isTrue(); // GC264JZ
+ assertThat(parseMapPNG(bitmap, 168, 140, 12).isFound()).isTrue(); // GC37RRV
}
public void testParseExtraMap2() {
final Bitmap bitmap = getBitmap(R.raw.map2);
- assertTrue(parseMapPNG(bitmap, 132, 136, 12).isFound()); // GC3JDBW
- assertTrue(parseMapPNG(bitmap, 68, 24, 12).isFound()); // GC2T0AH
- assertTrue(parseMapPNG(bitmap, 176, 232, 12).isOwner()); // GC2RPBX
- assertTrue(parseMapPNG(bitmap, 148, 60, 12).isFound()); // GC31FY6
- assertTrue(parseMapPNG(bitmap, 216, 20, 12).isFound()); // GC2KP3M
- assertTrue(parseMapPNG(bitmap, 212, 184, 12).isOwner()); // GC30W3K
- assertTrue(parseMapPNG(bitmap, 148, 72, 12).isOwner()); // GC2RPAZ
- assertTrue(parseMapPNG(bitmap, 216, 48, 12).isOwner()); // GC2RP8W
- assertTrue(parseMapPNG(bitmap, 212, 60, 12).isFound()); // GC3CC97
- assertTrue(parseMapPNG(bitmap, 148, 100, 12).isOwner()); // GC2RPAT
- assertTrue(parseMapPNG(bitmap, 104, 136, 12).isFound()); // GC3AE31
- assertTrue(parseMapPNG(bitmap, 52, 96, 12).isOwner()); // GC2RPCH
- assertTrue(parseMapPNG(bitmap, 172, 156, 12).isOwner()); // GC2RQ07
- assertTrue(parseMapPNG(bitmap, 116, 56, 12).isFound()); // GC3AYR2
- assertTrue(parseMapPNG(bitmap, 208, 68, 12).isOwner()); // GC2RP93
- assertTrue(parseMapPNG(bitmap, 200, 52, 12).isOwner()); // GC2RPAA
- assertTrue(parseMapPNG(bitmap, 208, 44, 12).isFound()); // GC3HE15
- assertTrue(parseMapPNG(bitmap, 112, 76, 12).isOwner()); // GC2RPBE
- assertTrue(parseMapPNG(bitmap, 232, 192, 12).isOwner()); // GC2E1KF
- assertTrue(parseMapPNG(bitmap, 184, 76, 12).isFound()); // GC2NK5R
- assertTrue(parseMapPNG(bitmap, 132, 148, 12).isOwner()); // GC2RPBC
+ assertThat(parseMapPNG(bitmap, 132, 136, 12).isFound()).isTrue(); // GC3JDBW
+ assertThat(parseMapPNG(bitmap, 68, 24, 12).isFound()).isTrue(); // GC2T0AH
+ assertThat(parseMapPNG(bitmap, 176, 232, 12).isOwner()).isTrue(); // GC2RPBX
+ assertThat(parseMapPNG(bitmap, 148, 60, 12).isFound()).isTrue(); // GC31FY6
+ assertThat(parseMapPNG(bitmap, 216, 20, 12).isFound()).isTrue(); // GC2KP3M
+ assertThat(parseMapPNG(bitmap, 212, 184, 12).isOwner()).isTrue(); // GC30W3K
+ assertThat(parseMapPNG(bitmap, 148, 72, 12).isOwner()).isTrue(); // GC2RPAZ
+ assertThat(parseMapPNG(bitmap, 216, 48, 12).isOwner()).isTrue(); // GC2RP8W
+ assertThat(parseMapPNG(bitmap, 212, 60, 12).isFound()).isTrue(); // GC3CC97
+ assertThat(parseMapPNG(bitmap, 148, 100, 12).isOwner()).isTrue(); // GC2RPAT
+ assertThat(parseMapPNG(bitmap, 104, 136, 12).isFound()).isTrue(); // GC3AE31
+ assertThat(parseMapPNG(bitmap, 52, 96, 12).isOwner()).isTrue(); // GC2RPCH
+ assertThat(parseMapPNG(bitmap, 172, 156, 12).isOwner()).isTrue(); // GC2RQ07
+ assertThat(parseMapPNG(bitmap, 116, 56, 12).isFound()).isTrue(); // GC3AYR2
+ assertThat(parseMapPNG(bitmap, 208, 68, 12).isOwner()).isTrue(); // GC2RP93
+ assertThat(parseMapPNG(bitmap, 200, 52, 12).isOwner()).isTrue(); // GC2RPAA
+ assertThat(parseMapPNG(bitmap, 208, 44, 12).isFound()).isTrue(); // GC3HE15
+ assertThat(parseMapPNG(bitmap, 112, 76, 12).isOwner()).isTrue(); // GC2RPBE
+ assertThat(parseMapPNG(bitmap, 232, 192, 12).isOwner()).isTrue(); // GC2E1KF
+ assertThat(parseMapPNG(bitmap, 184, 76, 12).isFound()).isTrue(); // GC2NK5R
+ assertThat(parseMapPNG(bitmap, 132, 148, 12).isOwner()).isTrue(); // GC2RPBC
}
public void testParseExtraMap3() {
@@ -179,7 +181,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 44, 72, 12).getType()); // GC10W91
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 104, 36, 12).getType()); // GCRC1W
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 88, 36, 12).getType()); // GC30PQF
- assertTrue(parseMapPNG(bitmap, 116, 36, 12).isFound()); // GC17VWA
+ assertThat(parseMapPNG(bitmap, 116, 36, 12).isFound()).isTrue(); // GC17VWA
assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 28, 56, 12).getType()); // GC1E6A6
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 96, 72, 12).getType()); // GCMVAC
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 140, 48, 12).getType()); // GCZPE4
@@ -212,7 +214,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 104, 88, 12).getType()); // GC1FKZY
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 56, 248, 12).getType()); // GC2Y5Z4
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 72, 32, 12).getType()); // GC395J6
- assertTrue(parseMapPNG(bitmap, 180, 4, 12).isFound()); // GC21MFG
+ assertThat(parseMapPNG(bitmap, 180, 4, 12).isFound()).isTrue(); // GC21MFG
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 96, 100, 12).getType()); // GC1W45E
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 160, 12).getType()); // GC37BA1
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 12, 4, 12).getType()); // GC1K8KR
@@ -237,7 +239,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 92, 192, 12).getType()); // GC11D9P
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 52, 84, 12).getType()); // GC2M693
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 196, 12).getType()); // GCZHVE
- assertTrue(parseMapPNG(bitmap, 140, 108, 12).isFound()); // GC1Q5PW
+ assertThat(parseMapPNG(bitmap, 140, 108, 12).isFound()).isTrue(); // GC1Q5PW
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 108, 148, 12).getType()); // GC2ZR0C
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 168, 8, 12).getType()); // GCYWQH
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 196, 92, 12).getType()); // GC39VXN
@@ -245,15 +247,15 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 168, 28, 12).getType()); // GC2H1TG
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 240, 52, 12).getType()); // GC2QTXT
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 152, 148, 12).getType()); // GC3E7QD
- assertTrue(parseMapPNG(bitmap, 160, 60, 12).isFound()); // GC2J3G9
- assertTrue(parseMapPNG(bitmap, 160, 100, 12).isFound()); // GC2327G
+ assertThat(parseMapPNG(bitmap, 160, 60, 12).isFound()).isTrue(); // GC2J3G9
+ assertThat(parseMapPNG(bitmap, 160, 100, 12).isFound()).isTrue(); // GC2327G
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 136, 32, 12).getType()); // GC2JVEH
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 208, 164, 12).getType()); // GC1NN15
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 244, 12).getType()); // GC3E5JP
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 172, 16, 12).getType()); // GC1Z581
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 104, 20, 12).getType()); // GC2MENX
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 60, 12).getType()); // GC1V3MG
- assertTrue(parseMapPNG(bitmap, 228, 56, 12).isFound()); // GC36WZN
+ assertThat(parseMapPNG(bitmap, 228, 56, 12).isFound()).isTrue(); // GC36WZN
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 144, 212, 12).getType()); // GCR9GB
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 180, 68, 12).getType()); // GC3JZ1K
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 228, 104, 12).getType()); // GCQ95T
@@ -264,7 +266,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 128, 12).getType()); // GC2XQ6C
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 248, 164, 12).getType()); // GC3B1JK
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 84, 12).getType()); // GC3AT8J
- assertTrue(parseMapPNG(bitmap, 160, 88, 12).isFound()); // GC2MB4P
+ assertThat(parseMapPNG(bitmap, 160, 88, 12).isFound()).isTrue(); // GC2MB4P
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 132, 20, 12).getType()); // GC2NW3F
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 56, 132, 12).getType()); // GC22ERA
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 28, 32, 12).getType()); // GC2EFFK
@@ -289,7 +291,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 220, 48, 12).getType()); // GC1HQ8Y
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 136, 176, 12).getType()); // GC310B7
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 132, 232, 12).getType()); // GC12CR5
- assertTrue(parseMapPNG(bitmap, 240, 40, 12).isFound()); // GC24GW1
+ assertThat(parseMapPNG(bitmap, 240, 40, 12).isFound()).isTrue(); // GC24GW1
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 140, 116, 12).getType()); // GC2YYE7
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 144, 12).getType()); // GC111RZ
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 48, 128, 12).getType()); // GC13A7V
@@ -302,7 +304,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 108, 168, 12).getType()); // GC3C043
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 28, 12).getType()); // GC1TEAR
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 204, 12).getType()); // GC3AKFV
- assertTrue(parseMapPNG(bitmap, 228, 28, 12).isFound()); // GC2NMPR
+ assertThat(parseMapPNG(bitmap, 228, 28, 12).isFound()).isTrue(); // GC2NMPR
//assertEquals(CacheType.VIRTUAL, parseMapPNG(bitmap, 232, 252, 12).getType()); // GC1AH0N - False detection
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 220, 188, 12).getType()); // GC1ZXDK
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 168, 212, 12).getType()); // GC3A919
@@ -339,7 +341,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 56, 12).getType()); // GC1N11P
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 100, 180, 12).getType()); // GCM6AE
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 124, 12).getType()); // GC2A1RQ
- assertTrue(parseMapPNG(bitmap, 212, 4, 12).isFound()); // GC1TVKE
+ assertThat(parseMapPNG(bitmap, 212, 4, 12).isFound()).isTrue(); // GC1TVKE
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 28, 212, 12).getType()); // GC2A1RR
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 128, 84, 12).getType()); // GC16AWC
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 220, 16, 12).getType()); // GC282V9
@@ -365,7 +367,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 172, 12).getType()); // GC3B30A
assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 104, 92, 12).getType()); // GC2GY9D
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 128, 120, 12).getType()); // GC2Y90M
- assertTrue(parseMapPNG(bitmap, 204, 40, 12).isFound()); // GC1BZ6P
+ assertThat(parseMapPNG(bitmap, 204, 40, 12).isFound()).isTrue(); // GC1BZ6P
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 56, 76, 12).getType()); // GC10K7X
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 196, 108, 12).getType()); // GC1F0R5
assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 196, 12).getType()); // GC1KQQW
@@ -386,13 +388,13 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
public void testParseExtraMapall14() {
final Bitmap bitmap = getBitmap(R.raw.map_all14);
- assertTrue(parseMapPNG(bitmap, 40, 16, 14).isFound());
- assertTrue(parseMapPNG(bitmap, 72, 16, 14).isFound());
- assertTrue(parseMapPNG(bitmap, 100, 16, 14).isFound());
- assertTrue(parseMapPNG(bitmap, 128, 16, 14).isFound());
- assertTrue(parseMapPNG(bitmap, 44, 44, 14).isOwner());
- assertTrue(parseMapPNG(bitmap, 76, 44, 14).isOwner());
- assertTrue(parseMapPNG(bitmap, 132, 44, 14).isOwner());
+ assertThat(parseMapPNG(bitmap, 40, 16, 14).isFound()).isTrue();
+ assertThat(parseMapPNG(bitmap, 72, 16, 14).isFound()).isTrue();
+ assertThat(parseMapPNG(bitmap, 100, 16, 14).isFound()).isTrue();
+ assertThat(parseMapPNG(bitmap, 128, 16, 14).isFound()).isTrue();
+ assertThat(parseMapPNG(bitmap, 44, 44, 14).isOwner()).isTrue();
+ assertThat(parseMapPNG(bitmap, 76, 44, 14).isOwner()).isTrue();
+ assertThat(parseMapPNG(bitmap, 132, 44, 14).isOwner()).isTrue();
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 40, 72, 14).getType());
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 72, 72, 14).getType());
assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 100, 72, 14).getType());
diff --git a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java
index 9e5039c..c45efd7 100644
--- a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.gc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Image;
import cgeo.geocaching.LogEntry;
import cgeo.geocaching.Trackable;
@@ -15,74 +17,74 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase {
public void testLogPageWithTrackables() {
final List<TrackableLog> tbLogs = GCParser.parseTrackableLog(getFileContent(R.raw.log_with_2tb));
- assertNotNull(tbLogs);
- assertEquals(2, tbLogs.size());
+ assertThat(tbLogs).isNotNull();
+ assertThat(tbLogs).hasSize(2);
final TrackableLog log = tbLogs.get(0);
- assertEquals("Steffen's Kaiserwagen", log.name);
- assertEquals("1QG1EE", log.trackCode);
+ assertThat(log.name).isEqualTo("Steffen's Kaiserwagen");
+ assertThat(log.trackCode).isEqualTo("1QG1EE");
}
public void testLogPageWithoutTrackables() {
final List<TrackableLog> tbLogs = GCParser.parseTrackableLog(getFileContent(R.raw.log_without_tb));
- assertNotNull(tbLogs);
- assertEquals(0, tbLogs.size());
+ assertThat(tbLogs).isNotNull();
+ assertThat(tbLogs).isEmpty();
}
public void testTrackable() {
final Trackable trackable = getTB2R124();
- assertEquals("TB2R124", trackable.getGeocode());
- assertEquals("Bor. Dortmund - FC Schalke 04", trackable.getName());
- assertEquals("Spiridon Lui", trackable.getOwner());
+ assertThat(trackable.getGeocode()).isEqualTo("TB2R124");
+ assertThat(trackable.getName()).isEqualTo("Bor. Dortmund - FC Schalke 04");
+ assertThat(trackable.getOwner()).isEqualTo("Spiridon Lui");
}
public void testTrackableWithoutImage() {
final Trackable trackable = getTB2R124();
- assertNull(trackable.getImage());
- assertNotNull(trackable.getDetails());
+ assertThat(trackable.getImage()).isNull();
+ assertThat(trackable.getDetails()).isNotNull();
}
public void testTrackableWithLogImages() {
final Trackable trackable = getTBXATG();
- assertEquals("TBXATG", trackable.getGeocode());
+ assertThat(trackable.getGeocode()).isEqualTo("TBXATG");
final List<LogEntry> log = trackable.getLogs();
- assertNotNull(log);
- assertEquals(10, log.size());
+ assertThat(log).isNotNull();
+ assertThat(log).hasSize(10);
// log entry 4 has several images; just check the first one
final List<Image> log4Images = log.get(4).getLogImages();
- assertNotNull(log4Images);
- assertEquals(1, log4Images.size());
- assertEquals("http://imgcdn.geocaching.com/track/log/large/3dc286d2-671e-4502-937a-f1bd35a13813.jpg", log4Images.get(0).getUrl());
- assertEquals("@Osaka", log4Images.get(0).getTitle());
+ assertThat(log4Images).isNotNull();
+ assertThat(log4Images).hasSize(1);
+ assertThat(log4Images.get(0).getUrl()).isEqualTo("http://imgcdn.geocaching.com/track/log/large/3dc286d2-671e-4502-937a-f1bd35a13813.jpg");
+ assertThat(log4Images.get(0).getTitle()).isEqualTo("@Osaka");
for (LogEntry entry : log) {
- assertFalse(entry.log.startsWith("<div>"));
+ assertThat(entry.log.startsWith("<div>")).isFalse();
}
- assertEquals("Dropped in Una Bhan (GC49XCJ)", log.get(0).log);
+ assertThat(log.get(0).log).isEqualTo("Dropped in Una Bhan (GC49XCJ)");
}
public void testParseTrackableWithoutReleaseDate() {
final Trackable trackable = parseTrackable(R.raw.tb14wfv);
- assertNotNull(trackable);
- assertEquals("The Brickster", trackable.getName());
- assertEquals("Adrian C", trackable.getOwner());
- assertTrue(trackable.getGoal().startsWith("I'm on the run from the law."));
- assertTrue(trackable.getGoal().endsWith("what I've seen."));
- assertTrue(trackable.getDistance() >= 11663.5f);
+ assertThat(trackable).isNotNull();
+ assertThat(trackable.getName()).isEqualTo("The Brickster");
+ assertThat(trackable.getOwner()).isEqualTo("Adrian C");
+ assertThat(trackable.getGoal().startsWith("I'm on the run from the law.")).isTrue();
+ assertThat(trackable.getGoal().endsWith("what I've seen.")).isTrue();
+ assertThat(trackable.getDistance() >= 11663.5f).isTrue();
// the next two items are normally available for trackables, but not for this one, so explicitly test for null
- assertNull(trackable.getReleased());
- assertNull(trackable.getOrigin());
+ assertThat(trackable.getReleased()).isNull();
+ assertThat(trackable.getOrigin()).isNull();
}
public void testParseRelativeLink() {
final Trackable trackable = parseTrackable(R.raw.tb4cwjx);
- assertNotNull(trackable);
- assertEquals("The Golden Lisa", trackable.getName());
+ assertThat(trackable).isNotNull();
+ assertThat(trackable.getName()).isEqualTo("The Golden Lisa");
final String goal = trackable.getGoal();
- assertNotNull(goal);
- assertFalse(goal.contains(".."));
- assertTrue(goal.contains("href=\"http://www.geocaching.com/seek/cache_details.aspx?wp=GC3B7PD#\""));
+ assertThat(goal).isNotNull();
+ assertThat(goal.contains("..")).isFalse();
+ assertThat(goal.contains("href=\"http://www.geocaching.com/seek/cache_details.aspx?wp=GC3B7PD#\"")).isTrue();
}
public void testParseSpeedManagerCompressedTrackable() {
@@ -93,27 +95,27 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase {
}
private static void assertTB54VJJ(final Trackable trackable) {
- assertNotNull(trackable);
- assertEquals("Krtek - Der kleine Maulwurf", trackable.getName());
+ assertThat(trackable).isNotNull();
+ assertThat(trackable.getName()).isEqualTo("Krtek - Der kleine Maulwurf");
final String goal = trackable.getGoal();
- assertNotNull(goal);
- assertTrue(goal.startsWith("Bei meinem Besitzer auf der Couch"));
- assertTrue(goal.endsWith("Geocachern zusammen fotografieren."));
+ 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());
- assertEquals("TB54VJJ", trackable.getGeocode());
+ assertThat(trackable.getGeocode()).isEqualTo("TB54VJJ");
assertEquals("Nordrhein-Westfalen, Germany", trackable.getOrigin());
- assertEquals("Lineflyer", trackable.getOwner());
+ assertThat(trackable.getOwner()).isEqualTo("Lineflyer");
// the icon url is manipulated during compression
- assertTrue(trackable.getIconUrl().endsWith("www.geocaching.com/images/wpttypes/21.gif"));
- assertTrue(trackable.getImage().endsWith("img.geocaching.com/track/display/d9a475fa-da90-43ec-aec0-92afe26163e1.jpg"));
- assertEquals("d11a3e3d-7db0-4d43-87f2-7893238844a6", trackable.getOwnerGuid());
- assertNull(trackable.getSpottedGuid());
- assertEquals(Trackable.SPOTTED_OWNER, trackable.getSpottedType());
- assertNotNull(trackable.getReleased());
- assertEquals("Travel Bug Dog Tag", trackable.getType());
+ assertThat(trackable.getIconUrl().endsWith("www.geocaching.com/images/wpttypes/21.gif")).isTrue();
+ assertThat(trackable.getImage().endsWith("img.geocaching.com/track/display/d9a475fa-da90-43ec-aec0-92afe26163e1.jpg")).isTrue();
+ assertThat(trackable.getOwnerGuid()).isEqualTo("d11a3e3d-7db0-4d43-87f2-7893238844a6");
+ assertThat(trackable.getSpottedGuid()).isNull();
+ assertThat(trackable.getSpottedType()).isEqualTo(Trackable.SPOTTED_OWNER);
+ assertThat(trackable.getReleased()).isNotNull();
+ assertThat(trackable.getType()).isEqualTo("Travel Bug Dog Tag");
final List<LogEntry> logs = trackable.getLogs();
- assertNotNull(logs);
- assertEquals(10, logs.size());
+ assertThat(logs).isNotNull();
+ assertThat(logs).hasSize(10);
}
private Trackable parseTrackable(int trackablePage) {
@@ -123,12 +125,12 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase {
public void testParseMarkMissing() {
final Trackable trackable = parseTrackable(R.raw.tb3f206);
- assertNotNull(trackable);
+ assertThat(trackable).isNotNull();
final List<LogEntry> logs = trackable.getLogs();
- assertNotNull(logs);
- assertFalse(logs.isEmpty());
+ assertThat(logs).isNotNull();
+ assertThat(logs.isEmpty()).isFalse();
final LogEntry marked = logs.get(0);
- assertEquals(LogType.MARKED_MISSING, marked.type);
+ assertThat(marked.type).isEqualTo(LogType.MARKED_MISSING);
}
private Trackable getTB2R124() {
@@ -141,7 +143,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase {
public void testParseTrackableNotExisting() {
final Trackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb_not_existing), null);
- assertNull(trackable);
+ assertThat(trackable).isNull();
}
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java b/tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java
index a742faf..8ee022b 100644
--- a/tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java
@@ -1,21 +1,22 @@
package cgeo.geocaching.connector.gc;
+import static org.assertj.core.api.Assertions.assertThat;
import junit.framework.TestCase;
public class UTFGridPositionTest extends TestCase {
public static void testValidUTFGridPosition() {
- assertNotNull(new UTFGridPosition(0, 0));
+ assertThat(new UTFGridPosition(0, 0)).isNotNull();
}
public static void testInvalidUTFGridPosition() {
boolean valid = true;
try {
- assertNotNull(new UTFGridPosition(-1, 0));
+ assertThat(new UTFGridPosition(-1, 0)).isNotNull();
} catch (Exception e) {
valid = false;
}
- assertFalse(valid);
+ assertThat(valid).isFalse();
}
public static void testFromString() throws Exception {
@@ -27,8 +28,8 @@ public class UTFGridPositionTest extends TestCase {
private static void assertXYFromString(final String key, int x, int y) {
final UTFGridPosition pos = UTFGridPosition.fromString(key);
- assertEquals(x, pos.getX());
- assertEquals(y, pos.getY());
+ assertThat(pos.getX()).isEqualTo(x);
+ assertThat(pos.getY()).isEqualTo(y);
}
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java b/tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java
index 19acd7c..10b793c 100644
--- a/tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.gc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.DataStore;
import cgeo.geocaching.Geocache;
@@ -20,7 +22,7 @@ public class WaypointsTest extends CGeoTestCase {
private static Geocache downloadCache(final String geocode) {
final SearchResult searchResult = Geocache.searchByGeocode(geocode, null, 0, true, handler);
- assertEquals(1, searchResult.getCount());
+ assertThat(searchResult.getCount()).isEqualTo(1);
return searchResult.getFirstCacheFromResult(LoadFlags.LOAD_WAYPOINTS);
}
@@ -28,8 +30,8 @@ public class WaypointsTest extends CGeoTestCase {
// Check that repeated loads of "GC33HXE" hold the right number of waypoints (issue #2430).
final String GEOCODE = "GC33HXE";
DataStore.removeCache(GEOCODE, LoadFlags.REMOVE_ALL);
- assertEquals(9, downloadCache(GEOCODE).getWaypoints().size());
- assertEquals(9, downloadCache(GEOCODE).getWaypoints().size());
+ assertThat(downloadCache(GEOCODE).getWaypoints()).hasSize(9);
+ assertThat(downloadCache(GEOCODE).getWaypoints()).hasSize(9);
}
}
diff --git a/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java b/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java
index bbbd710..0aad3aa 100644
--- a/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.oc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.IConnector;
@@ -12,13 +14,13 @@ public class OCConnectorTest extends TestCase {
*/
public static void testCanHandleNew5DigitCodes() {
final IConnector ocConnector = getOcDeConnector();
- assertTrue(ocConnector.canHandle("OCFFFF"));
- assertTrue(ocConnector.canHandle("OC10000"));
+ assertThat(ocConnector.canHandle("OCFFFF")).isTrue();
+ assertThat(ocConnector.canHandle("OC10000")).isTrue();
}
private static IConnector getOcDeConnector() {
final IConnector ocConnector = ConnectorFactory.getConnector("OCXXX");
- assertTrue(ocConnector.getHost().contains(".de"));
+ assertThat(ocConnector.getHost().contains(".de")).isTrue();
return ocConnector;
}
diff --git a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
index d98e33a..05d676b 100644
--- a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
+++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.oc;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.DataStore;
import cgeo.geocaching.Geocache;
@@ -10,38 +12,38 @@ public class OkapiClientTest extends CGeoTestCase {
public static void testGetOCCache() {
final String geoCode = "OU0331";
Geocache cache = OkapiClient.getCache(geoCode);
- assertNotNull("Did not get cache from OKAPI", cache);
+ assertThat(cache).as("Cache from OKAPI").isNotNull();
assertEquals("Unexpected geo code", geoCode, cache.getGeocode());
- assertEquals("Oshkosh Municipal Tank", cache.getName());
- assertTrue(cache.isDetailed());
+ assertThat(cache.getName()).isEqualTo("Oshkosh Municipal Tank");
+ assertThat(cache.isDetailed()).isTrue();
// cache should be stored to DB (to listID 0) when loaded above
cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
- assertNotNull(cache);
- assertEquals(geoCode, cache.getGeocode());
- assertEquals("Oshkosh Municipal Tank", cache.getName());
- assertTrue(cache.isDetailed());
+ assertThat(cache).isNotNull();
+ assertThat(cache.getGeocode()).isEqualTo(geoCode);
+ assertThat(cache.getName()).isEqualTo("Oshkosh Municipal Tank");
+ assertThat(cache.isDetailed()).isTrue();
}
public static void testOCSearchMustWorkWithoutOAuthAccessTokens() {
final String geoCode = "OC1234";
Geocache cache = OkapiClient.getCache(geoCode);
- assertNotNull("You must have a valid OKAPI key installed for running this test (but you do not need to set credentials in the app).", cache);
- assertEquals("Wupper-Schein", cache.getName());
+ assertThat(cache).overridingErrorMessage("You must have a valid OKAPI key installed for running this test (but you do not need to set credentials in the app).").isNotNull();
+ assertThat(cache.getName()).isEqualTo("Wupper-Schein");
}
public static void testOCCacheWithWaypoints() {
final String geoCode = "OCDDD2";
removeCacheCompletely(geoCode);
Geocache cache = OkapiClient.getCache(geoCode);
- assertNotNull("Did not get cache from OKAPI", cache);
+ assertThat(cache).as("Cache from OKAPI").isNotNull();
// cache should be stored to DB (to listID 0) when loaded above
cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
- assertNotNull(cache);
- assertEquals(3, cache.getWaypoints().size());
+ assertThat(cache).isNotNull();
+ assertThat(cache.getWaypoints()).hasSize(3);
// load again
cache.refreshSynchronous(cache.getListId(), null);
- assertEquals(3, cache.getWaypoints().size());
+ assertThat(cache.getWaypoints()).hasSize(3);
}
}
diff --git a/tests/src/cgeo/geocaching/connector/ox/OXConnectorTest.java b/tests/src/cgeo/geocaching/connector/ox/OXConnectorTest.java
index 77394de..5433387 100644
--- a/tests/src/cgeo/geocaching/connector/ox/OXConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/ox/OXConnectorTest.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.connector.ox;
+import static org.assertj.core.api.Assertions.assertThat;
import junit.framework.TestCase;
public class OXConnectorTest extends TestCase {
@@ -7,10 +8,10 @@ public class OXConnectorTest extends TestCase {
public static void testCanHandle() {
// http://www.opencaching.com/api_doc/concepts/oxcodes.html
final OXConnector oxConnector = new OXConnector();
- assertTrue(oxConnector.canHandle("OXZZZZZ"));
- assertTrue(oxConnector.canHandle("OX1"));
- assertFalse(oxConnector.canHandle("GCABCDE"));
- assertFalse(oxConnector.canHandle("OX_"));
+ assertThat(oxConnector.canHandle("OXZZZZZ")).isTrue();
+ assertThat(oxConnector.canHandle("OX1")).isTrue();
+ assertThat(oxConnector.canHandle("GCABCDE")).isFalse();
+ assertThat(oxConnector.canHandle("OX_")).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/connector/trackable/GeokretyConnectorTest.java b/tests/src/cgeo/geocaching/connector/trackable/GeokretyConnectorTest.java
index d3633cb..c23e11f 100644
--- a/tests/src/cgeo/geocaching/connector/trackable/GeokretyConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/trackable/GeokretyConnectorTest.java
@@ -1,27 +1,28 @@
package cgeo.geocaching.connector.trackable;
+import static org.assertj.core.api.Assertions.assertThat;
import junit.framework.TestCase;
public class GeokretyConnectorTest extends TestCase {
public static void testCanHandleTrackable() {
- assertTrue(new GeokretyConnector().canHandleTrackable("GK82A2"));
- assertFalse(new GeokretyConnector().canHandleTrackable("GKXYZ1")); // non hex
- assertFalse(new GeokretyConnector().canHandleTrackable("TB1234"));
- assertFalse(new GeokretyConnector().canHandleTrackable("UNKNOWN"));
+ assertThat(new GeokretyConnector().canHandleTrackable("GK82A2")).isTrue();
+ assertThat(new GeokretyConnector().canHandleTrackable("GKXYZ1")).isFalse(); // non hex
+ assertThat(new GeokretyConnector().canHandleTrackable("TB1234")).isFalse();
+ assertThat(new GeokretyConnector().canHandleTrackable("UNKNOWN")).isFalse();
}
public static void testGetTrackableCodeFromUrl() throws Exception {
- assertEquals("GK78FA", new GeokretyConnector().getTrackableCodeFromUrl("http://www.geokrety.org/konkret.php?id=30970"));
- assertEquals("GK78FA", new GeokretyConnector().getTrackableCodeFromUrl("http://geokrety.org/konkret.php?id=30970"));
+ assertThat(new GeokretyConnector().getTrackableCodeFromUrl("http://www.geokrety.org/konkret.php?id=30970")).isEqualTo("GK78FA");
+ assertThat(new GeokretyConnector().getTrackableCodeFromUrl("http://geokrety.org/konkret.php?id=30970")).isEqualTo("GK78FA");
}
public static void testGeocode() throws Exception {
- assertEquals("GK97C1", GeokretyConnector.geocode(38849));
+ assertThat(GeokretyConnector.geocode(38849)).isEqualTo("GK97C1");
}
public static void testGetId() throws Exception {
- assertEquals(38849, GeokretyConnector.getId("GK97C1"));
+ assertThat(GeokretyConnector.getId("GK97C1")).isEqualTo(38849);
}
}
diff --git a/tests/src/cgeo/geocaching/connector/trackable/GeokretyParserTest.java b/tests/src/cgeo/geocaching/connector/trackable/GeokretyParserTest.java
index 8f21342..be63123 100644
--- a/tests/src/cgeo/geocaching/connector/trackable/GeokretyParserTest.java
+++ b/tests/src/cgeo/geocaching/connector/trackable/GeokretyParserTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.trackable;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.Trackable;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
@@ -9,11 +11,11 @@ public class GeokretyParserTest extends AbstractResourceInstrumentationTestCase
public void testParse() {
Trackable trackable = GeokretyParser.parse(getFileContent(R.raw.geokret141_xml));
- assertNotNull(trackable);
- assertEquals("WeltenbummlerKret", trackable.getName());
- assertEquals("GK008D", trackable.getGeocode());
- assertEquals(2235f, trackable.getDistance());
- assertEquals(CgeoApplication.getInstance().getString(cgeo.geocaching.R.string.geokret_type_traditional), trackable.getType());
+ assertThat(trackable).isNotNull();
+ assertThat(trackable.getName()).isEqualTo("WeltenbummlerKret");
+ assertThat(trackable.getGeocode()).isEqualTo("GK008D");
+ assertThat(trackable.getDistance()).isEqualTo(2235f);
+ assertThat(trackable.getType()).isEqualTo(CgeoApplication.getInstance().getString(cgeo.geocaching.R.string.geokret_type_traditional));
}
}
diff --git a/tests/src/cgeo/geocaching/connector/trackable/TravelBugConnectorTest.java b/tests/src/cgeo/geocaching/connector/trackable/TravelBugConnectorTest.java
index 7e85b71..8d80822 100644
--- a/tests/src/cgeo/geocaching/connector/trackable/TravelBugConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/trackable/TravelBugConnectorTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.connector.trackable;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Trackable;
import junit.framework.TestCase;
@@ -7,32 +9,32 @@ import junit.framework.TestCase;
public class TravelBugConnectorTest extends TestCase {
public static void testCanHandleTrackable() {
- assertTrue(getConnector().canHandleTrackable("TB1234"));
- assertTrue(getConnector().canHandleTrackable("TB1"));
- assertTrue(getConnector().canHandleTrackable("TB123F"));
- assertTrue(getConnector().canHandleTrackable("TB123Z"));
- assertTrue(getConnector().canHandleTrackable("TB4JD36")); // existing TB, 5 specific characters
- assertTrue(getConnector().canHandleTrackable("GK1234")); // valid secret code, even though this might be a geokrety
- assertTrue(getConnector().canHandleTrackable("GST9HV")); // existing secret code
- assertFalse(getConnector().canHandleTrackable("UNKNOWN"));
+ assertThat(getConnector().canHandleTrackable("TB1234")).isTrue();
+ assertThat(getConnector().canHandleTrackable("TB1")).isTrue();
+ assertThat(getConnector().canHandleTrackable("TB123F")).isTrue();
+ assertThat(getConnector().canHandleTrackable("TB123Z")).isTrue();
+ assertThat(getConnector().canHandleTrackable("TB4JD36")).isTrue(); // existing TB, 5 specific characters
+ assertThat(getConnector().canHandleTrackable("GK1234")).isTrue(); // valid secret code, even though this might be a geokrety
+ assertThat(getConnector().canHandleTrackable("GST9HV")).isTrue(); // existing secret code
+ assertThat(getConnector().canHandleTrackable("UNKNOWN")).isFalse();
}
public static void testGetUrl() {
final Trackable trackable = new Trackable();
trackable.setGeocode("TB2345");
- assertEquals("http://www.geocaching.com//track/details.aspx?tracker=TB2345", getConnector().getUrl(trackable));
+ assertThat(getConnector().getUrl(trackable)).isEqualTo("http://www.geocaching.com//track/details.aspx?tracker=TB2345");
}
public static void testOnlineSearchBySecretCode() {
Trackable trackable = getConnector().searchTrackable("GST9HV", null, null);
- assertNotNull(trackable);
- assertEquals("Deutschland", trackable.getName());
+ assertThat(trackable).isNotNull();
+ assertThat(trackable.getName()).isEqualTo("Deutschland");
}
public static void testOnlineSearchByPublicCode() {
Trackable trackable = getConnector().searchTrackable("TB4JD36", null, null);
- assertNotNull(trackable);
- assertEquals("Mein Kilometerzähler", trackable.getName());
+ assertThat(trackable).isNotNull();
+ assertThat(trackable.getName()).isEqualTo("Mein Kilometerzähler");
}
private static TravelBugConnector getConnector() {
@@ -40,13 +42,13 @@ public class TravelBugConnectorTest extends TestCase {
}
public static void testGetTrackableCodeFromUrl() throws Exception {
- assertEquals("TB1234", TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://coord.info/TB1234"));
- assertEquals("TB1234", TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://www.coord.info/TB1234"));
- assertEquals("TB1234", TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://geocaching.com/track/details.aspx?tracker=TB1234"));
- assertEquals("TB1234", TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://www.geocaching.com/track/details.aspx?tracker=TB1234"));
+ assertThat(TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://coord.info/TB1234")).isEqualTo("TB1234");
+ assertThat(TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://www.coord.info/TB1234")).isEqualTo("TB1234");
+ assertThat(TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://geocaching.com/track/details.aspx?tracker=TB1234")).isEqualTo("TB1234");
+ assertThat(TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://www.geocaching.com/track/details.aspx?tracker=TB1234")).isEqualTo("TB1234");
// do not match coord.info URLs of caches
- assertNull(TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://coord.info/GC1234"));
- assertNull(TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://www.coord.info/GC1234"));
+ assertThat(TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://coord.info/GC1234")).isNull();
+ assertThat(TravelBugConnector.getInstance().getTrackableCodeFromUrl("http://www.coord.info/GC1234")).isNull();
}
}
diff --git a/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java
index d126c0b..a8a9ced 100644
--- a/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.enumerations;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.test.AndroidTestCase;
public class CacheAttributeTest extends AndroidTestCase {
@@ -7,18 +9,18 @@ public class CacheAttributeTest extends AndroidTestCase {
public static void testTrimAttributeName() {
for (CacheAttribute attribute : CacheAttribute.values()) {
final String rawName = attribute.rawName;
- assertTrue("bad attribute name " + rawName, CacheAttribute.trimAttributeName(rawName).equals(rawName));
+ assertThat(CacheAttribute.trimAttributeName(rawName)).as("attribute name").isEqualTo(rawName);
}
}
public static void testIds() {
for (CacheAttribute attribute : CacheAttribute.values()) {
if (attribute != CacheAttribute.UNKNOWN) {
- assertTrue(attribute.rawName != null);
- assertTrue(attribute.rawName.length() > 0);
- assertTrue(attribute.drawableId != 0);
- assertTrue(attribute.stringIdYes != 0);
- assertTrue(attribute.stringIdNo != 0);
+ assertThat(attribute.rawName != null).isTrue();
+ assertThat(attribute.rawName.length() > 0).isTrue();
+ assertThat(attribute.drawableId != 0).isTrue();
+ assertThat(attribute.stringIdYes != 0).isTrue();
+ assertThat(attribute.stringIdNo != 0).isTrue();
}
}
}
@@ -34,18 +36,18 @@ public class CacheAttributeTest extends AndroidTestCase {
public static void testGetBy() {
final CacheAttribute attribute = CacheAttribute.HIKING; // an attribute that is present in GC and OC
- assertTrue("Test cannot be run with this attribute", attribute.gcid >= 0);
- assertTrue("Test cannot be run with this attribute", attribute.ocacode >= 0);
- assertSame(CacheAttribute.getByRawName(attribute.rawName), attribute);
- assertSame(CacheAttribute.getByOcACode(attribute.ocacode), attribute);
+ assertThat(attribute.gcid).overridingErrorMessage("Test cannot be run with this attribute").isGreaterThanOrEqualTo(0);
+ assertThat(attribute.ocacode).overridingErrorMessage("Test cannot be run with this attribute").isGreaterThanOrEqualTo(0);
+ assertThat(attribute).isSameAs(CacheAttribute.getByRawName(attribute.rawName));
+ assertThat(attribute).isSameAs(CacheAttribute.getByOcACode(attribute.ocacode));
}
public static void testIsEnabled() {
final CacheAttribute attribute = CacheAttribute.HIKING;
final String hiking_yes = attribute.getAttributeName(true);
final String hiking_no = attribute.getAttributeName(false);
- assertTrue(CacheAttribute.isEnabled(hiking_yes));
- assertFalse(CacheAttribute.isEnabled(hiking_no));
+ assertThat(CacheAttribute.isEnabled(hiking_yes)).isTrue();
+ assertThat(CacheAttribute.isEnabled(hiking_no)).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
index 26a1953..6e02b85 100644
--- a/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.enumerations;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.test.AndroidTestCase;
import java.util.Locale;
@@ -7,29 +9,29 @@ import java.util.Locale;
public class CacheSizeTest extends AndroidTestCase {
public static void testOrder() {
- assertTrue(CacheSize.MICRO.comparable < CacheSize.SMALL.comparable);
- assertTrue(CacheSize.SMALL.comparable < CacheSize.REGULAR.comparable);
- assertTrue(CacheSize.REGULAR.comparable < CacheSize.LARGE.comparable);
+ assertThat(CacheSize.MICRO.comparable < CacheSize.SMALL.comparable).isTrue();
+ assertThat(CacheSize.SMALL.comparable < CacheSize.REGULAR.comparable).isTrue();
+ assertThat(CacheSize.REGULAR.comparable < CacheSize.LARGE.comparable).isTrue();
}
public static void testGetById() {
- assertEquals(CacheSize.UNKNOWN, CacheSize.getById(""));
- assertEquals(CacheSize.UNKNOWN, CacheSize.getById(null));
- assertEquals(CacheSize.UNKNOWN, CacheSize.getById("random garbage"));
- assertEquals(CacheSize.LARGE, CacheSize.getById("large"));
- assertEquals(CacheSize.LARGE, CacheSize.getById("LARGE"));
+ assertThat(CacheSize.getById("")).isEqualTo(CacheSize.UNKNOWN);
+ assertThat(CacheSize.getById(null)).isEqualTo(CacheSize.UNKNOWN);
+ assertThat(CacheSize.getById("random garbage")).isEqualTo(CacheSize.UNKNOWN);
+ assertThat(CacheSize.getById("large")).isEqualTo(CacheSize.LARGE);
+ assertThat(CacheSize.getById("LARGE")).isEqualTo(CacheSize.LARGE);
}
public static void testGetByIdComplete() {
for (CacheSize size : CacheSize.values()) {
- assertEquals(size, CacheSize.getById(size.id));
- assertEquals(size, CacheSize.getById(size.id.toLowerCase(Locale.US)));
- assertEquals(size, CacheSize.getById(size.id.toUpperCase(Locale.US)));
+ assertThat(CacheSize.getById(size.id)).isEqualTo(size);
+ assertThat(CacheSize.getById(size.id.toLowerCase(Locale.US))).isEqualTo(size);
+ assertThat(CacheSize.getById(size.id.toUpperCase(Locale.US))).isEqualTo(size);
}
}
public static void testGetByIdNumeric() {
- assertEquals(CacheSize.REGULAR, CacheSize.getById("3"));
- assertEquals(CacheSize.UNKNOWN, CacheSize.getById("-1"));
+ assertThat(CacheSize.getById("3")).isEqualTo(CacheSize.REGULAR);
+ assertThat(CacheSize.getById("-1")).isEqualTo(CacheSize.UNKNOWN);
}
}
diff --git a/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java
index 96796f2..ce42e0c 100644
--- a/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.enumerations;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import android.test.AndroidTestCase;
@@ -9,32 +11,32 @@ import java.util.Locale;
public class CacheTypeTest extends AndroidTestCase {
public static void testGetById() {
- assertEquals(CacheType.UNKNOWN, CacheType.getById(""));
- assertEquals(CacheType.UNKNOWN, CacheType.getById(null));
- assertEquals(CacheType.UNKNOWN, CacheType.getById("random garbage"));
- assertEquals(CacheType.WHERIGO, CacheType.getById("wherigo"));
+ assertThat(CacheType.getById("")).isEqualTo(CacheType.UNKNOWN);
+ assertThat(CacheType.getById(null)).isEqualTo(CacheType.UNKNOWN);
+ assertThat(CacheType.getById("random garbage")).isEqualTo(CacheType.UNKNOWN);
+ assertThat(CacheType.getById("wherigo")).isEqualTo(CacheType.WHERIGO);
}
public static void testGetByPattern() {
- assertEquals(CacheType.UNKNOWN, CacheType.getByPattern(""));
- assertEquals(CacheType.UNKNOWN, CacheType.getByPattern(null));
- assertEquals(CacheType.UNKNOWN, CacheType.getByPattern("random garbage"));
- assertEquals(CacheType.CITO, CacheType.getByPattern("cache in trash out event"));
+ assertThat(CacheType.getByPattern("")).isEqualTo(CacheType.UNKNOWN);
+ assertThat(CacheType.getByPattern(null)).isEqualTo(CacheType.UNKNOWN);
+ assertThat(CacheType.getByPattern("random garbage")).isEqualTo(CacheType.UNKNOWN);
+ assertThat(CacheType.getByPattern("cache in trash out event")).isEqualTo(CacheType.CITO);
}
public static void testGetByIdComplete() {
for (CacheType type : CacheType.values()) {
- assertEquals(type, CacheType.getById(type.id));
- assertEquals(type, CacheType.getById(type.id.toLowerCase(Locale.US)));
- assertEquals(type, CacheType.getById(type.id.toUpperCase(Locale.US)));
+ assertThat(CacheType.getById(type.id)).isEqualTo(type);
+ assertThat(CacheType.getById(type.id.toLowerCase(Locale.US))).isEqualTo(type);
+ assertThat(CacheType.getById(type.id.toUpperCase(Locale.US))).isEqualTo(type);
}
}
public static void testGetByPatternComplete() {
for (CacheType type : CacheType.values()) {
- assertEquals(type, CacheType.getByPattern(type.pattern));
- assertEquals(type, CacheType.getByPattern(type.pattern.toLowerCase(Locale.US)));
- assertEquals(type, CacheType.getByPattern(type.pattern.toUpperCase(Locale.US)));
+ assertThat(CacheType.getByPattern(type.pattern)).isEqualTo(type);
+ assertThat(CacheType.getByPattern(type.pattern.toLowerCase(Locale.US))).isEqualTo(type);
+ assertThat(CacheType.getByPattern(type.pattern.toUpperCase(Locale.US))).isEqualTo(type);
}
}
@@ -42,8 +44,8 @@ public class CacheTypeTest extends AndroidTestCase {
final Geocache traditional = new Geocache();
traditional.setType(CacheType.TRADITIONAL);
- assertTrue(CacheType.ALL.contains(traditional));
- assertTrue(CacheType.TRADITIONAL.contains(traditional));
- assertFalse(CacheType.MYSTERY.contains(traditional));
+ assertThat(CacheType.ALL.contains(traditional)).isTrue();
+ assertThat(CacheType.TRADITIONAL.contains(traditional)).isTrue();
+ assertThat(CacheType.MYSTERY.contains(traditional)).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java b/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java
index 47879a0..4c72a2a 100644
--- a/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java
@@ -1,25 +1,27 @@
package cgeo.geocaching.enumerations;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.test.AndroidTestCase;
public class LogTypeTest extends AndroidTestCase {
public static void testGetById() {
- assertEquals(LogType.UNKNOWN, LogType.getById(0));
- assertEquals(LogType.UNKNOWN, LogType.getById(4711));
- assertEquals(LogType.ENABLE_LISTING, LogType.getById(23));
+ assertThat(LogType.getById(0)).isEqualTo(LogType.UNKNOWN);
+ assertThat(LogType.getById(4711)).isEqualTo(LogType.UNKNOWN);
+ assertThat(LogType.getById(23)).isEqualTo(LogType.ENABLE_LISTING);
}
public static void testGetByIconName() {
- assertEquals(LogType.UNKNOWN, LogType.getByIconName(""));
- assertEquals(LogType.UNKNOWN, LogType.getByIconName(null));
- assertEquals(LogType.WEBCAM_PHOTO_TAKEN, LogType.getByIconName("11"));
+ assertThat(LogType.getByIconName("")).isEqualTo(LogType.UNKNOWN);
+ assertThat(LogType.getByIconName(null)).isEqualTo(LogType.UNKNOWN);
+ assertThat(LogType.getByIconName("11")).isEqualTo(LogType.WEBCAM_PHOTO_TAKEN);
}
public static void testGetByType() {
- assertEquals(LogType.UNKNOWN, LogType.getByType("obviously unknown type"));
- assertEquals(LogType.GRABBED_IT, LogType.getByType("grabbed it"));
- assertEquals(LogType.GRABBED_IT, LogType.getByType(" gRAbbed IT "));
+ assertThat(LogType.getByType("obviously unknown type")).isEqualTo(LogType.UNKNOWN);
+ assertThat(LogType.getByType("grabbed it")).isEqualTo(LogType.GRABBED_IT);
+ assertThat(LogType.getByType(" gRAbbed IT ")).isEqualTo(LogType.GRABBED_IT);
}
}
diff --git a/tests/src/cgeo/geocaching/enumerations/LogTypeTrackableTest.java b/tests/src/cgeo/geocaching/enumerations/LogTypeTrackableTest.java
index d6b7d33..76bd465 100644
--- a/tests/src/cgeo/geocaching/enumerations/LogTypeTrackableTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/LogTypeTrackableTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.enumerations;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.apache.commons.lang3.StringUtils;
import android.test.AndroidTestCase;
@@ -8,7 +10,7 @@ public class LogTypeTrackableTest extends AndroidTestCase {
public static void testFindById() {
for (LogTypeTrackable logTypeTrackable : LogTypeTrackable.values()) {
- assertTrue(StringUtils.isNotEmpty(logTypeTrackable.getLabel()));
+ assertThat(StringUtils.isNotEmpty(logTypeTrackable.getLabel())).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/enumerations/WaypointTypeTest.java b/tests/src/cgeo/geocaching/enumerations/WaypointTypeTest.java
index 6781a8e..cc4869b 100644
--- a/tests/src/cgeo/geocaching/enumerations/WaypointTypeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/WaypointTypeTest.java
@@ -1,11 +1,13 @@
package cgeo.geocaching.enumerations;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.test.AndroidTestCase;
public class WaypointTypeTest extends AndroidTestCase {
public static void testFindById() {
- assertEquals(WaypointType.WAYPOINT, WaypointType.findById("random garbage"));
+ assertThat(WaypointType.findById("random garbage")).isEqualTo(WaypointType.WAYPOINT);
}
}
diff --git a/tests/src/cgeo/geocaching/export/ExportTest.java b/tests/src/cgeo/geocaching/export/ExportTest.java
index b03c9bb..aeab90e 100644
--- a/tests/src/cgeo/geocaching/export/ExportTest.java
+++ b/tests/src/cgeo/geocaching/export/ExportTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.export;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.DataStore;
import cgeo.geocaching.Geocache;
@@ -42,7 +44,7 @@ public class ExportTest extends CGeoTestCase {
DataStore.removeCache(cache.getGeocode(), LoadFlags.REMOVE_ALL);
}
- assertNotNull(result);
+ assertThat(result).isNotNull();
FileUtils.deleteIgnoringFailure(result);
}
diff --git a/tests/src/cgeo/geocaching/export/GpxSerializerTest.java b/tests/src/cgeo/geocaching/export/GpxSerializerTest.java
index 9e3c3a4..f64796a 100644
--- a/tests/src/cgeo/geocaching/export/GpxSerializerTest.java
+++ b/tests/src/cgeo/geocaching/export/GpxSerializerTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.export;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import cgeo.geocaching.files.GPX10Parser;
import cgeo.geocaching.files.ParserException;
@@ -22,15 +24,14 @@ public class GpxSerializerTest extends AbstractResourceInstrumentationTestCase {
public static void testWriteEmptyGPX() throws Exception {
final StringWriter writer = new StringWriter();
new GpxSerializer().writeGPX(Collections.<String> emptyList(), writer, null);
- assertEquals("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>" +
+ assertThat(writer.getBuffer().toString()).isEqualTo("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>" +
"<gpx version=\"1.0\" creator=\"c:geo - http://www.cgeo.org/\" " +
"xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd " +
"http://www.groundspeak.com/cache/1/0 http://www.groundspeak.com/cache/1/0/1/cache.xsd " +
"http://www.gsak.net/xmlv1/4 http://www.gsak.net/xmlv1/4/gsak.xsd\" " +
"xmlns=\"http://www.topografix.com/GPX/1/0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:groundspeak=\"http://www.groundspeak.com/cache/1/0\" xmlns:gsak=\"http://www.gsak.net/xmlv1/4\" " +
- "xmlns:cgeo=\"http://www.cgeo.org/wptext/1/0\" />",
- writer.getBuffer().toString());
+ "xmlns:cgeo=\"http://www.cgeo.org/wptext/1/0\" />");
}
public void testProgressReporting() throws IOException, ParserException {
@@ -38,7 +39,7 @@ public class GpxSerializerTest extends AbstractResourceInstrumentationTestCase {
final StringWriter writer = new StringWriter();
Geocache cache = loadCacheFromResource(R.raw.gc1bkp3_gpx101);
- assertNotNull(cache);
+ assertThat(cache).isNotNull();
new GpxSerializer().writeGPX(Collections.singletonList("GC1BKP3"), writer, new GpxSerializer.ProgressListener() {
@@ -60,21 +61,21 @@ public class GpxSerializerTest extends AbstractResourceInstrumentationTestCase {
final String geocode = "GC1BKP3";
final int cacheResource = R.raw.gc1bkp3_gpx101;
final Geocache cache = loadCacheFromResource(cacheResource);
- assertNotNull(cache);
+ assertThat(cache).isNotNull();
final String gpxFirst = getGPXFromCache(geocode);
- assertTrue(gpxFirst.length() > 0);
+ assertThat(gpxFirst.length() > 0).isTrue();
final GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST_ID);
final InputStream stream = new ByteArrayInputStream(gpxFirst.getBytes(CharEncoding.UTF_8));
Collection<Geocache> caches = parser.parse(stream, null);
- assertNotNull(caches);
- assertEquals(1, caches.size());
+ assertThat(caches).isNotNull();
+ assertThat(caches).hasSize(1);
final String gpxSecond = getGPXFromCache(geocode);
- assertEquals(replaceLogIds(gpxFirst), replaceLogIds(gpxSecond));
+ assertThat(replaceLogIds(gpxSecond)).isEqualTo(replaceLogIds(gpxFirst));
}
private static String replaceLogIds(String gpx) {
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
index 6d7456c..02c997c 100644
--- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.files;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.DataStore;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.SearchResult;
@@ -46,16 +48,16 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
File gpx = new File(tempDir, gpxFileName);
File wpts = new File(tempDir, wptsFileName);
// the files need to exist - we create them
- assertTrue(gpx.createNewFile());
- assertTrue(wpts.createNewFile());
+ assertThat(gpx.createNewFile()).isTrue();
+ assertThat(wpts.createNewFile()).isTrue();
// the "real" method check
- assertEquals(wptsFileName, GPXImporter.getWaypointsFileNameForGpxFile(gpx));
+ assertThat(GPXImporter.getWaypointsFileNameForGpxFile(gpx)).isEqualTo(wptsFileName);
// they also need to be deleted, because of case sensitive tests that will not work correct on case insensitive file systems
FileUtils.deleteQuietly(gpx);
FileUtils.deleteQuietly(wpts);
}
final File gpx1 = new File(tempDir, "abc.gpx");
- assertNull(GPXImporter.getWaypointsFileNameForGpxFile(gpx1));
+ assertThat(GPXImporter.getWaypointsFileNameForGpxFile(gpx1)).isNull();
}
public void testImportGpx() throws IOException {
@@ -67,18 +69,18 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
final GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler);
runImportThread(importThread);
- assertEquals(4, importStepHandler.messages.size());
+ assertThat(importStepHandler.messages).hasSize(4);
final Iterator<Message> iMsg = importStepHandler.messages.iterator();
- assertEquals(GPXImporter.IMPORT_STEP_START, iMsg.next().what);
- assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, iMsg.next().what);
- assertEquals(GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, iMsg.next().what);
- assertEquals(GPXImporter.IMPORT_STEP_FINISHED, iMsg.next().what);
+ assertThat(iMsg.next().what).isEqualTo(GPXImporter.IMPORT_STEP_START);
+ assertThat(iMsg.next().what).isEqualTo(GPXImporter.IMPORT_STEP_READ_FILE);
+ assertThat(iMsg.next().what).isEqualTo(GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS);
+ assertThat(iMsg.next().what).isEqualTo(GPXImporter.IMPORT_STEP_FINISHED);
final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj;
- assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
+ assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode));
final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
- assertTrue(cache.getWaypoints().isEmpty());
+ assertThat(cache.getWaypoints().isEmpty()).isTrue();
}
public void testImportOcGpx() throws IOException {
@@ -90,18 +92,18 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
final GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(ocddd2, listId, importStepHandler, progressHandler);
runImportThread(importThread);
- assertEquals(4, importStepHandler.messages.size());
+ assertThat(importStepHandler.messages).hasSize(4);
final Iterator<Message> iMsg = importStepHandler.messages.iterator();
- assertEquals(GPXImporter.IMPORT_STEP_START, iMsg.next().what);
- assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, iMsg.next().what);
- assertEquals(GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, iMsg.next().what);
- assertEquals(GPXImporter.IMPORT_STEP_FINISHED, iMsg.next().what);
+ assertThat(iMsg.next().what).isEqualTo(GPXImporter.IMPORT_STEP_START);
+ assertThat(iMsg.next().what).isEqualTo(GPXImporter.IMPORT_STEP_READ_FILE);
+ assertThat(iMsg.next().what).isEqualTo(GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS);
+ assertThat(iMsg.next().what).isEqualTo(GPXImporter.IMPORT_STEP_FINISHED);
final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj;
- assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
+ assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode));
final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
- assertEquals("Incorrect number of waypoints imported", 4, cache.getWaypoints().size());
+ assertThat(cache.getWaypoints()).as("Number of imported waypoints").hasSize(4);
}
private void runImportThread(GPXImporter.ImportThread importThread) {
@@ -124,10 +126,10 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj;
- assertEquals(Collections.singletonList("GC31J2H"), new ArrayList<String>(search.getGeocodes()));
+ assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList("GC31J2H"));
final Geocache cache = DataStore.loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
- assertEquals(2, cache.getWaypoints().size());
+ assertThat(cache.getWaypoints()).hasSize(2);
}
public void testImportGpxWithLowercaseNames() throws IOException {
@@ -140,13 +142,13 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
final Geocache cache = DataStore.loadCache("AID1", LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
- assertEquals("First Aid Station #1", cache.getName());
+ assertThat(cache.getName()).isEqualTo("First Aid Station #1");
}
private void assertImportStepMessages(int... importSteps) {
- assertEquals(importSteps.length, importStepHandler.messages.size());
+ assertThat(importStepHandler.messages).hasSize(importSteps.length);
for (int i = 0; i < importSteps.length; i++) {
- assertEquals(importSteps[i], importStepHandler.messages.get(i).what);
+ assertThat(importStepHandler.messages.get(i).what).isEqualTo(importSteps[i]);
}
}
@@ -159,15 +161,15 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj;
- assertEquals(Collections.singletonList("OC5952"), new ArrayList<String>(search.getGeocodes()));
+ assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList("OC5952"));
final Geocache cache = DataStore.loadCache("OC5952", LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
}
private static void assertCacheProperties(Geocache cache) {
- assertNotNull(cache);
- assertFalse(cache.getLocation().startsWith(","));
- assertTrue(cache.isReliableLatLon());
+ assertThat(cache).isNotNull();
+ assertThat(cache.getLocation().startsWith(",")).isFalse();
+ assertThat(cache.isReliableLatLon()).isTrue();
}
public void testImportGpxError() throws IOException {
@@ -201,11 +203,11 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj;
- assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
+ assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode));
final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
- assertTrue(cache.getWaypoints().isEmpty());
+ assertThat(cache.getWaypoints().isEmpty()).isTrue();
}
public void testImportGpxZip() throws IOException {
@@ -219,10 +221,10 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj;
- assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
+ assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode));
final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
- assertEquals(1, cache.getWaypoints().size()); // this is the original pocket query result without test waypoint
+ assertThat(cache.getWaypoints()).hasSize(1); // this is the original pocket query result without test waypoint
}
public void testImportGpxZipErr() throws IOException {
@@ -245,10 +247,10 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj;
- assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
+ assertThat(new ArrayList<String>(search.getGeocodes())).isEqualTo(Collections.singletonList(geocode));
final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
- assertEquals(1, cache.getWaypoints().size()); // this is the original pocket query result without test waypoint
+ assertThat(cache.getWaypoints()).hasSize(1); // this is the original pocket query result without test waypoint
}
static class TestHandler extends CancellableHandler {
@@ -285,11 +287,11 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
super.setUp();
final String globalTempDir = System.getProperty("java.io.tmpdir");
- assertTrue("java.io.tmpdir is not defined", StringUtils.isNotBlank(globalTempDir));
+ assertThat(StringUtils.isNotBlank(globalTempDir)).overridingErrorMessage("java.io.tmpdir is not defined").isTrue();
tempDir = new File(globalTempDir, "cgeogpxesTest");
cgeo.geocaching.utils.FileUtils.mkdirs(tempDir);
- assertTrue("Could not create directory " + tempDir.getPath(), tempDir.exists());
+ assertThat(tempDir).overridingErrorMessage("Could not create directory %s", tempDir.getPath()).exists();
// workaround to get storage initialized
DataStore.getAllHistoryCachesCount();
listId = DataStore.createList("cgeogpxesTest");
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index 9297819..4cd0b6f 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.files;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.DataStore;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.LogEntry;
@@ -36,20 +38,20 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
private Geocache testGPXVersion(final int resourceId) throws IOException, ParserException {
final List<Geocache> caches = readGPX10(resourceId);
- assertNotNull(caches);
- assertEquals(1, caches.size());
+ assertThat(caches).isNotNull();
+ assertThat(caches).hasSize(1);
final Geocache cache = caches.get(0);
- assertEquals("GC1BKP3", cache.getGeocode());
- assertEquals("9946f030-a514-46d8-a050-a60e92fd2e1a", cache.getGuid());
- assertEquals(CacheType.TRADITIONAL, cache.getType());
- assertEquals(false, cache.isArchived());
- assertEquals(false, cache.isDisabled());
- assertEquals("Die Schatzinsel / treasure island", cache.getName());
- assertEquals("Die unbesiegbaren Geo - Geparden", cache.getOwnerDisplayName());
- assertEquals("Die unbesiegbaren Geo - Geparden", cache.getOwnerUserId());
- assertEquals(CacheSize.MICRO, cache.getSize());
- assertEquals(1.0f, cache.getDifficulty());
- assertEquals(5.0f, cache.getTerrain());
+ assertThat(cache.getGeocode()).isEqualTo("GC1BKP3");
+ assertThat(cache.getGuid()).isEqualTo("9946f030-a514-46d8-a050-a60e92fd2e1a");
+ assertThat(cache.getType()).isEqualTo(CacheType.TRADITIONAL);
+ assertThat(cache.isArchived()).isEqualTo(false);
+ assertThat(cache.isDisabled()).isEqualTo(false);
+ assertThat(cache.getName()).isEqualTo("Die Schatzinsel / treasure island");
+ assertThat(cache.getOwnerDisplayName()).isEqualTo("Die unbesiegbaren Geo - Geparden");
+ assertThat(cache.getOwnerUserId()).isEqualTo("Die unbesiegbaren Geo - Geparden");
+ 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());
@@ -58,47 +60,47 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
public void testGPXVersion101() throws IOException, ParserException {
final Geocache cache = testGPXVersion(R.raw.gc1bkp3_gpx101);
- assertNotNull(cache.getAttributes());
- assertEquals(10, cache.getAttributes().size());
+ assertThat(cache.getAttributes()).isNotNull();
+ assertThat(cache.getAttributes()).hasSize(10);
}
public void testOC() throws IOException, ParserException {
final List<Geocache> caches = readGPX10(R.raw.oc5952_gpx);
final Geocache cache = caches.get(0);
- assertEquals("OC5952", cache.getGeocode());
- assertEquals(CacheType.TRADITIONAL, cache.getType());
- assertEquals(false, cache.isArchived());
- assertEquals(false, cache.isDisabled());
- assertEquals("Die Schatzinsel / treasure island", cache.getName());
- assertEquals("Die unbesiegbaren Geo - Geparden", cache.getOwnerDisplayName());
- assertEquals("Die unbesiegbaren Geo - Geparden", cache.getOwnerUserId());
- assertEquals(CacheSize.SMALL, cache.getSize());
- assertEquals(1.0f, cache.getDifficulty());
- assertEquals(4.0f, cache.getTerrain());
+ assertThat(cache.getGeocode()).isEqualTo("OC5952");
+ assertThat(cache.getType()).isEqualTo(CacheType.TRADITIONAL);
+ assertThat(cache.isArchived()).isEqualTo(false);
+ assertThat(cache.isDisabled()).isEqualTo(false);
+ assertThat(cache.getName()).isEqualTo("Die Schatzinsel / treasure island");
+ assertThat(cache.getOwnerDisplayName()).isEqualTo("Die unbesiegbaren Geo - Geparden");
+ assertThat(cache.getOwnerUserId()).isEqualTo("Die unbesiegbaren Geo - Geparden");
+ 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());
- assertTrue(cache.isReliableLatLon());
+ assertThat(cache.isReliableLatLon()).isTrue();
}
public void testGc31j2h() throws IOException, ParserException {
removeCacheCompletely("GC31J2H");
final List<Geocache> caches = readGPX10(R.raw.gc31j2h);
- assertEquals(1, caches.size());
+ assertThat(caches).hasSize(1);
final Geocache cache = caches.get(0);
assertGc31j2h(cache);
- assertSame(cache, caches.get(0));
+ assertThat(caches.get(0)).isSameAs(cache);
// no waypoints without importing waypoint file
- assertEquals(0, cache.getWaypoints().size());
- assertTrue(cache.isReliableLatLon());
+ assertThat(cache.getWaypoints()).isEmpty();
+ assertThat(cache.isReliableLatLon()).isTrue();
}
public void testGc31j2hWpts() throws IOException, ParserException {
removeCacheCompletely("GC31J2H");
final List<Geocache> caches = readGPX10(R.raw.gc31j2h, R.raw.gc31j2h_wpts);
- assertEquals(1, caches.size());
+ assertThat(caches).hasSize(1);
final Geocache cache = caches.get(0);
assertGc31j2h(cache);
assertGc31j2hWaypoints(cache);
@@ -106,56 +108,56 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
public void testGc31j2hWptsWithoutCache() throws IOException, ParserException {
final List<Geocache> caches = readGPX10(R.raw.gc31j2h_wpts);
- assertEquals(0, caches.size());
+ assertThat(caches).isEmpty();
}
public static void testConvertWaypointSym2Type() {
- assertEquals(WaypointType.WAYPOINT, GPXParser.convertWaypointSym2Type("unknown sym"));
+ assertThat(GPXParser.convertWaypointSym2Type("unknown sym")).isEqualTo(WaypointType.WAYPOINT);
- assertEquals(WaypointType.PARKING, GPXParser.convertWaypointSym2Type("Parking area"));
- assertEquals(WaypointType.STAGE, GPXParser.convertWaypointSym2Type("Stages of a multicache"));
- assertEquals(WaypointType.PUZZLE, GPXParser.convertWaypointSym2Type("Question to answer"));
- assertEquals(WaypointType.TRAILHEAD, GPXParser.convertWaypointSym2Type("Trailhead"));
- assertEquals(WaypointType.FINAL, GPXParser.convertWaypointSym2Type("Final location"));
- assertEquals(WaypointType.WAYPOINT, GPXParser.convertWaypointSym2Type("Reference point"));
+ assertThat(GPXParser.convertWaypointSym2Type("Parking area")).isEqualTo(WaypointType.PARKING);
+ assertThat(GPXParser.convertWaypointSym2Type("Stages of a multicache")).isEqualTo(WaypointType.STAGE);
+ assertThat(GPXParser.convertWaypointSym2Type("Question to answer")).isEqualTo(WaypointType.PUZZLE);
+ assertThat(GPXParser.convertWaypointSym2Type("Trailhead")).isEqualTo(WaypointType.TRAILHEAD);
+ assertThat(GPXParser.convertWaypointSym2Type("Final location")).isEqualTo(WaypointType.FINAL);
+ assertThat(GPXParser.convertWaypointSym2Type("Reference point")).isEqualTo(WaypointType.WAYPOINT);
- assertEquals(WaypointType.PARKING, GPXParser.convertWaypointSym2Type(WaypointType.PARKING.getL10n()));
+ assertThat(GPXParser.convertWaypointSym2Type(WaypointType.PARKING.getL10n())).isEqualTo(WaypointType.PARKING);
}
private static void assertGc31j2h(final Geocache cache) {
- assertEquals("GC31J2H", cache.getGeocode());
- assertEquals("Hockenheimer City-Brunnen", cache.getName());
- assertTrue("Hockenheimer City-Brunnen by vptsz, Multi-cache (2/1)", cache.getShortDescription().startsWith("Kurzer informativer Multi entlang der Brunnen"));
- assertTrue(cache.getDescription().startsWith("Cachemobile können kostenfrei am Messplatz geparkt werden."));
- assertTrue(cache.hasTrackables());
+ assertThat(cache.getGeocode()).isEqualTo("GC31J2H");
+ assertThat(cache.getName()).isEqualTo("Hockenheimer City-Brunnen");
+ assertThat(cache.getShortDescription()).startsWith("Kurzer informativer Multi entlang der Brunnen");
+ assertThat(cache.getDescription()).startsWith("Cachemobile können kostenfrei am Messplatz geparkt werden.");
+ assertThat(cache.hasTrackables()).isTrue();
assertEquals(2.0f, cache.getDifficulty(), 0.01f);
assertEquals(1.0f, cache.getTerrain(), 0.01f);
final Geopoint refCoordinates = new Geopoint("N 49° 19.122", "E 008° 32.739");
- assertEquals(refCoordinates, cache.getCoords());
- assertEquals("vptsz", cache.getOwnerDisplayName());
- assertEquals("vptsz", cache.getOwnerUserId());
- assertEquals(CacheSize.SMALL, cache.getSize());
- assertEquals(CacheType.MULTI, cache.getType());
- assertFalse(cache.isArchived());
- assertFalse(cache.isDisabled());
- assertFalse(cache.isEventCache());
- assertFalse(cache.isPremiumMembersOnly());
- assertFalse(cache.isOwner());
- assertTrue(cache.isFound());
- assertEquals("Station3: Der zerbrochene Stein zählt doppelt.\nFinal: Oben neben dem Tor", cache.getHint());
+ assertThat(cache.getCoords()).isEqualTo(refCoordinates);
+ assertThat(cache.getOwnerDisplayName()).isEqualTo("vptsz");
+ assertThat(cache.getOwnerUserId()).isEqualTo("vptsz");
+ assertThat(cache.getSize()).isEqualTo(CacheSize.SMALL);
+ assertThat(cache.getType()).isEqualTo(CacheType.MULTI);
+ assertThat(cache.isArchived()).isFalse();
+ assertThat(cache.isDisabled()).isFalse();
+ assertThat(cache.isEventCache()).isFalse();
+ assertThat(cache.isPremiumMembersOnly()).isFalse();
+ assertThat(cache.isOwner()).isFalse();
+ assertThat(cache.isFound()).isTrue();
+ assertThat(cache.getHint()).isEqualTo("Station3: Der zerbrochene Stein zählt doppelt.\nFinal: Oben neben dem Tor");
// logs
- assertEquals(6, cache.getLogs().size());
+ assertThat(cache.getLogs()).hasSize(6);
final LogEntry log = cache.getLogs().get(5);
- assertEquals("Geoteufel", log.author);
- assertEquals(parseTime("2011-09-11T07:00:00Z"), log.date);
- assertEquals(-1, log.found);
+ 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);
- assertFalse(log.isOwn());
- assertEquals(log.log, log.getDisplayText());
- assertTrue(log.daysSinceLog() > 700);
+ assertThat(log.isOwn()).isFalse();
+ assertThat(log.getDisplayText()).isEqualTo(log.log);
+ assertThat(log.daysSinceLog() > 700).isTrue();
// following info is not contained in pocket query gpx file
- assertEquals(0, cache.getAttributes().size());
+ assertThat(cache.getAttributes()).isEmpty();
}
private static long parseTime(final String time) {
@@ -167,25 +169,25 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
}
private static void assertGc31j2hWaypoints(final Geocache cache) {
- assertNotNull(cache.getWaypoints());
- assertEquals(2, cache.getWaypoints().size());
+ assertThat(cache.getWaypoints()).isNotNull();
+ assertThat(cache.getWaypoints()).hasSize(2);
Waypoint wp = cache.getWaypoints().get(0);
- assertEquals("GC31J2H", wp.getGeocode());
- assertEquals("00", wp.getPrefix());
- assertEquals("---", wp.getLookup());
- assertEquals("Parkplatz", wp.getName());
- assertEquals("Kostenfreies Parken (je nach Parkreihe Parkscheibe erforderlich)", wp.getNote());
- assertEquals(WaypointType.PARKING, wp.getWaypointType());
+ assertThat(wp.getGeocode()).isEqualTo("GC31J2H");
+ assertThat(wp.getPrefix()).isEqualTo("00");
+ assertThat(wp.getLookup()).isEqualTo("---");
+ assertThat(wp.getName()).isEqualTo("Parkplatz");
+ assertThat(wp.getNote()).isEqualTo("Kostenfreies Parken (je nach Parkreihe Parkscheibe erforderlich)");
+ assertThat(wp.getWaypointType()).isEqualTo(WaypointType.PARKING);
assertEquals(49.317517, wp.getCoords().getLatitude(), 0.000001);
assertEquals(8.545083, wp.getCoords().getLongitude(), 0.000001);
wp = cache.getWaypoints().get(1);
- assertEquals("GC31J2H", wp.getGeocode());
- assertEquals("S1", wp.getPrefix());
- assertEquals("---", wp.getLookup());
- assertEquals("Station 1", wp.getName());
+ assertThat(wp.getGeocode()).isEqualTo("GC31J2H");
+ 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());
- assertEquals(WaypointType.STAGE, wp.getWaypointType());
+ assertThat(wp.getWaypointType()).isEqualTo(WaypointType.STAGE);
assertEquals(49.317500, wp.getCoords().getLatitude(), 0.000001);
assertEquals(8.545100, wp.getCoords().getLongitude(), 0.000001);
}
@@ -206,7 +208,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
final InputStream instream = getResourceStream(resourceId);
try {
Collection<Geocache> caches = parser.parse(instream, null);
- assertNotNull(caches);
+ assertThat(caches).isNotNull();
for (Geocache cache : caches) {
result.add(cache.getGeocode());
}
@@ -232,24 +234,24 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
public void testSelfmadeGPXWithoutGeocodes() throws Exception {
final List<Geocache> caches = readGPX11(R.raw.no_connector);
- assertEquals(13, caches.size());
+ assertThat(caches).hasSize(13);
}
public void testTexasChallenge2012() throws Exception {
final List<Geocache> caches = readGPX10(R.raw.challenge);
// previously these caches overwrote each other during parsing
- assertEquals(130, caches.size());
+ assertThat(caches).hasSize(130);
}
public void testGeoToad() throws Exception {
final List<Geocache> caches = readGPX10(R.raw.geotoad);
- assertEquals(2, caches.size());
+ assertThat(caches).hasSize(2);
final List<String> codes = new ArrayList<String>();
for (Geocache cache : caches) {
codes.add(cache.getGeocode());
}
- assertTrue(codes.contains("GC2KN6K"));
- assertTrue(codes.contains("GC1T3MK"));
+ assertThat(codes.contains("GC2KN6K")).isTrue();
+ assertThat(codes.contains("GC1T3MK")).isTrue();
}
public void testLazyLogLoading() throws IOException, ParserException {
@@ -257,14 +259,14 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
final String geocode = "GC31J2H";
removeCacheCompletely(geocode);
final List<Geocache> caches = readGPX10(R.raw.lazy);
- assertEquals(1, caches.size());
+ assertThat(caches).hasSize(1);
DataStore.removeAllFromCache();
// load only the minimum cache, it has several members missing
final Geocache minimalCache = DataStore.loadCache(geocode, EnumSet.of(LoadFlag.LOAD_DB_MINIMAL));
// now check that we load lazy members on demand
- assertFalse(minimalCache.getAttributes().isEmpty());
- assertFalse(minimalCache.getLogs().isEmpty());
+ assertThat(minimalCache.getAttributes().isEmpty()).isFalse();
+ assertThat(minimalCache.getLogs().isEmpty()).isFalse();
removeCacheCompletely(geocode);
}
@@ -275,27 +277,27 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
// first import
List<Geocache> caches = readGPX10(R.raw.lazy);
- assertEquals(1, caches.size());
- assertEquals(6, caches.get(0).getLogs().size());
+ assertThat(caches).hasSize(1);
+ assertThat(caches.get(0).getLogs()).hasSize(6);
// second import
caches = readGPX10(R.raw.lazy);
- assertEquals(1, caches.size());
- assertEquals(6, caches.get(0).getLogs().size());
+ assertThat(caches).hasSize(1);
+ assertThat(caches.get(0).getLogs()).hasSize(6);
removeCacheCompletely(geocode);
}
public void testWaymarking() throws Exception {
final List<Geocache> caches = readGPX10(R.raw.waymarking_gpx);
- assertEquals(1, caches.size());
+ assertThat(caches).hasSize(1);
final Geocache waymark = caches.get(0);
- assertNotNull(waymark);
- assertEquals("WM7BM7", waymark.getGeocode());
- assertEquals("Roman water pipe Kornwestheim", waymark.getName());
- assertTrue(StringUtils.isNotBlank(waymark.getUrl())); // connector must be able to create it
- assertEquals(CacheType.UNKNOWN, waymark.getType());
- assertEquals(CacheSize.UNKNOWN, waymark.getSize());
+ assertThat(waymark).isNotNull();
+ assertThat(waymark.getGeocode()).isEqualTo("WM7BM7");
+ assertThat(waymark.getName()).isEqualTo("Roman water pipe Kornwestheim");
+ assertThat(StringUtils.isNotBlank(waymark.getUrl())).isTrue(); // connector must be able to create it
+ assertThat(waymark.getType()).isEqualTo(CacheType.UNKNOWN);
+ assertThat(waymark.getSize()).isEqualTo(CacheSize.UNKNOWN);
}
/**
@@ -303,49 +305,49 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
*/
public void testGCTour() throws Exception {
final List<Geocache> caches = readGPX10(R.raw.gctour_gpx);
- assertEquals(54, caches.size());
+ assertThat(caches).hasSize(54);
}
public void testOX() throws IOException, ParserException {
final List<Geocache> caches = readGPX10(R.raw.ox1ry0y_gpx);
- assertEquals(1, caches.size());
+ assertThat(caches).hasSize(1);
final Geocache cache = caches.get(0);
- assertEquals("OX1RY0Y", cache.getGeocode());
- assertEquals(CacheType.TRADITIONAL, cache.getType());
- assertEquals(false, cache.isArchived());
- assertEquals(false, cache.isDisabled());
- assertEquals("Kornwestheim und die Römer", cache.getName());
- assertEquals("Thomas&Dani", cache.getOwnerDisplayName());
- assertEquals(CacheSize.SMALL, cache.getSize());
- assertEquals(1.5f, cache.getDifficulty());
- assertEquals(1.0f, cache.getTerrain());
- assertTrue(cache.getDescription().startsWith("Dieses sind die Reste einer in Kornwestheim gefundenen"));
+ assertThat(cache.getGeocode()).isEqualTo("OX1RY0Y");
+ assertThat(cache.getType()).isEqualTo(CacheType.TRADITIONAL);
+ assertThat(cache.isArchived()).isEqualTo(false);
+ assertThat(cache.isDisabled()).isEqualTo(false);
+ assertThat(cache.getName()).isEqualTo("Kornwestheim und die Römer");
+ assertThat(cache.getOwnerDisplayName()).isEqualTo("Thomas&Dani");
+ assertThat(cache.getSize()).isEqualTo(CacheSize.SMALL);
+ 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());
- assertTrue(cache.isReliableLatLon());
- assertEquals("Wasserleitung", cache.getHint());
+ assertThat(cache.isReliableLatLon()).isTrue();
+ assertThat(cache.getHint()).isEqualTo("Wasserleitung");
}
private Geocache getFirstCache(int gpxResourceId) throws IOException, ParserException {
final List<Geocache> caches = readGPX10(gpxResourceId);
- assertNotNull(caches);
- assertEquals(1, caches.size());
+ assertThat(caches).isNotNull();
+ assertThat(caches).hasSize(1);
final Geocache cache = caches.get(0);
return cache;
}
public void testGsakFavPoints() throws IOException, ParserException {
final Geocache cache = getFirstCache(R.raw.gc3t1xg_gsak);
- assertEquals(258, cache.getFavoritePoints());
+ assertThat(cache.getFavoritePoints()).isEqualTo(258);
}
public void testGsakPersonalNote() throws IOException, ParserException {
final Geocache cache = getFirstCache(R.raw.gc3t1xg_gsak);
- assertEquals("Personal Note Test", cache.getPersonalNote());
+ assertThat(cache.getPersonalNote()).isEqualTo("Personal Note Test");
}
public void testGsakPremium() throws IOException, ParserException {
final Geocache cache = getFirstCache(R.raw.gc3t1xg_gsak);
- assertTrue(cache.isPremiumMembersOnly());
+ assertThat(cache.isPremiumMembersOnly()).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/files/LocParserTest.java b/tests/src/cgeo/geocaching/files/LocParserTest.java
index 3039a1f..d87b593 100644
--- a/tests/src/cgeo/geocaching/files/LocParserTest.java
+++ b/tests/src/cgeo/geocaching/files/LocParserTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.files;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
@@ -20,8 +22,8 @@ public class LocParserTest extends AbstractResourceInstrumentationTestCase {
final InputStream instream = getResourceStream(resourceId);
try {
caches = parser.parse(instream, null);
- assertNotNull(caches);
- assertTrue(caches.size() > 0);
+ assertThat(caches).isNotNull();
+ assertThat(caches.size() > 0).isTrue();
} finally {
instream.close();
}
@@ -31,42 +33,42 @@ public class LocParserTest extends AbstractResourceInstrumentationTestCase {
public void testOCLoc() throws IOException, ParserException {
final List<Geocache> caches = readLoc(R.raw.oc5952_loc);
- assertEquals(1, caches.size());
+ assertThat(caches).hasSize(1);
final Geocache cache = caches.get(0);
- assertNotNull(cache);
- assertEquals("OC5952", cache.getGeocode());
- assertEquals("Die Schatzinsel / treasure island", cache.getName());
- assertEquals("Die unbesiegbaren Geo - Geparden", cache.getOwnerUserId());
+ assertThat(cache).isNotNull();
+ assertThat(cache.getGeocode()).isEqualTo("OC5952");
+ assertThat(cache.getName()).isEqualTo("Die Schatzinsel / treasure island");
+ assertThat(cache.getOwnerUserId()).isEqualTo("Die unbesiegbaren Geo - Geparden");
assertEquals(new Geopoint(48.85968, 9.18740), cache.getCoords());
}
public void testGCLoc() throws IOException, ParserException {
final List<Geocache> caches = readLoc(R.raw.gc1bkp3_loc);
- assertEquals(1, caches.size());
+ assertThat(caches).hasSize(1);
final Geocache cache = caches.get(0);
- assertNotNull(cache);
- assertEquals("GC1BKP3", cache.getGeocode());
- assertEquals("Die Schatzinsel / treasure island", cache.getName());
- assertEquals("Die unbesiegbaren Geo - Geparden", cache.getOwnerUserId());
+ assertThat(cache).isNotNull();
+ assertThat(cache.getGeocode()).isEqualTo("GC1BKP3");
+ assertThat(cache.getName()).isEqualTo("Die Schatzinsel / treasure island");
+ assertThat(cache.getOwnerUserId()).isEqualTo("Die unbesiegbaren Geo - Geparden");
assertEquals(new Geopoint(48.859683, 9.1874), cache.getCoords());
- assertEquals(1.0f, cache.getDifficulty());
- assertEquals(5.0f, cache.getTerrain());
- assertEquals(CacheSize.MICRO, cache.getSize());
+ assertThat(cache.getDifficulty()).isEqualTo(1.0f);
+ assertThat(cache.getTerrain()).isEqualTo(5.0f);
+ assertThat(cache.getSize()).isEqualTo(CacheSize.MICRO);
}
public void testWaymarkingLoc() throws IOException, ParserException {
final List<Geocache> waymarks = readLoc(R.raw.waymarking_loc);
- assertEquals(1, waymarks.size());
+ assertThat(waymarks).hasSize(1);
final Geocache waymark = waymarks.get(0);
- assertNotNull(waymark);
- assertEquals("WM7BK7", waymark.getGeocode());
- assertEquals("Römerstrasse Kornwestheim", waymark.getName());
- assertEquals("travelling", waymark.getOwnerUserId());
+ assertThat(waymark).isNotNull();
+ assertThat(waymark.getGeocode()).isEqualTo("WM7BK7");
+ assertThat(waymark.getName()).isEqualTo("Römerstrasse Kornwestheim");
+ assertThat(waymark.getOwnerUserId()).isEqualTo("travelling");
assertEquals(new Geopoint(48.856733, 9.197683), waymark.getCoords());
// links are not yet stored for single caches
- // assertEquals("http://www.waymarking.com/waymarks/WM7BK7_Rmerstrasse_Kornwestheim", waymark.getUrl());
- assertEquals(CacheSize.UNKNOWN, waymark.getSize());
- assertEquals(CacheType.UNKNOWN, waymark.getType());
+ // assertThat(waymark.getUrl()).isEqualTo("http://www.waymarking.com/waymarks/WM7BK7_Rmerstrasse_Kornwestheim");
+ assertThat(waymark.getSize()).isEqualTo(CacheSize.UNKNOWN);
+ assertThat(waymark.getType()).isEqualTo(CacheType.UNKNOWN);
}
}
diff --git a/tests/src/cgeo/geocaching/files/LocalStorageTest.java b/tests/src/cgeo/geocaching/files/LocalStorageTest.java
index 8405899..4142188 100644
--- a/tests/src/cgeo/geocaching/files/LocalStorageTest.java
+++ b/tests/src/cgeo/geocaching/files/LocalStorageTest.java
@@ -1,18 +1,16 @@
package cgeo.geocaching.files;
-import cgeo.geocaching.files.LocalStorage;
+import static org.assertj.core.api.Assertions.assertThat;
import android.test.AndroidTestCase;
-import junit.framework.Assert;
-
public class LocalStorageTest extends AndroidTestCase {
public static void testGetExtension() {
- Assert.assertEquals("", LocalStorage.getExtension("foo/bar/xyzzy"));
- Assert.assertEquals(".jpg", LocalStorage.getExtension("foo/bar/xyzzy.jpg"));
- Assert.assertEquals(".jpeg", LocalStorage.getExtension("foo/bar/xyzzy.jpeg"));
- Assert.assertEquals("", LocalStorage.getExtension("foo/bar/xyzzy.mjpeg"));
+ assertThat(LocalStorage.getExtension("foo/bar/xyzzy")).isEqualTo("");
+ assertThat(LocalStorage.getExtension("foo/bar/xyzzy.jpg")).isEqualTo(".jpg");
+ assertThat(LocalStorage.getExtension("foo/bar/xyzzy.jpeg")).isEqualTo(".jpeg");
+ assertThat(LocalStorage.getExtension("foo/bar/xyzzy.mjpeg")).isEqualTo("");
}
}
diff --git a/tests/src/cgeo/geocaching/files/ProgressInputStreamTest.java b/tests/src/cgeo/geocaching/files/ProgressInputStreamTest.java
index e2ef2ba..a0aaa68 100644
--- a/tests/src/cgeo/geocaching/files/ProgressInputStreamTest.java
+++ b/tests/src/cgeo/geocaching/files/ProgressInputStreamTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.files;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.apache.commons.io.IOUtils;
import junit.framework.TestCase;
@@ -8,14 +10,14 @@ public class ProgressInputStreamTest extends TestCase {
public static void testRead() throws Exception {
ProgressInputStream stream = new ProgressInputStream(IOUtils.toInputStream("test"));
- assertEquals(0, stream.getProgress());
+ assertThat(stream.getProgress()).isEqualTo(0);
int bytesRead = 0;
while (stream.read() >= 0 && bytesRead < 10000) {
bytesRead++;
}
- assertEquals(4, bytesRead);
- assertEquals(4, stream.getProgress());
+ assertThat(bytesRead).isEqualTo(4);
+ assertThat(stream.getProgress()).isEqualTo(4);
IOUtils.closeQuietly(stream);
}
diff --git a/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java b/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
index 7607ad0..d8d099d 100644
--- a/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
+++ b/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.files;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Intents;
import com.robotium.solo.Solo;
@@ -47,8 +49,8 @@ public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<Sim
final int lastIndex = getCurrentCheckBoxes().size() - 1;
solo.clickOnCheckBox(lastIndex);
- assertTrue(solo.isCheckBoxChecked(lastIndex));
- assertFalse(solo.isCheckBoxChecked(0));
+ assertThat(solo.isCheckBoxChecked(lastIndex)).isTrue();
+ assertThat(solo.isCheckBoxChecked(0)).isFalse();
assertChecked("Clicked last checkbox", 1);
solo.scrollUp();
@@ -61,10 +63,10 @@ public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<Sim
pause();
solo.clickOnCheckBox(0);
assertChecked("Clicked first checkbox", 1);
- assertTrue(solo.isCheckBoxChecked(0));
+ assertThat(solo.isCheckBoxChecked(0)).isTrue();
solo.clickOnCheckBox(1);
assertChecked("Clicked second checkbox", 1);
- assertTrue(solo.isCheckBoxChecked(1));
+ assertThat(solo.isCheckBoxChecked(1)).isTrue();
}
private static void pause() throws InterruptedException {
@@ -73,8 +75,8 @@ public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<Sim
private void assertChecked(String message, int expectedChecked) {
final ArrayList<CheckBox> boxes = getCurrentCheckBoxes();
- assertNotNull("Could not get checkboxes", boxes);
- assertTrue("There are no checkboxes", boxes.size() > 1);
+ assertThat(boxes).as("Checkboxes").isNotNull();
+ assertThat(boxes.size()).as("number of checkboxes").isGreaterThan(1);
int checked = 0;
for (int i = 0; i < boxes.size(); i++) {
if (solo.isCheckBoxChecked(i)) {
diff --git a/tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java b/tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java
index ebe4cf6..58eeaa4 100644
--- a/tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
@@ -14,11 +16,11 @@ public class DifficultyFilterTest extends CGeoTestCase {
final DifficultyFilter easyFilter = new DifficultyFilter(1);
- assertTrue(easyFilter.accepts(easy));
- assertFalse(easyFilter.accepts(hard));
+ assertThat(easyFilter.accepts(easy)).isTrue();
+ assertThat(easyFilter.accepts(hard)).isFalse();
}
public static void testAllFilters() {
- assertTrue(new DifficultyFilter.Factory().getFilters().size() == 5); // difficulty ranges from 1 to 5
+ assertThat(new DifficultyFilter.Factory().getFilters().size() == 5).isTrue(); // difficulty ranges from 1 to 5
}
}
diff --git a/tests/src/cgeo/geocaching/filter/SizeFilterTest.java b/tests/src/cgeo/geocaching/filter/SizeFilterTest.java
index 8b909f3..38fcf53 100644
--- a/tests/src/cgeo/geocaching/filter/SizeFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/SizeFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.enumerations.CacheSize;
@@ -27,23 +29,23 @@ public class SizeFilterTest extends CGeoTestCase {
}
public void testAccepts() {
- assertTrue(microFilter.accepts(micro));
- assertFalse(microFilter.accepts(regular));
+ assertThat(microFilter.accepts(micro)).isTrue();
+ assertThat(microFilter.accepts(regular)).isFalse();
}
public static void testGetAllFilters() {
final int expectedSizes = CacheSize.values().length - 1; // hide "UNKNOWN"
- assertEquals(expectedSizes, new SizeFilter.Factory().getFilters().size());
+ assertThat(new SizeFilter.Factory().getFilters()).hasSize(expectedSizes);
}
public void testFilter() {
final ArrayList<Geocache> list = new ArrayList<Geocache>();
list.add(regular);
list.add(micro);
- assertEquals(2, list.size());
+ assertThat(list).hasSize(2);
microFilter.filter(list);
- assertEquals(1, list.size());
+ assertThat(list).hasSize(1);
}
}
diff --git a/tests/src/cgeo/geocaching/filter/StateArchivedFilterTest.java b/tests/src/cgeo/geocaching/filter/StateArchivedFilterTest.java
index 2d7f2d2..d474857 100644
--- a/tests/src/cgeo/geocaching/filter/StateArchivedFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/StateArchivedFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.filter.StateFilter.StateArchivedFilter;
@@ -20,8 +22,8 @@ public class StateArchivedFilterTest extends CGeoTestCase {
}
public void testAccepts() {
- assertTrue(archivedFilter.accepts(archivedCache));
- assertFalse(archivedFilter.accepts(new Geocache()));
+ assertThat(archivedFilter.accepts(archivedCache)).isTrue();
+ assertThat(archivedFilter.accepts(new Geocache())).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/filter/StateDisabledFilterTest.java b/tests/src/cgeo/geocaching/filter/StateDisabledFilterTest.java
index 6d50beb..71a1134 100644
--- a/tests/src/cgeo/geocaching/filter/StateDisabledFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/StateDisabledFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.filter.StateFilter.StateDisabledFilter;
@@ -19,8 +21,8 @@ public class StateDisabledFilterTest extends CGeoTestCase {
}
public void testAccepts() {
- assertTrue(disabledFilter.accepts(disabledCache));
- assertFalse(disabledFilter.accepts(new Geocache()));
+ assertThat(disabledFilter.accepts(disabledCache)).isTrue();
+ assertThat(disabledFilter.accepts(new Geocache())).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/filter/StateFoundFilterTest.java b/tests/src/cgeo/geocaching/filter/StateFoundFilterTest.java
index c02794c..e763881 100644
--- a/tests/src/cgeo/geocaching/filter/StateFoundFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/StateFoundFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.filter.StateFilter.StateFoundFilter;
@@ -19,8 +21,8 @@ public class StateFoundFilterTest extends CGeoTestCase {
}
public void testAccepts() {
- assertTrue(foundFilter.accepts(foundCache));
- assertFalse(foundFilter.accepts(new Geocache()));
+ assertThat(foundFilter.accepts(foundCache)).isTrue();
+ assertThat(foundFilter.accepts(new Geocache())).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/filter/StateNonPremiumFilterTest.java b/tests/src/cgeo/geocaching/filter/StateNonPremiumFilterTest.java
index 3c36c0d..c698e8b 100644
--- a/tests/src/cgeo/geocaching/filter/StateNonPremiumFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/StateNonPremiumFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.filter.StateFilter.StateNonPremiumFilter;
@@ -19,8 +21,8 @@ public class StateNonPremiumFilterTest extends CGeoTestCase {
}
public void testAccepts() {
- assertFalse(nonPremiumFilter.accepts(premiumCache));
- assertTrue(nonPremiumFilter.accepts(new Geocache()));
+ assertThat(nonPremiumFilter.accepts(premiumCache)).isFalse();
+ assertThat(nonPremiumFilter.accepts(new Geocache())).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/filter/StatePremiumFilterTest.java b/tests/src/cgeo/geocaching/filter/StatePremiumFilterTest.java
index 744ebb9..ac8682b 100644
--- a/tests/src/cgeo/geocaching/filter/StatePremiumFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/StatePremiumFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.filter.StateFilter.StatePremiumFilter;
@@ -19,8 +21,8 @@ public class StatePremiumFilterTest extends CGeoTestCase {
}
public void testAccepts() {
- assertTrue(premiumFilter.accepts(premiumCache));
- assertFalse(premiumFilter.accepts(new Geocache()));
+ assertThat(premiumFilter.accepts(premiumCache)).isTrue();
+ assertThat(premiumFilter.accepts(new Geocache())).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/filter/StateStoredFilterTest.java b/tests/src/cgeo/geocaching/filter/StateStoredFilterTest.java
index 2f65a6b..d110921 100644
--- a/tests/src/cgeo/geocaching/filter/StateStoredFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/StateStoredFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.filter.StateFilter.StateNotStoredFilter;
@@ -20,8 +22,8 @@ public class StateStoredFilterTest extends CGeoTestCase {
}
public void testAccepts() {
- assertFalse(storedFilter.accepts(cache));
- assertTrue(notStoredFilter.accepts(cache));
+ assertThat(storedFilter.accepts(cache)).isFalse();
+ assertThat(notStoredFilter.accepts(cache)).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java b/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java
index 78bd14d..59ad8db 100644
--- a/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
@@ -14,11 +16,11 @@ public class TerrainFilterTest extends CGeoTestCase {
final AbstractRangeFilter easyFilter = new TerrainFilter(1);
- assertTrue(easyFilter.accepts(easy));
- assertFalse(easyFilter.accepts(hard));
+ assertThat(easyFilter.accepts(easy)).isTrue();
+ assertThat(easyFilter.accepts(hard)).isFalse();
}
public static void testAllFilters() {
- assertTrue(new TerrainFilter.Factory().getFilters().size() == 7); // terrain ranges from 1 to 7 (due to ExtremCaching.com using that value)
+ assertThat(new TerrainFilter.Factory().getFilters().size() == 7); // terrain ranges from 1 to 7 (due to ExtremCaching.com using that value).isTrue()
}
}
diff --git a/tests/src/cgeo/geocaching/filter/TypeFilterTest.java b/tests/src/cgeo/geocaching/filter/TypeFilterTest.java
index e813052..03519ec 100644
--- a/tests/src/cgeo/geocaching/filter/TypeFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/TypeFilterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.filter;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.enumerations.CacheType;
@@ -25,28 +27,28 @@ public class TypeFilterTest extends CGeoTestCase {
}
public void testAccepts() {
- assertTrue(traditionalFilter.accepts(traditional));
- assertFalse(traditionalFilter.accepts(mystery));
+ assertThat(traditionalFilter.accepts(traditional)).isTrue();
+ assertThat(traditionalFilter.accepts(mystery)).isFalse();
}
public void testFilter() {
final ArrayList<Geocache> list = new ArrayList<Geocache>();
traditionalFilter.filter(list);
- assertEquals(0, list.size());
+ assertThat(list).isEmpty();
list.add(traditional);
list.add(mystery);
- assertEquals(2, list.size());
+ assertThat(list).hasSize(2);
traditionalFilter.filter(list);
- assertEquals(1, list.size());
- assertTrue(list.contains(traditional));
+ assertThat(list).hasSize(1);
+ assertThat(list.contains(traditional)).isTrue();
}
public static void testGetAllFilters() {
final int expectedEntries = CacheType.values().length - 1; // hide "all"
- assertEquals(expectedEntries, new TypeFilter.Factory().getFilters().size());
+ assertThat(new TypeFilter.Factory().getFilters()).hasSize(expectedEntries);
}
}
diff --git a/tests/src/cgeo/geocaching/geopoint/DistanceParserTest.java b/tests/src/cgeo/geocaching/geopoint/DistanceParserTest.java
index a549cf1..621d268 100644
--- a/tests/src/cgeo/geocaching/geopoint/DistanceParserTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/DistanceParserTest.java
@@ -2,31 +2,29 @@ package cgeo.geocaching.geopoint;
import android.test.AndroidTestCase;
-import junit.framework.Assert;
-
public class DistanceParserTest extends AndroidTestCase {
static private final double MM = 1e-6; // 1mm, in kilometers
public static void testFormats() {
- Assert.assertEquals(1.2, DistanceParser.parseDistance("1200 m", true), MM);
- Assert.assertEquals(1.2, DistanceParser.parseDistance("1.2 km", true), MM);
- Assert.assertEquals(0.36576, DistanceParser.parseDistance("1200 ft", true), MM);
- Assert.assertEquals(1.09728, DistanceParser.parseDistance("1200 yd", true), MM);
- Assert.assertEquals(1.9312128, DistanceParser.parseDistance("1.2 mi", true), MM);
+ assertEquals(1.2, DistanceParser.parseDistance("1200 m", true), MM);
+ assertEquals(1.2, DistanceParser.parseDistance("1.2 km", true), MM);
+ assertEquals(0.36576, DistanceParser.parseDistance("1200 ft", true), MM);
+ assertEquals(1.09728, DistanceParser.parseDistance("1200 yd", true), MM);
+ assertEquals(1.9312128, DistanceParser.parseDistance("1.2 mi", true), MM);
}
public static void testImplicit() {
- Assert.assertEquals(1.2, DistanceParser.parseDistance("1200", true), MM);
- Assert.assertEquals(0.36576, DistanceParser.parseDistance("1200", false), MM);
+ assertEquals(1.2, DistanceParser.parseDistance("1200", true), MM);
+ assertEquals(0.36576, DistanceParser.parseDistance("1200", false), MM);
}
public static void testComma() {
- Assert.assertEquals(1.2, DistanceParser.parseDistance("1,2km", true), MM);
+ assertEquals(1.2, DistanceParser.parseDistance("1,2km", true), MM);
}
public static void testCase() {
- Assert.assertEquals(0.36576, DistanceParser.parseDistance("1200 FT", true), MM);
+ assertEquals(0.36576, DistanceParser.parseDistance("1200 FT", true), MM);
}
} \ No newline at end of file
diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java
index a1be25d..4b25247 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.geopoint;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.ui.Formatter;
import android.test.AndroidTestCase;
@@ -12,7 +14,7 @@ public class GeoPointFormatterTest extends AndroidTestCase {
final String format = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECDEGREE_COMMA, point);
assertEquals("50.000000,5.000000", format);
final String formatMinute = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECMINUTE_RAW, point);
- assertEquals("N 50° 00.000 E 005° 00.000", formatMinute);
+ assertThat(formatMinute).isEqualTo("N 50° 00.000 E 005° 00.000");
final String formatSecond = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECSECOND, point).replaceAll(",", ".");
assertEquals(formatSecond, "N 50° 00' 00.000\"" + Formatter.SEPARATOR + "E 005° 00' 00.000\"", formatSecond);
}
diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
index 1a24609..3e5667b 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.geopoint;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.ui.Formatter;
import android.test.AndroidTestCase;
@@ -23,9 +25,9 @@ public class GeoPointParserTest extends AndroidTestCase {
}
private static void assertEquals(final Geopoint expected, Geopoint actual, double tolerance) {
- assertNotNull(expected);
- assertNotNull(actual);
- assertTrue(expected.distanceTo(actual) <= tolerance);
+ assertThat(expected).isNotNull();
+ assertThat(actual).isNotNull();
+ assertThat(expected.distanceTo(actual) <= tolerance).isTrue();
}
public static void testCoordinateMissingPart() {
@@ -36,7 +38,7 @@ public class GeoPointParserTest extends AndroidTestCase {
} catch (Geopoint.ParseException e) {
// expected
}
- assertNull(point);
+ assertThat(point).isNull();
}
public static void testSouth() {
@@ -66,9 +68,9 @@ public class GeoPointParserTest extends AndroidTestCase {
public static void testInSentence() {
final Geopoint p1 = GeopointParser.parse("Station3: N51 21.523 / E07 02.680");
final Geopoint p2 = GeopointParser.parse("N51 21.523 E07 02.680");
- assertNotNull(p1);
- assertNotNull(p2);
- assertEquals(p1, p2);
+ assertThat(p1).isNotNull();
+ assertThat(p2).isNotNull();
+ assertThat(p2).isEqualTo(p1);
}
public static void testUnrelatedParts() {
@@ -78,7 +80,7 @@ public class GeoPointParserTest extends AndroidTestCase {
} catch (Geopoint.ParseException e) {
// expected
}
- assertNull(point);
+ assertThat(point).isNull();
}
public static void testComma() {
@@ -86,9 +88,9 @@ public class GeoPointParserTest extends AndroidTestCase {
"E 15° 53' 41,68''");
final Geopoint pointDot = GeopointParser.parse("N 46° 27' 55.65''\n" +
"E 15° 53' 41.68''");
- assertNotNull(pointComma);
- assertNotNull(pointDot);
- assertEquals(pointComma, pointDot);
+ assertThat(pointComma).isNotNull();
+ assertThat(pointDot).isNotNull();
+ assertThat(pointDot).isEqualTo(pointComma);
}
public static void testBlankAddedByAutocorrectionDot() {
@@ -112,6 +114,6 @@ public class GeoPointParserTest extends AndroidTestCase {
}
public static void testEquatorMeridian() {
- assertEquals(Geopoint.ZERO, GeopointParser.parse("00° 00.000 00° 00.000"));
+ assertThat(GeopointParser.parse("00° 00.000 00° 00.000")).isEqualTo(Geopoint.ZERO);
}
}
diff --git a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
index 9e65a02..5db877a 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
@@ -1,48 +1,49 @@
package cgeo.geocaching.geopoint;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.offset;
+
import android.os.Build;
import android.os.Bundle;
import android.test.AndroidTestCase;
-import junit.framework.Assert;
-
public class GeopointTest extends AndroidTestCase {
public static void testCreation() {
final Geopoint gp = new Geopoint(48.2, 3.5);
- Assert.assertEquals(48.2, gp.getLatitude(), 1e-8);
- Assert.assertEquals(3.5, gp.getLongitude(), 1e-8);
+ assertThat(gp.getLatitude()).isEqualTo(48.2, offset(1e-8));
+ assertThat(gp.getLongitude()).isEqualTo(3.5, offset(1e-8));
}
public static void testCreationWithParsing() {
final Geopoint gp = new Geopoint("N 52° 25,111 E 009° 39,111");
- Assert.assertEquals(52.41852, gp.getLatitude(), 1e-4);
- Assert.assertEquals(9.65185, gp.getLongitude(), 1e-4);
+ assertThat(gp.getLatitude()).isEqualTo(52.41852, offset(1e-4));
+ assertThat(gp.getLongitude()).isEqualTo(9.65185, offset(1e-4));
}
public static void testCreationAtLimit() {
// No exception should be raised.
final Geopoint gp1 = new Geopoint(90.0, 10.0);
- Assert.assertEquals(90, gp1.getLatitude(), 1e-8);
+ assertThat(gp1.getLatitude()).isEqualTo(90, offset(1e-8));
final Geopoint gp2 = new Geopoint(-90.0, 10.0);
- Assert.assertEquals(-90, gp2.getLatitude(), 1e-8);
+ assertThat(gp2.getLatitude()).isEqualTo(-90, offset(1e-8));
final Geopoint gp3 = new Geopoint(10.0, 180.0);
- Assert.assertEquals(180, gp3.getLongitude(), 1e-8);
+ assertThat(gp3.getLongitude()).isEqualTo(180, offset(1e-8));
}
public static void testEqual() {
final Geopoint gp1 = new Geopoint(48.2, 2.31);
- Assert.assertTrue(gp1.equals(gp1));
+ assertThat(gp1.equals(gp1)).isTrue();
final Geopoint gp2 = new Geopoint(48.3, 2.31);
- Assert.assertFalse(gp1.equals(gp2));
+ assertThat(gp1.equals(gp2)).isFalse();
}
public static void testGetE6() {
final Geopoint gp = new Geopoint(41.2, -3.4);
- Assert.assertEquals(41200000.0, gp.getLatitudeE6(), 1e-6);
- Assert.assertEquals(-3400000.0, gp.getLongitudeE6(), 1e-6);
+ assertThat((double) gp.getLatitudeE6()).isEqualTo(41200000.0, offset(1e-6));
+ assertThat((double) gp.getLongitudeE6()).isEqualTo(-3400000.0, offset(1e-6));
}
public static void testBearingDistance() {
@@ -53,18 +54,18 @@ public class GeopointTest extends AndroidTestCase {
// broken distance calculation in 4.2.1
if (Build.VERSION.SDK_INT == 17) {
- Assert.assertEquals(110.83107, d12, 1e-6);
+ assertThat((double) d12).isEqualTo(110.83107, offset(1e-6));
}
else {
- Assert.assertEquals(110.967995, d12, 1e-6);
+ assertThat((double) d12).isEqualTo(110.967995, offset(1e-6));
}
- Assert.assertEquals(d12, gp2.distanceTo(gp1), 1e-6);
+ assertThat((double) gp2.distanceTo(gp1)).isEqualTo(d12, offset(1e-6));
// Bearing in both directions cannot be added, as this is
// the initial bearing of the path in both cases.
- Assert.assertEquals(287.162, gp1.bearingTo(gp2), 1e-3);
- Assert.assertEquals(107.715, gp2.bearingTo(gp1), 1e-3);
+ assertThat((double) gp1.bearingTo(gp2)).isEqualTo(287.162, offset(1e-3));
+ assertThat((double) gp2.bearingTo(gp1)).isEqualTo(107.715, offset(1e-3));
}
public static void testParcelable() {
@@ -72,7 +73,7 @@ public class GeopointTest extends AndroidTestCase {
final String KEY = "geopoint";
final Bundle bundle = new Bundle();
bundle.putParcelable(KEY, gp);
- assertEquals(gp, bundle.getParcelable(KEY));
+ assertThat(bundle.getParcelable(KEY)).isEqualTo(gp);
}
public static void testDDD() {
@@ -84,7 +85,7 @@ public class GeopointTest extends AndroidTestCase {
final Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatDegFrac()),
String.valueOf(gp1.getLonDir()), String.valueOf(gp1.getLonDeg()), String.valueOf(gp1.getLonDegFrac()));
- Assert.assertTrue(gp1a.equals(gp1));
+ assertThat(gp1a).isEqualTo(gp1);
// case 2
final Geopoint gp2 = new Geopoint(51.34567d, 13.87654d);
@@ -94,7 +95,7 @@ public class GeopointTest extends AndroidTestCase {
final Geopoint gp2a = new Geopoint(String.valueOf(gp2.getLatDir()), String.valueOf(gp2.getLatDeg()), String.valueOf(gp2.getLatDegFrac()),
String.valueOf(gp2.getLonDir()), String.valueOf(gp2.getLonDeg()), String.valueOf(gp2.getLonDegFrac()));
- Assert.assertTrue(gp2a.equals(gp2));
+ assertThat(gp2a).isEqualTo(gp2);
// case 3
final Geopoint gp3 = new Geopoint(51.29999833333333d, 13.8d);
@@ -118,17 +119,17 @@ public class GeopointTest extends AndroidTestCase {
}
private static void checkDDD(Geopoint gp, char latDir, int latDeg, int latDegFrac, char lonDir, int lonDeg, int lonDegFrac) {
- Assert.assertEquals(latDir, gp.getLatDir());
- Assert.assertEquals(latDeg, gp.getLatDeg());
- Assert.assertEquals(latDegFrac, gp.getLatDegFrac());
- Assert.assertEquals(lonDir, gp.getLonDir());
- Assert.assertEquals(lonDeg, gp.getLonDeg());
- Assert.assertEquals(lonDegFrac, gp.getLonDegFrac());
+ assertThat(gp.getLatDir()).isEqualTo(latDir);
+ assertThat(gp.getLatDeg()).isEqualTo(latDeg);
+ assertThat(gp.getLatDegFrac()).isEqualTo(latDegFrac);
+ assertThat(gp.getLonDir()).isEqualTo(lonDir);
+ assertThat(gp.getLonDeg()).isEqualTo(lonDeg);
+ assertThat(gp.getLonDegFrac()).isEqualTo(lonDegFrac);
}
private static void checkTolerance(Geopoint gp1, Geopoint gp2, double tolerance) {
- Assert.assertTrue(Math.abs(gp1.getLatitude() - gp2.getLatitude()) <= tolerance);
- Assert.assertTrue(Math.abs(gp1.getLongitude() - gp2.getLongitude()) <= tolerance);
+ assertThat(Math.abs(gp1.getLatitude() - gp2.getLatitude()) <= tolerance).isTrue();
+ assertThat(Math.abs(gp1.getLongitude() - gp2.getLongitude()) <= tolerance).isTrue();
}
public static void testDMM() {
@@ -140,7 +141,7 @@ public class GeopointTest extends AndroidTestCase {
final Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatMin()), String.valueOf(gp1.getLatMinFrac()),
String.valueOf(gp1.getLonDir()), String.valueOf(gp1.getLonDeg()), String.valueOf(gp1.getLonMin()), String.valueOf(gp1.getLonMinFrac()));
- Assert.assertTrue(gp1a.equals(gp1));
+ assertThat(gp1a).isEqualTo(gp1);
// case 2
final Geopoint gp2 = new Geopoint(51.34567d, 13.87654d);
@@ -174,14 +175,14 @@ public class GeopointTest extends AndroidTestCase {
}
private static void checkDMM(Geopoint gp, char latDir, int latDeg, int latMin, int latMinFrac, char lonDir, int lonDeg, int lonMin, int lonMinFrac) {
- Assert.assertEquals(latDir, gp.getLatDir());
- Assert.assertEquals(latDeg, gp.getLatDeg());
- Assert.assertEquals(latMin, gp.getLatMin());
- Assert.assertEquals(latMinFrac, gp.getLatMinFrac());
- Assert.assertEquals(lonDir, gp.getLonDir());
- Assert.assertEquals(lonDeg, gp.getLonDeg());
- Assert.assertEquals(lonMin, gp.getLonMin());
- Assert.assertEquals(lonMinFrac, gp.getLonMinFrac());
+ assertThat(gp.getLatDir()).isEqualTo(latDir);
+ assertThat(gp.getLatDeg()).isEqualTo(latDeg);
+ assertThat(gp.getLatMin()).isEqualTo(latMin);
+ assertThat(gp.getLatMinFrac()).isEqualTo(latMinFrac);
+ assertThat(gp.getLonDir()).isEqualTo(lonDir);
+ assertThat(gp.getLonDeg()).isEqualTo(lonDeg);
+ assertThat(gp.getLonMin()).isEqualTo(lonMin);
+ assertThat(gp.getLonMinFrac()).isEqualTo(lonMinFrac);
}
public static void testDMS() {
@@ -193,7 +194,7 @@ public class GeopointTest extends AndroidTestCase {
final Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatMin()), String.valueOf(gp1.getLatSec()), String.valueOf(gp1.getLatSecFrac()),
String.valueOf(gp1.getLonDir()), String.valueOf(gp1.getLonDeg()), String.valueOf(gp1.getLonMin()), String.valueOf(gp1.getLonSec()), String.valueOf(gp1.getLonSecFrac()));
- Assert.assertTrue(gp1a.equals(gp1));
+ assertThat(gp1a).isEqualTo(gp1);
// case 2
final Geopoint gp2 = new Geopoint(51.34567d, 13.87654d);
@@ -227,22 +228,22 @@ public class GeopointTest extends AndroidTestCase {
}
private static void checkDMS(Geopoint gp, char latDir, int latDeg, int latMin, int latSec, int latSecFrac, char lonDir, int lonDeg, int lonMin, int lonSec, int lonSecFrac) {
- Assert.assertEquals(latDir, gp.getLatDir());
- Assert.assertEquals(latDeg, gp.getLatDeg());
- Assert.assertEquals(latMin, gp.getLatMin());
- Assert.assertEquals(latSec, gp.getLatSec());
- Assert.assertEquals(latSecFrac, gp.getLatSecFrac());
- Assert.assertEquals(lonDir, gp.getLonDir());
- Assert.assertEquals(lonDeg, gp.getLonDeg());
- Assert.assertEquals(lonMin, gp.getLonMin());
- Assert.assertEquals(lonSec, gp.getLonSec());
- Assert.assertEquals(lonSecFrac, gp.getLonSecFrac());
+ assertThat(gp.getLatDir()).isEqualTo(latDir);
+ assertThat(gp.getLatDeg()).isEqualTo(latDeg);
+ assertThat(gp.getLatMin()).isEqualTo(latMin);
+ assertThat(gp.getLatSec()).isEqualTo(latSec);
+ assertThat(gp.getLatSecFrac()).isEqualTo(latSecFrac);
+ assertThat(gp.getLonDir()).isEqualTo(lonDir);
+ assertThat(gp.getLonDeg()).isEqualTo(lonDeg);
+ assertThat(gp.getLonMin()).isEqualTo(lonMin);
+ assertThat(gp.getLonSec()).isEqualTo(lonSec);
+ assertThat(gp.getLonSecFrac()).isEqualTo(lonSecFrac);
}
private static void assertParseException(Runnable runnable) {
try {
runnable.run();
- Assert.fail("Should have thrown Geopoint.ParseException");
+ fail("Should have thrown Geopoint.ParseException");
} catch (Geopoint.ParseException e) {
//success
}
diff --git a/tests/src/cgeo/geocaching/geopoint/UnitsTest.java b/tests/src/cgeo/geocaching/geopoint/UnitsTest.java
index 52c5adf..acc964a 100644
--- a/tests/src/cgeo/geocaching/geopoint/UnitsTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/UnitsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.geopoint;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.CGeoTestCase;
import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.settings.TestSettings;
@@ -20,7 +22,7 @@ public class UnitsTest extends CGeoTestCase {
// Make method non-static so that Settings is initialized
@SuppressWarnings("static-method")
public void testDistance() {
- assertEquals("?", Units.getDistanceFromKilometers(null));
+ assertThat(Units.getDistanceFromKilometers(null)).isEqualTo("?");
final boolean savedImperial = Settings.isUseImperialUnits();
try {
TestSettings.setUseImperialUnits(false);
@@ -43,7 +45,7 @@ public class UnitsTest extends CGeoTestCase {
// Make method non-static so that Settings is initialized
@SuppressWarnings("static-method")
public void testSpeed() {
- assertEquals("?", Units.getDistanceFromKilometers(null));
+ assertThat(Units.getDistanceFromKilometers(null)).isEqualTo("?");
final boolean savedImperial = Settings.isUseImperialUnits();
try {
TestSettings.setUseImperialUnits(false);
diff --git a/tests/src/cgeo/geocaching/geopoint/ViewportTest.java b/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
index 11f78ad..ab59e79 100644
--- a/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.geopoint;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.ICoordinates;
import org.eclipse.jdt.annotation.NonNull;
@@ -38,66 +40,66 @@ public class ViewportTest extends AndroidTestCase {
}
public static void testMinMax() {
- assertEquals(-1.0, vpRef.getLatitudeMin());
- assertEquals(3.0, vpRef.getLatitudeMax());
- assertEquals(-2.0, vpRef.getLongitudeMin());
- assertEquals(4.0, vpRef.getLongitudeMax());
+ assertThat(vpRef.getLatitudeMin()).isEqualTo(-1.0);
+ assertThat(vpRef.getLatitudeMax()).isEqualTo(3.0);
+ assertThat(vpRef.getLongitudeMin()).isEqualTo(-2.0);
+ assertThat(vpRef.getLongitudeMax()).isEqualTo(4.0);
}
public static void testSpans() {
- assertEquals(4.0, vpRef.getLatitudeSpan());
- assertEquals(6.0, vpRef.getLongitudeSpan());
+ assertThat(vpRef.getLatitudeSpan()).isEqualTo(4.0);
+ assertThat(vpRef.getLongitudeSpan()).isEqualTo(6.0);
}
public static void testInViewport() {
- assertFalse(vpRef.contains(new Geopoint(-2.0, -2.0)));
- assertFalse(vpRef.contains(new Geopoint(4.0, 4.0)));
- assertTrue(vpRef.contains(Geopoint.ZERO));
- assertTrue(vpRef.contains(new Geopoint(-1.0, -2.0)));
- assertTrue(vpRef.contains(new Geopoint(3.0, 4.0)));
+ assertThat(vpRef.contains(new Geopoint(-2.0, -2.0))).isFalse();
+ assertThat(vpRef.contains(new Geopoint(4.0, 4.0))).isFalse();
+ assertThat(vpRef.contains(Geopoint.ZERO)).isTrue();
+ assertThat(vpRef.contains(new Geopoint(-1.0, -2.0))).isTrue();
+ assertThat(vpRef.contains(new Geopoint(3.0, 4.0))).isTrue();
}
public static void testSqlWhere() {
- assertEquals("latitude >= -1.0 and latitude <= 3.0 and longitude >= -2.0 and longitude <= 4.0", vpRef.sqlWhere(null).toString());
- assertEquals("t.latitude >= -1.0 and t.latitude <= 3.0 and t.longitude >= -2.0 and t.longitude <= 4.0", vpRef.sqlWhere("t").toString());
+ assertThat(vpRef.sqlWhere(null).toString()).isEqualTo("latitude >= -1.0 and latitude <= 3.0 and longitude >= -2.0 and longitude <= 4.0");
+ 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");
Locale current = null;
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
- assertEquals("t.latitude >= -1.0 and t.latitude <= 3.0 and t.longitude >= -2.0 and t.longitude <= 4.0", vpRef.sqlWhere("t").toString());
+ 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);
}
}
public static void testEquals() {
- assertEquals(vpRef, vpRef);
+ assertThat(vpRef).isEqualTo(vpRef);
assertEquals(vpRef, new Viewport(vpRef.bottomLeft, vpRef.topRight));
- assertFalse(vpRef.equals(new Viewport(new Geopoint(0.0, 0.0), 1.0, 1.0)));
+ assertThat(vpRef.equals(new Viewport(new Geopoint(0.0, 0.0), 1.0, 1.0))).isFalse();
}
public static void testResize() {
- assertEquals(vpRef, vpRef.resize(1.0));
+ assertThat(vpRef.resize(1.0)).isEqualTo(vpRef);
assertEquals(new Viewport(new Geopoint(-3.0, -5.0), new Geopoint(5.0, 7.0)), vpRef.resize(2.0));
assertEquals(new Viewport(new Geopoint(0.0, -0.5), new Geopoint(2.0, 2.5)), vpRef.resize(0.5));
}
public static void testIncludes() {
- assertTrue(vpRef.includes(vpRef));
- assertTrue(vpRef.includes(vpRef.resize(0.5)));
- assertFalse(vpRef.includes(vpRef.resize(2.0)));
+ assertThat(vpRef.includes(vpRef)).isTrue();
+ assertThat(vpRef.includes(vpRef.resize(0.5))).isTrue();
+ assertThat(vpRef.includes(vpRef.resize(2.0))).isFalse();
}
public static void testContaining() {
- assertNull(Viewport.containing(Collections.singleton((ICoordinates) null)));
+ assertThat(Viewport.containing(Collections.singleton((ICoordinates) null))).isNull();
final Set<Geopoint> points = new HashSet<Geopoint>();
points.add(vpRef.bottomLeft);
assertEquals(new Viewport(vpRef.bottomLeft, vpRef.bottomLeft), Viewport.containing(points));
points.add(vpRef.topRight);
- assertEquals(vpRef, Viewport.containing(points));
+ assertThat(Viewport.containing(points)).isEqualTo(vpRef);
points.add(vpRef.center);
- assertEquals(vpRef, Viewport.containing(points));
+ assertThat(Viewport.containing(points)).isEqualTo(vpRef);
}
}
diff --git a/tests/src/cgeo/geocaching/list/PseudoListTest.java b/tests/src/cgeo/geocaching/list/PseudoListTest.java
index 8a138ef..3dec694 100644
--- a/tests/src/cgeo/geocaching/list/PseudoListTest.java
+++ b/tests/src/cgeo/geocaching/list/PseudoListTest.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.list;
+import static org.assertj.core.api.Assertions.assertThat;
import junit.framework.TestCase;
public class PseudoListTest extends TestCase {
@@ -7,12 +8,12 @@ public class PseudoListTest extends TestCase {
public static void testGetTitleAndCount() throws Exception {
final String title = PseudoList.ALL_LIST.getTitleAndCount();
for (int i = 0; i < title.length(); i++) {
- assertFalse("pseudo lists shall not have a number shown in their title", Character.isDigit(title.charAt(i)));
+ assertThat(Character.isDigit(title.charAt(i))).overridingErrorMessage("pseudo lists shall not have a number shown in their title").isFalse();
}
}
public static void testIsConcrete() throws Exception {
- assertFalse("pseudo lists are not concrete lists", PseudoList.ALL_LIST.isConcrete());
+ assertThat(PseudoList.ALL_LIST.isConcrete()).overridingErrorMessage("pseudo lists are not concrete lists").isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/list/StoredListTest.java b/tests/src/cgeo/geocaching/list/StoredListTest.java
index bc4ebe4..50e4b5d 100644
--- a/tests/src/cgeo/geocaching/list/StoredListTest.java
+++ b/tests/src/cgeo/geocaching/list/StoredListTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.list;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.DataStore;
import junit.framework.TestCase;
@@ -8,7 +10,7 @@ public class StoredListTest extends TestCase {
public static void testStandardListExists() {
final StoredList list = getStandardList();
- assertNotNull(list);
+ assertThat(list).isNotNull();
}
private static StoredList getStandardList() {
@@ -18,14 +20,14 @@ public class StoredListTest extends TestCase {
public static void testEquals() {
final StoredList list1 = getStandardList();
final StoredList list2 = getStandardList();
- assertEquals(list1, list2);
+ assertThat(list2).isEqualTo(list1);
}
public static void testConcrete() {
- assertTrue(getStandardList().isConcrete());
+ assertThat(getStandardList().isConcrete()).isTrue();
}
public static void testTitleAndCountContainsTitle() {
- assertTrue(getStandardList().getTitleAndCount().startsWith(getStandardList().getTitle()));
+ assertThat(getStandardList().getTitleAndCount().startsWith(getStandardList().getTitle())).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/network/NetworkTest.java b/tests/src/cgeo/geocaching/network/NetworkTest.java
index 98179cc..93c7cbc 100644
--- a/tests/src/cgeo/geocaching/network/NetworkTest.java
+++ b/tests/src/cgeo/geocaching/network/NetworkTest.java
@@ -1,13 +1,14 @@
package cgeo.geocaching.network;
+import static org.assertj.core.api.Assertions.assertThat;
import junit.framework.TestCase;
public class NetworkTest extends TestCase {
public static void testRfc3986URLEncode() {
- assertEquals("*", Network.rfc3986URLEncode("*"));
- assertEquals("~", Network.rfc3986URLEncode("~"));
- assertEquals("%20", Network.rfc3986URLEncode(" "));
+ assertThat(Network.rfc3986URLEncode("*")).isEqualTo("*");
+ assertThat(Network.rfc3986URLEncode("~")).isEqualTo("~");
+ assertThat(Network.rfc3986URLEncode(" ")).isEqualTo("%20");
}
}
diff --git a/tests/src/cgeo/geocaching/network/OAuthTest.java b/tests/src/cgeo/geocaching/network/OAuthTest.java
index 6888cec..5e119e8 100644
--- a/tests/src/cgeo/geocaching/network/OAuthTest.java
+++ b/tests/src/cgeo/geocaching/network/OAuthTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.network;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.eclipse.jdt.annotation.NonNull;
import java.util.ArrayList;
@@ -41,13 +43,13 @@ public class OAuthTest extends TestCase {
final @NonNull
String charAsString = String.valueOf(c);
final String encoded = OAuth.percentEncode(charAsString);
- assertFalse("Character '" + charAsString + "' not encoded", charAsString.equals(encoded));
- assertTrue(encoded.startsWith("%"));
+ assertThat(charAsString).overridingErrorMessage("Character '" + charAsString + "' not encoded").isNotEqualTo(encoded);
+ assertThat(encoded).startsWith("%");
}
}
}
public static void testAsterisk() {
- assertFalse("*".equals(OAuth.percentEncode("*")));
+ assertThat("*".equals(OAuth.percentEncode("*"))).isFalse();
}
}
diff --git a/tests/src/cgeo/geocaching/network/ParametersTest.java b/tests/src/cgeo/geocaching/network/ParametersTest.java
index 4c56f05..8fff1f7 100644
--- a/tests/src/cgeo/geocaching/network/ParametersTest.java
+++ b/tests/src/cgeo/geocaching/network/ParametersTest.java
@@ -1,27 +1,25 @@
package cgeo.geocaching.network;
-import cgeo.geocaching.network.Parameters;
+import static org.assertj.core.api.Assertions.assertThat;
import android.test.AndroidTestCase;
import java.security.InvalidParameterException;
-import junit.framework.Assert;
-
public class ParametersTest extends AndroidTestCase {
public static void testException() {
try {
final Parameters params = new Parameters("aaa", "AAA", "bbb");
params.clear(); // this will never be invoked, but suppresses warnings about unused objects
- Assert.fail("Exception not raised");
+ fail("Exception not raised");
} catch (InvalidParameterException e) {
// Ok
}
try {
final Parameters params = new Parameters("aaa", "AAA");
params.put("bbb", "BBB", "ccc");
- Assert.fail("Exception not raised");
+ fail("Exception not raised");
} catch (InvalidParameterException e) {
// Ok
}
@@ -30,7 +28,7 @@ public class ParametersTest extends AndroidTestCase {
public static void testMultipleValues() {
final Parameters params = new Parameters("aaa", "AAA", "bbb", "BBB");
params.put("ccc", "CCC", "ddd", "DDD");
- Assert.assertEquals("aaa=AAA&bbb=BBB&ccc=CCC&ddd=DDD", params.toString());
+ assertThat(params.toString()).isEqualTo("aaa=AAA&bbb=BBB&ccc=CCC&ddd=DDD");
}
public static void testSort() {
@@ -38,16 +36,16 @@ public class ParametersTest extends AndroidTestCase {
params.put("aaa", "AAA");
params.put("ccc", "CCC");
params.put("bbb", "BBB");
- Assert.assertEquals("aaa=AAA&ccc=CCC&bbb=BBB", params.toString());
+ assertThat(params.toString()).isEqualTo("aaa=AAA&ccc=CCC&bbb=BBB");
params.sort();
- Assert.assertEquals("aaa=AAA&bbb=BBB&ccc=CCC", params.toString());
+ assertThat(params.toString()).isEqualTo("aaa=AAA&bbb=BBB&ccc=CCC");
}
public static void testToString() {
final Parameters params = new Parameters();
params.put("name", "foo&bar");
params.put("type", "moving");
- Assert.assertEquals("name=foo%26bar&type=moving", params.toString());
+ assertThat(params.toString()).isEqualTo("name=foo%26bar&type=moving");
}
}
diff --git a/tests/src/cgeo/geocaching/sensors/SensorsTest.java b/tests/src/cgeo/geocaching/sensors/SensorsTest.java
index 2d75465..c4f70aa 100644
--- a/tests/src/cgeo/geocaching/sensors/SensorsTest.java
+++ b/tests/src/cgeo/geocaching/sensors/SensorsTest.java
@@ -1,11 +1,11 @@
package cgeo.geocaching.sensors;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.MainActivity;
import android.test.ActivityInstrumentationTestCase2;
-import junit.framework.Assert;
-
public class SensorsTest extends ActivityInstrumentationTestCase2<MainActivity> {
public SensorsTest() {
@@ -19,7 +19,7 @@ public class SensorsTest extends ActivityInstrumentationTestCase2<MainActivity>
public static void testGetDirectionNow() {
final float angle = DirectionProvider.getDirectionNow(1.0f);
- Assert.assertTrue(angle == 1.0f || angle == 91.0f || angle == 181.0f || angle == 271.0f);
+ assertThat(angle == 1.0f || angle == 91.0f || angle == 181.0f || angle == 271.0f).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java b/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
index 8e020c4..533135d 100644
--- a/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
+++ b/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.sorting;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import android.test.AndroidTestCase;
@@ -45,20 +47,20 @@ public class NameComparatorTest extends AndroidTestCase {
}
Collections.sort(caches, comp);
for (int i = 0; i < caches.size(); i++) {
- assertEquals(names[i], caches.get(i).getName());
+ assertThat(caches.get(i).getName()).isEqualTo(names[i]);
}
}
public void testNumericalWithSuffix() {
assertSorted(new NamedCache("abc123def"), new NamedCache("abc123xyz"));
- assertEquals("abc000123def000456", (new NamedCache("abc123def456")).getNameForSorting());
+ assertThat((new NamedCache("abc123def456")).getNameForSorting()).isEqualTo("abc000123def000456");
}
private void assertSorted(final Geocache cache1, final Geocache cache2) {
- assertTrue(comp.compare(cache1, cache2) < 0);
+ assertThat(comp.compare(cache1, cache2) < 0).isTrue();
}
private void assertNotSorted(final Geocache cache1, final Geocache cache2) {
- assertTrue(comp.compare(cache1, cache2) > 0);
+ assertThat(comp.compare(cache1, cache2) > 0).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
index e4f8ca5..df8dc1f 100644
--- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
+++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.test;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.DataStore;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.SearchResult;
@@ -71,14 +73,14 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
protected void setUp() throws Exception {
super.setUp();
temporaryListId = DataStore.createList("Temporary unit testing");
- assertTrue(temporaryListId != StoredList.TEMPORARY_LIST_ID);
- assertTrue(temporaryListId != StoredList.STANDARD_LIST_ID);
+ assertThat(temporaryListId != StoredList.TEMPORARY_LIST_ID).isTrue();
+ assertThat(temporaryListId != StoredList.STANDARD_LIST_ID).isTrue();
}
@Override
protected void tearDown() throws Exception {
final SearchResult search = DataStore.getBatchOfStoredCaches(null, CacheType.ALL, temporaryListId);
- assertNotNull(search);
+ assertThat(search).isNotNull();
DataStore.removeCaches(search.getGeocodes(), LoadFlags.REMOVE_ALL);
DataStore.removeList(temporaryListId);
super.tearDown();
@@ -93,8 +95,8 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
try {
GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST_ID);
Collection<Geocache> caches = parser.parse(instream, null);
- assertNotNull(caches);
- assertFalse(caches.isEmpty());
+ assertThat(caches).isNotNull();
+ assertThat(caches.isEmpty()).isFalse();
return caches.iterator().next();
} finally {
instream.close();
diff --git a/tests/src/cgeo/geocaching/test/EmulatorStateTest.java b/tests/src/cgeo/geocaching/test/EmulatorStateTest.java
index 6346608..c35fbe3 100644
--- a/tests/src/cgeo/geocaching/test/EmulatorStateTest.java
+++ b/tests/src/cgeo/geocaching/test/EmulatorStateTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.test;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.os.Environment;
import junit.framework.TestCase;
@@ -8,6 +10,6 @@ public class EmulatorStateTest extends TestCase {
public static void testWritableMedia() {
// check the emulator running our tests
- assertTrue(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED));
+ assertThat(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
index 7c3b195..d40e76b 100644
--- a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
+++ b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.test;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.test.mock.GC1ZXX2;
import cgeo.geocaching.test.mock.GC2CJPF;
import cgeo.geocaching.test.mock.GC2JVEH;
@@ -98,7 +100,7 @@ public class RegExPerformanceTest extends TestCase {
String page = cache.getData();
String result1 = TextUtils.getMatch(page, p1, true, "");
String result2 = TextUtils.getMatch(page, p2, true, "");
- assertEquals(result1, result2);
+ assertThat(result2).isEqualTo(result1);
long diff1, diff2;
diff --git a/tests/src/cgeo/geocaching/test/WhitespaceTest.java b/tests/src/cgeo/geocaching/test/WhitespaceTest.java
index 125a0cb..1ce7cc8 100644
--- a/tests/src/cgeo/geocaching/test/WhitespaceTest.java
+++ b/tests/src/cgeo/geocaching/test/WhitespaceTest.java
@@ -1,7 +1,9 @@
package cgeo.geocaching.test;
-import cgeo.geocaching.utils.TextUtils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.utils.Log;
+import cgeo.geocaching.utils.TextUtils;
import org.apache.commons.lang3.StringUtils;
@@ -11,7 +13,7 @@ import java.util.regex.Pattern;
/**
* This test is meant for performance measurements of different whitespace replacement implementations.
* It does not test semantical correctness.
- *
+ *
*/
public class WhitespaceTest extends AbstractResourceInstrumentationTestCase {
@@ -27,7 +29,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase {
/**
* The place for the implementation to prove that the new version of replaceWhitespace is faster than
* BaseUtils.replaceWhitespace()
- *
+ *
* @param data
* @return
*/
@@ -61,7 +63,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase {
final Matcher matcher = pattern.matcher(data);
final String result = matcher.replaceAll(" ").trim();
final long end = System.currentTimeMillis();
- assertEquals(EXPECTED_SIZE - 1, result.length());
+ assertThat(result.length()).isEqualTo(EXPECTED_SIZE - 1);
Log.d((end - start) + " ms regex");
}
@@ -69,7 +71,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase {
final long start = System.currentTimeMillis();
final String result = data.replaceAll("\\s+", " ");
final long end = System.currentTimeMillis();
- assertEquals(EXPECTED_SIZE + 1, result.length());
+ assertThat(result.length()).isEqualTo(EXPECTED_SIZE + 1);
Log.d((end - start) + " ms replaceAll");
}
@@ -78,7 +80,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase {
final long start = System.currentTimeMillis();
result = TextUtils.replaceWhitespace(data);
final long end = System.currentTimeMillis();
- assertEquals(EXPECTED_SIZE, result.length());
+ assertThat(result.length()).isEqualTo(EXPECTED_SIZE);
Log.d((end - start) + " ms actual implementation");
}
@@ -87,7 +89,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase {
final long start = System.currentTimeMillis();
result = replaceWhitespaceManually(data);
final long end = System.currentTimeMillis();
- assertEquals(EXPECTED_SIZE, result.length());
+ assertThat(result.length()).isEqualTo(EXPECTED_SIZE);
Log.d((end - start) + " ms manually");
}
@@ -96,7 +98,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase {
final long start = System.currentTimeMillis();
result = replaceWhitespaceStringUtils(data);
final long end = System.currentTimeMillis();
- assertEquals(EXPECTED_SIZE - 1, result.length());
+ assertThat(result.length()).isEqualTo(EXPECTED_SIZE - 1);
Log.d((end - start) + " ms StringUtils");
}
} \ No newline at end of file
diff --git a/tests/src/cgeo/geocaching/test/mock/MockedCache.java b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
index d1252ce..d06e715 100644
--- a/tests/src/cgeo/geocaching/test/mock/MockedCache.java
+++ b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.test.mock;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.ICache;
import cgeo.geocaching.Image;
import cgeo.geocaching.Trackable;
@@ -32,13 +34,13 @@ public abstract class MockedCache implements ICache {
}
public String getMockedDataUser() {
- Assert.assertTrue(StringUtils.isNotBlank(this.mockedDataUser));
+ assertThat(StringUtils.isNotBlank(this.mockedDataUser)).isTrue();
return mockedDataUser;
}
public void setMockedDataUser(String mockedDataUser) {
this.mockedDataUser = mockedDataUser;
- Assert.assertTrue(StringUtils.isNotBlank(this.mockedDataUser));
+ assertThat(StringUtils.isNotBlank(this.mockedDataUser)).isTrue();
}
public static String getDateFormat() {
diff --git a/tests/src/cgeo/geocaching/ui/FormatterTest.java b/tests/src/cgeo/geocaching/ui/FormatterTest.java
index 53aba0f..22008e0 100644
--- a/tests/src/cgeo/geocaching/ui/FormatterTest.java
+++ b/tests/src/cgeo/geocaching/ui/FormatterTest.java
@@ -1,8 +1,10 @@
package cgeo.geocaching.ui;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.R;
import cgeo.geocaching.Waypoint;
-import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.enumerations.WaypointType;
import android.test.AndroidTestCase;
@@ -24,7 +26,7 @@ public class FormatterTest extends AndroidTestCase {
}
private static void assertFormatting(Waypoint waypoint, String expected) {
- assertEquals(expected, Formatter.formatWaypointInfo(waypoint));
+ assertThat(Formatter.formatWaypointInfo(waypoint)).isEqualTo(expected);
}
}
diff --git a/tests/src/cgeo/geocaching/utils/AngleUtilsTest.java b/tests/src/cgeo/geocaching/utils/AngleUtilsTest.java
index e214d84..7ab3909 100644
--- a/tests/src/cgeo/geocaching/utils/AngleUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/AngleUtilsTest.java
@@ -1,17 +1,19 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import android.test.AndroidTestCase;
public class AngleUtilsTest extends AndroidTestCase {
public static void testNormalize() {
- assertEquals(0.0f, AngleUtils.normalize(0));
- assertEquals(0.0f, AngleUtils.normalize(360));
- assertEquals(0.0f, AngleUtils.normalize(720));
- assertEquals(0.0f, AngleUtils.normalize(-360));
- assertEquals(0.0f, AngleUtils.normalize(-720));
- assertEquals(1.0f, AngleUtils.normalize(721));
- assertEquals(359.0f, AngleUtils.normalize(-721));
+ assertThat(AngleUtils.normalize(0)).isEqualTo(0.0f);
+ assertThat(AngleUtils.normalize(360)).isEqualTo(0.0f);
+ assertThat(AngleUtils.normalize(720)).isEqualTo(0.0f);
+ assertThat(AngleUtils.normalize(-360)).isEqualTo(0.0f);
+ assertThat(AngleUtils.normalize(-720)).isEqualTo(0.0f);
+ assertThat(AngleUtils.normalize(721)).isEqualTo(1.0f);
+ assertThat(AngleUtils.normalize(-721)).isEqualTo(359.0f);
}
public static void testDifference() {
diff --git a/tests/src/cgeo/geocaching/utils/CryptUtilsTest.java b/tests/src/cgeo/geocaching/utils/CryptUtilsTest.java
index 9a74167..7175f3d 100644
--- a/tests/src/cgeo/geocaching/utils/CryptUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/CryptUtilsTest.java
@@ -1,32 +1,34 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.connector.gc.GCConstants;
import junit.framework.TestCase;
public class CryptUtilsTest extends TestCase {
public static void testROT13() {
- assertEquals("", CryptUtils.rot13(""));
- assertEquals("", CryptUtils.rot13((String) null));
- assertEquals("Pnpur uvag", CryptUtils.rot13("Cache hint"));
- assertEquals("Pnpur [plain] uvag", CryptUtils.rot13("Cache [plain] hint"));
- assertEquals("[all plain]", CryptUtils.rot13("[all plain]"));
- assertEquals("123", CryptUtils.rot13("123"));
+ assertThat(CryptUtils.rot13("")).isEqualTo("");
+ assertThat(CryptUtils.rot13((String) null)).isEqualTo("");
+ assertThat(CryptUtils.rot13("Cache hint")).isEqualTo("Pnpur uvag");
+ assertThat(CryptUtils.rot13("Cache [plain] hint")).isEqualTo("Pnpur [plain] uvag");
+ assertThat(CryptUtils.rot13("[all plain]")).isEqualTo("[all plain]");
+ assertThat(CryptUtils.rot13("123")).isEqualTo("123");
}
public static void testConvertToGcBase31() {
- assertEquals(1186660, GCConstants.gccodeToGCId("GC1PKK9"));
- assertEquals(4660, GCConstants.gccodeToGCId("GC1234"));
- assertEquals(61731, GCConstants.gccodeToGCId("GCF123"));
+ assertThat(GCConstants.gccodeToGCId("GC1PKK9")).isEqualTo(1186660);
+ assertThat(GCConstants.gccodeToGCId("GC1234")).isEqualTo(4660);
+ assertThat(GCConstants.gccodeToGCId("GCF123")).isEqualTo(61731);
}
public static void testIssue1902() {
- assertEquals("ƖƖlƖƖƖƖ", CryptUtils.rot13("ƖƖyƖƖƖƖ"));
+ assertThat(CryptUtils.rot13("ƖƖyƖƖƖƖ")).isEqualTo("ƖƖlƖƖƖƖ");
}
public static void testMd5() {
- assertEquals("d41d8cd98f00b204e9800998ecf8427e", CryptUtils.md5(""));
+ assertThat(CryptUtils.md5("")).isEqualTo("d41d8cd98f00b204e9800998ecf8427e");
// expected value taken from debugger. should assure every developer uses UTF-8
- assertEquals("a7f4e3ec08f09be2ef7ecb4eea5f8981", CryptUtils.md5("äöü"));
+ assertThat(CryptUtils.md5("äöü")).isEqualTo("a7f4e3ec08f09be2ef7ecb4eea5f8981");
}
}
diff --git a/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
index 5f2070d..65e86b8 100644
--- a/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.apache.commons.lang3.StringUtils;
import junit.framework.TestCase;
@@ -7,10 +9,10 @@ import junit.framework.TestCase;
public class HtmlUtilsTest extends TestCase {
public static void testExtractText() {
- assertEquals(StringUtils.EMPTY, HtmlUtils.extractText(null));
- assertEquals(StringUtils.EMPTY, HtmlUtils.extractText(StringUtils.EMPTY));
- assertEquals(StringUtils.EMPTY, HtmlUtils.extractText(" "));
- assertEquals("bold", HtmlUtils.extractText("<b>bold</b>"));
+ assertThat(HtmlUtils.extractText(null)).isEqualTo(StringUtils.EMPTY);
+ assertThat(HtmlUtils.extractText(StringUtils.EMPTY)).isEqualTo(StringUtils.EMPTY);
+ assertThat(HtmlUtils.extractText(" ")).isEqualTo(StringUtils.EMPTY);
+ assertThat(HtmlUtils.extractText("<b>bold</b>")).isEqualTo("bold");
}
}
diff --git a/tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java b/tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java
index c0be156..9338d10 100644
--- a/tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java
+++ b/tests/src/cgeo/geocaching/utils/LazyInitializedListTest.java
@@ -1,10 +1,12 @@
package cgeo.geocaching.utils;
-import junit.framework.TestCase;
+import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List;
+import junit.framework.TestCase;
+
public class LazyInitializedListTest extends TestCase {
private static final class MockedLazyInitializedList extends LazyInitializedList<String> {
@@ -16,16 +18,16 @@ public class LazyInitializedListTest extends TestCase {
public static void testAccess() {
final LazyInitializedList<String> list = new MockedLazyInitializedList();
- assertTrue(list.isEmpty());
+ assertThat(list.isEmpty()).isTrue();
list.add("Test");
- assertFalse(list.isEmpty());
- assertEquals(1, list.size());
+ assertThat(list.isEmpty()).isFalse();
+ assertThat(list).hasSize(1);
int iterations = 0;
for (String element : list) {
- assertEquals("Test", element);
+ assertThat(element).isEqualTo("Test");
iterations++;
}
- assertEquals(1, iterations);
+ assertThat(iterations).isEqualTo(1);
}
}
diff --git a/tests/src/cgeo/geocaching/utils/LeastRecentlyUsedMapTest.java b/tests/src/cgeo/geocaching/utils/LeastRecentlyUsedMapTest.java
index 11088e2..c3f563c 100644
--- a/tests/src/cgeo/geocaching/utils/LeastRecentlyUsedMapTest.java
+++ b/tests/src/cgeo/geocaching/utils/LeastRecentlyUsedMapTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import java.util.Map;
@@ -47,39 +49,39 @@ public class LeastRecentlyUsedMapTest extends AbstractLRUTest {
public static void testRemoveEldestEntry() {
final LeastRecentlyUsedMap<String, Geocache> cache = new LeastRecentlyUsedMap.LruCache<String, Geocache>(10);
final Geocache first = new Geocache();
- assertNull(cache.put("1", first));
+ assertThat(cache.put("1", first)).isNull();
final Geocache second = new Geocache();
- assertNull(cache.put("2", second));
+ assertThat(cache.put("2", second)).isNull();
- assertEquals(2, cache.size());
- assertTrue(cache.containsKey("1"));
- assertTrue(cache.containsValue(first));
- assertTrue(cache.containsKey("2"));
- assertTrue(cache.containsValue(second));
+ assertThat(cache).hasSize(2);
+ assertThat(cache.containsKey("1")).isTrue();
+ assertThat(cache.containsValue(first)).isTrue();
+ assertThat(cache.containsKey("2")).isTrue();
+ assertThat(cache.containsValue(second)).isTrue();
for (int i = 3; i <= 10; i++) {
- assertNull(cache.put(Integer.toString(i), new Geocache()));
+ assertThat(cache.put(Integer.toString(i), new Geocache())).isNull();
}
- assertEquals(10, cache.size());
- assertTrue(cache.containsKey("1"));
- assertTrue(cache.containsValue(first));
- assertTrue(cache.containsKey("2"));
- assertTrue(cache.containsValue(second));
+ assertThat(cache).hasSize(10);
+ assertThat(cache.containsKey("1")).isTrue();
+ assertThat(cache.containsValue(first)).isTrue();
+ assertThat(cache.containsKey("2")).isTrue();
+ assertThat(cache.containsValue(second)).isTrue();
- assertNotNull(cache.remove("1")); // just replacing the old entry would not work
- assertNull(cache.put("1", new Geocache()));
- assertNull(cache.put("11", new Geocache()));
+ assertThat(cache.remove("1")).isNotNull(); // just replacing the old entry would not work
+ assertThat(cache.put("1", new Geocache())).isNull();
+ assertThat(cache.put("11", new Geocache())).isNull();
- assertEquals(10, cache.size());
+ assertThat(cache).hasSize(10);
// first has been overwritten by new value, but key must be in, because it is very new
- assertTrue(cache.containsKey("1"));
+ assertThat(cache.containsKey("1")).isTrue();
// second has been overwritten by 11
- assertFalse(cache.containsKey("2"));
- assertTrue(cache.containsKey("11"));
+ assertThat(cache.containsKey("2")).isFalse();
+ assertThat(cache.containsKey("11")).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/utils/LeastRecentlyUsedSetTest.java b/tests/src/cgeo/geocaching/utils/LeastRecentlyUsedSetTest.java
index 7e06b83..2b6f8a0 100644
--- a/tests/src/cgeo/geocaching/utils/LeastRecentlyUsedSetTest.java
+++ b/tests/src/cgeo/geocaching/utils/LeastRecentlyUsedSetTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.Geocache;
import java.util.Set;
@@ -29,38 +31,38 @@ public class LeastRecentlyUsedSetTest extends AbstractLRUTest {
final LeastRecentlyUsedSet<Geocache> caches = new LeastRecentlyUsedSet<Geocache>(10);
final Geocache first = new Geocache();
first.setGeocode("1");
- assertTrue(caches.add(first));
+ assertThat(caches.add(first)).isTrue();
final Geocache second = new Geocache();
second.setGeocode("2");
- assertTrue(caches.add(second));
+ assertThat(caches.add(second)).isTrue();
- assertEquals(2, caches.size());
- assertTrue(caches.contains(first));
- assertTrue(caches.contains(second));
+ assertThat(caches).hasSize(2);
+ assertThat(caches.contains(first)).isTrue();
+ assertThat(caches.contains(second)).isTrue();
// adding first cache again does not change set
- assertFalse(caches.add(first));
- assertEquals(2, caches.size());
+ assertThat(caches.add(first)).isFalse();
+ assertThat(caches).hasSize(2);
for (int i = 3; i <= 10; i++) {
final Geocache cache = new Geocache();
cache.setGeocode(Integer.toString(i));
- assertTrue(caches.add(cache));
+ assertThat(caches.add(cache)).isTrue();
}
- assertEquals(10, caches.size());
- assertTrue(caches.contains(first));
- assertTrue(caches.contains(second));
+ assertThat(caches).hasSize(10);
+ assertThat(caches.contains(first)).isTrue();
+ assertThat(caches.contains(second)).isTrue();
final Geocache c11 = new Geocache();
c11.setGeocode("11");
- assertTrue(caches.add(c11));
+ assertThat(caches.add(c11)).isTrue();
- assertEquals(10, caches.size());
+ assertThat(caches).hasSize(10);
// first was used again, there second is the oldest and has been overwritten by 11
- assertTrue(caches.contains(first));
- assertFalse(caches.contains(second));
+ assertThat(caches.contains(first)).isTrue();
+ assertThat(caches.contains(second)).isFalse();
}
} \ No newline at end of file
diff --git a/tests/src/cgeo/geocaching/utils/LogTemplateProviderTest.java b/tests/src/cgeo/geocaching/utils/LogTemplateProviderTest.java
index 249cbb1..a7dcb2b 100644
--- a/tests/src/cgeo/geocaching/utils/LogTemplateProviderTest.java
+++ b/tests/src/cgeo/geocaching/utils/LogTemplateProviderTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.utils.LogTemplateProvider.LogContext;
import java.util.Calendar;
@@ -14,7 +16,7 @@ public class LogTemplateProviderTest extends TestCase {
// This test can occasionally fail if the current year changes right after the next line.
final String currentYear = Integer.toString(Calendar.YEAR);
- assertTrue(LogTemplateProvider.applyTemplates("[DATE]", new LogContext(null, null, true)).contains(currentYear));
+ assertThat(LogTemplateProvider.applyTemplates("[DATE]", new LogContext(null, null, true)).contains(currentYear)).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/utils/MiscUtilsTest.java b/tests/src/cgeo/geocaching/utils/MiscUtilsTest.java
index 1a3804b..8678d75 100644
--- a/tests/src/cgeo/geocaching/utils/MiscUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/MiscUtilsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.util.LinkedList;
import java.util.List;
@@ -21,7 +23,7 @@ public class MiscUtilsTest extends TestCase {
}
int count = 0;
for (final List<Integer> subList: MiscUtils.buffer(list, 10)) {
- assertEquals("each sublist has the right size", 10, subList.size());
+ assertThat(subList).hasSize(10);
assertEquals("sublist has the right content", count * 10, (int) subList.get(0));
count++;
}
@@ -35,7 +37,7 @@ public class MiscUtilsTest extends TestCase {
}
int count = 0;
for (final List<Integer> subList: MiscUtils.buffer(list, 10)) {
- assertTrue("each sublist has no more than the allowed number of arguments", subList.size() <= 10);
+ assertThat(subList.size()).overridingErrorMessage("each sublist has no more than the allowed number of arguments").isLessThanOrEqualTo(10);
count += subList.size();
}
assertEquals("all the elements were seen", 48, count);
diff --git a/tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java b/tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java
index f34faa6..2c6ed18 100644
--- a/tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java
@@ -1,21 +1,22 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
import junit.framework.TestCase;
public class ProcessUtilsTest extends TestCase {
public static void testIsInstalled() {
- assertTrue(ProcessUtils.isInstalled("com.android.launcher"));
+ assertThat(ProcessUtils.isInstalled("com.android.launcher")).isTrue();
}
public static void testIsInstalledNotLaunchable() {
final String packageName = "com.android.systemui";
- assertTrue(ProcessUtils.isInstalled(packageName));
- assertFalse(ProcessUtils.isLaunchable(packageName));
+ assertThat(ProcessUtils.isInstalled(packageName)).isTrue();
+ assertThat(ProcessUtils.isLaunchable(packageName)).isFalse();
}
public static void testIsLaunchable() {
- assertTrue(ProcessUtils.isInstalled("com.android.settings"));
+ assertThat(ProcessUtils.isInstalled("com.android.settings")).isTrue();
}
}
diff --git a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
index 2093383..d1dba84 100644
--- a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.connector.gc.GCConstantsTest;
import cgeo.geocaching.test.mock.MockedCache;
@@ -12,11 +14,11 @@ 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, "???"));
- assertTrue(page.contains("id=\"ctl00_hlRenew\"") || GCConstants.MEMBER_STATUS_PM.equals(TextUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???")));
+ assertThat(page.contains("id=\"ctl00_hlRenew\"") || GCConstants.MEMBER_STATUS_PM.equals(TextUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???"))).isTrue();
}
public static void testReplaceWhitespaces() {
- assertEquals("foo bar baz ", TextUtils.replaceWhitespace(" foo\n\tbar \r baz "));
+ assertThat(TextUtils.replaceWhitespace(" foo\n\tbar \r baz ")).isEqualTo("foo bar baz ");
}
public static void testControlCharactersCleanup() {
diff --git a/tests/src/cgeo/geocaching/utils/XmlUtilsTest.java b/tests/src/cgeo/geocaching/utils/XmlUtilsTest.java
index a089ee0..71f3100 100644
--- a/tests/src/cgeo/geocaching/utils/XmlUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/XmlUtilsTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.utils;
+import static org.assertj.core.api.Assertions.assertThat;
+
import cgeo.org.kxml2.io.KXmlSerializer;
import org.apache.commons.lang3.CharEncoding;
@@ -37,7 +39,7 @@ public class XmlUtilsTest extends TestCase {
private void assertXmlEquals(final String expected) throws IOException {
xml.endDocument();
xml.flush();
- assertEquals("<?xml version='1.0' encoding='UTF-8' ?>" + expected, stringWriter.toString());
+ assertThat(stringWriter.toString()).isEqualTo("<?xml version='1.0' encoding='UTF-8' ?>" + expected);
}
public void testMultipleTexts() throws Exception {
diff --git a/tests/src/cgeo/test/Compare.java b/tests/src/cgeo/test/Compare.java
index 2ce8d49..5e5d5b8 100644
--- a/tests/src/cgeo/test/Compare.java
+++ b/tests/src/cgeo/test/Compare.java
@@ -1,8 +1,6 @@
package cgeo.test;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.ICache;
@@ -17,42 +15,43 @@ public abstract class Compare {
public static void assertCompareCaches(ICache expected, Geocache actual, boolean all) {
String geocode = expected.getGeocode();
- assertNotNull("Cache " + geocode + " is missing", actual);
- assertEquals("Cache " + geocode + ": geocode wrong", expected.getGeocode(), actual.getGeocode());
- assertTrue("Cache " + geocode + ": type wrong", expected.getType() == actual.getType());
- assertEquals("Cache " + geocode + ": OwnerDisplayName wrong", expected.getOwnerDisplayName(), actual.getOwnerDisplayName());
- assertEquals("Cache " + geocode + ": difficulty wrong", expected.getDifficulty(), actual.getDifficulty());
- assertEquals("Cache " + geocode + ": terrain wrong", expected.getTerrain(), actual.getTerrain());
- assertEquals("Cache " + geocode + ": disabled wrong", expected.isDisabled(), actual.isDisabled());
- assertEquals("Cache " + geocode + ": archived wrong", expected.isArchived(), actual.isArchived());
- assertEquals("Cache " + geocode + ": size wrong", expected.getSize(), actual.getSize());
- assertEquals("Cache " + geocode + ": name wrong", expected.getName(), actual.getName());
- assertEquals("Cache " + geocode + ": guid wrong", expected.getGuid(), actual.getGuid());
- assertTrue("Cache " + geocode + ": fav points wrong", expected.getFavoritePoints() <= actual.getFavoritePoints());
+ assertThat(actual).isNotNull();
+ assertThat(expected.getGeocode()).as("Cache " + geocode + ": geocode").isEqualTo(actual.getGeocode());
+ assertThat(expected.getType()).as("Cache " + geocode + ": type").isEqualTo(actual.getType());
+ assertThat(expected.getOwnerDisplayName()).as("Cache " + geocode + ": OwnerDisplayName").isEqualTo(actual.getOwnerDisplayName());
+ assertThat(expected.getDifficulty()).as("Cache " + geocode + ": difficulty").isEqualTo(actual.getDifficulty());
+ assertThat(expected.getTerrain()).as("Cache " + geocode + ": terrain").isEqualTo(actual.getTerrain());
+ assertThat(expected.isDisabled()).as("Cache " + geocode + ": disabled").isEqualTo(actual.isDisabled());
+ assertThat(expected.isArchived()).as("Cache " + geocode + ": archived").isEqualTo(actual.isArchived());
+ assertThat(actual.getSize()).overridingErrorMessage("Cache " + geocode + ": expected size", expected.getSize()).isEqualTo(expected.getSize());
+ assertThat(expected.getName()).as("Cache " + geocode + ": name").isEqualTo(actual.getName());
+ assertThat(expected.getGuid()).as("Cache " + geocode + ": guid").isEqualTo(actual.getGuid());
+ assertThat(expected.getFavoritePoints()).as("Cache " + geocode + ": fav points").isLessThanOrEqualTo(actual.getFavoritePoints());
final Date hiddenDate = actual.getHiddenDate();
- assertNotNull(hiddenDate);
- assertEquals("Cache " + geocode + ": hidden date wrong", expected.getHiddenDate().toString(), hiddenDate.toString());
- assertEquals("Cache " + geocode + ": premium only wrong", expected.isPremiumMembersOnly(), actual.isPremiumMembersOnly());
+ assertThat(hiddenDate).isNotNull();
+ assert hiddenDate != null; // silence the eclipse compiler in the next line
+ assertThat(expected.getHiddenDate().toString()).as("Cache " + geocode + ": hidden date").isEqualTo(hiddenDate.toString());
+ assertThat(expected.isPremiumMembersOnly()).as("Cache " + geocode + ": premium only").isEqualTo(actual.isPremiumMembersOnly());
if (all) {
- assertEquals("Cache " + geocode + ": coords wrong", expected.getCoords(), actual.getCoords());
- assertTrue("Cache " + geocode + ": reliable latlon wrong", actual.isReliableLatLon());
- assertEquals("Cache " + geocode + ": owning status wrong", expected.isOwner(), actual.isOwner());
- assertEquals("Cache " + geocode + ": owner user id wrong", expected.getOwnerUserId(), actual.getOwnerUserId());
- assertTrue("Cache " + geocode + ": hint wrong", StringUtils.equals(expected.getHint(), actual.getHint()) || StringUtils.equals(expected.getHint(), CryptUtils.rot13(actual.getHint())));
- assertTrue("Cache " + geocode + ": description wrong", actual.getDescription().startsWith(expected.getDescription()));
- assertEquals("Cache " + geocode + ": short description wrong", expected.getShortDescription(), actual.getShortDescription());
- assertEquals("Cache " + geocode + ": cache id wrong", expected.getCacheId(), actual.getCacheId());
- assertEquals("Cache " + geocode + ": location wrong", expected.getLocation(), actual.getLocation());
- assertEquals("Cache " + geocode + ": found status wrong", expected.isFound(), actual.isFound());
- assertEquals("Cache " + geocode + ": favorite status wrong", expected.isFavorite(), actual.isFavorite());
- assertEquals("Cache " + geocode + ": watchlist status wrong", expected.isOnWatchlist(), actual.isOnWatchlist());
+ assertThat(expected.getCoords()).as("Cache " + geocode + ": coords").isEqualTo(actual.getCoords());
+ assertThat(actual.isReliableLatLon()).as("Cache " + geocode + ": reliable latlon").isTrue();
+ assertThat(expected.isOwner()).as("Cache " + geocode + ": owning status").isEqualTo(actual.isOwner());
+ assertThat(expected.getOwnerUserId()).as("Cache " + geocode + ": owner user id").isEqualTo(actual.getOwnerUserId());
+ assertThat(StringUtils.equals(expected.getHint(), actual.getHint()) || StringUtils.equals(expected.getHint(), CryptUtils.rot13(actual.getHint()))).isTrue();
+ assertThat(actual.getDescription()).as("description").startsWith(expected.getDescription());
+ assertThat(expected.getShortDescription()).as("Cache " + geocode + ": short description").isEqualTo(actual.getShortDescription());
+ assertThat(expected.getCacheId()).as("Cache " + geocode + ": cache id").isEqualTo(actual.getCacheId());
+ assertThat(expected.getLocation()).as("Cache " + geocode + ": location").isEqualTo(actual.getLocation());
+ assertThat(expected.isFound()).as("Cache " + geocode + ": found status").isEqualTo(actual.isFound());
+ assertThat(expected.isFavorite()).as("Cache " + geocode + ": favorite status").isEqualTo(actual.isFavorite());
+ assertThat(expected.isOnWatchlist()).as("Cache " + geocode + ": watchlist status").isEqualTo(actual.isOnWatchlist());
for (String attribute : expected.getAttributes()) {
- assertTrue("Expected attribute '" + attribute + "' not found in " + actual.getGeocode(), actual.getAttributes().contains(attribute));
+ assertThat(actual.getAttributes()).as("attributes of " + actual.getGeocode()).contains(attribute);
}
for (LogType logType : expected.getLogCounts().keySet()) {
- assertTrue("Cache " + geocode + ": logcount for type " + logType.toString() + " wrong", actual.getLogCounts().get(logType) >= expected.getLogCounts().get(logType));
+ assertThat(actual.getLogCounts().get(logType)).as("logcount of " + geocode + " for type " + logType.toString()).isGreaterThanOrEqualTo(expected.getLogCounts().get(logType));
}
// The inventories can differ too often, therefore we don't compare them. Also, the personal note
@@ -60,7 +59,7 @@ public abstract class Compare {
final int actualSpoilersSize = null != actual.getSpoilers() ? actual.getSpoilers().size() : 0;
final int expectedSpoilersSize = null != expected.getSpoilers() ? expected.getSpoilers().size() : 0;
- assertEquals("Cache " + geocode + ": spoiler count wrong", expectedSpoilersSize, actualSpoilersSize);
+ assertThat(expectedSpoilersSize).as("Cache " + geocode + ": spoiler count").isEqualTo(actualSpoilersSize);
}
}