Search in sources :

Example 21 with VXStringList

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

the class TestXUserREST method test106deleteGroupsByGroupName.

// //////////////////////////////
@Test
public void test106deleteGroupsByGroupName() {
    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("testVXGroup");
    VXGroup testVXGroup = createVXGroup();
    VXStringList vxStringList = createVXStringListGroup();
    Mockito.when(xGroupService.getGroupByGroupName(testVXString.getValue())).thenReturn(testVXGroup);
    forceDelete = true;
    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 22 with VXStringList

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

the class TestXUserREST method test95setUserRolesByExternalID.

@Test
public void test95setUserRolesByExternalID() {
    VXStringList testVXStringList = createVXStringList();
    Mockito.when(xUserMgr.setUserRolesByExternalID(id, testVXStringList.getVXStrings())).thenReturn(testVXStringList);
    VXStringList retVXStringList = xUserRest.setUserRolesByExternalID(id, testVXStringList);
    Mockito.verify(xUserMgr).setUserRolesByExternalID(id, testVXStringList.getVXStrings());
    assertNotNull(retVXStringList);
    assertEquals(testVXStringList.getTotalCount(), retVXStringList.getTotalCount());
    assertEquals(testVXStringList.getClass(), retVXStringList.getClass());
}
Also used : VXStringList(org.apache.ranger.view.VXStringList) Test(org.junit.Test)

Example 23 with VXStringList

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

the class TestXUserREST method test109deleteGroupsByGroupNameSetValueNull.

@Test
public void test109deleteGroupsByGroupNameSetValueNull() {
    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("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 24 with VXStringList

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

the class TestXUserREST method test98getUserRolesByName.

@Test
public void test98getUserRolesByName() {
    VXStringList testVXStringList = createVXStringList();
    Mockito.when(xUserMgr.getUserRolesByName("Admin")).thenReturn(testVXStringList);
    VXStringList retVXStringList = xUserRest.getUserRolesByName("Admin");
    Mockito.verify(xUserMgr).getUserRolesByName("Admin");
    assertNotNull(retVXStringList);
    assertEquals(testVXStringList.getTotalCount(), retVXStringList.getTotalCount());
    assertEquals(testVXStringList.getClass(), retVXStringList.getClass());
}
Also used : VXStringList(org.apache.ranger.view.VXStringList) Test(org.junit.Test)

Aggregations

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