Skip to content

Commit

Permalink
added NOT_FOUND exception (closes #10)
Browse files Browse the repository at this point in the history
  • Loading branch information
markmcd committed Sep 2, 2014
1 parent dd15aed commit 1b77499
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/google/maps/errors/ApiException.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static ApiException from(String status, String errorMessage) {
return new InvalidRequestException(errorMessage);
case "MAX_ELEMENTS_EXCEEDED":
return new MaxElementsExceededException(errorMessage);
case "NOT_FOUND":
return new NotFoundException(errorMessage);
case "OVER_QUERY_LIMIT":
return new OverQueryLimitException(errorMessage);
case "REQUEST_DENIED":
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/google/maps/errors/NotFoundException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.google.maps.errors;

/**
* Indicates at least one of the locations specified in the request's origin, destination,
* or waypoints could not be geocoded.
*/
public class NotFoundException extends ApiException {

public NotFoundException(String errorMessage) {
super(errorMessage);
}
}
19 changes: 4 additions & 15 deletions src/test/java/com/google/maps/DirectionsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.junit.Assert.assertTrue;

import com.google.maps.DirectionsApi.RouteRestriction;
import com.google.maps.errors.NotFoundException;
import com.google.maps.model.DirectionsRoute;
import com.google.maps.model.TravelMode;
import com.google.maps.model.Unit;
Expand Down Expand Up @@ -246,20 +247,8 @@ public void testAlternatives() throws Exception {
assertTrue(routes.length > 1);
}


@Test
public void testEnterprise() throws Exception {

// NOTE: test disabled. Fill in "clientId" and "secret" strings
if (true) {
return;
}

GeoApiContext context = new GeoApiContext().setEnterpriseCredentials("TODO_clientId",
"TODO_secret");
DirectionsRoute[] routes = DirectionsApi.getDirections(context, "Toronto", "San Francisco")
.await();
assertNotNull(routes);
assertNotNull(routes[0]);
@Test(expected = NotFoundException.class)
public void testNotFound() throws Exception {
DirectionsRoute[] routes = DirectionsApi.getDirections(context, "fksjdhgf", "faldfdaf").await();
}
}

0 comments on commit 1b77499

Please sign in to comment.