private boolean isAnonymous() {
   AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
   SecurityContext ctx = SecurityContextHolder.getContext();
   if (ctx != null) {
     Authentication auth = ctx.getAuthentication();
     return resolver.isAnonymous(auth);
   }
   return true;
 }
 @Test
 public void isAnonymousReturnsFalseIfTrustResolverReportsNonAnonymous() {
   when(trustResolver.isAnonymous(user)).thenReturn(false);
   assertThat(root.isAnonymous()).isFalse();
 }