use of org.apache.atlas.catalog.Request in project incubator-atlas by apache.
the class TaxonomyServiceTest method testDeleteSubTerm.
@Test
public void testDeleteSubTerm() throws Exception {
MetadataService metadataService = createStrictMock(MetadataService.class);
AtlasTypeDefStore typeDefStore = createStrictMock(AtlasTypeDefStore.class);
ResourceProvider taxonomyResourceProvider = createStrictMock(ResourceProvider.class);
ResourceProvider termResourceProvider = createStrictMock(ResourceProvider.class);
UriInfo uriInfo = createNiceMock(UriInfo.class);
URI uri = new URI("http://localhost:21000/api/atlas/v1/taxonomies/testTaxonomy/terms/testTerm/terms/testTerm2");
Capture<Request> requestCapture = newCapture();
// set mock expectations
expect(uriInfo.getRequestUri()).andReturn(uri);
termResourceProvider.deleteResourceById(capture(requestCapture));
expect(metadataService.getTypeDefinition(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE)).andReturn(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE + "-definition");
replay(uriInfo, metadataService, taxonomyResourceProvider, termResourceProvider);
// instantiate service and invoke method being tested
TestTaxonomyService service = new TestTaxonomyService(metadataService, typeDefStore, taxonomyResourceProvider, termResourceProvider, null);
Response response = service.deleteSubTerm(null, uriInfo, "testTaxonomy", "testTerm", "terms/testTerm2");
Request request = requestCapture.getValue();
assertEquals(request.getQueryProperties().size(), 1);
TermPath termPath = (TermPath) request.getQueryProperties().get("termPath");
assertEquals(termPath.getFullyQualifiedName(), "testTaxonomy.testTerm.testTerm2");
assertNull(request.getQueryString());
assertEquals(response.getStatus(), 200);
BaseService.Results createResults = (BaseService.Results) response.getEntity();
assertEquals(createResults.href, "http://localhost:21000/api/atlas/v1/taxonomies/testTaxonomy/terms/testTerm/terms/testTerm2");
assertEquals(createResults.status, 200);
verify(uriInfo, taxonomyResourceProvider, termResourceProvider);
}
use of org.apache.atlas.catalog.Request in project incubator-atlas by apache.
the class TaxonomyServiceTest method testDeleteTaxonomy.
@Test
public void testDeleteTaxonomy() throws Exception {
MetadataService metadataService = createStrictMock(MetadataService.class);
AtlasTypeDefStore typeDefStore = createStrictMock(AtlasTypeDefStore.class);
ResourceProvider taxonomyResourceProvider = createStrictMock(ResourceProvider.class);
ResourceProvider termResourceProvider = createStrictMock(ResourceProvider.class);
UriInfo uriInfo = createNiceMock(UriInfo.class);
URI uri = new URI("http://localhost:21000/api/atlas/v1/taxonomies/testTaxonomy");
Capture<Request> requestCapture = newCapture();
// set mock expectations
expect(uriInfo.getRequestUri()).andReturn(uri);
taxonomyResourceProvider.deleteResourceById(capture(requestCapture));
expect(metadataService.getTypeDefinition(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE)).andReturn(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE + "-definition");
replay(uriInfo, metadataService, taxonomyResourceProvider, termResourceProvider);
// instantiate service and invoke method being tested
TestTaxonomyService service = new TestTaxonomyService(metadataService, typeDefStore, taxonomyResourceProvider, termResourceProvider, null);
Response response = service.deleteTaxonomy(null, uriInfo, "testTaxonomy");
Request request = requestCapture.getValue();
assertEquals(request.getQueryProperties().size(), 1);
assertEquals(request.getQueryProperties().get("name"), "testTaxonomy");
assertNull(request.getQueryString());
assertEquals(response.getStatus(), 200);
BaseService.Results createResults = (BaseService.Results) response.getEntity();
assertEquals(createResults.href, "http://localhost:21000/api/atlas/v1/taxonomies/testTaxonomy");
assertEquals(createResults.status, 200);
verify(uriInfo, taxonomyResourceProvider, termResourceProvider);
}
use of org.apache.atlas.catalog.Request in project incubator-atlas by apache.
the class EntityResourceDefinitionTest method testValidate.
// Because we don't currently support entity creation, this method is basically a no-op.
@Test
public void testValidate() throws Exception {
Request request = new InstanceRequest(Collections.<String, Object>emptyMap());
ResourceDefinition entityDefinition = new EntityResourceDefinition();
entityDefinition.validateCreatePayload(request);
}
use of org.apache.atlas.catalog.Request in project incubator-atlas by apache.
the class EntityTagResourceDefinitionTest method testFilterProperties_Instance.
@Test
public void testFilterProperties_Instance() {
Map<String, Object> resourceProps = new HashMap<>();
resourceProps.put("id", "111-222-333");
resourceProps.put("name", "nameVal");
resourceProps.put("type", "someType");
resourceProps.put("foo", "fooVal");
resourceProps.put("bar", "barVal");
resourceProps.put("description", "desc");
resourceProps.put("creation_time", "2016:10:10");
resourceProps.put("acceptable_use", "something");
resourceProps.put("available_as_tag", true);
resourceProps.put("other", "otherVal");
Request request = new InstanceRequest(resourceProps);
request.addAdditionalSelectProperties(Collections.singleton("foo"));
ResourceDefinition entityTagDefinition = new EntityTagResourceDefinition();
Map<String, Object> filteredProperties = entityTagDefinition.filterProperties(request, resourceProps);
assertEquals(filteredProperties.size(), 4);
// registered collection props
assertTrue(filteredProperties.containsKey("name"));
assertTrue(filteredProperties.containsKey("description"));
assertTrue(filteredProperties.containsKey("creation_time"));
// added prop
assertTrue(filteredProperties.containsKey("foo"));
}
use of org.apache.atlas.catalog.Request in project incubator-atlas by apache.
the class EntityTagResourceDefinitionTest method testFilterProperties_Collection.
@Test
public void testFilterProperties_Collection() {
Map<String, Object> resourceProps = new HashMap<>();
resourceProps.put("id", "111-222-333");
resourceProps.put("name", "nameVal");
resourceProps.put("type", "someType");
resourceProps.put("foo", "fooVal");
resourceProps.put("bar", "barVal");
resourceProps.put("description", "desc");
resourceProps.put("creation_time", "2016:10:10");
resourceProps.put("acceptable_use", "something");
resourceProps.put("available_as_tag", true);
resourceProps.put("other", "otherVal");
Request request = new CollectionRequest(resourceProps, "someProperty:someValue");
request.addAdditionalSelectProperties(Collections.singleton("foo"));
ResourceDefinition entityTagDefinition = new EntityTagResourceDefinition();
Map<String, Object> filteredProps = entityTagDefinition.filterProperties(request, resourceProps);
assertEquals(filteredProps.size(), 3);
// registered collection props
assertTrue(filteredProps.containsKey("name"));
assertTrue(filteredProps.containsKey("description"));
// added prop
assertTrue(filteredProps.containsKey("foo"));
}
Aggregations