@Test
public void testGetGrantedAuthoritiesWithLoginAlias() throws Exception {

  // Given
  String loginAlias = "testLoginAlias@testdomain.com";
  String ambariUserName = "user";
  PowerMock.mockStatic(AuthorizationHelper.class);
  expect(AuthorizationHelper.resolveLoginAliasToUserName(loginAlias)).andReturn(ambariUserName);
  PowerMock.replay(AuthorizationHelper.class);
  AmbariLdapAuthoritiesPopulator populator = createMockBuilder(AmbariLdapAuthoritiesPopulator.class)
    .withConstructor(helper, userDAO, memberDAO, privilegeDAO, users).createMock();
  expect(userEntity.getActive()).andReturn(true);
  expect(users.getUserPrivileges(userEntity)).andReturn(Collections.singletonList(privilegeEntity));
  expect(userDAO.findLdapUserByName(ambariUserName)).andReturn(userEntity); // user should be looked up by user name instead of login alias
  replayAll();
  // When
  populator.getGrantedAuthorities(userData, loginAlias);
  PowerMock.verify(AuthorizationHelper.class);
  verifyAll();
}