Search in sources :

Example 6 with VXString

use of org.apache.ranger.view.VXString in project ranger by apache.

the class TestXUserREST method test108deleteGroupsByGroupNameNull.

@Test
public void test108deleteGroupsByGroupNameNull() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    String TestforceDeleteStr = null;
    boolean forceDelete = true;
    Mockito.when(request.getParameter("forceDelete")).thenReturn(TestforceDeleteStr);
    VXString testVXString = new VXString();
    testVXString.setValue("testVXGroup");
    VXGroup testVXGroup = createVXGroup();
    VXStringList vxStringList = createVXStringListGroup();
    Mockito.when(xGroupService.getGroupByGroupName(testVXString.getValue())).thenReturn(testVXGroup);
    forceDelete = false;
    Mockito.doNothing().when(xUserMgr).deleteXGroup(testVXGroup.getId(), forceDelete);
    xUserRest.deleteGroupsByGroupName(request, vxStringList);
    Mockito.verify(xUserMgr).deleteXGroup(testVXGroup.getId(), forceDelete);
    Mockito.verify(xGroupService).getGroupByGroupName(testVXString.getValue());
    Mockito.verify(request).getParameter("forceDelete");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXString(org.apache.ranger.view.VXString) VXStringList(org.apache.ranger.view.VXStringList) VXString(org.apache.ranger.view.VXString) VXGroup(org.apache.ranger.view.VXGroup) Test(org.junit.Test)

Example 7 with VXString

use of org.apache.ranger.view.VXString 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");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXString(org.apache.ranger.view.VXString) VXStringList(org.apache.ranger.view.VXStringList) VXString(org.apache.ranger.view.VXString) VXUser(org.apache.ranger.view.VXUser) Test(org.junit.Test)

Example 8 with VXString

use of org.apache.ranger.view.VXString in project ranger by apache.

the class TestXUserREST method createVXStringListGroup.

private VXStringList createVXStringListGroup() {
    VXStringList testVXStringList = new VXStringList();
    VXString testVXString = new VXString();
    testVXString.setValue("testVXGroup");
    List<VXString> testVXStrings = new ArrayList<VXString>();
    testVXStrings.add(testVXString);
    testVXStringList.setVXStrings(testVXStrings);
    testVXStringList.setResultSize(1);
    testVXStringList.setPageSize(1);
    testVXStringList.setSortBy("Id");
    testVXStringList.setStartIndex(1);
    testVXStringList.setTotalCount(1);
    return testVXStringList;
}
Also used : VXString(org.apache.ranger.view.VXString) VXStringList(org.apache.ranger.view.VXStringList) ArrayList(java.util.ArrayList)

Example 9 with VXString

use of org.apache.ranger.view.VXString in project ranger by apache.

the class TestXUserREST method test110deleteGroupsByGroupNameListNull.

@Test
public void test110deleteGroupsByGroupNameListNull() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    String TestforceDeleteStr = "false";
    Mockito.when(request.getParameter("forceDelete")).thenReturn(TestforceDeleteStr);
    VXString testVXString = new VXString();
    testVXString.setValue("testVXGroup");
    xUserRest.deleteGroupsByGroupName(request, null);
    Mockito.verify(request).getParameter("forceDelete");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXString(org.apache.ranger.view.VXString) VXString(org.apache.ranger.view.VXString) Test(org.junit.Test)

Example 10 with VXString

use of org.apache.ranger.view.VXString in project ranger by apache.

the class TestXUserREST method test105deleteUsersByUserNameNull.

@Test
public void test105deleteUsersByUserNameNull() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    String TestforceDeleteStr = "true";
    Mockito.when(request.getParameter("forceDelete")).thenReturn(TestforceDeleteStr);
    VXString testVXString = new VXString();
    testVXString.setValue(null);
    VXStringList vxStringList = createVXStringList();
    List<VXString> testVXStrings = new ArrayList<VXString>();
    testVXStrings.add(testVXString);
    vxStringList.setVXStrings(testVXStrings);
    xUserRest.deleteUsersByUserName(request, vxStringList);
    Mockito.verify(request).getParameter("forceDelete");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXString(org.apache.ranger.view.VXString) VXStringList(org.apache.ranger.view.VXStringList) ArrayList(java.util.ArrayList) VXString(org.apache.ranger.view.VXString) Test(org.junit.Test)

Aggregations

VXString (org.apache.ranger.view.VXString)24 Test (org.junit.Test)19 VXStringList (org.apache.ranger.view.VXStringList)17 ArrayList (java.util.ArrayList)12 HttpServletRequest (javax.servlet.http.HttpServletRequest)12 VXPortalUser (org.apache.ranger.view.VXPortalUser)6 VXUser (org.apache.ranger.view.VXUser)6 Date (java.util.Date)5 XXPortalUserRoleDao (org.apache.ranger.db.XXPortalUserRoleDao)5 XXGroupPermission (org.apache.ranger.entity.XXGroupPermission)5 XXModuleDef (org.apache.ranger.entity.XXModuleDef)5 XXPortalUser (org.apache.ranger.entity.XXPortalUser)5 XXPortalUserRole (org.apache.ranger.entity.XXPortalUserRole)5 XXUserPermission (org.apache.ranger.entity.XXUserPermission)5 VXGroupPermission (org.apache.ranger.view.VXGroupPermission)5 VXUserPermission (org.apache.ranger.view.VXUserPermission)5 VXGroup (org.apache.ranger.view.VXGroup)4 XXGroupPermissionDao (org.apache.ranger.db.XXGroupPermissionDao)1 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)1 XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)1