blob: f4073a959e519388f609752fb0f45943ccb7a755 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
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;
import java.util.List;
import junit.framework.TestCase;
public class ECConnectorTest extends TestCase {
public static void testCanHandle() throws Exception {
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());
assertThat(possibleLogTypes).isNotNull();
assertThat(possibleLogTypes).isNotEmpty();
assertThat(possibleLogTypes).contains(LogType.FOUND_IT);
}
private static Geocache createCache() {
final Geocache geocache = new Geocache();
geocache.setType(CacheType.TRADITIONAL);
geocache.setGeocode("EC727");
return geocache;
}
public static void testGetGeocodeFromUrl() throws Exception {
assertThat(ECConnector.getInstance().getGeocodeFromUrl("http://extremcaching.com/index.php/output-2/738")).isEqualTo("EC738");
}
}
|