QueuingParameterRequestResolver implements ParameterRequestQueue { @Override public PreparedParameter resolve(String parameterName, ParameterRequest request) { Future<PreparedParameter> waitingRequest = currentRequests.get(parameterName); if (waitingRequest == null) { waitingRequest = executorService.submit(new ParameterResolvingCallable(parameterName, request)); currentRequests.put(parameterName, waitingRequest); } return resolvePromise(parameterName, waitingRequest); } QueuingParameterRequestResolver(ExecutorService executorService); @Override PreparedParameter resolve(String parameterName, ParameterRequest request);  }
@Test( enabled = false, description = "Concurrent test should be run with integration tests or when sth changes in tested class", invocationCount = 10, threadPoolSize = 2 ) public void shouldWaitForFirstRequestToResolveBeforeCallingAnotherForSameParameter() { resolver.resolve("test", request); assertThat(request.invocations).isLessThanOrEqualTo(2); }