Java Code Examples for org.apache.atlas.model.instance.EntityMutationResponse#addEntity()

The following examples show how to use org.apache.atlas.model.instance.EntityMutationResponse#addEntity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityResourceTest.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteEntitiesDoesNotLookupDeletedEntity() throws Exception {
    List<String> guids = Collections.singletonList(DELETED_GUID);
    List<AtlasEntityHeader> deletedEntities = Collections.singletonList(new AtlasEntityHeader(null, DELETED_GUID, null));

    // Create EntityResult with a deleted guid and no other guids.
    EntityMutationResponse  resp    = new EntityMutationResponse();
    List<AtlasEntityHeader> headers = toAtlasEntityHeaders(guids);

    if (CollectionUtils.isNotEmpty(headers)) {
        for (AtlasEntityHeader entity : headers) {
            resp.addEntity(EntityMutations.EntityOperation.DELETE, entity);
        }
    }

    when(entitiesStore.deleteByIds(guids)).thenReturn(resp);

    EntityMutationResponse response = entitiesStore.deleteByIds(guids);

    List<AtlasEntityHeader> responseDeletedEntities = response.getDeletedEntities();

    Assert.assertEquals(responseDeletedEntities, deletedEntities);
}
 
Example 2
Source File: EntityResourceTest.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteEntitiesDoesNotLookupDeletedEntity() throws Exception {
    List<String> guids = Collections.singletonList(DELETED_GUID);
    List<AtlasEntityHeader> deletedEntities = Collections.singletonList(new AtlasEntityHeader(null, DELETED_GUID, null));

    // Create EntityResult with a deleted guid and no other guids.
    EntityMutationResponse  resp    = new EntityMutationResponse();
    List<AtlasEntityHeader> headers = toAtlasEntityHeaders(guids);

    if (CollectionUtils.isNotEmpty(headers)) {
        for (AtlasEntityHeader entity : headers) {
            resp.addEntity(EntityMutations.EntityOperation.DELETE, entity);
        }
    }

    when(entitiesStore.deleteByIds(guids)).thenReturn(resp);

    EntityMutationResponse response = entitiesStore.deleteByIds(guids);

    List<AtlasEntityHeader> responseDeletedEntities = response.getDeletedEntities();

    Assert.assertEquals(responseDeletedEntities, deletedEntities);
}
 
Example 3
Source File: AtlasEntityStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
private EntityMutationResponse purgeVertices(Collection<AtlasVertex> purgeCandidates) throws AtlasBaseException {
    EntityMutationResponse response = new EntityMutationResponse();
    RequestContext         req      = RequestContext.get();

    req.setDeleteType(DeleteType.HARD);
    req.setPurgeRequested(true);
    deleteDelegate.getHandler().deleteEntities(purgeCandidates); // this will update req with list of purged entities

    for (AtlasEntityHeader entity : req.getDeletedEntities()) {
        response.addEntity(PURGE, entity);
    }

    return response;
}