AuthenticationService.java
public <T> Mono<T> withUser(Function<User, Mono<T>> function){
    return Mono.deferContextual(ctx -> {
        User user = ctx.get(User.class);
        function.apply(user);
    })
}
Then I have a separate client using this
UserService.java
public Mono<Boolean> doSomethingMeaningfulWithUser(){
    authenticationService.withUser(user -> {
        ... 
    }
}
In my test I would have
@Mock
private AuthenticationService authService;
private UserService userService = new UserService(authService);
@Test
public void testMeaningfulStuff(){
   ...when(...)
   ...userService.doSomethingMeaningfulWithUser()
}
Is there an idiomatic way to setup a @Mock with AuthenticationService here, so that I can test the business logic with User in doSomethingMeaningfulWithUser, or is it easier to wire AuthenticationService fully in this case here?
 
     
    