Skip to content

Commit

Permalink
Add tests for methods in MapillaryURL
Browse files Browse the repository at this point in the history
  • Loading branch information
floscher committed Apr 17, 2017
1 parent a11c384 commit e65f6bf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ public final class MapillaryURL {
private static final String BASE_API_V2_URL = "https://a.mapillary.com/v2/";
private static final String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";

public enum IMAGE_SELECTOR {
BLURRED_ONLY, COMMENTED_ONLY, OBJ_REC_ONLY // null is used when all images should be selected
}

public static final class APIv3 {
private static final String BASE_URL = "https://a.mapillary.com/v3/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@
import java.nio.charset.StandardCharsets;

import org.junit.Test;

import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryURL.IMAGE_SELECTOR;

public class MapillaryURLTest {
private static final String CLIENT_ID_QUERY_PART = "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
private static final String LIMIT_20_QUERY_PART = "limit=20";

public static class APIv3 {

@Test
public void testSearchDetections() {
assertUrlEquals(MapillaryURL.APIv3.searchDetections(null), "https://a.mapillary.com/v3/detections", CLIENT_ID_QUERY_PART);
}

@Test
public void testSearchImages() {
assertUrlEquals(MapillaryURL.APIv3.searchImages(null), "https://a.mapillary.com/v3/images", CLIENT_ID_QUERY_PART);
}

@Test
public void testSearchSequences() throws UnsupportedEncodingException {
assertUrlEquals(
Expand Down Expand Up @@ -88,6 +98,14 @@ public void testParseNextFromHeaderValueMalformed() {
}
}

public class Cloudfront {
@Test
public void testThumbnail() {
assertUrlEquals(MapillaryURL.Cloudfront.thumbnail("arbitrary_key", true), "https://d1cuyjsrcm0gby.cloudfront.net/arbitrary_key/thumb-2048.jpg");
assertUrlEquals(MapillaryURL.Cloudfront.thumbnail("arbitrary_key2", true), "https://d1cuyjsrcm0gby.cloudfront.net/arbitrary_key2/thumb-320.jpg");
}
}

@Test
public void testBrowseImageURL() throws MalformedURLException {
assertEquals(
Expand Down Expand Up @@ -151,12 +169,14 @@ public void testString2MalformedURL()
Method method = MapillaryURL.class.getDeclaredMethod("string2URL", String[].class);
method.setAccessible(true);
assertNull(method.invoke(null, new Object[]{new String[]{"malformed URL"}})); // this simply invokes string2URL("malformed URL")
assertNull(method.invoke(null, new Object[]{null})); // invokes string2URL(null)
}

@Test
public void testUtilityClass() {
TestUtil.testUtilityClass(MapillaryURL.class);
TestUtil.testUtilityClass(MapillaryURL.APIv3.class);
TestUtil.testUtilityClass(MapillaryURL.Cloudfront.class);
TestUtil.testUtilityClass(MapillaryURL.MainWebsite.class);
}

Expand Down

0 comments on commit e65f6bf

Please sign in to comment.