aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/connector/trackable/SwaggieConnectorTest.java
blob: 54c3319a05301c77a972481061bd158dc8dd051d (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
package cgeo.geocaching.connector.trackable;

import static org.assertj.core.api.Assertions.assertThat;

import cgeo.geocaching.Trackable;

import junit.framework.TestCase;

public class SwaggieConnectorTest extends TestCase {

    public static void testCanHandleTrackable() {
        assertThat(new SwaggieConnector().canHandleTrackable("SW0001")).isTrue();
        assertThat(new SwaggieConnector().canHandleTrackable("SWABCD")).isFalse();
        assertThat(new SwaggieConnector().canHandleTrackable("GK82A2")).isFalse();
        assertThat(new SwaggieConnector().canHandleTrackable("TB1234")).isFalse();
        assertThat(new SwaggieConnector().canHandleTrackable("UNKNOWN")).isFalse();
    }

    public static void testGetTrackableCodeFromUrl() throws Exception {
        assertThat(new SwaggieConnector().getTrackableCodeFromUrl("http://geocaching.com.au/swaggie/sw0017")).isEqualTo("SW0017");
    }

    public static void testGetUrl() throws Exception {
        final Trackable trackable = new Trackable();
        trackable.setGeocode("SW0017");
        assertThat(new SwaggieConnector().getUrl(trackable)).isEqualTo("http://geocaching.com.au/swaggie/SW0017");
    }

}