aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/utils/CheckerUtilsTest.java
blob: fa7c7e751b188ff44310d62b92a5d5695d8794f4 (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
package cgeo.geocaching.utils;

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

import cgeo.geocaching.Geocache;

import junit.framework.TestCase;

public class CheckerUtilsTest extends TestCase {

    public static void testGetCheckerUrl() throws Exception {
        assertUrl("<p style=\"text-align:center;\"><a href=\"http://geocheck.org/geo_inputchkcoord.php?gid=618932716cc7e68-c4bb-4f41-8bb1-3e0a3e374a1f\" target=\"_blank\"><img", "http://geocheck.org/geo_inputchkcoord.php?gid=618932716cc7e68-c4bb-4f41-8bb1-3e0a3e374a1f");
        assertUrl("<p style=\"text-align:center;\"><a href=\"http://google.com/geo_inputchkcoord.php?gid=618932716cc7e68-c4bb-4f41-8bb1-3e0a3e374a1f\" target=\"_blank\"><img", null);
        assertUrl("http://www.certitudes.org/certitude?wp=GC5MVX7", "http://www.certitudes.org/certitude?wp=GC5MVX7");
        assertUrl("http://geochecker.com/index.php?code=e001928e3c2682ec2bae0f24b9d02cfb&action=check&wp=474350573454&name=47656f636865636b6572205465737420666f72204e33382030302e303030205737362030302e303030", "http://geochecker.com/index.php?code=e001928e3c2682ec2bae0f24b9d02cfb&action=check&wp=474350573454&name=47656f636865636b6572205465737420666f72204e33382030302e303030205737362030302e303030");
        assertUrl("<p>Haarige Aussichten gibt es <a href=\"http://www.geochecker.com/index.php?code=cd52752a8649c5e385a624b5341176f9&amp;action=check&amp;wp=4743314a43384b&amp;name=4b61747a656e&amp;language=German\">hier</a>.</p></span>", "http://www.geochecker.com/index.php?code=cd52752a8649c5e385a624b5341176f9&action=check&wp=4743314a43384b&name=4b61747a656e&language=German");
    }

    private static void assertUrl(final String description, final String expected) {
        final Geocache geocache = new Geocache();
        geocache.setDescription(description);
        assertThat(CheckerUtils.getCheckerUrl(geocache)).isEqualTo(expected);
    }

}