@Test public void testToVXRepository(){ Map<String, String> map = new HashMap<String, String>(); map.put("config", "hiveConfig"); VXRepository expectedVXRepository = new VXRepository(); expectedVXRepository.setRepositoryType("hive"); expectedVXRepository.setName("hive"); expectedVXRepository.setDescription("hive Description"); expectedVXRepository.setIsActive(true); expectedVXRepository.setVersion("3"); RangerService rangerService = new RangerService(); rangerService.setId(1L); rangerService.setCreateTime(new Date()); rangerService.setUpdateTime(new Date()); rangerService.setCreatedBy("ranger"); rangerService.setUpdatedBy("rangerAdmin"); rangerService.setType("hive"); rangerService.setName("hive"); rangerService.setDescription("hive Description"); rangerService.setIsEnabled(true); rangerService.setConfigs(map); rangerService.setVersion(3L); Mockito.when(jsonUtil.readMapToString(map)).thenReturn("{config : hiveConfig}"); VXRepository actualvXRepository = serviceUtil.toVXRepository(rangerService); Assert.assertNotNull(actualvXRepository); Assert.assertEquals(actualvXRepository.getRepositoryType(), expectedVXRepository.getRepositoryType()); Assert.assertEquals(actualvXRepository.getName(), expectedVXRepository.getName()); Assert.assertEquals(actualvXRepository.getDescription(), expectedVXRepository.getDescription()); Assert.assertTrue(actualvXRepository.getIsActive()); Assert.assertEquals(actualvXRepository.getVersion(), expectedVXRepository.getVersion()); }
public VXRepository toVXRepository(RangerService service){ if(service == null || toAssetType(service.getType()) == null) { return null; } VXRepository ret = new VXRepository(); rangerObjectToDataObject(service,ret); ret.setRepositoryType(service.getType()); ret.setName(service.getName()); ret.setDescription(service.getDescription()); ret.setIsActive(service.getIsEnabled()); ret.setConfig(jsonUtil.readMapToString(service.getConfigs())); ret.setVersion(Long.toString(service.getVersion())); return ret; }
ServiceUtil { public VXRepository toVXRepository(RangerService service){ if(service == null || toAssetType(service.getType()) == null) { return null; } VXRepository ret = new VXRepository(); rangerObjectToDataObject(service,ret); ret.setRepositoryType(service.getType()); ret.setName(service.getName()); ret.setDescription(service.getDescription()); ret.setIsActive(service.getIsEnabled()); ret.setConfig(jsonUtil.readMapToString(service.getConfigs())); ret.setVersion(Long.toString(service.getVersion())); return ret; } }
ServiceUtil { public VXRepository toVXRepository(RangerService service){ if(service == null || toAssetType(service.getType()) == null) { return null; } VXRepository ret = new VXRepository(); rangerObjectToDataObject(service,ret); ret.setRepositoryType(service.getType()); ret.setName(service.getName()); ret.setDescription(service.getDescription()); ret.setIsActive(service.getIsEnabled()); ret.setConfig(jsonUtil.readMapToString(service.getConfigs())); ret.setVersion(Long.toString(service.getVersion())); return ret; }  }
ServiceUtil { public VXRepository toVXRepository(RangerService service){ if(service == null || toAssetType(service.getType()) == null) { return null; } VXRepository ret = new VXRepository(); rangerObjectToDataObject(service,ret); ret.setRepositoryType(service.getType()); ret.setName(service.getName()); ret.setDescription(service.getDescription()); ret.setIsActive(service.getIsEnabled()); ret.setConfig(jsonUtil.readMapToString(service.getConfigs())); ret.setVersion(Long.toString(service.getVersion())); 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 VXRepository toVXRepository(RangerService service){ if(service == null || toAssetType(service.getType()) == null) { return null; } VXRepository ret = new VXRepository(); rangerObjectToDataObject(service,ret); ret.setRepositoryType(service.getType()); ret.setName(service.getName()); ret.setDescription(service.getDescription()); ret.setIsActive(service.getIsEnabled()); ret.setConfig(jsonUtil.readMapToString(service.getConfigs())); ret.setVersion(Long.toString(service.getVersion())); 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);  }