ifs-web-service/ifs-application-commons/src/test/java/org/innovateuk/ifs/async/controller/endtoend/EndToEndAsyncControllerIntegrationTest.java
/**
     * This method asserts that our async work is being done on the expected Threads, and that the
     * expected ThreadLocal values to support the RestTemplateAdaptors are present.
     *
     */
This method asserts that our async work is being done on the expected Threads, and that the
expected ThreadLocal values to support the RestTemplateAdaptors are present.
This method asserts that our async work is being done on the expected Threads and that the expected ThreadLocal values to support the RestTemplateAdaptors are present .
private <T> ResponseEntity<T> dataLayerResponse(T response, ExpectedExecutionBehaviour executionBehaviour) {
        assertThat(((UserAuthentication) SecurityContextHolder.getContext().getAuthentication()).getDetails(), sameInstance(loggedInUser));
        assertThat(RequestContextHolder.getRequestAttributes().getAttribute("REQUEST_UUID_KEY", SCOPE_REQUEST),
                equalTo(requestCachingUuid));
        if (ExpectedExecutionBehaviour.ASYNC_THREADS.equals(executionBehaviour)) {
            assertThat(Thread.currentThread().getName(), startsWith("IFS-Async-Executor-"));
            return delayedResponse(entity(response));
        } else {
            assertThat(Thread.currentThread().getName(), not(startsWith("IFS-Async-Executor-")));
            return nonAsyncResponse(entity(response));
        }
    }
private < T > ResponseEntity < T > dataLayerResponse ( T response , ExpectedExecutionBehaviour executionBehaviour ) { assertThat ( ( ( UserAuthentication ) SecurityContextHolder . getContext ( ) . getAuthentication ( ) ) . getDetails ( ) , sameInstance ( loggedInUser ) ) ; assertThat ( RequestContextHolder . getRequestAttributes ( ) . getAttribute ( "REQUEST_UUID_KEY" , SCOPE_REQUEST ) , equalTo ( requestCachingUuid ) ) ; if ( ExpectedExecutionBehaviour . ASYNC_THREADS . equals ( executionBehaviour ) ) { assertThat ( Thread . currentThread ( ) . getName ( ) , startsWith ( "IFS-Async-Executor-" ) ) ; return delayedResponse ( entity ( response ) ) ; } else { assertThat ( Thread . currentThread ( ) . getName ( ) , not ( startsWith ( "IFS-Async-Executor-" ) ) ) ; return nonAsyncResponse ( entity ( response ) ) ; } }
This method asserts that our async work is being done on the expected Threads, and that the
 expected ThreadLocal values to support the RestTemplateAdaptors are present.
This method asserts that our async work is being done on the expected Threads and that the expected ThreadLocal values to support the RestTemplateAdaptors are present .