Search in sources :

Example 6 with XXTagAttributeDef

use of org.apache.ranger.entity.XXTagAttributeDef in project ranger by apache.

the class RangerTagDefServiceBase method getAttributeDefForTagDef.

public List<RangerTagAttributeDef> getAttributeDefForTagDef(XXTagDef xtagDef) {
    List<XXTagAttributeDef> tagAttrDefList = daoMgr.getXXTagAttributeDef().findByTagDefId(xtagDef.getId());
    List<RangerTagDef.RangerTagAttributeDef> attributeDefList = new ArrayList<RangerTagDef.RangerTagAttributeDef>();
    for (XXTagAttributeDef xAttrTag : tagAttrDefList) {
        RangerTagAttributeDef attrDef = populateRangerTagAttributeDef(xAttrTag);
        attributeDefList.add(attrDef);
    }
    return attributeDefList;
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagAttributeDef(org.apache.ranger.entity.XXTagAttributeDef) ArrayList(java.util.ArrayList) RangerTagAttributeDef(org.apache.ranger.plugin.model.RangerTagDef.RangerTagAttributeDef)

Example 7 with XXTagAttributeDef

use of org.apache.ranger.entity.XXTagAttributeDef in project ranger by apache.

the class RangerTagDefServiceBase method populateXXTagAttributeDef.

/**
 * @param attrDef
 * @param xTagAttrDef
 * @param parentObj
 * @return
 */
public XXTagAttributeDef populateXXTagAttributeDef(RangerTagAttributeDef attrDef, XXTagAttributeDef xTagAttrDef, XXTagDef parentObj) {
    if (xTagAttrDef == null) {
        xTagAttrDef = new XXTagAttributeDef();
    }
    xTagAttrDef = rangerAuditFields.populateAuditFields(xTagAttrDef, parentObj);
    xTagAttrDef.setTagDefId(parentObj.getId());
    xTagAttrDef.setName(attrDef.getName());
    xTagAttrDef.setType(attrDef.getType());
    return xTagAttrDef;
}
Also used : XXTagAttributeDef(org.apache.ranger.entity.XXTagAttributeDef)

Example 8 with XXTagAttributeDef

use of org.apache.ranger.entity.XXTagAttributeDef in project ranger by apache.

the class TestRangerTagDefService method test8getTagDefsByServiceId.

@Test
public void test8getTagDefsByServiceId() {
    List<XXTagDef> xxTagDefs = new ArrayList<XXTagDef>();
    XXTagDef xxTagDef = new XXTagDef();
    xxTagDef.setId(id);
    xxTagDef.setName(name);
    xxTagDefs.add(xxTagDef);
    XXTagDefDao xXTagDefDao = Mockito.mock(XXTagDefDao.class);
    Mockito.when(daoMgr.getXXTagDef()).thenReturn(xXTagDefDao);
    Mockito.when(xXTagDefDao.findByServiceId(serviceId)).thenReturn(xxTagDefs);
    List<XXTagAttributeDef> tagAttrDefList = new ArrayList<XXTagAttributeDef>();
    XXTagAttributeDef xxTagAttributeDef = new XXTagAttributeDef();
    xxTagAttributeDef.setId(id);
    xxTagAttributeDef.setName(name);
    tagAttrDefList.add(xxTagAttributeDef);
    XXTagAttributeDefDao xxTagAttributeDefDao = Mockito.mock(XXTagAttributeDefDao.class);
    Mockito.when(daoMgr.getXXTagAttributeDef()).thenReturn(xxTagAttributeDefDao);
    Mockito.when(xxTagAttributeDefDao.findByTagDefId(xxTagDef.getId())).thenReturn(tagAttrDefList);
    List<RangerTagDef> result = rangerTagDefService.getTagDefsByServiceId(serviceId);
    Assert.assertEquals(result.get(0).getId(), tagAttrDefList.get(0).getId());
    Assert.assertEquals(result.get(0).getName(), tagAttrDefList.get(0).getName());
    Mockito.verify(daoMgr).getXXTagDef();
    Mockito.verify(xXTagDefDao).findByServiceId(serviceId);
    Mockito.verify(daoMgr).getXXTagAttributeDef();
    Mockito.verify(xxTagAttributeDefDao).findByTagDefId(xxTagDef.getId());
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef) ArrayList(java.util.ArrayList) XXTagAttributeDef(org.apache.ranger.entity.XXTagAttributeDef) XXTagAttributeDefDao(org.apache.ranger.db.XXTagAttributeDefDao) XXTagDefDao(org.apache.ranger.db.XXTagDefDao) Test(org.junit.Test)

Aggregations

XXTagAttributeDef (org.apache.ranger.entity.XXTagAttributeDef)8 ArrayList (java.util.ArrayList)7 RangerTagDef (org.apache.ranger.plugin.model.RangerTagDef)6 XXTagAttributeDefDao (org.apache.ranger.db.XXTagAttributeDefDao)5 XXTagDef (org.apache.ranger.entity.XXTagDef)5 Test (org.junit.Test)5 Date (java.util.Date)4 XXTagDefDao (org.apache.ranger.db.XXTagDefDao)3 RangerTagAttributeDef (org.apache.ranger.plugin.model.RangerTagDef.RangerTagAttributeDef)2 XXServiceVersionInfoDao (org.apache.ranger.db.XXServiceVersionInfoDao)1