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);
}
Aggregations