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;
}
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;
}
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());
}
Aggregations