use of org.apache.atlas.catalog.exception.ResourceNotFoundException in project incubator-atlas by apache.
the class DefaultTypeSystem method deleteEntity.
@Override
public void deleteEntity(ResourceDefinition definition, Request request) throws ResourceNotFoundException {
String typeName = definition.getTypeName();
String cleanIdPropName = definition.getIdPropertyName();
String idValue = request.getProperty(cleanIdPropName);
try {
// transaction handled by atlas repository
metadataService.deleteEntityByUniqueAttribute(typeName, cleanIdPropName, idValue);
} catch (EntityNotFoundException e) {
throw new ResourceNotFoundException(String.format("The specified entity doesn't exist: type=%s, %s=%s", typeName, cleanIdPropName, idValue));
} catch (AtlasException e) {
throw new CatalogRuntimeException(String.format("An unexpected error occurred while attempting to delete entity: type=%s, %s=%s : %s", typeName, cleanIdPropName, idValue, e), e);
}
}
use of org.apache.atlas.catalog.exception.ResourceNotFoundException in project incubator-atlas by apache.
the class TaxonomyResourceProviderTest method testDeleteResourceById_404.
@Test(expectedExceptions = ResourceNotFoundException.class)
public void testDeleteResourceById_404() throws Exception {
AtlasTypeSystem typeSystem = createStrictMock(AtlasTypeSystem.class);
QueryFactory queryFactory = createStrictMock(QueryFactory.class);
AtlasQuery query = createStrictMock(AtlasQuery.class);
Capture<Request> getRequestCapture = newCapture();
// mock expectations
expect(queryFactory.createTaxonomyQuery(capture(getRequestCapture))).andReturn(query);
expect(query.execute()).andThrow(new ResourceNotFoundException("test msg"));
replay(typeSystem, queryFactory, query);
TaxonomyResourceProvider provider = new TestTaxonomyResourceProvider(typeSystem, null);
provider.setQueryFactory(queryFactory);
Map<String, Object> requestProperties = new HashMap<>();
requestProperties.put("name", "badName");
Request userRequest = new InstanceRequest(requestProperties);
// invoke method being tested
provider.deleteResourceById(userRequest);
}
Aggregations