Search in sources :

Example 6 with SearchCriteria

use of org.apache.ranger.common.SearchCriteria 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 7 with SearchCriteria

use of org.apache.ranger.common.SearchCriteria 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 8 with SearchCriteria

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

the class TestXUserREST method createsearchCriteria.

private SearchCriteria createsearchCriteria() {
    SearchCriteria testsearchCriteria = new SearchCriteria();
    testsearchCriteria.setStartIndex(0);
    testsearchCriteria.setMaxRows(Integer.MAX_VALUE);
    testsearchCriteria.setSortBy("id");
    testsearchCriteria.setSortType("asc");
    testsearchCriteria.setGetCount(true);
    testsearchCriteria.setOwnerId(null);
    testsearchCriteria.setGetChildren(false);
    testsearchCriteria.setDistinct(false);
    return testsearchCriteria;
}
Also used : SearchCriteria(org.apache.ranger.common.SearchCriteria)

Example 9 with SearchCriteria

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

the class TestXUserREST method test86searchXUserPermission.

@SuppressWarnings("unchecked")
@Test
public void test86searchXUserPermission() {
    VXUserPermissionList testVXUserPermissionList = new VXUserPermissionList();
    testVXUserPermissionList.setTotalCount(1);
    testVXUserPermissionList.setStartIndex(1);
    VXUserPermission testVXUserPermission = createVXUserPermission();
    List<VXUserPermission> testVXUserPermissions = new ArrayList<VXUserPermission>();
    testVXUserPermissions.add(testVXUserPermission);
    testVXUserPermissionList.setvXModuleDef(testVXUserPermissions);
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "id", "id", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "userPermissionList", "userId", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(xUserMgr.searchXUserPermission(testSearchCriteria)).thenReturn(testVXUserPermissionList);
    VXUserPermissionList outputVXUserPermissionList = xUserRest.searchXUserPermission(request);
    assertNotNull(outputVXUserPermissionList);
    assertEquals(outputVXUserPermissionList.getStartIndex(), testVXUserPermissionList.getStartIndex());
    assertEquals(outputVXUserPermissionList.getTotalCount(), testVXUserPermissionList.getTotalCount());
    Mockito.verify(xUserMgr).searchXUserPermission(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "id", "id", StringUtil.VALIDATION_NAME);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "userPermissionList", "userId", StringUtil.VALIDATION_NAME);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXUserPermissionList(org.apache.ranger.view.VXUserPermissionList) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXUserPermission(org.apache.ranger.view.VXUserPermission) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 10 with SearchCriteria

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

the class TestXUserREST method test81countXModuleDef.

@SuppressWarnings("unchecked")
@Test
public void test81countXModuleDef() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    vXLong.setValue(1);
    Mockito.when(xUserMgr.getXModuleDefSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXModuleDef(request);
    Mockito.verify(xUserMgr).getXModuleDefSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(testvxLong);
    assertEquals(testvxLong.getValue(), vXLong.getValue());
    assertEquals(testvxLong.getClass(), vXLong.getClass());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Aggregations

SearchCriteria (org.apache.ranger.common.SearchCriteria)61 Test (org.junit.Test)29 SortField (org.apache.ranger.common.SortField)27 ArrayList (java.util.ArrayList)22 HttpServletRequest (javax.servlet.http.HttpServletRequest)20 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)12 VXLong (org.apache.ranger.view.VXLong)10 Date (java.util.Date)9 DateUtil (org.apache.ranger.common.DateUtil)6 HashMap (java.util.HashMap)4 XXPortalUser (org.apache.ranger.entity.XXPortalUser)4 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)4 RangerPolicyItem (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem)4 VXPermMap (org.apache.ranger.view.VXPermMap)4 VXUserList (org.apache.ranger.view.VXUserList)4 List (java.util.List)3 XXServiceDef (org.apache.ranger.entity.XXServiceDef)3