Search in sources :

Example 36 with ITypedReferenceableInstance

use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.

the class GraphBackedRepositoryHardDeleteTest method assertTestDisconnectMapReferenceFromClassType.

@Override
protected void assertTestDisconnectMapReferenceFromClassType(String mapOwnerGuid) throws Exception {
    // Verify map references from mapOwner were disconnected.
    ITypedReferenceableInstance mapOwnerInstance = repositoryService.getEntityDefinition(mapOwnerGuid);
    assertNull(mapOwnerInstance.get("map"));
    assertNull(mapOwnerInstance.get("biMap"));
    AtlasVertex mapOwnerVertex = GraphHelper.getInstance().getVertexForGUID(mapOwnerGuid);
    Object object = mapOwnerVertex.getProperty("MapOwner.map.value1", String.class);
    assertNull(object);
    object = mapOwnerVertex.getProperty("MapOwner.biMap.value1", String.class);
    assertNull(object);
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance)

Example 37 with ITypedReferenceableInstance

use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.

the class GraphBackedRepositoryHardDeleteTest method assertProcessForTestDeleteReference.

@Override
protected void assertProcessForTestDeleteReference(ITypedReferenceableInstance processInstance) throws Exception {
    // assert that outputs is empty
    ITypedReferenceableInstance newProcess = repositoryService.getEntityDefinition(processInstance.getId()._getId());
    assertNull(newProcess.get(AtlasClient.PROCESS_ATTRIBUTE_OUTPUTS));
}
Also used : ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance)

Example 38 with ITypedReferenceableInstance

use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.

the class GraphBackedRepositorySoftDeleteTest method assertEntityDeleted.

@Override
protected void assertEntityDeleted(String id) throws Exception {
    ITypedReferenceableInstance entity = repositoryService.getEntityDefinition(id);
    assertEquals(entity.getId().getState(), Id.EntityState.DELETED);
}
Also used : ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance)

Example 39 with ITypedReferenceableInstance

use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.

the class GraphBackedRepositorySoftDeleteTest method assertMaxForTestDisconnectBidirectionalReferences.

@Override
protected void assertMaxForTestDisconnectBidirectionalReferences(Map<String, String> nameGuidMap) throws Exception {
    // Verify that the Department.employees reference to the deleted employee
    // was disconnected.
    ITypedReferenceableInstance hrDept = repositoryService.getEntityDefinition(nameGuidMap.get("hr"));
    List<ITypedReferenceableInstance> employees = (List<ITypedReferenceableInstance>) hrDept.get("employees");
    Assert.assertEquals(employees.size(), 4);
    String maxGuid = nameGuidMap.get("Max");
    for (ITypedReferenceableInstance employee : employees) {
        if (employee.getId()._getId().equals(maxGuid)) {
            assertEquals(employee.getId().getState(), Id.EntityState.DELETED);
        }
    }
    // Verify that the Manager.subordinates still references deleted employee
    ITypedReferenceableInstance jane = repositoryService.getEntityDefinition(nameGuidMap.get("Jane"));
    List<ITypedReferenceableInstance> subordinates = (List<ITypedReferenceableInstance>) jane.get("subordinates");
    assertEquals(subordinates.size(), 2);
    for (ITypedReferenceableInstance subordinate : subordinates) {
        if (subordinate.getId()._getId().equals(maxGuid)) {
            assertEquals(subordinate.getId().getState(), Id.EntityState.DELETED);
        }
    }
    // Verify that max's Person.mentor unidirectional reference to john was disconnected.
    ITypedReferenceableInstance john = repositoryService.getEntityDefinition(nameGuidMap.get("John"));
    Id mentor = (Id) john.get("mentor");
    assertEquals(mentor._getId(), maxGuid);
    assertEquals(mentor.getState(), Id.EntityState.DELETED);
}
Also used : ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) List(java.util.List) Id(org.apache.atlas.typesystem.persistence.Id)

Example 40 with ITypedReferenceableInstance

use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.

the class GraphBackedRepositorySoftDeleteTest method assertTestUpdateEntity_MultiplicityOneNonCompositeReference.

@Override
protected void assertTestUpdateEntity_MultiplicityOneNonCompositeReference(String janeGuid) throws Exception {
    // Verify Jane's subordinates reference cardinality is still 2.
    ITypedReferenceableInstance jane = repositoryService.getEntityDefinition(janeGuid);
    List<ITypedReferenceableInstance> subordinates = (List<ITypedReferenceableInstance>) jane.get("subordinates");
    Assert.assertEquals(subordinates.size(), 2);
}
Also used : ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) List(java.util.List)

Aggregations

ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)142 Test (org.testng.annotations.Test)54 List (java.util.List)34 ArrayList (java.util.ArrayList)30 Id (org.apache.atlas.typesystem.persistence.Id)28 Referenceable (org.apache.atlas.typesystem.Referenceable)22 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)21 ImmutableList (com.google.common.collect.ImmutableList)20 ClassType (org.apache.atlas.typesystem.types.ClassType)19 HashMap (java.util.HashMap)16 AtlasException (org.apache.atlas.AtlasException)16 IReferenceableInstance (org.apache.atlas.typesystem.IReferenceableInstance)16 ITypedStruct (org.apache.atlas.typesystem.ITypedStruct)14 EntityResult (org.apache.atlas.model.legacy.EntityResult)12 IStruct (org.apache.atlas.typesystem.IStruct)10 Map (java.util.Map)9 CreateUpdateEntitiesResult (org.apache.atlas.CreateUpdateEntitiesResult)9 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)9 RepositoryException (org.apache.atlas.repository.RepositoryException)9 BeforeTest (org.testng.annotations.BeforeTest)9