### Question:
RequestMetric { String getHttpRequestPath() { if (pathMatched) { return path; } if (routingContext != null) { String rcPath = routingContext.get(HTTP_REQUEST_PATH); if (rcPath != null) { return rcPath; } String matchedPath = routingContext.currentRoute().getPath(); if (matchedPath != null) { if (matchedPath.contains(":")) { matchedPath = vertxRoutePath.computeIfAbsent(matchedPath, k -> { String segments[] = k.split("/"); for (int i = 0; i < segments.length; i++) { segments[i] = VERTX_ROUTE_PARAM.matcher(segments[i]).replaceAll("{$1}"); } return String.join("/", segments); }); } return matchedPath; } } return path; }  static void setRequestMetric(Context context, RequestMetric requestMetric); static RequestMetric retrieveRequestMetric(Context context);  }### Answer:
@Test public void testReturnPathFromHttpRequestPath() { RequestMetric requestMetric = new RequestMetric(); requestMetric.routingContext = Mockito.mock(RoutingContext.class); Mockito.when(requestMetric.routingContext.get(RequestMetric.HTTP_REQUEST_PATH)) .thenReturn("/item/{id}"); Assertions.assertEquals("/item/{id}", requestMetric.getHttpRequestPath()); }
@Test public void testReturnPathFromRoutingContext() { RequestMetric requestMetric = new RequestMetric(); requestMetric.routingContext = Mockito.mock(RoutingContext.class); Route currentRoute = Mockito.mock(Route.class); Mockito.when(requestMetric.routingContext.currentRoute()).thenReturn(currentRoute); Mockito.when(currentRoute.getPath()).thenReturn("/item"); Assertions.assertEquals("/item", requestMetric.getHttpRequestPath()); }
@Test public void testReturnGenericPathFromRoutingContext() { RequestMetric requestMetric = new RequestMetric(); requestMetric.routingContext = Mockito.mock(RoutingContext.class); Route currentRoute = Mockito.mock(Route.class); Mockito.when(requestMetric.routingContext.currentRoute()).thenReturn(currentRoute); Mockito.when(currentRoute.getPath()).thenReturn("/item/:id"); Assertions.assertEquals("/item/{id}", requestMetric.getHttpRequestPath()); Assertions.assertEquals("/item/{id}", RequestMetric.vertxRoutePath.get("/item/:id")); }