use of org.apache.ranger.view.VXUser in project ranger by apache.
the class TestXUserREST method test73getXGroupUsers.
@SuppressWarnings("unchecked")
@Test
public void test73getXGroupUsers() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
SearchCriteria testSearchCriteria = createsearchCriteria();
testSearchCriteria.addParam("xGroupId", id);
Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
VXUser testVXUser = createVXUser();
VXUserList testVXUserList = new VXUserList();
List<VXUser> testVXUsers = new ArrayList<VXUser>();
testVXUsers.add(testVXUser);
testVXUserList.setVXUsers(testVXUsers);
testVXUserList.setStartIndex(1);
testVXUserList.setTotalCount(1);
Mockito.when(xUserMgr.getXGroupUsers(testSearchCriteria)).thenReturn(testVXUserList);
VXUserList retVxGroupList = xUserRest.getXGroupUsers(request, id);
assertNotNull(retVxGroupList);
assertEquals(testVXUserList.getTotalCount(), retVxGroupList.getTotalCount());
assertEquals(testVXUserList.getStartIndex(), retVxGroupList.getStartIndex());
Mockito.verify(xUserMgr).getXGroupUsers(testSearchCriteria);
}
use of org.apache.ranger.view.VXUser in project ranger by apache.
the class TestXUserREST method test18updateXUser.
@Test
public void test18updateXUser() {
Mockito.when(xUserMgr.updateXUser(vxUser)).thenReturn(vxUser);
VXUser gotVXUser = xUserRest.updateXUser(vxUser);
Mockito.verify(xUserMgr).updateXUser(vxUser);
assertNotNull(gotVXUser);
assertEquals(vxUser.getId(), gotVXUser.getId());
assertEquals(vxUser.getName(), gotVXUser.getName());
}
use of org.apache.ranger.view.VXUser in project ranger by apache.
the class TestXUserREST method test99deleteUsersByUserName.
@Test
public void test99deleteUsersByUserName() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
String TestforceDeleteStr = "true";
boolean forceDelete = false;
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 = true;
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 test100deleteUsersByUserNameNull.
@Test
public void test100deleteUsersByUserNameNull() {
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 test70deleteXGroupAndXUser.
@Test
public void test70deleteXGroupAndXUser() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
VXGroup testVXGroup = createVXGroup();
VXUser testVXuser = createVXUser();
Mockito.doNothing().when(xUserMgr).deleteXGroupAndXUser(testVXGroup.getName(), testVXuser.getName());
xUserRest.deleteXGroupAndXUser(testVXGroup.getName(), testVXuser.getName(), request);
Mockito.verify(xUserMgr).deleteXGroupAndXUser(testVXGroup.getName(), testVXuser.getName());
}
Aggregations