Skip to content

Commit

Permalink
fixed typo in static map annotations and added tests for map annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
“osana” committed Jul 24, 2018
1 parent 0dfbee7 commit e28b5f7
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String url() {

sb.append("path");
if (strokeWidth() != null) {
sb.append("-").append(strokeColor());
sb.append("-").append(strokeWidth());
}
if (strokeColor() != null) {
sb.append("+").append(strokeColor());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.mapbox.api.staticmap.v1.models;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.junit.Assert.assertTrue;

public class StaticPolylineAnnotationTest {

@Rule
public final ExpectedException exception = ExpectedException.none();

@Test
public void sanity() throws Exception {
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
.polyline("test-polylineAnnotation")
.build();

System.err.print(">>>>>>>> url=" +staticPolylineAnnotation.url());

// path-strokeWidth+strokeColor-strokeOpacity+fillColor-fillOpacity(polylineName)
// assertTrue(staticPolylineAnnotation.url().contains("path-10.0+646464-0.5+323232-0.75(test-polylineAnnotation)"));
}

@Test
public void polyline_ispresent() throws Exception {
exception.expect(IllegalStateException.class);
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
.build();
}

@Test
public void url_annotations() throws Exception {
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
.polyline("test-polylineAnnotation")
.strokeColor(100, 100, 100)
.strokeWidth(10.0)
.strokeOpacity(0.5f)
.fillColor(50, 50, 50)
.fillOpacity(0.75f)
.build();

// path-{strokeWidth}+{strokeColor}-{strokeOpacity}+{fillColor}-{fillOpacity}({polyline})
assertTrue(staticPolylineAnnotation.url().contains("path-10.0+646464-0.5+323232-0.75(test-polylineAnnotation)"));
}

@Test
public void url_annotations_stroke() throws Exception {
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
.polyline("test-polylineAnnotation")
.strokeColor(100, 100, 100)
.strokeWidth(10.0)
.strokeOpacity(0.5f)
.build();

// path-{strokeWidth}+{strokeColor}-{strokeOpacity}+{fillColor}-{fillOpacity}({polyline})
assertTrue(staticPolylineAnnotation.url().contains("path-10.0+646464-0.5(test-polylineAnnotation)"));
}

@Test
public void url_annotations_fill() throws Exception {
StaticPolylineAnnotation staticPolylineAnnotation = StaticPolylineAnnotation.builder()
.polyline("test-polylineAnnotation")
.fillColor(50, 50, 50)
.fillOpacity(0.75f)
.build();

// path-{strokeWidth}+{strokeColor}-{strokeOpacity}+{fillColor}-{fillOpacity}({polyline})
assertTrue(staticPolylineAnnotation.url().contains("path+323232-0.75(test-polylineAnnotation)"));
}
}

0 comments on commit e28b5f7

Please sign in to comment.