Search in sources :

Example 31 with VXGroup

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

the class TestXUserMgr method test29deleteXGroupAndXUser.

@Test
public void test29deleteXGroupAndXUser() {
    setup();
    VXUser vxUser = vxUser();
    VXGroup vxGroup = new VXGroup();
    VXGroupUserList vxGroupUserList = new VXGroupUserList();
    String groupName = "Grp2";
    String userName = "test";
    Mockito.when(xGroupService.getGroupByGroupName(Mockito.anyString())).thenReturn(vxGroup);
    Mockito.when(xUserService.getXUserByUserName(Mockito.anyString())).thenReturn(vxUser);
    Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(vxGroupUserList);
    xUserMgr.deleteXGroupAndXUser(groupName, userName);
    Mockito.verify(xGroupService).getGroupByGroupName(Mockito.anyString());
    Mockito.verify(xUserService).getXUserByUserName(Mockito.anyString());
    Mockito.verify(xGroupUserService).searchXGroupUsers((SearchCriteria) Mockito.any());
}
Also used : VXGroupUserList(org.apache.ranger.view.VXGroupUserList) VXString(org.apache.ranger.view.VXString) VXUser(org.apache.ranger.view.VXUser) VXGroup(org.apache.ranger.view.VXGroup) Test(org.junit.Test)

Example 32 with VXGroup

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

the class TestXUserMgr method test20ModifyGroupsVisibilitySetEmpty.

@Test
public void test20ModifyGroupsVisibilitySetEmpty() {
    XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
    VXGroup vXGroup = new VXGroup();
    vXGroup.setId(userId);
    vXGroup.setDescription("group test");
    vXGroup.setName("grouptest");
    XXGroup xxGroup = new XXGroup();
    HashMap<Long, Integer> groupVisibilityMap = new HashMap<Long, Integer>();
    groupVisibilityMap.put(userId, emptyValue);
    Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
    Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
    Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vXGroup);
    Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
    xUserMgr.modifyGroupsVisibility(groupVisibilityMap);
    Assert.assertEquals(emptyValue, vXGroup.getIsVisible());
    Assert.assertEquals(userId, vXGroup.getId());
    Mockito.verify(daoManager).getXXGroup();
    Mockito.verify(xGroupService).populateViewBean(xxGroup);
    Mockito.verify(xGroupService).updateResource(vXGroup);
}
Also used : XXGroup(org.apache.ranger.entity.XXGroup) HashMap(java.util.HashMap) VXGroup(org.apache.ranger.view.VXGroup) XXGroupDao(org.apache.ranger.db.XXGroupDao) Test(org.junit.Test)

Aggregations

VXGroup (org.apache.ranger.view.VXGroup)32 Test (org.junit.Test)26 VXString (org.apache.ranger.view.VXString)10 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 XXGroup (org.apache.ranger.entity.XXGroup)7 ArrayList (java.util.ArrayList)5 XXGroupDao (org.apache.ranger.db.XXGroupDao)5 VXStringList (org.apache.ranger.view.VXStringList)4 HashMap (java.util.HashMap)3 VXGroupUser (org.apache.ranger.view.VXGroupUser)3 VXUser (org.apache.ranger.view.VXUser)3 XXGroupUserDao (org.apache.ranger.db.XXGroupUserDao)2 VXGroupList (org.apache.ranger.view.VXGroupList)2 VXGroupUserList (org.apache.ranger.view.VXGroupUserList)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 SearchCriteria (org.apache.ranger.common.SearchCriteria)1 UserSessionBase (org.apache.ranger.common.UserSessionBase)1 XXAuditMapDao (org.apache.ranger.db.XXAuditMapDao)1