-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from ibi-group/prevent-nonplan-pojo-errors
Prevent conversion of non-plan OTP responses to POJO
- Loading branch information
Showing
5 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/org/opentripplanner/middleware/otp/OtpDispatcherResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.opentripplanner.middleware.otp; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.middleware.utils.FileUtils; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.opentripplanner.middleware.TestUtils.TEST_RESOURCE_PATH; | ||
import static org.opentripplanner.middleware.otp.OtpDispatcher.OTP_PLAN_ENDPOINT; | ||
|
||
public class OtpDispatcherResponseTest { | ||
@Test | ||
public void toStringShouldExcludeResponseFieldIfNotCallingPlan() throws IOException { | ||
String mockParkRideResponse = FileUtils.getFileContents( | ||
TEST_RESOURCE_PATH + "otp/parkRideResponse.json" | ||
); | ||
|
||
|
||
// The call below creates a request URI that is "http://test.com", | ||
// which is not the OTP /plan endpoint, but we still assert that too. | ||
OtpDispatcherResponse dispatcherResponse = new OtpDispatcherResponse(mockParkRideResponse); | ||
Assertions.assertFalse(dispatcherResponse.requestUri.getPath().endsWith(OTP_PLAN_ENDPOINT)); | ||
|
||
// Expected string does not include the response={} field. | ||
String expected = "OtpDispatcherResponse{statusCode=200, responseBody='" + mockParkRideResponse + "'}"; | ||
|
||
Assertions.assertEquals(expected, dispatcherResponse.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/test/resources/org/opentripplanner/middleware/otp/parkRideResponse.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"name":"P+R","x":-81.36548775,"y":28.4528734},{"name":"P+R","x":-81.274944,"y":28.911900600000003},{"name":"P+R","x":-81.7390652,"y":28.540740550000002},{"name":"P+R","x":-81.13372815,"y":28.561692100000002}] |