@Test(expected = AmbariException.class)
  public void testCreateUser_Duplicate() throws Exception {
    UserEntity existing = new UserEntity();
    existing.setUserName(UserName.fromString(SERVICEOP_USER_NAME).toString());
    existing.setUserId(1);
    existing.setMemberEntities(Collections.emptySet());
    PrincipalEntity principal = new PrincipalEntity();
    principal.setPrivileges(Collections.emptySet());
    existing.setPrincipal(principal);
    initForCreateUser(existing);

    Users users = injector.getInstance(Users.class);
    users.createUser(SERVICEOP_USER_NAME, SERVICEOP_USER_NAME, SERVICEOP_USER_NAME);
  }
User creation should throw {@link AmbariException} in case another user exists with the same name but
different user type.
ambari-server/src/test/java/org/apache/ambari/server/security/authorization/UsersTest.java