Search in sources :

Example 1 with XXTagDefDao

use of org.apache.ranger.db.XXTagDefDao in project ranger by apache.

the class TestRangerTagDefService method test6getTagDefByName.

@Test
public void test6getTagDefByName() {
    RangerTagDef oldTagDef = new RangerTagDef();
    oldTagDef.setId(id);
    oldTagDef.setName(name);
    XXTagDef xxTagDef = new XXTagDef();
    xxTagDef.setId(id);
    xxTagDef.setName(name);
    xxTagDef.setUpdateTime(new Date());
    XXTagDefDao xXTagDefDao = Mockito.mock(XXTagDefDao.class);
    Mockito.when(daoMgr.getXXTagDef()).thenReturn(xXTagDefDao);
    Mockito.when(xXTagDefDao.findByName(name)).thenReturn(xxTagDef);
    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);
    RangerTagDef result = rangerTagDefService.getTagDefByName(name);
    Assert.assertEquals(result.getId(), tagAttrDefList.get(0).getId());
    Assert.assertEquals(result.getName(), tagAttrDefList.get(0).getName());
    Mockito.verify(daoMgr).getXXTagDef();
    Mockito.verify(xXTagDefDao).findByName(name);
    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) XXTagAttributeDef(org.apache.ranger.entity.XXTagAttributeDef) ArrayList(java.util.ArrayList) XXTagAttributeDefDao(org.apache.ranger.db.XXTagAttributeDefDao) XXTagDefDao(org.apache.ranger.db.XXTagDefDao) Date(java.util.Date) Test(org.junit.Test)

Example 2 with XXTagDefDao

use of org.apache.ranger.db.XXTagDefDao in project ranger by apache.

the class TestRangerTagDefService method test5getTagDefByGuid.

@Test
public void test5getTagDefByGuid() {
    XXTagDef xxTagDef = null;
    XXTagDefDao xXTagDefDao = Mockito.mock(XXTagDefDao.class);
    Mockito.when(daoMgr.getXXTagDef()).thenReturn(xXTagDefDao);
    Mockito.when(xXTagDefDao.findByGuid(guid)).thenReturn(xxTagDef);
    RangerTagDef result = rangerTagDefService.getTagDefByGuid(guid);
    Assert.assertNull(result);
    Mockito.verify(daoMgr).getXXTagDef();
    Mockito.verify(xXTagDefDao).findByGuid(guid);
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef) XXTagDefDao(org.apache.ranger.db.XXTagDefDao) Test(org.junit.Test)

Example 3 with XXTagDefDao

use of org.apache.ranger.db.XXTagDefDao in project ranger by apache.

the class TestRangerTagDefService method test4getTagDefByGuid.

@Test
public void test4getTagDefByGuid() {
    XXTagDef xxTagDef = new XXTagDef();
    xxTagDef.setId(id);
    xxTagDef.setName(name);
    xxTagDef.setUpdateTime(new Date());
    XXTagDefDao xXTagDefDao = Mockito.mock(XXTagDefDao.class);
    Mockito.when(daoMgr.getXXTagDef()).thenReturn(xXTagDefDao);
    Mockito.when(xXTagDefDao.findByGuid(guid)).thenReturn(xxTagDef);
    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);
    RangerTagDef result = rangerTagDefService.getTagDefByGuid(guid);
    Assert.assertEquals(result.getId(), tagAttrDefList.get(0).getId());
    Assert.assertEquals(result.getName(), tagAttrDefList.get(0).getName());
    Mockito.verify(daoMgr).getXXTagDef();
    Mockito.verify(xXTagDefDao).findByGuid(guid);
    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) XXTagAttributeDef(org.apache.ranger.entity.XXTagAttributeDef) ArrayList(java.util.ArrayList) XXTagAttributeDefDao(org.apache.ranger.db.XXTagAttributeDefDao) XXTagDefDao(org.apache.ranger.db.XXTagDefDao) Date(java.util.Date) Test(org.junit.Test)

Example 4 with XXTagDefDao

use of org.apache.ranger.db.XXTagDefDao 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)

Example 5 with XXTagDefDao

use of org.apache.ranger.db.XXTagDefDao in project ranger by apache.

the class TestRangerTagDefService method test9getTagDefsByServiceId.

@Test
public void test9getTagDefsByServiceId() {
    List<XXTagDef> xxTagDefs = new ArrayList<XXTagDef>();
    XXTagDefDao xXTagDefDao = Mockito.mock(XXTagDefDao.class);
    Mockito.when(daoMgr.getXXTagDef()).thenReturn(xXTagDefDao);
    Mockito.when(xXTagDefDao.findByServiceId(serviceId)).thenReturn(xxTagDefs);
    List<RangerTagDef> result = rangerTagDefService.getTagDefsByServiceId(serviceId);
    Assert.assertNotNull(result);
    Mockito.verify(daoMgr).getXXTagDef();
    Mockito.verify(xXTagDefDao).findByServiceId(serviceId);
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef) ArrayList(java.util.ArrayList) XXTagDefDao(org.apache.ranger.db.XXTagDefDao) Test(org.junit.Test)

Aggregations

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