NetworkToSubnetRedirectionFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { final UriInfo uriInfo = requestContext.getUriInfo(); final URI oldRequestURI = uriInfo.getRequestUri(); final String oldPath = oldRequestURI.getPath().toLowerCase(); if (oldPath.startsWith("/networks")) { redirectNetworkToSubnet(requestContext, uriInfo, oldRequestURI, oldPath); return; } if (oldPath.startsWith("/projects") || oldPath.startsWith("/vms")) { if (oldPath.contains("/networks")) { redirectNetworkToSubnet(requestContext, uriInfo, oldRequestURI, oldPath); } } }  @Override void filter(ContainerRequestContext requestContext);  }
@Test(dataProvider = "NetworkAndSubnetRequests") public void testSuccess(String httpMethod, String actualPath, String expectedPath) throws Throwable { ContainerRequest request = buildRequest(actualPath, httpMethod, new MultivaluedHashMap<>()); this.networkToSubnetRedirectionFilter.filter(request); assertThat(request.getRequestUri().getPath(), startsWith(expectedPath)); }