Search in sources :

Example 46 with SearchCriteria

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

the class TestXUserREST method test30searchXGroupUsers.

@SuppressWarnings("unchecked")
@Test
public void test30searchXGroupUsers() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    VXGroupUserList testVXGroupUserList = new VXGroupUserList();
    VXGroupUser vXGroupUser = createVXGroupUser();
    List<VXGroupUser> vXGroupUsers = new ArrayList<VXGroupUser>();
    vXGroupUsers.add(vXGroupUser);
    testVXGroupUserList.setVXGroupUsers(vXGroupUsers);
    Mockito.when(xUserMgr.searchXGroupUsers(testSearchCriteria)).thenReturn(testVXGroupUserList);
    VXGroupUserList outputvXGroupList = xUserRest.searchXGroupUsers(request);
    Mockito.verify(xUserMgr).searchXGroupUsers(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(outputvXGroupList);
    assertEquals(outputvXGroupList.getClass(), testVXGroupUserList.getClass());
    assertEquals(outputvXGroupList.getResultSize(), testVXGroupUserList.getResultSize());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXGroupUserList(org.apache.ranger.view.VXGroupUserList) ArrayList(java.util.ArrayList) VXGroupUser(org.apache.ranger.view.VXGroupUser) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 47 with SearchCriteria

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

the class TestXUserREST method test61countXAuditMaps.

@SuppressWarnings("unchecked")
@Test
public void test61countXAuditMaps() {
    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.getXAuditMapSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXAuditMaps(request);
    Mockito.verify(xUserMgr).getXAuditMapSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertEquals(testvxLong.getClass(), vXLong.getClass());
    assertEquals(testvxLong.getValue(), vXLong.getValue());
    assertNotNull(testvxLong);
}
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)

Example 48 with SearchCriteria

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

the class TestXUserREST method test87countXUserPermission.

@SuppressWarnings("unchecked")
@Test
public void test87countXUserPermission() {
    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.getXUserPermissionSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXUserPermission(request);
    Mockito.verify(xUserMgr).getXUserPermissionSearchCount(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)

Example 49 with SearchCriteria

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

the class TestXUserREST method test92searchXGroupPermission.

@SuppressWarnings("unchecked")
@Test
public void test92searchXGroupPermission() {
    VXGroupPermissionList testVXGroupPermissionList = new VXGroupPermissionList();
    testVXGroupPermissionList.setTotalCount(1);
    VXGroupPermission testVXGroupPermission = createVXGroupPermission();
    List<VXGroupPermission> testVXGroupPermissions = new ArrayList<VXGroupPermission>();
    testVXGroupPermissions.add(testVXGroupPermission);
    testVXGroupPermissionList.setvXGroupPermission(testVXGroupPermissions);
    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, "groupPermissionList", "groupId", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(xUserMgr.searchXGroupPermission(testSearchCriteria)).thenReturn(testVXGroupPermissionList);
    VXGroupPermissionList outputVXGroupPermissionList = xUserRest.searchXGroupPermission(request);
    assertNotNull(outputVXGroupPermissionList);
    assertEquals(outputVXGroupPermissionList.getClass(), testVXGroupPermissionList.getClass());
    assertEquals(outputVXGroupPermissionList.getTotalCount(), testVXGroupPermissionList.getTotalCount());
    Mockito.verify(xUserMgr).searchXGroupPermission(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, "groupPermissionList", "groupId", StringUtil.VALIDATION_NAME);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXGroupPermission(org.apache.ranger.view.VXGroupPermission) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXGroupPermissionList(org.apache.ranger.view.VXGroupPermissionList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 50 with SearchCriteria

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

the class TestXUserREST method test12countXGroups.

@SuppressWarnings("unchecked")
@Test
public void test12countXGroups() {
    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.getXGroupSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXGroups(request);
    Mockito.verify(xUserMgr).getXGroupSearchCount(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