Skip to content

Commit 8b95a8c

Browse files
authored
fixed typo in static map annotations and added tests for map annotations (#855)
1 parent 5c86c34 commit 8b95a8c

2 files changed

Lines changed: 73 additions & 1 deletion

File tree

services-staticmap/src/main/java/com/mapbox/api/staticmap/v1/models/StaticPolylineAnnotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public String url() {
4747

4848
sb.append("path");
4949
if (strokeWidth() != null) {
50-
sb.append("-").append(strokeColor());
50+
sb.append("-").append(strokeWidth());
5151
}
5252
if (strokeColor() != null) {
5353
sb.append("+").append(strokeColor());
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.mapbox.api.staticmap.v1.models;
2+
3+
import org.junit.Rule;
4+
import org.junit.Test;
5+
import org.junit.rules.ExpectedException;
6+
7+
import static org.junit.Assert.assertTrue;
8+
9+
public class StaticPolylineAnnotationTest {
10+
11+
@Rule
12+
public final ExpectedException exception = ExpectedException.none();
13+
14+
@Test
15+
public void sanity() throws Exception {
16+
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
17+
.polyline("test-polylineAnnotation")
18+
.build();
19+
20+
System.err.print(">>>>>>>> url=" +staticPolylineAnnotation.url());
21+
22+
// path-strokeWidth+strokeColor-strokeOpacity+fillColor-fillOpacity(polylineName)
23+
// assertTrue(staticPolylineAnnotation.url().contains("path-10.0+646464-0.5+323232-0.75(test-polylineAnnotation)"));
24+
}
25+
26+
@Test
27+
public void polyline_ispresent() throws Exception {
28+
exception.expect(IllegalStateException.class);
29+
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
30+
.build();
31+
}
32+
33+
@Test
34+
public void url_annotations() throws Exception {
35+
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
36+
.polyline("test-polylineAnnotation")
37+
.strokeColor(100, 100, 100)
38+
.strokeWidth(10.0)
39+
.strokeOpacity(0.5f)
40+
.fillColor(50, 50, 50)
41+
.fillOpacity(0.75f)
42+
.build();
43+
44+
// path-{strokeWidth}+{strokeColor}-{strokeOpacity}+{fillColor}-{fillOpacity}({polyline})
45+
assertTrue(staticPolylineAnnotation.url().contains("path-10.0+646464-0.5+323232-0.75(test-polylineAnnotation)"));
46+
}
47+
48+
@Test
49+
public void url_annotations_stroke() throws Exception {
50+
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
51+
.polyline("test-polylineAnnotation")
52+
.strokeColor(100, 100, 100)
53+
.strokeWidth(10.0)
54+
.strokeOpacity(0.5f)
55+
.build();
56+
57+
// path-{strokeWidth}+{strokeColor}-{strokeOpacity}+{fillColor}-{fillOpacity}({polyline})
58+
assertTrue(staticPolylineAnnotation.url().contains("path-10.0+646464-0.5(test-polylineAnnotation)"));
59+
}
60+
61+
@Test
62+
public void url_annotations_fill() throws Exception {
63+
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
64+
.polyline("test-polylineAnnotation")
65+
.fillColor(50, 50, 50)
66+
.fillOpacity(0.75f)
67+
.build();
68+
69+
// path-{strokeWidth}+{strokeColor}-{strokeOpacity}+{fillColor}-{fillOpacity}({polyline})
70+
assertTrue(staticPolylineAnnotation.url().contains("path+323232-0.75(test-polylineAnnotation)"));
71+
}
72+
}

0 commit comments

Comments
 (0)