use of org.apache.ranger.view.VXPortalUser in project ranger by apache.
the class TestUserREST method test8CreateDefaultAccountUser.
@Test
public void test8CreateDefaultAccountUser() {
VXPortalUser vxPUserExp = CreateVXPortalUser();
Mockito.when(userManager.createDefaultAccountUser(vxPUserExp)).thenReturn(vxPUserExp);
Mockito.doNothing().when(xUserMgr).assignPermissionToUser(vxPUserExp, true);
VXPortalUser VXPUserAct = userREST.createDefaultAccountUser(vxPUserExp, request);
Assert.assertNotNull(VXPUserAct);
Assert.assertEquals(vxPUserExp, VXPUserAct);
Assert.assertEquals(vxPUserExp.getLoginId(), VXPUserAct.getLoginId());
Assert.assertEquals(vxPUserExp.getFirstName(), VXPUserAct.getFirstName());
Assert.assertEquals(vxPUserExp.getLastName(), VXPUserAct.getLastName());
Assert.assertEquals(vxPUserExp.getEmailAddress(), VXPUserAct.getEmailAddress());
Mockito.verify(userManager).createDefaultAccountUser(vxPUserExp);
Mockito.verify(xUserMgr).assignPermissionToUser(vxPUserExp, true);
}
use of org.apache.ranger.view.VXPortalUser in project ranger by apache.
the class TestUserREST method test7CreateDefaultAccountUser.
@Test
public void test7CreateDefaultAccountUser() {
VXPortalUser vxPUserExp = new VXPortalUser();
vxPUserExp = null;
Mockito.when(userManager.createDefaultAccountUser(vxPUserExp)).thenReturn(vxPUserExp);
VXPortalUser VXPUserAct = userREST.createDefaultAccountUser(vxPUserExp, request);
Assert.assertNull(VXPUserAct);
Mockito.verify(userManager).createDefaultAccountUser(vxPUserExp);
}
use of org.apache.ranger.view.VXPortalUser in project ranger by apache.
the class TestUserREST method test9Update.
@Test
public void test9Update() {
VXPortalUser vxPUserExp = new VXPortalUser();
XXPortalUser xxPUserExp = new XXPortalUser();
xxPUserExp = null;
XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class);
Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao);
Mockito.doNothing().when(userManager).checkAccess(xxPUserExp);
Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any(), Mockito.nullable(Long.class), Mockito.nullable(String.class), Mockito.anyString())).thenReturn(new WebApplicationException());
thrown.expect(WebApplicationException.class);
userREST.update(vxPUserExp, request);
Mockito.verify(daoManager).getXXPortalUser();
Mockito.verify(xxPortalUserDao).getById(Mockito.anyLong());
Mockito.verify(userManager).checkAccess(xxPUserExp);
Mockito.verify(restErrorUtil).createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any(), Mockito.anyLong(), Mockito.anyString(), Mockito.anyString());
}
use of org.apache.ranger.view.VXPortalUser in project ranger by apache.
the class TestUserREST method test8Update.
@Test
public void test8Update() {
VXPortalUser vxPUserExp = CreateVXPortalUser();
vxPUserExp.setLoginId(loginId);
XXPortalUser xxPUserExp = new XXPortalUser();
xxPUserExp.setLoginId(loginId);
XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class);
Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao);
Mockito.when(xxPortalUserDao.getById(Mockito.anyLong())).thenReturn(xxPUserExp);
Mockito.doNothing().when(userManager).checkAccess(xxPUserExp);
Mockito.doNothing().when(msRestUtil).validateVUserProfileForUpdate(xxPUserExp, vxPUserExp);
Mockito.when(userManager.updateUser(vxPUserExp)).thenReturn(xxPUserExp);
Mockito.when(userManager.mapXXPortalUserVXPortalUser(xxPUserExp)).thenReturn(vxPUserExp);
VXPortalUser vxPUserAct = userREST.update(vxPUserExp, request);
Assert.assertNotNull(vxPUserAct);
Assert.assertEquals(xxPUserExp.getLoginId(), vxPUserAct.getLoginId());
Assert.assertEquals(vxPUserExp.getId(), vxPUserAct.getId());
Assert.assertEquals(vxPUserExp.getFirstName(), vxPUserAct.getFirstName());
Mockito.verify(daoManager).getXXPortalUser();
Mockito.verify(xxPortalUserDao).getById(Mockito.anyLong());
Mockito.verify(userManager).checkAccess(xxPUserExp);
Mockito.verify(msRestUtil).validateVUserProfileForUpdate(xxPUserExp, vxPUserExp);
Mockito.verify(userManager).updateUser(vxPUserExp);
Mockito.verify(userManager).mapXXPortalUserVXPortalUser(xxPUserExp);
}
use of org.apache.ranger.view.VXPortalUser in project ranger by apache.
the class TestUserREST method CreateVXPortalUser.
private VXPortalUser CreateVXPortalUser() {
VXPortalUser vxPUserExp = new VXPortalUser();
vxPUserExp.setId(userId);
vxPUserExp.setFirstName(firstName);
vxPUserExp.setLastName(lastName);
vxPUserExp.setEmailAddress(emailId);
vxPUserExp.setLoginId(loginId);
return vxPUserExp;
}
Aggregations