use of org.apache.ranger.view.VXUser in project ranger by apache.
the class TestXUserREST method test102deleteUsersByUserNameSetValueNull.
@Test
public void test102deleteUsersByUserNameSetValueNull() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
String TestforceDeleteStr = "false";
boolean forceDelete = true;
Mockito.when(request.getParameter("forceDelete")).thenReturn(TestforceDeleteStr);
VXString testVXString = new VXString();
testVXString.setValue("User1");
VXUser testVXUser = createVXUser();
VXStringList vxStringList = createVXStringList();
Mockito.when(xUserService.getXUserByUserName(testVXString.getValue())).thenReturn(testVXUser);
forceDelete = false;
Mockito.doNothing().when(xUserMgr).deleteXUser(testVXUser.getId(), forceDelete);
xUserRest.deleteUsersByUserName(request, vxStringList);
Mockito.verify(xUserMgr).deleteXUser(testVXUser.getId(), forceDelete);
Mockito.verify(xUserService).getXUserByUserName(testVXString.getValue());
Mockito.verify(request).getParameter("forceDelete");
}
use of org.apache.ranger.view.VXUser in project ranger by apache.
the class TestXUserREST method test64deleteXUserByUserName.
@Test
public void test64deleteXUserByUserName() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
String TestforceDeleteStr = "true";
boolean forceDelete = false;
Mockito.when(request.getParameter("forceDelete")).thenReturn(TestforceDeleteStr);
VXUser testUser = createVXUser();
Mockito.when(xUserService.getXUserByUserName(testUser.getName())).thenReturn(testUser);
forceDelete = true;
Mockito.doNothing().when(xUserMgr).deleteXUser(testUser.getId(), forceDelete);
xUserRest.deleteXUserByUserName(testUser.getName(), request);
Mockito.verify(xUserMgr).deleteXUser(testUser.getId(), forceDelete);
Mockito.verify(xUserService).getXUserByUserName(testUser.getName());
Mockito.verify(request).getParameter("forceDelete");
}
use of org.apache.ranger.view.VXUser in project ranger by apache.
the class TestXUserREST method test62getXUserByUserName.
@Test
public void test62getXUserByUserName() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
VXUser compareTestVxUser = createVXUser();
Mockito.when(xUserMgr.getXUserByUserName("User1")).thenReturn(compareTestVxUser);
VXUser retVXUser = xUserRest.getXUserByUserName(request, "User1");
assertNotNull(retVXUser);
assertEquals(compareTestVxUser.getClass(), retVXUser.getClass());
assertEquals(compareTestVxUser.getId(), retVXUser.getId());
Mockito.verify(xUserMgr).getXUserByUserName("User1");
}
use of org.apache.ranger.view.VXUser in project ranger by apache.
the class TestXUserREST method test66deleteXUserByUserNameNull.
@Test
public void test66deleteXUserByUserNameNull() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
String TestforceDeleteStr = null;
boolean forceDelete = true;
Mockito.when(request.getParameter("forceDelete")).thenReturn(TestforceDeleteStr);
VXUser testUser = createVXUser();
Mockito.when(xUserService.getXUserByUserName(testUser.getName())).thenReturn(testUser);
forceDelete = false;
Mockito.doNothing().when(xUserMgr).deleteXUser(testUser.getId(), forceDelete);
xUserRest.deleteXUserByUserName(testUser.getName(), request);
Mockito.verify(xUserMgr).deleteXUser(testUser.getId(), forceDelete);
Mockito.verify(xUserService).getXUserByUserName(testUser.getName());
Mockito.verify(request).getParameter("forceDelete");
}
use of org.apache.ranger.view.VXUser in project ranger by apache.
the class TestXUserREST method test24searchXUsers.
@SuppressWarnings("unchecked")
@Test
public void test24searchXUsers() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
SearchCriteria testSearchCriteria = createsearchCriteria();
Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
Mockito.when(searchUtil.extractString(request, testSearchCriteria, "name", "User name", null)).thenReturn("");
Mockito.when(searchUtil.extractString(request, testSearchCriteria, "emailAddress", "Email Address", null)).thenReturn("");
Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "userSource", "User Source")).thenReturn(1);
Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "isVisible", "User Visibility")).thenReturn(1);
Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "status", "User Status")).thenReturn(1);
Mockito.when(searchUtil.extractStringList(request, testSearchCriteria, "userRoleList", "User Role List", "userRoleList", null, null)).thenReturn(new ArrayList<String>());
Mockito.when(searchUtil.extractString(request, testSearchCriteria, "userRole", "UserRole", null)).thenReturn("");
List<VXUser> vXUsersList = new ArrayList<VXUser>();
vXUsersList.add(vxUser);
VXUserList testVXUserList = new VXUserList();
testVXUserList.setVXUsers(vXUsersList);
Mockito.when(xUserMgr.searchXUsers(testSearchCriteria)).thenReturn(testVXUserList);
VXUserList gotVXUserList = xUserRest.searchXUsers(request);
Mockito.verify(xUserMgr).searchXUsers(testSearchCriteria);
Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "name", "User name", null);
Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "emailAddress", "Email Address", null);
Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "userSource", "User Source");
Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "isVisible", "User Visibility");
Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "status", "User Status");
Mockito.verify(searchUtil).extractStringList(request, testSearchCriteria, "userRoleList", "User Role List", "userRoleList", null, null);
Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "userRole", "UserRole", null);
assertNotNull(gotVXUserList);
assertEquals(testVXUserList.getTotalCount(), gotVXUserList.getTotalCount());
assertEquals(testVXUserList.getClass(), gotVXUserList.getClass());
}
Aggregations