Search in sources :

Example 11 with SearchCriteria

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

the class TestXUserREST method test36searchXGroupGroups.

@SuppressWarnings("unchecked")
@Test
public void test36searchXGroupGroups() {
    VXGroupGroupList testvXGroupGroupList = new VXGroupGroupList();
    VXGroupGroup testVXGroup = createVXGroupGroup();
    List<VXGroupGroup> testVXGroupGroups = new ArrayList<VXGroupGroup>();
    testVXGroupGroups.add(testVXGroup);
    testvXGroupGroupList.setVXGroupGroups(testVXGroupGroups);
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    Mockito.when(xUserMgr.searchXGroupGroups(testSearchCriteria)).thenReturn(testvXGroupGroupList);
    VXGroupGroupList outputvXGroupGroupList = xUserRest.searchXGroupGroups(request);
    Mockito.verify(xUserMgr).searchXGroupGroups(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(outputvXGroupGroupList);
    assertEquals(outputvXGroupGroupList.getClass(), testvXGroupGroupList.getClass());
    assertEquals(outputvXGroupGroupList.getResultSize(), testvXGroupGroupList.getResultSize());
}
Also used : VXGroupGroupList(org.apache.ranger.view.VXGroupGroupList) HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) VXGroupGroup(org.apache.ranger.view.VXGroupGroup) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 12 with SearchCriteria

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

the class TestXUserREST method test93countXGroupPermission.

@SuppressWarnings("unchecked")
@Test
public void test93countXGroupPermission() {
    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.getXGroupPermissionSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXGroupPermission(request);
    Mockito.verify(xUserMgr).getXGroupPermissionSearchCount(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 13 with SearchCriteria

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

the class TestXUserREST method test31countXGroupUserst.

@SuppressWarnings("unchecked")
@Test
public void test31countXGroupUserst() {
    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.getXGroupUserSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXGroupUsers(request);
    Mockito.verify(xUserMgr).getXGroupUserSearchCount(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 14 with SearchCriteria

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

the class TestXUserREST method test24searchXUsers.

@SuppressWarnings("unchecked")
@Test
public void test24searchXUsers() {
    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, "name", "User name", null)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "emailAddress", "Email Address", null)).thenReturn("");
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "userSource", "User Source")).thenReturn(1);
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "isVisible", "User Visibility")).thenReturn(1);
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "status", "User Status")).thenReturn(1);
    Mockito.when(searchUtil.extractStringList(request, testSearchCriteria, "userRoleList", "User Role List", "userRoleList", null, null)).thenReturn(new ArrayList<String>());
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "userRole", "UserRole", null)).thenReturn("");
    List<VXUser> vXUsersList = new ArrayList<VXUser>();
    vXUsersList.add(vxUser);
    VXUserList testVXUserList = new VXUserList();
    testVXUserList.setVXUsers(vXUsersList);
    Mockito.when(xUserMgr.searchXUsers(testSearchCriteria)).thenReturn(testVXUserList);
    VXUserList gotVXUserList = xUserRest.searchXUsers(request);
    Mockito.verify(xUserMgr).searchXUsers(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "name", "User name", null);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "emailAddress", "Email Address", null);
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "userSource", "User Source");
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "isVisible", "User Visibility");
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "status", "User Status");
    Mockito.verify(searchUtil).extractStringList(request, testSearchCriteria, "userRoleList", "User Role List", "userRoleList", null, null);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "userRole", "UserRole", null);
    assertNotNull(gotVXUserList);
    assertEquals(testVXUserList.getTotalCount(), gotVXUserList.getTotalCount());
    assertEquals(testVXUserList.getClass(), gotVXUserList.getClass());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXString(org.apache.ranger.view.VXString) VXUser(org.apache.ranger.view.VXUser) VXUserList(org.apache.ranger.view.VXUserList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 15 with SearchCriteria

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

the class TestXUserREST method test49countXPermMaps.

@SuppressWarnings("unchecked")
@Test
public void test49countXPermMaps() {
    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.getXPermMapSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXPermMaps(request);
    Mockito.verify(xUserMgr).getXPermMapSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    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)

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