use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestPublicAPIsv2 method test3searchServiceDefs.
@Test
public void test3searchServiceDefs() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
List<RangerServiceDef> serviceDefsList = new ArrayList<RangerServiceDef>();
RangerServiceDef serviceDef = rangerServiceDef();
serviceDefsList.add(serviceDef);
RangerServiceDefList serviceDefList = new RangerServiceDefList(serviceDefsList);
Mockito.when(serviceREST.getServiceDefs(request)).thenReturn(serviceDefList);
List<RangerServiceDef> dbRangerServiceDefList = publicAPIsv2.searchServiceDefs(request);
Assert.assertNotNull(dbRangerServiceDefList);
Assert.assertEquals(dbRangerServiceDefList.size(), serviceDefsList.size());
Mockito.verify(serviceREST).getServiceDefs(request);
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestPublicAPIsv2 method test5updateServiceDef.
@Test
public void test5updateServiceDef() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
Mockito.when(serviceREST.updateServiceDef(rangerServiceDef)).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = publicAPIsv2.updateServiceDef(rangerServiceDef, Id);
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
Mockito.verify(serviceREST).updateServiceDef(rangerServiceDef);
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestPublicAPIsv2 method test8deleteServiceDefByName.
@Test
public void test8deleteServiceDefByName() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
RangerServiceDef rangerServiceDef = rangerServiceDef();
String name = rangerServiceDef.getName();
Mockito.when(serviceREST.getServiceDefByName(name)).thenReturn(rangerServiceDef);
Mockito.doNothing().when(serviceREST).deleteServiceDef(rangerServiceDef.getId(), request);
publicAPIsv2.deleteServiceDefByName(name, request);
Mockito.verify(serviceREST).deleteServiceDef(rangerServiceDef.getId(), request);
Mockito.verify(serviceREST).getServiceDefByName(name);
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestPublicAPIsv2 method rangerServiceDef.
private RangerServiceDef rangerServiceDef() {
List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerPolicyConditionDef>();
List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerContextEnricherDef>();
List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
RangerServiceDef rangerServiceDef = new RangerServiceDef();
rangerServiceDef.setId(Id);
rangerServiceDef.setName("RangerServiceHdfs");
rangerServiceDef.setImplClass("RangerServiceHdfs");
rangerServiceDef.setLabel("HDFS Repository");
rangerServiceDef.setDescription("HDFS Repository");
rangerServiceDef.setRbKeyDescription(null);
rangerServiceDef.setUpdatedBy("Admin");
rangerServiceDef.setUpdateTime(new Date());
rangerServiceDef.setConfigs(configs);
rangerServiceDef.setResources(resources);
rangerServiceDef.setAccessTypes(accessTypes);
rangerServiceDef.setPolicyConditions(policyConditions);
rangerServiceDef.setContextEnrichers(contextEnrichers);
rangerServiceDef.setEnums(enums);
return rangerServiceDef;
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestPublicAPIsv2 method test4createServiceDef.
@Test
public void test4createServiceDef() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
Mockito.when(serviceREST.createServiceDef(rangerServiceDef)).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = publicAPIsv2.createServiceDef(rangerServiceDef);
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
Mockito.verify(serviceREST).createServiceDef(rangerServiceDef);
}
Aggregations