@Test public void testGetServiceByName() throws Exception{ RangerService expectedRangerService = new RangerService(); expectedRangerService.setId(1L); expectedRangerService.setName("hdfs"); Mockito.when(svcStore.getServiceByName("hdfs")).thenReturn(expectedRangerService); RangerService actualRangerService = serviceUtil.getServiceByName("hdfs"); Assert.assertEquals(expectedRangerService.getName(), actualRangerService.getName()); Assert.assertEquals(expectedRangerService.getId(), actualRangerService.getId()); }
public RangerService getServiceByName(@PathParam("name") String name) { if(LOG.isDebugEnabled()) { LOG.debug("==> ServiceUtil.getServiceByName(" + name + ")"); } RangerService ret = null; try { ret = svcStore.getServiceByName(name); } catch(WebApplicationException excp) { throw excp; } catch(Throwable excp) { LOG.error("getServiceByName(" + name + ") failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } if(ret == null) { throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, RangerServiceNotFoundException.buildExceptionMsg(name), true); } if(LOG.isDebugEnabled()) { LOG.debug("<== ServiceUtil.getServiceByName(" + name + "): " + ret); } return ret; }
ServiceUtil { public RangerService getServiceByName(@PathParam("name") String name) { if(LOG.isDebugEnabled()) { LOG.debug("==> ServiceUtil.getServiceByName(" + name + ")"); } RangerService ret = null; try { ret = svcStore.getServiceByName(name); } catch(WebApplicationException excp) { throw excp; } catch(Throwable excp) { LOG.error("getServiceByName(" + name + ") failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } if(ret == null) { throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, RangerServiceNotFoundException.buildExceptionMsg(name), true); } if(LOG.isDebugEnabled()) { LOG.debug("<== ServiceUtil.getServiceByName(" + name + "): " + ret); } return ret; } }
ServiceUtil { public RangerService getServiceByName(@PathParam("name") String name) { if(LOG.isDebugEnabled()) { LOG.debug("==> ServiceUtil.getServiceByName(" + name + ")"); } RangerService ret = null; try { ret = svcStore.getServiceByName(name); } catch(WebApplicationException excp) { throw excp; } catch(Throwable excp) { LOG.error("getServiceByName(" + name + ") failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } if(ret == null) { throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, RangerServiceNotFoundException.buildExceptionMsg(name), true); } if(LOG.isDebugEnabled()) { LOG.debug("<== ServiceUtil.getServiceByName(" + name + "): " + ret); } return ret; }  }
ServiceUtil { public RangerService getServiceByName(@PathParam("name") String name) { if(LOG.isDebugEnabled()) { LOG.debug("==> ServiceUtil.getServiceByName(" + name + ")"); } RangerService ret = null; try { ret = svcStore.getServiceByName(name); } catch(WebApplicationException excp) { throw excp; } catch(Throwable excp) { LOG.error("getServiceByName(" + name + ") failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } if(ret == null) { throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, RangerServiceNotFoundException.buildExceptionMsg(name), true); } if(LOG.isDebugEnabled()) { LOG.debug("<== ServiceUtil.getServiceByName(" + name + "): " + ret); } return ret; }  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 RangerService getServiceByName(@PathParam("name") String name) { if(LOG.isDebugEnabled()) { LOG.debug("==> ServiceUtil.getServiceByName(" + name + ")"); } RangerService ret = null; try { ret = svcStore.getServiceByName(name); } catch(WebApplicationException excp) { throw excp; } catch(Throwable excp) { LOG.error("getServiceByName(" + name + ") failed", excp); throw restErrorUtil.createRESTException(excp.getMessage()); } if(ret == null) { throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, RangerServiceNotFoundException.buildExceptionMsg(name), true); } if(LOG.isDebugEnabled()) { LOG.debug("<== ServiceUtil.getServiceByName(" + name + "): " + ret); } return ret; }  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);  }