use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class TestXUserREST method test48searchXPermMaps.
@SuppressWarnings("unchecked")
@Test
public void test48searchXPermMaps() {
VXPermMap permMap = testcreateXPermMap();
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
SearchCriteria testSearchCriteria = createsearchCriteria();
Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
List<VXPermMap> vXPermMaps = new ArrayList<VXPermMap>();
vXPermMaps.add(permMap);
VXPermMapList testvXGroupList = new VXPermMapList();
testvXGroupList.setTotalCount(1);
testvXGroupList.setVXPermMaps(vXPermMaps);
Mockito.when(xUserMgr.searchXPermMaps(testSearchCriteria)).thenReturn(testvXGroupList);
VXPermMapList outputvXGroupList = xUserRest.searchXPermMaps(request);
Mockito.verify(xUserMgr).searchXPermMaps(testSearchCriteria);
Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
assertNotNull(outputvXGroupList);
assertEquals(outputvXGroupList.getClass(), testvXGroupList.getClass());
assertEquals(outputvXGroupList.getTotalCount(), testvXGroupList.getTotalCount());
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class TestUserMgr method test25searchUsers.
@Test
public void test25searchUsers() {
Query query = Mockito.mock(Query.class);
EntityManager entityManager = Mockito.mock(EntityManager.class);
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.setDistinct(true);
searchCriteria.setGetChildren(true);
searchCriteria.setGetCount(true);
searchCriteria.setMaxRows(12);
searchCriteria.setOwnerId(userId);
searchCriteria.setStartIndex(1);
searchCriteria.setSortBy("asc");
Long count = 1l;
Mockito.when(daoManager.getEntityManager()).thenReturn(entityManager);
Mockito.when(entityManager.createQuery(Mockito.anyString())).thenReturn(query);
Mockito.when(query.getSingleResult()).thenReturn(count);
VXPortalUserList dbVXPortalUserList = userMgr.searchUsers(searchCriteria);
Assert.assertNotNull(dbVXPortalUserList);
Mockito.verify(query).getSingleResult();
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class TestXUserMgr method test23GetXGroupUsers.
@Test
public void test23GetXGroupUsers() {
SearchCriteria testSearchCriteria = createsearchCriteria();
testSearchCriteria.addParam("xGroupId", userId);
VXUserList dbVXUserList = xUserMgr.getXGroupUsers(testSearchCriteria);
VXGroup vXGroup = new VXGroup();
vXGroup.setId(userId);
vXGroup.setDescription("group test");
vXGroup.setName("grouptest");
Assert.assertNotNull(dbVXUserList);
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class TestAssetREST method testGetAccessLogs.
@Test
public void testGetAccessLogs() {
SearchCriteria searchCriteria = new SearchCriteria();
List<SortField> sortFields = null;
List<VXAccessAudit> vXAccessAudits = new ArrayList<VXAccessAudit>();
VXAccessAuditList vXAccessAuditList = new VXAccessAuditList();
vXAccessAuditList.setVXAccessAudits(vXAccessAudits);
Mockito.when(searchUtil.extractCommonCriterias(request, sortFields)).thenReturn(searchCriteria);
Mockito.when(searchUtil.extractString((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn("test");
Mockito.when(searchUtil.extractInt((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString())).thenReturn((Integer) 8);
Mockito.when(searchUtil.extractDate((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(new Date());
Mockito.when(searchUtil.extractLong((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString())).thenReturn((Long) 8l);
Mockito.when(msBizUtil.isKeyAdmin()).thenReturn(false);
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xxServiceDefDao);
XXServiceDef xServiceDef = new XXServiceDef();
xServiceDef.setId(Id);
Mockito.when(xxServiceDefDao.findByName(EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_KMS_NAME)).thenReturn(xServiceDef);
Mockito.when(assetMgr.getAccessLogs(searchCriteria)).thenReturn(vXAccessAuditList);
VXAccessAuditList expectedVXAccessAuditList = assetREST.getAccessLogs(request);
Assert.assertEquals(vXAccessAuditList, expectedVXAccessAuditList);
Mockito.verify(msBizUtil).isKeyAdmin();
Mockito.verify(assetMgr).getAccessLogs(searchCriteria);
Mockito.verify(daoManager).getXXServiceDef();
Mockito.verify(searchUtil, Mockito.times(12)).extractString((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.nullable(String.class));
Mockito.verify(searchUtil, Mockito.times(4)).extractInt((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString());
Mockito.verify(searchUtil, Mockito.times(2)).extractDate((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
Mockito.verify(searchUtil).extractLong((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString());
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class TestAssetREST method testSearchXPolicyExportAudits.
@Test
public void testSearchXPolicyExportAudits() {
SearchCriteria searchCriteria = new SearchCriteria();
List<SortField> sortFields = null;
List<VXPolicyExportAudit> vXPolicyExportAudits = new ArrayList<VXPolicyExportAudit>();
VXPolicyExportAuditList vXPolicyExportAuditList = new VXPolicyExportAuditList();
vXPolicyExportAuditList.setVXPolicyExportAudits(vXPolicyExportAudits);
Mockito.when(searchUtil.extractCommonCriterias(request, sortFields)).thenReturn(searchCriteria);
Mockito.when(searchUtil.extractString((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn("test");
Mockito.when(searchUtil.extractInt((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString())).thenReturn((Integer) 8);
Mockito.when(assetMgr.searchXPolicyExportAudits(searchCriteria)).thenReturn(vXPolicyExportAuditList);
VXPolicyExportAuditList expectedVXPolicyExportAuditList = assetREST.searchXPolicyExportAudits(request);
Assert.assertEquals(vXPolicyExportAuditList, expectedVXPolicyExportAuditList);
Mockito.verify(searchUtil).extractCommonCriterias(request, sortFields);
Mockito.verify(searchUtil, Mockito.times(4)).extractString((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
Mockito.verify(searchUtil).extractInt((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString());
Mockito.verify(searchUtil, Mockito.times(2)).extractDate((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), (String) Mockito.isNull());
Mockito.verify(searchUtil).extractCommonCriterias(request, sortFields);
Mockito.verify(assetMgr).searchXPolicyExportAudits(searchCriteria);
}
Aggregations