private UserEntity createMockUserEntity(String username) {
    UserEntity userEntity = createMock(UserEntity.class);
    expect(userEntity.getUserId()).andReturn(username.hashCode()).anyTimes();
    expect(userEntity.getUserName()).andReturn(username).anyTimes();
    expect(userEntity.getLocalUsername()).andReturn(username).anyTimes();
    expect(userEntity.getDisplayName()).andReturn(username).anyTimes();
    expect(userEntity.getActive()).andReturn(true).anyTimes();
    expect(userEntity.getCreateTime()).andReturn(CREATE_TIME).anyTimes();
    expect(userEntity.getConsecutiveFailures()).andReturn(0).anyTimes();
    expect(userEntity.getAuthenticationEntities()).andReturn(Collections.<UserAuthenticationEntity>emptyList()).anyTimes();
    expect(userEntity.getMemberEntities()).andReturn(Collections.<MemberEntity>emptySet()).anyTimes();
    return userEntity;
  }
Test give a user Ambari administrative rights by assigning the user to the AMBARI.ADMINISTRATOR role
when creating the account. This is for backward compatibility to maintain the REST API V1 contract.
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java