### Question:
RestUtils { public static String extractResourcePath(HttpServletRequest request) { if (request == null || request.getRequestURI().length() <= 3) { return ""; } String uri = request.getRequestURI().substring(1); int start = uri.indexOf('/'); if (start >= 0 && start + 1 < uri.length()) { return uri.substring(start + 1); } else { return ""; } } private  RestUtils(); static String extractAccessKey(HttpServletRequest request); static boolean isAnonymousRequest(HttpServletRequest request); static String extractDate(HttpServletRequest request); static String extractResourcePath(HttpServletRequest request); static ParaObject readResourcePath(String appid, String path); static Response getEntity(InputStream is, Class<?> type); static byte[] readEntityBytes(InputStream in); static Response getVotingResponse(ParaObject object, Map<String, Object> entity); static Response getReadResponse(App app, ParaObject content); static Response getCreateResponse(App app, String type, InputStream is); static Response getOverwriteResponse(App app, String id, String type, InputStream is); static Response getUpdateResponse(App app, ParaObject object, InputStream is); static Response getDeleteResponse(App app, ParaObject content); static Response getBatchReadResponse(App app, List<String> ids); static Response getBatchCreateResponse(final App app, InputStream is); static Response getBatchUpdateResponse(App app, Map<String, ParaObject> oldObjects,
			List<Map<String, Object>> newProperties); static Response getBatchDeleteResponse(App app, List<String> ids); static Response readLinksHandler(ParaObject pobj, String id2, String type2,
			MultivaluedMap<String, String> params, Pager pager, boolean childrenOnly); static Response deleteLinksHandler(ParaObject pobj, String id2, String type2, boolean childrenOnly); static Response createLinksHandler(ParaObject pobj, String id2); static Pager getPagerFromParams(MultivaluedMap<String, String> params); static Response getStatusResponse(Response.Status status, String... messages); static void returnStatusResponse(HttpServletResponse response, int status, String message); static void returnObjectResponse(HttpServletResponse response, Object obj); static String pathParam(String param, ContainerRequestContext ctx); static List<String> pathParams(String param, ContainerRequestContext ctx); static String queryParam(String param, ContainerRequestContext ctx); static List<String> queryParams(String param, ContainerRequestContext ctx); static boolean hasQueryParam(String param, ContainerRequestContext ctx);  }### Answer:
@Test public void testExtractResourcePath() { HttpServletRequest req = Mockito.mock(HttpServletRequest.class); Mockito.when(req.getRequestURI()).thenReturn(""); assertEquals(extractResourcePath(null), ""); assertEquals(extractResourcePath(req), ""); Mockito.when(req.getRequestURI()).thenReturn("/v1"); assertEquals("", extractResourcePath(req)); Mockito.when(req.getRequestURI()).thenReturn("/v1/"); assertEquals("", extractResourcePath(req)); Mockito.when(req.getRequestURI()).thenReturn("/v1/_"); assertEquals("_", extractResourcePath(req)); Mockito.when(req.getRequestURI()).thenReturn("/v1/_test"); assertEquals("_test", extractResourcePath(req)); Mockito.when(req.getRequestURI()).thenReturn("/v1/_test/path/id"); assertEquals("_test/path/id", extractResourcePath(req)); Mockito.when(req.getRequestURI()).thenReturn("/v2.0/posts/123"); assertEquals("posts/123", extractResourcePath(req)); }