@Test
public void testToRangerPolicy(){

        Date date = new Date();
        List<String> userList = new ArrayList<String>();
        userList.add("rangerAdmin");
        List<String> groupList = new ArrayList<String>();
        groupList.add("rangerGroup");
        List<String> permObjList = new ArrayList<String>();
        permObjList.add("Admin");
        Map<String, RangerPolicyResource> resourceMap = new HashMap<String, RangerPolicyResource>();
        List<String> valuesList = new ArrayList<String>();
        valuesList.add("resource");
        RangerPolicyResource rangerPolicyResource = new RangerPolicyResource();
        rangerPolicyResource.setIsExcludes(false);
        rangerPolicyResource.setIsRecursive(true);
        rangerPolicyResource.setValues(valuesList);
        resourceMap.put("path", rangerPolicyResource);
        List<RangerPolicyItem> rangerPolicyItemList = new ArrayList<RangerPolicy.RangerPolicyItem>();
        RangerPolicyItem rangerPolicyItem = new RangerPolicyItem();
        rangerPolicyItem.setUsers(userList);
        rangerPolicyItem.setGroups(groupList);
        List<RangerPolicyItemCondition> rangerPolicyItemConditionList = new ArrayList<RangerPolicy.RangerPolicyItemCondition>();
        RangerPolicyItemCondition rangerPolicyItemCondition = new RangerPolicyItemCondition();
        rangerPolicyItemCondition.setType("ipaddress");
        List<String> conditionValueList = new ArrayList<String>();
        conditionValueList.add("10.129.35.86");
        rangerPolicyItemCondition.setValues(conditionValueList);
        rangerPolicyItemConditionList.add(rangerPolicyItemCondition);
        rangerPolicyItem.setConditions(rangerPolicyItemConditionList);
        rangerPolicyItem.setDelegateAdmin(true);
        rangerPolicyItemList.add(rangerPolicyItem);
        RangerPolicy expectedRangerPolicy = new RangerPolicy();
        expectedRangerPolicy.setId(1L);
        expectedRangerPolicy.setName("hdfs");
        expectedRangerPolicy.setCreatedBy("rangerAdmin");
        expectedRangerPolicy.setCreateTime(date);
        expectedRangerPolicy.setDescription("hdfs policy description");
        expectedRangerPolicy.setIsAuditEnabled(true);
        expectedRangerPolicy.setResources(resourceMap);
        expectedRangerPolicy.setPolicyItems(rangerPolicyItemList);
        VXPolicy vXPolicy = new VXPolicy();
        vXPolicy.setId(1L);
        vXPolicy.setCreateDate(date);
        vXPolicy.setUpdateDate(date);
        vXPolicy.setOwner("rangerAdmin");
        vXPolicy.setUpdatedBy("rangerAdmin");
        vXPolicy.setPolicyName("hdfs");
        vXPolicy.setDescription("hdfs policy description");
        vXPolicy.setIsEnabled(true);
        vXPolicy.setIsAuditEnabled(true);
        vXPolicy.setIsRecursive(true);
        vXPolicy.setResourceName("resource");
        RangerService service = new RangerService();
        service.setId(1L);
        service.setName("hdfsService");
        service.setType("hdfs");
        List<VXPermObj> vXPermObjList = new ArrayList<VXPermObj>();
        VXPermObj vXPermObj = new VXPermObj();
        vXPermObj.setUserList(userList);
        vXPermObj.setGroupList(groupList);
        vXPermObj.setPermList(permObjList);
        vXPermObj.setIpAddress("10.129.35.86");
        vXPermObjList.add(vXPermObj);
        vXPolicy.setPermMapList(vXPermObjList);
        RangerPolicy actualRangerPolicy = serviceUtil.toRangerPolicy(vXPolicy, service);
        Assert.assertNotNull(actualRangerPolicy);
        Assert.assertEquals(expectedRangerPolicy.getId(), actualRangerPolicy.getId());
        Assert.assertEquals(expectedRangerPolicy.getName(), actualRangerPolicy.getName());
        Assert.assertEquals(expectedRangerPolicy.getDescription(), actualRangerPolicy.getDescription());
        Assert.assertEquals(expectedRangerPolicy.getCreatedBy(), actualRangerPolicy.getCreatedBy());
        Assert.assertTrue(actualRangerPolicy.getIsAuditEnabled());
        Assert.assertEquals(expectedRangerPolicy.getResources(), actualRangerPolicy.getResources());
        Assert.assertEquals(expectedRangerPolicy.getPolicyItems(), actualRangerPolicy.getPolicyItems());
}