GetQueryParameterRule implements IResolveDependencyStrategy { @Override public <T> T resolve(final Object... args) throws ResolveDependencyStrategyException { try { URL url = new URL("http:" + ((FullHttpRequest) args[0]).getUri()); String query = url.getQuery(); String param = Stream.of(query.split("&")) .map(x -> x.split("=")) .filter(x -> x[0].equals(args[1])) .findFirst().get()[1]; return (T) param; } catch (MalformedURLException e) { throw new ResolveDependencyStrategyException("Failed to parse url", e); } }  @Override T resolve(final Object... args);  }
@Test public void shouldExtractRightCookie() throws Exception { GetQueryParameterRule rule = new GetQueryParameterRule(); FullHttpRequest request = mock(FullHttpRequest.class); String uri = "/?key1=val1&key2=val2"; when(request.getUri()).thenReturn(uri); assertEquals("val2", rule.resolve(request, "key2")); }