roleHierarchy.setHierarchy("ROLE_A > ROLE_B");
final UserDetails user = new User("EXISTING_USER", "PASSWORD", true, true, true, true,
AuthorityUtils.createAuthorityList("ROLE_A"));
final UserDetailsService wrappedUserDetailsService = mock(UserDetailsService.class);
when(wrappedUserDetailsService.loadUserByUsername("EXISTING_USER")).thenReturn(user);
when(wrappedUserDetailsService.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION")).thenThrow(new UsernameNotFoundException("USERNAME_NOT_FOUND_EXCEPTION"));
this.wrappedUserDetailsService = wrappedUserDetailsService;
userDetailsServiceWrapper = new UserDetailsServiceWrapper();
userDetailsServiceWrapper.setRoleHierarchy(roleHierarchy);
userDetailsServiceWrapper.setUserDetailsService(wrappedUserDetailsService);