Skip to content

Commit 464c42f

Browse files
jvretameroCameron Mace
authored andcommitted
Fixed source and destination formatting from DirectionsMatrix request builder (#588)
1 parent 176cca6 commit 464c42f

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

mapbox/libjava-services/src/main/java/com/mapbox/services/api/directionsmatrix/v1/MapboxDirectionsMatrix.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ public String getDestinations() {
299299
}
300300

301301
String[] destinationsFormatted = new String[destinations.length];
302+
303+
for (int i = 0; i < destinations.length; i++) {
304+
destinationsFormatted[i] = String.valueOf(destinations[i]);
305+
}
306+
302307
return TextUtils.join(";", destinationsFormatted);
303308
}
304309

@@ -312,6 +317,11 @@ public String getSources() {
312317
}
313318

314319
String[] sourcesFormatted = new String[sources.length];
320+
321+
for (int i = 0; i < sources.length; i++) {
322+
sourcesFormatted[i] = String.valueOf(sources[i]);
323+
}
324+
315325
return TextUtils.join(";", sourcesFormatted);
316326
}
317327

mapbox/libjava-services/src/test/java/com/mapbox/services/api/directionsmatrix/v1/MapboxDirectionsMatrixTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,26 @@ public void testResponse() throws ServicesException, IOException {
184184
assertEquals(response.body().getDurations()[0][1], 1888.3, DELTA);
185185
assertEquals(response.body().getDestinations().get(0).getName(), "McAllister Street");
186186
}
187+
188+
@Test
189+
public void testDestinationsAreFormatted() {
190+
MapboxDirectionsMatrix.Builder builder = new MapboxDirectionsMatrix.Builder()
191+
.setDestinations(1, 2);
192+
193+
String formattedDestinations = builder.getDestinations();
194+
195+
assertNotNull(formattedDestinations);
196+
assertEquals(formattedDestinations, "1;2");
197+
}
198+
199+
@Test
200+
public void testSourcesAreFormatted() {
201+
MapboxDirectionsMatrix.Builder builder = new MapboxDirectionsMatrix.Builder()
202+
.setSources(1, 2);
203+
204+
String formattedSources = builder.getSources();
205+
206+
assertNotNull(formattedSources);
207+
assertEquals(formattedSources, "1;2");
208+
}
187209
}

0 commit comments

Comments
 (0)