Search in sources :

Example 1 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestAssetREST method testGetAccessLogsForKms.

@Test
public void testGetAccessLogsForKms() {
    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(searchUtil.extractLong((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString())).thenReturn((Long) 8l);
    Mockito.when(msBizUtil.isKeyAdmin()).thenReturn(true);
    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());
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXAccessAudit(org.apache.ranger.view.VXAccessAudit) VXAccessAuditList(org.apache.ranger.view.VXAccessAuditList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Date(java.util.Date) Test(org.junit.Test)

Example 2 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestAssetREST method testGetReportLogs.

@Test
public void testGetReportLogs() {
    SearchCriteria searchCriteria = new SearchCriteria();
    List<SortField> sortFields = null;
    List<VXTrxLog> vXTrxLogs = new ArrayList<VXTrxLog>();
    VXTrxLogList vXTrxLogList = new VXTrxLogList();
    vXTrxLogList.setVXTrxLogs(vXTrxLogs);
    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(assetMgr.getReportLogs(searchCriteria)).thenReturn(vXTrxLogList);
    VXTrxLogList expectedVXTrxLogListt = assetREST.getReportLogs(request);
    Assert.assertEquals(vXTrxLogList, expectedVXTrxLogListt);
    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(), Mockito.anyString());
    Mockito.verify(assetMgr).getReportLogs(searchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias(request, sortFields);
}
Also used : VXTrxLog(org.apache.ranger.view.VXTrxLog) VXTrxLogList(org.apache.ranger.view.VXTrxLogList) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Date(java.util.Date) Test(org.junit.Test)

Example 3 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestAssetREST method testCountXCredentialStores.

@Test
public void testCountXCredentialStores() {
    VXLong expectedvXLong = new VXLong();
    SearchCriteria searchCriteria = new SearchCriteria();
    List<SortField> sortFields = null;
    Mockito.when(searchUtil.extractCommonCriterias(request, sortFields)).thenReturn(searchCriteria);
    Mockito.when(assetMgr.getXCredentialStoreSearchCount(searchCriteria)).thenReturn(expectedvXLong);
    VXLong actualvXLong = assetREST.countXCredentialStores(request);
    Assert.assertEquals(expectedvXLong, actualvXLong);
    Mockito.verify(assetMgr).getXCredentialStoreSearchCount(searchCriteria);
}
Also used : VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 4 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestXAuditREST method Test5searchXTrxLog.

@SuppressWarnings("unchecked")
@Test
public void Test5searchXTrxLog() {
    VXTrxLogList vxExpList = new VXTrxLogList();
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    searchCriteria.addParam("name", name);
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(searchCriteria);
    Mockito.when(xAuditMgr.searchXTrxLogs(searchCriteria)).thenReturn(vxExpList);
    VXTrxLogList vxActList = auditREST.searchXTrxLogs(request);
    Assert.assertNotNull(vxActList);
    Assert.assertEquals(vxExpList, vxActList);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(xAuditMgr).searchXTrxLogs(searchCriteria);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXTrxLogList(org.apache.ranger.view.VXTrxLogList) SortField(org.apache.ranger.common.SortField) Test(org.junit.Test)

Example 5 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestXAuditREST method Test7searchXAccessAudits.

@SuppressWarnings("unchecked")
@Test
public void Test7searchXAccessAudits() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    searchCriteria.addParam("name", name);
    VXAccessAuditList vxAAListExp = new VXAccessAuditList();
    vxAAListExp.setTotalCount(6L);
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(searchCriteria);
    Mockito.when(xAuditMgr.searchXAccessAudits(searchCriteria)).thenReturn(vxAAListExp);
    VXAccessAuditList vxAAListAct = auditREST.searchXAccessAudits(request);
    Assert.assertNotNull(vxAAListAct);
    Assert.assertEquals(vxAAListExp, vxAAListAct);
    Assert.assertEquals(vxAAListExp.getTotalCount(), vxAAListAct.getTotalCount());
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(xAuditMgr).searchXAccessAudits(searchCriteria);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SortField(org.apache.ranger.common.SortField) VXAccessAuditList(org.apache.ranger.view.VXAccessAuditList) Test(org.junit.Test)

Aggregations

SortField (org.apache.ranger.common.SortField)34 Test (org.junit.Test)30 SearchCriteria (org.apache.ranger.common.SearchCriteria)26 HttpServletRequest (javax.servlet.http.HttpServletRequest)23 ArrayList (java.util.ArrayList)15 VXLong (org.apache.ranger.view.VXLong)12 Date (java.util.Date)3 VXAccessAuditList (org.apache.ranger.view.VXAccessAuditList)3 XXServiceDef (org.apache.ranger.entity.XXServiceDef)2 VXAccessAudit (org.apache.ranger.view.VXAccessAudit)2 VXTrxLogList (org.apache.ranger.view.VXTrxLogList)2 VXUser (org.apache.ranger.view.VXUser)2 VXUserList (org.apache.ranger.view.VXUserList)2 Predicate (org.apache.commons.collections.Predicate)1 KeySearchFilter (org.apache.ranger.plugin.util.KeySearchFilter)1 VXAuditMap (org.apache.ranger.view.VXAuditMap)1 VXAuditMapList (org.apache.ranger.view.VXAuditMapList)1 VXAuthSession (org.apache.ranger.view.VXAuthSession)1 VXAuthSessionList (org.apache.ranger.view.VXAuthSessionList)1 VXCredentialStore (org.apache.ranger.view.VXCredentialStore)1