XUserMgr extends XUserMgrBase { public VXGroupUserInfo getXGroupUserFromMap( String groupName) { checkAdminAccess(); VXGroupUserInfo vxGUInfo = new VXGroupUserInfo(); XXGroup xGroup = daoManager.getXXGroup().findByGroupName(groupName); if (xGroup == null) { return vxGUInfo; } VXGroup xgroupInfo = xGroupService.populateViewBean(xGroup); vxGUInfo.setXgroupInfo(xgroupInfo); SearchCriteria searchCriteria = new SearchCriteria(); searchCriteria.addParam("xGroupId", xGroup.getId()); VXGroupUserList vxGroupUserList = searchXGroupUsers(searchCriteria); List<VXUser> vxu = new ArrayList<VXUser>(); logger.debug("removing all the group user mapping for : " + xGroup.getName()); for (VXGroupUser groupUser : vxGroupUserList.getList()) { XXUser xUser = daoManager.getXXUser().getById(groupUser.getUserId()); if (xUser != null) { VXUser vxUser = new VXUser(); vxUser.setName(xUser.getName()); XXPortalUser xXPortalUser = daoManager.getXXPortalUser() .findByLoginId(xUser.getName()); if (xXPortalUser != null) { List<String> existingRole = daoManager .getXXPortalUserRole() .findXPortalUserRolebyXPortalUserId( xXPortalUser.getId()); if (existingRole != null) { vxUser.setUserRoleList(existingRole); } } vxu.add(vxUser); } } vxGUInfo.setXuserInfo(vxu); return vxGUInfo; }  VXUser getXUserByUserName(String userName); VXGroup getGroupByGroupName(String groupName); VXUser createXUser(VXUser vXUser); void assignPermissionToUser(VXPortalUser vXPortalUser, boolean isCreate); void createOrUpdateUserPermisson(VXPortalUser portalUser, Long moduleId, boolean isCreate); HashMap<String, Long> getAllModuleNameAndIdMap(); VXUser updateXUser(VXUser vXUser); VXUserGroupInfo createXUserGroupFromMap(VXUserGroupInfo vXUserGroupInfo); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) VXGroupUserInfo createXGroupUserFromMap(
			VXGroupUserInfo vXGroupUserInfo); VXGroupUserInfo getXGroupUserFromMap(
			String groupName); VXUser createXUserWithOutLogin(VXUser vXUser); VXUser createExternalUser(String userName); VXGroup createXGroup(VXGroup vXGroup); VXGroup createXGroupWithoutLogin(VXGroup vXGroup); VXGroupUser createXGroupUser(VXGroupUser vXGroupUser); VXUser getXUser(Long id); VXGroupUser getXGroupUser(Long id); VXGroup getXGroup(Long id); void deleteXGroupAndXUser(String groupName, String userName); VXGroupList getXUserGroups(Long xUserId); Set<String> getGroupsForUser(String userName); VXUserList getXGroupUsers(SearchCriteria searchCriteria); @Override VXGroup updateXGroup(VXGroup vXGroup); VXGroupUser updateXGroupUser(VXGroupUser vXGroupUser); void deleteXGroupUser(Long id, boolean force); VXGroupGroup createXGroupGroup(VXGroupGroup vXGroupGroup); VXGroupGroup updateXGroupGroup(VXGroupGroup vXGroupGroup); void deleteXGroupGroup(Long id, boolean force); void deleteXPermMap(Long id, boolean force); VXLong getXPermMapSearchCount(SearchCriteria searchCriteria); void deleteXAuditMap(Long id, boolean force); VXLong getXAuditMapSearchCount(SearchCriteria searchCriteria); void modifyUserVisibility(HashMap<Long, Integer> visibilityMap); void modifyGroupsVisibility(HashMap<Long, Integer> groupVisibilityMap); VXModuleDef createXModuleDefPermission(VXModuleDef vXModuleDef); VXModuleDef getXModuleDefPermission(Long id); VXModuleDef updateXModuleDefPermission(VXModuleDef vXModuleDef); void deleteXModuleDefPermission(Long id, boolean force); VXUserPermission createXUserPermission(VXUserPermission vXUserPermission); VXUserPermission getXUserPermission(Long id); VXUserPermission updateXUserPermission(VXUserPermission vXUserPermission); void deleteXUserPermission(Long id, boolean force); VXGroupPermission createXGroupPermission(VXGroupPermission vXGroupPermission); VXGroupPermission getXGroupPermission(Long id); VXGroupPermission updateXGroupPermission(VXGroupPermission vXGroupPermission); void deleteXGroupPermission(Long id, boolean force); void modifyUserActiveStatus(HashMap<Long, Integer> statusMap); void checkAdminAccess(); void checkAccess(String loginID); VXPermMapList searchXPermMaps(SearchCriteria searchCriteria); VXAuditMapList searchXAuditMaps(SearchCriteria searchCriteria); void checkAccessRoles(List<String> stringRolesList); VXStringList setUserRolesByExternalID(Long userId, List<VXString> vStringRolesList); VXStringList setUserRolesByName(String userName, List<VXString> vStringRolesList); List<String> updateUserRoleAssignments(VXUsersGroupRoleAssignments ugRoleAssignments); VXStringList getUserRolesByExternalID(Long userId); VXStringList getUserRolesByName(String userName); void updateUserRolesPermissions(VXPortalUser oldUserProfile,List<String> roleListNewProfile); VXStringList getStringListFromUserRoleList(
			List<XXPortalUserRole> listXXPortalUserRole); boolean hasAccess(String loginID); VXUser getMaskedVXUser(VXUser vXUser); VXGroup getMaskedVXGroup(VXGroup vXGroup); @Override VXUserList searchXUsers(SearchCriteria searchCriteria); @Override VXGroupList searchXGroups(SearchCriteria searchCriteria); VXGroupList lookupXGroups(SearchCriteria searchCriteria); Collection<String> getMaskedCollection(Collection<String> listunMasked); boolean hasAccessToModule(String moduleName); void deleteXGroup(Long id, boolean force); synchronized void deleteXUser(Long id, boolean force); void restrictSelfAccountDeletion(String loginID); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) VXUser createServiceConfigUser(String userName); void denySelfRoleChange(String userName); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) synchronized VXUgsyncAuditInfo postUserGroupAuditInfo(
			VXUgsyncAuditInfo vxUgsyncAuditInfo); Long getUserStoreVersion(); Set<UserInfo> getUsers(); Set<GroupInfo> getGroups(); Map<String, Set<String>> getUserGroups(); RangerUserStore getRangerUserStore(Long lastKnownUserStoreVersion);  }
@Test public void test53getXGroupUserFromMap() { setup(); VXGroup vxGroup=vxGroup(); VXUser vxUser = vxUser(); List<VXUser> vXUserList=new ArrayList<VXUser>(); vXUserList.add(vxUser); VXGroupUserInfo vxGUInfo = new VXGroupUserInfo(); vxGUInfo.setXgroupInfo(vxGroup); vxGUInfo.setXuserInfo(vXUserList); XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class); XXGroup xxGroup = new XXGroup(); xxGroup.setId(vxGroup.getId()); xxGroup.setName(vxGroup.getName()); xxGroup.setDescription(vxGroup.getDescription()); xxGroup.setIsVisible(vxGroup.getIsVisible()); VXPortalUser userProfile = userProfile(); XXPortalUser xXPortalUser = xxPortalUser(userProfile); xXPortalUser.setUserSource(RangerCommonEnums.USER_EXTERNAL); VXGroupUserList vxGroupUserList = new VXGroupUserList(); List<VXGroupUser> vXGroupUsers = new ArrayList<VXGroupUser>(); VXGroupUser vxGroupUser = vxGroupUser(); vXGroupUsers.add(vxGroupUser); vxGroupUserList.setVXGroupUsers(vXGroupUsers); List<String> lstRole = new ArrayList<String>(); lstRole.add(RangerConstants.ROLE_USER); Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao); SearchCriteria searchCriteria = createsearchCriteria(); searchCriteria.addParam("xGroupId", xxGroup.getId()); Mockito.when(xxGroupDao.findByGroupName("")).thenReturn(null); VXGroupUserInfo vxGUInfoObjNull=xUserMgr.getXGroupUserFromMap(""); Assert.assertNull(vxGUInfoObjNull.getXgroupInfo()); Mockito.when(xxGroupDao.findByGroupName(Mockito.anyString())).thenReturn(xxGroup); Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vxGroup); Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(vxGroupUserList); XXUser xXUser = xxUser(vxUser); XXUserDao xxUserDao = Mockito.mock(XXUserDao.class); Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao); Mockito.when(xxUserDao.getById(userId)).thenReturn(xXUser); XXPortalUserDao xXPortalUserDao = Mockito.mock(XXPortalUserDao.class); Mockito.when(daoManager.getXXPortalUser()).thenReturn(xXPortalUserDao); Mockito.when(xXPortalUserDao.findByLoginId(xXUser.getName().trim())).thenReturn(xXPortalUser); XXPortalUserRoleDao xXPortalUserRoleDao = Mockito.mock(XXPortalUserRoleDao.class); Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(xXPortalUserRoleDao); vxGUInfoObjNull=xUserMgr.getXGroupUserFromMap(xxGroup.getName()); }