@Test public void testGetMappedSearchParams(){ ArrayList<Integer> statusList = new ArrayList<Integer>(); statusList.add(RangerCommonEnums.STATUS_DISABLED); statusList.add(RangerCommonEnums.STATUS_ENABLED); SearchCriteria expectedSearchCriteria = new SearchCriteria(); expectedSearchCriteria.addParam("status", statusList); expectedSearchCriteria.addParam("type", 3); SearchCriteria sc = new SearchCriteria(); HttpServletRequest request = Mockito.mock(HttpServletRequest.class); sc.addParam("status", null); sc.addParam("type", "hive"); SearchCriteria actualSearchCriteria = serviceUtil.getMappedSearchParams(request, sc); Assert.assertNotNull(actualSearchCriteria); Assert.assertEquals(expectedSearchCriteria.getParamValue("type"), actualSearchCriteria.getParamValue("type")); Assert.assertEquals(expectedSearchCriteria.getParamValue("status"), actualSearchCriteria.getParamValue("status")); }
public SearchCriteria getMappedSearchParams(HttpServletRequest request, SearchCriteria searchCriteria) { Object typeObj = searchCriteria.getParamValue("type"); Object statusObj = searchCriteria.getParamValue("status"); ArrayList<Integer> statusList = new ArrayList<Integer>(); if (statusObj == null) { statusList.add(RangerCommonEnums.STATUS_DISABLED); statusList.add(RangerCommonEnums.STATUS_ENABLED); } else { Boolean status = restErrorUtil.parseBoolean( request.getParameter("status"), "Invalid value for " + "status", MessageEnums.INVALID_INPUT_DATA, null, "status"); int statusEnum = (status == null || status == false) ? AppConstants.STATUS_DISABLED : AppConstants.STATUS_ENABLED; statusList.add(statusEnum); } searchCriteria.addParam("status", statusList); if (typeObj != null) { String type = typeObj.toString(); int typeEnum = AppConstants.getEnumFor_AssetType(type); searchCriteria.addParam("type", typeEnum); } return searchCriteria; }
ServiceUtil { public SearchCriteria getMappedSearchParams(HttpServletRequest request, SearchCriteria searchCriteria) { Object typeObj = searchCriteria.getParamValue("type"); Object statusObj = searchCriteria.getParamValue("status"); ArrayList<Integer> statusList = new ArrayList<Integer>(); if (statusObj == null) { statusList.add(RangerCommonEnums.STATUS_DISABLED); statusList.add(RangerCommonEnums.STATUS_ENABLED); } else { Boolean status = restErrorUtil.parseBoolean( request.getParameter("status"), "Invalid value for " + "status", MessageEnums.INVALID_INPUT_DATA, null, "status"); int statusEnum = (status == null || status == false) ? AppConstants.STATUS_DISABLED : AppConstants.STATUS_ENABLED; statusList.add(statusEnum); } searchCriteria.addParam("status", statusList); if (typeObj != null) { String type = typeObj.toString(); int typeEnum = AppConstants.getEnumFor_AssetType(type); searchCriteria.addParam("type", typeEnum); } return searchCriteria; } }
ServiceUtil { public SearchCriteria getMappedSearchParams(HttpServletRequest request, SearchCriteria searchCriteria) { Object typeObj = searchCriteria.getParamValue("type"); Object statusObj = searchCriteria.getParamValue("status"); ArrayList<Integer> statusList = new ArrayList<Integer>(); if (statusObj == null) { statusList.add(RangerCommonEnums.STATUS_DISABLED); statusList.add(RangerCommonEnums.STATUS_ENABLED); } else { Boolean status = restErrorUtil.parseBoolean( request.getParameter("status"), "Invalid value for " + "status", MessageEnums.INVALID_INPUT_DATA, null, "status"); int statusEnum = (status == null || status == false) ? AppConstants.STATUS_DISABLED : AppConstants.STATUS_ENABLED; statusList.add(statusEnum); } searchCriteria.addParam("status", statusList); if (typeObj != null) { String type = typeObj.toString(); int typeEnum = AppConstants.getEnumFor_AssetType(type); searchCriteria.addParam("type", typeEnum); } return searchCriteria; }  }
ServiceUtil { public SearchCriteria getMappedSearchParams(HttpServletRequest request, SearchCriteria searchCriteria) { Object typeObj = searchCriteria.getParamValue("type"); Object statusObj = searchCriteria.getParamValue("status"); ArrayList<Integer> statusList = new ArrayList<Integer>(); if (statusObj == null) { statusList.add(RangerCommonEnums.STATUS_DISABLED); statusList.add(RangerCommonEnums.STATUS_ENABLED); } else { Boolean status = restErrorUtil.parseBoolean( request.getParameter("status"), "Invalid value for " + "status", MessageEnums.INVALID_INPUT_DATA, null, "status"); int statusEnum = (status == null || status == false) ? AppConstants.STATUS_DISABLED : AppConstants.STATUS_ENABLED; statusList.add(statusEnum); } searchCriteria.addParam("status", statusList); if (typeObj != null) { String type = typeObj.toString(); int typeEnum = AppConstants.getEnumFor_AssetType(type); searchCriteria.addParam("type", typeEnum); } return searchCriteria; }  RangerService getServiceByName(@PathParam("name") String name); RangerService toRangerService(VXAsset asset); VXAsset toVXAsset(RangerService service); VXRepository toVXRepository(RangerService service); RangerPolicy toRangerPolicy(VXResource resource, RangerService service); VXResource toVXResource(RangerPolicy policy, RangerService service); VXAsset publicObjecttoVXAsset(VXRepository vXRepository); VXRepository vXAssetToPublicObject(VXAsset asset); static String toAccessType(int permType); SearchCriteria getMappedSearchParams(HttpServletRequest request,
			SearchCriteria searchCriteria); VXRepositoryList rangerServiceListToPublicObjectList(List<RangerService> serviceList); VXPolicy toVXPolicy(RangerPolicy policy, RangerService service); List<VXPermMap> getVXPermMapList(RangerPolicy policy); List<VXPermObj> mapPermMapToPermObj(List<VXPermMap> permMapList); RangerPolicy toRangerPolicy(VXPolicy vXPolicy, RangerService service ); VXPolicyList rangerPolicyListToPublic(List<RangerPolicy> rangerPolicyList,SearchFilter filter); GrantRevokeRequest toGrantRevokeRequest(VXPolicy vXPolicy); boolean isValidateHttpsAuthentication( String serviceName, HttpServletRequest request); boolean isValidService(String serviceName, HttpServletRequest request); List<RangerPolicy> getMatchingPoliciesForResource(HttpServletRequest request,
			List<RangerPolicy> policyLists); }
ServiceUtil { public SearchCriteria getMappedSearchParams(HttpServletRequest request, SearchCriteria searchCriteria) { Object typeObj = searchCriteria.getParamValue("type"); Object statusObj = searchCriteria.getParamValue("status"); ArrayList<Integer> statusList = new ArrayList<Integer>(); if (statusObj == null) { statusList.add(RangerCommonEnums.STATUS_DISABLED); statusList.add(RangerCommonEnums.STATUS_ENABLED); } else { Boolean status = restErrorUtil.parseBoolean( request.getParameter("status"), "Invalid value for " + "status", MessageEnums.INVALID_INPUT_DATA, null, "status"); int statusEnum = (status == null || status == false) ? AppConstants.STATUS_DISABLED : AppConstants.STATUS_ENABLED; statusList.add(statusEnum); } searchCriteria.addParam("status", statusList); if (typeObj != null) { String type = typeObj.toString(); int typeEnum = AppConstants.getEnumFor_AssetType(type); searchCriteria.addParam("type", typeEnum); } return searchCriteria; }  RangerService getServiceByName(@PathParam("name") String name); RangerService toRangerService(VXAsset asset); VXAsset toVXAsset(RangerService service); VXRepository toVXRepository(RangerService service); RangerPolicy toRangerPolicy(VXResource resource, RangerService service); VXResource toVXResource(RangerPolicy policy, RangerService service); VXAsset publicObjecttoVXAsset(VXRepository vXRepository); VXRepository vXAssetToPublicObject(VXAsset asset); static String toAccessType(int permType); SearchCriteria getMappedSearchParams(HttpServletRequest request,
			SearchCriteria searchCriteria); VXRepositoryList rangerServiceListToPublicObjectList(List<RangerService> serviceList); VXPolicy toVXPolicy(RangerPolicy policy, RangerService service); List<VXPermMap> getVXPermMapList(RangerPolicy policy); List<VXPermObj> mapPermMapToPermObj(List<VXPermMap> permMapList); RangerPolicy toRangerPolicy(VXPolicy vXPolicy, RangerService service ); VXPolicyList rangerPolicyListToPublic(List<RangerPolicy> rangerPolicyList,SearchFilter filter); GrantRevokeRequest toGrantRevokeRequest(VXPolicy vXPolicy); boolean isValidateHttpsAuthentication( String serviceName, HttpServletRequest request); boolean isValidService(String serviceName, HttpServletRequest request); List<RangerPolicy> getMatchingPoliciesForResource(HttpServletRequest request,
			List<RangerPolicy> policyLists);  }