Users { public synchronized void setUserLdap(String userName) throws AmbariException { UserEntity userEntity = userDAO.findUserByName(userName); if (userEntity != null) { userEntity.setLdapUser(true); userDAO.merge(userEntity); } else { throw new AmbariException("User " + userName + " doesn't exist"); } }  List<User> getAllUsers(); @Deprecated User getAnyUser(String userName); User getUser(String userName, UserType userType); User getUser(Integer userId); @Deprecated User getUserIfUnique(String userName); synchronized void modifyPassword(String userName, String currentUserPassword, String newPassword); synchronized void setUserActive(String userName, boolean active); synchronized void setUserLdap(String userName); synchronized void setGroupLdap(String groupName); void createUser(String userName, String password); synchronized void createUser(String userName, String password, UserType userType, Boolean active, Boolean
      admin); synchronized void removeUser(User user); Group getGroup(String groupName); Group getGroupByNameAndType(String groupName, GroupType groupType); Collection<User> getGroupMembers(String groupName); @Transactional synchronized void createGroup(String groupName, GroupType groupType); List<Group> getAllGroups(); List<String> getAllMembers(String groupName); @Transactional synchronized void removeGroup(Group group); synchronized void grantAdminPrivilege(Integer userId); synchronized void grantPrivilegeToGroup(Integer groupId, Long resourceId, ResourceType resourceType, String permissionName); synchronized void revokeAdminPrivilege(Integer userId); @Transactional synchronized void addMemberToGroup(String groupName, String userName); @Transactional synchronized void removeMemberFromGroup(String groupName, String userName); synchronized boolean isUserCanBeRemoved(UserEntity userEntity); void processLdapSync(LdapBatchDto batchInfo); Collection<PrivilegeEntity> getUserPrivileges(UserEntity userEntity); Collection<PrivilegeEntity> getGroupPrivileges(GroupEntity groupEntity); Collection<AmbariGrantedAuthority> getUserAuthorities(String userName, UserType userType);  }
@Test public void testSetUserLdap() throws Exception { users.createUser("user", "user"); users.createUser("user_ldap", "user_ldap", UserType.LDAP, true, false); users.setUserLdap("user"); Assert.assertEquals(true, users.getAnyUser("user").isLdapUser()); try { users.setUserLdap("fake user"); Assert.fail("It shouldn't be possible to call setUserLdap() on non-existing user"); } catch (AmbariException ex) { } }