Skip to content

Commit 47acc92

Browse files
danieljesusamuramoto
authored andcommitted
fixed: Added path exception when there is no center or no zoom (#650)
1 parent 6500947 commit 47acc92

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/main/java/com/google/maps/StaticMapsRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ public StaticMapsRequest(GeoApiContext context) {
3737
@Override
3838
protected void validateRequest() {
3939
if (!((params().containsKey("center") && params().containsKey("zoom"))
40-
|| params().containsKey("markers"))) {
40+
|| params().containsKey("markers")
41+
|| params().containsKey("path"))) {
4142
throw new IllegalArgumentException(
42-
"Request must contain 'center' and 'zoom' if 'markers' isn't present.");
43+
"Request must contain 'center' and 'zoom' if 'markers' or 'path' aren't present.");
4344
}
4445
if (!params().containsKey("size")) {
4546
throw new IllegalArgumentException("Request must contain 'size'.");

src/test/java/com/google/maps/StaticMapsApiTest.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,39 @@ public void testValidateRequest_noZoom() throws Exception {
123123
}
124124
}
125125

126+
@Test
127+
public void testValidateRequest_noCenterAndNoZoomWithMarkers() throws Exception {
128+
try (LocalTestServerContext sc = new LocalTestServerContext(IMAGE)) {
129+
StaticMapsRequest req = StaticMapsApi.newRequest(sc.context, new Size(WIDTH, HEIGHT));
130+
131+
Markers markers = new Markers();
132+
markers.size(MarkersSize.small);
133+
markers.customIcon("http://not.a/real/url", CustomIconAnchor.bottomleft, 2);
134+
markers.color("blue");
135+
markers.label("A");
136+
markers.addLocation("Melbourne");
137+
markers.addLocation(SYDNEY);
138+
req.markers(markers);
139+
req.await();
140+
}
141+
}
142+
143+
@Test
144+
public void testValidateRequest_noCenterAndNoZoomWithPath() throws Exception {
145+
try (LocalTestServerContext sc = new LocalTestServerContext(IMAGE)) {
146+
StaticMapsRequest req = StaticMapsApi.newRequest(sc.context, new Size(WIDTH, HEIGHT));
147+
Path path = new Path();
148+
path.color("green");
149+
path.fillcolor("0xAACCEE");
150+
path.weight(3);
151+
path.geodesic(true);
152+
path.addPoint("Melbourne");
153+
path.addPoint(SYDNEY);
154+
req.path(path);
155+
req.await();
156+
}
157+
}
158+
126159
@Test(expected = IllegalArgumentException.class)
127160
public void testValidateRequest_noSize() throws Exception {
128161
try (LocalTestServerContext sc = new LocalTestServerContext(IMAGE)) {

0 commit comments

Comments
 (0)