@Test
public void TestValidateUserAndFetchUserList() {

    List<String> permissionList = new ArrayList<String>();
    permissionList.add(RangerConstants.MODULE_USER_GROUPS);
    String currentEncryptedPassword = "testpassword";
    XXPortalUser xxPortalUser = new XXPortalUser();
    xxPortalUser.setId(1L);
    xxPortalUser.setLoginId("testUser");
    xxPortalUser.setPassword("testpassword");
    xxPortalUser.setFirstName("testUser");
    VXUser vxUser = new VXUser();
    vxUser.setId(1L);
    VXUserList vXUserList = new VXUserList();
    List<VXUser> vXUsers = new ArrayList<VXUser>();
    vXUsers.add(vxUser);
    vXUserList.setVXUsers(vXUsers );
    List<String> userRoleList = new ArrayList<String>();
    userRoleList.add("ROLE_SYS_ADMIN");
    List<XXPortalUser> listXXPortalUser = new ArrayList<XXPortalUser>();
            listXXPortalUser.add(xxPortalUser);
    vxUser.setUserRoleList(userRoleList);
    XXModuleDefDao xXModuleDefDao = Mockito.mock(XXModuleDefDao.class);
    Mockito.when(daoMgr.getXXPortalUser()).thenReturn(xXPortalUserDao);
    Mockito.when(xXPortalUserDao.findByLoginId(Mockito.anyString())).thenReturn(xxPortalUser);
    Mockito.when(xUserService.getXUserByUserName(xxPortalUser.getLoginId())).thenReturn(vxUser);
    Mockito.when(daoMgr.getXXModuleDef()).thenReturn(xXModuleDefDao);
    Mockito.when(xXModuleDefDao.findAccessibleModulesByUserId(Mockito.anyLong(), Mockito.anyLong())).thenReturn(permissionList);
    Mockito.when(userMgr.encrypt(Mockito.anyString(),Mockito.anyString())).thenReturn(currentEncryptedPassword);
    Mockito.when(xXPortalUserDao.findByRole(Mockito.anyString())).thenReturn(listXXPortalUser);
    roleBasedUserSearchUtil.validateUserAndFetchUserList();
    Mockito.verify(xXPortalUserDao).findByLoginId(Mockito.anyString());
    Mockito.verify(xUserService).getXUserByUserName(xxPortalUser.getLoginId());
    Mockito.verify(xXModuleDefDao).findAccessibleModulesByUserId(Mockito.anyLong(), Mockito.anyLong());
    Mockito.verify(userMgr).encrypt(Mockito.anyString(),Mockito.anyString());
    Mockito.verify(xXPortalUserDao, Mockito.atLeast(2)).findByRole(Mockito.anyString());
}