Search in sources :

Example 21 with XXGroupUser

use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.

the class TestXUserMgr method test32createXGroupPermission.

@Test
public void test32createXGroupPermission() {
    VXGroupPermission vXGroupPermission = vxGroupPermission();
    XXGroupUserDao xGrpUserDao = Mockito.mock(XXGroupUserDao.class);
    Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGrpUserDao);
    Mockito.when(xGroupPermissionService.createResource(vXGroupPermission)).thenReturn(vXGroupPermission);
    List<XXGroupUser> xXGroupUserList = new ArrayList<XXGroupUser>();
    VXGroupUser vxGroupUser = vxGroupUser();
    XXGroupUser xXGroupUser = new XXGroupUser();
    xXGroupUser.setId(vxGroupUser.getId());
    xXGroupUser.setName(vxGroupUser.getName());
    xXGroupUser.setParentGroupId(vxGroupUser.getParentGroupId());
    xXGroupUser.setUserId(vxGroupUser.getUserId());
    xXGroupUserList.add(xXGroupUser);
    Mockito.when(xGrpUserDao.findByGroupId(vXGroupPermission.getGroupId())).thenReturn(xXGroupUserList);
    UserSessionBase userSession = Mockito.mock(UserSessionBase.class);
    Set<UserSessionBase> userSessions = new HashSet<UserSessionBase>();
    userSessions.add(userSession);
    Mockito.when(sessionMgr.getActiveUserSessionsForXUserId(xXGroupUser.getUserId())).thenReturn(userSessions);
    VXGroupPermission dbGroupPermission = xUserMgr.createXGroupPermission(vXGroupPermission);
    Assert.assertNotNull(dbGroupPermission);
    Assert.assertEquals(dbGroupPermission, vXGroupPermission);
    Assert.assertEquals(dbGroupPermission.getId(), vXGroupPermission.getId());
    Assert.assertEquals(dbGroupPermission.getGroupName(), vXGroupPermission.getGroupName());
    Assert.assertEquals(dbGroupPermission.getOwner(), vXGroupPermission.getOwner());
    Assert.assertEquals(dbGroupPermission.getUpdatedBy(), vXGroupPermission.getUpdatedBy());
    Assert.assertEquals(dbGroupPermission.getCreateDate(), vXGroupPermission.getCreateDate());
    Assert.assertEquals(dbGroupPermission.getGroupId(), vXGroupPermission.getGroupId());
    Assert.assertEquals(dbGroupPermission.getIsAllowed(), vXGroupPermission.getIsAllowed());
    Assert.assertEquals(dbGroupPermission.getModuleId(), vXGroupPermission.getModuleId());
    Assert.assertEquals(dbGroupPermission.getUpdateDate(), vXGroupPermission.getUpdateDate());
    Mockito.verify(xGroupPermissionService).createResource(vXGroupPermission);
}
Also used : XXGroupUser(org.apache.ranger.entity.XXGroupUser) XXGroupUserDao(org.apache.ranger.db.XXGroupUserDao) VXGroupPermission(org.apache.ranger.view.VXGroupPermission) ArrayList(java.util.ArrayList) VXGroupUser(org.apache.ranger.view.VXGroupUser) UserSessionBase(org.apache.ranger.common.UserSessionBase) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

XXGroupUser (org.apache.ranger.entity.XXGroupUser)21 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)10 XXGroupUserDao (org.apache.ranger.db.XXGroupUserDao)8 VXGroupUser (org.apache.ranger.view.VXGroupUser)8 XXGroup (org.apache.ranger.entity.XXGroup)6 HashSet (java.util.HashSet)5 UserSessionBase (org.apache.ranger.common.UserSessionBase)5 XXGroupPermission (org.apache.ranger.entity.XXGroupPermission)4 VXGroupPermission (org.apache.ranger.view.VXGroupPermission)4 VXGroup (org.apache.ranger.view.VXGroup)3 HashMap (java.util.HashMap)2 XXGroupDao (org.apache.ranger.db.XXGroupDao)2 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)2 XXModuleDef (org.apache.ranger.entity.XXModuleDef)2 XXUserPermission (org.apache.ranger.entity.XXUserPermission)2 HadoopException (org.apache.ranger.plugin.client.HadoopException)2 RangerSecurityZone (org.apache.ranger.plugin.model.RangerSecurityZone)2 VXLong (org.apache.ranger.view.VXLong)2 VXModuleDef (org.apache.ranger.view.VXModuleDef)2