### Question:
AuthenticationUtils { public static boolean isAdmin(Authentication authentication) { return hasRole(authentication, ROLE_ADMIN); }  static boolean hasRole(Authentication authentication, String role); static boolean isAdmin(Authentication authentication); static final String ROLE_ADMIN; }### Answer:
@Test public void testIsAdmin_validAdmin() { List<GrantedAuthority> grantedAuthoritiesList = new ArrayList<GrantedAuthority>(); grantedAuthoritiesList.add(new SimpleGrantedAuthority(AuthenticationUtils.ROLE_ADMIN)); EasyMock.<Collection<? extends GrantedAuthority>>expect(authentication.getAuthorities()).andReturn(grantedAuthoritiesList); replay(authentication); assertThat(AuthenticationUtils.isAdmin(authentication), is(true)); }
@Test public void testIsAdmin_notValidAdmin() { List<GrantedAuthority> grantedAuthoritiesList = new ArrayList<GrantedAuthority>(); grantedAuthoritiesList.add(new SimpleGrantedAuthority(VALID_ROLE)); EasyMock.<Collection<? extends GrantedAuthority>>expect(authentication.getAuthorities()).andReturn(grantedAuthoritiesList); replay(authentication); assertThat(AuthenticationUtils.isAdmin(authentication), is(false)); }