use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestPublicAPIsv2 method test2getServiceDefByName.
@Test
public void test2getServiceDefByName() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
String name = rangerServiceDef.getName();
Mockito.when(serviceREST.getServiceDefByName(name)).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = publicAPIsv2.getServiceDefByName(name);
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
Mockito.verify(serviceREST).getServiceDefByName(name);
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestPublicAPIsv2 method test1getServiceDef.
@Test
public void test1getServiceDef() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
Mockito.when(serviceREST.getServiceDef(rangerServiceDef.getId())).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = publicAPIsv2.getServiceDef(Id);
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
Mockito.verify(serviceREST).getServiceDef(Id);
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestPublicAPIsv2 method test6updateServiceDefByName.
@Test
public void test6updateServiceDefByName() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
String name = rangerServiceDef.getName();
Mockito.when(serviceREST.getServiceDefByName(name)).thenReturn(rangerServiceDef);
Mockito.when(serviceREST.updateServiceDef(rangerServiceDef)).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = publicAPIsv2.updateServiceDefByName(rangerServiceDef, name);
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
Mockito.verify(serviceREST).updateServiceDef(rangerServiceDef);
Mockito.verify(serviceREST).getServiceDefByName(name);
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceREST method test2updateServiceDef.
@Test
public void test2updateServiceDef() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
Mockito.when(validatorFactory.getServiceDefValidator(svcStore)).thenReturn(serviceDefValidator);
Mockito.when(svcStore.updateServiceDef((RangerServiceDef) Mockito.any())).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = serviceREST.updateServiceDef(rangerServiceDef);
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
Assert.assertEquals(dbRangerServiceDef.getImplClass(), rangerServiceDef.getImplClass());
Assert.assertEquals(dbRangerServiceDef.getLabel(), rangerServiceDef.getLabel());
Assert.assertEquals(dbRangerServiceDef.getDescription(), rangerServiceDef.getDescription());
Assert.assertEquals(dbRangerServiceDef.getRbKeyDescription(), rangerServiceDef.getRbKeyDescription());
Assert.assertEquals(dbRangerServiceDef.getUpdatedBy(), rangerServiceDef.getUpdatedBy());
Assert.assertEquals(dbRangerServiceDef.getUpdateTime(), rangerServiceDef.getUpdateTime());
Assert.assertEquals(dbRangerServiceDef.getVersion(), rangerServiceDef.getVersion());
Assert.assertEquals(dbRangerServiceDef.getConfigs(), rangerServiceDef.getConfigs());
Mockito.verify(validatorFactory).getServiceDefValidator(svcStore);
Mockito.verify(svcStore).updateServiceDef(rangerServiceDef);
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceREST method test4getServiceDefById.
@Test
public void test4getServiceDefById() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
XXServiceDef xServiceDef = serviceDef();
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
Mockito.when(xServiceDefDao.getById(Id)).thenReturn(xServiceDef);
Mockito.when(!bizUtil.hasAccess(xServiceDef, null)).thenReturn(true);
Mockito.when(svcStore.getServiceDef(rangerServiceDef.getId())).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = serviceREST.getServiceDef(rangerServiceDef.getId());
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
Mockito.verify(svcStore).getServiceDef(rangerServiceDef.getId());
Mockito.verify(daoManager).getXXServiceDef();
Mockito.verify(bizUtil).hasAccess(xServiceDef, null);
}
Aggregations