@Test
  public void testInvalidPath() throws UnsupportedEncodingException, URISyntaxException {
    String requestPath = "/SOME_INVALID_PATH";
    List<String> prefixesToRemove = new ArrayList<>();
    RestRequest restRequest = RestUtilsTest.createRestRequest(RestMethod.GET, requestPath, null);
    ((MockRestRequest) restRequest).throwExceptionOnGetPath(true);
    try {
      RequestPath.parse(restRequest, prefixesToRemove, CLUSTER_NAME);
      fail();
    } catch (RestServiceException e) {
      assertEquals(RestServiceErrorCode.BadRequest, e.getErrorCode());
    }
  }
Tests that the expected exception is thrown when URL path is invalid
ambry-api/src/test/java/com/github/ambry/rest/RequestPathTest.java