Search in sources :

Example 96 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class AtlasRelationshipStoreSoftDeleteV2Test method verifyRelationshipAttributeUpdate_ManyToMany_Friends.

@Override
protected void verifyRelationshipAttributeUpdate_ManyToMany_Friends(AtlasEntity max, AtlasEntity julius, AtlasEntity mike, AtlasEntity john) throws Exception {
    AtlasObjectId johnId = employeeNameIdMap.get("John");
    AtlasObjectId mikeId = employeeNameIdMap.get("Mike");
    AtlasObjectId juliusId = employeeNameIdMap.get("Julius");
    AtlasObjectId maxId = employeeNameIdMap.get("Max");
    // Max's updated friends: [Julius, John, Mike(soft deleted)]
    List<AtlasObjectId> maxFriendsIds = toAtlasObjectIds(max.getRelationshipAttribute("friends"));
    assertNotNull(maxFriendsIds);
    assertEquals(maxFriendsIds.size(), 3);
    assertObjectIdsContains(maxFriendsIds, johnId);
    assertObjectIdsContains(maxFriendsIds, juliusId);
    assertObjectIdsContains(maxFriendsIds, mikeId);
    // Julius's updated friends: [Max]
    List<AtlasObjectId> juliusFriendsIds = toAtlasObjectIds(julius.getRelationshipAttribute("friends"));
    assertNotNull(juliusFriendsIds);
    assertEquals(juliusFriendsIds.size(), 1);
    assertObjectIdsContains(juliusFriendsIds, maxId);
    // Mike's updated friends: [John, Max(soft deleted)]
    List<AtlasObjectId> mikeFriendsIds = toAtlasObjectIds(mike.getRelationshipAttribute("friends"));
    assertNotNull(mikeFriendsIds);
    assertEquals(mikeFriendsIds.size(), 2);
    assertObjectIdsContains(mikeFriendsIds, johnId);
    assertObjectIdsContains(mikeFriendsIds, maxId);
    // John's updated friends: [Max, Mike]
    List<AtlasObjectId> johnFriendsIds = toAtlasObjectIds(john.getRelationshipAttribute("friends"));
    assertNotNull(johnFriendsIds);
    assertEquals(johnFriendsIds.size(), 2);
    assertObjectIdsContains(johnFriendsIds, maxId);
    assertObjectIdsContains(johnFriendsIds, mikeId);
}
Also used : AtlasTypeUtil.getAtlasObjectId(org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 97 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class AtlasRelationshipStoreSoftDeleteV2Test method verifyRelationshipAttributeUpdate_OneToOne_Sibling.

protected void verifyRelationshipAttributeUpdate_OneToOne_Sibling(AtlasEntity julius, AtlasEntity jane, AtlasEntity mike) throws Exception {
    AtlasObjectId juliusId = employeeNameIdMap.get("Julius");
    AtlasObjectId mikeId = employeeNameIdMap.get("Mike");
    // Julius sibling updated to Mike
    AtlasObjectId juliusSiblingId = toAtlasObjectId(julius.getRelationshipAttribute("sibling"));
    assertNotNull(juliusSiblingId);
    assertObjectIdEquals(juliusSiblingId, mikeId);
    // Mike's sibling is Julius
    AtlasObjectId mikeSiblingId = toAtlasObjectId(mike.getRelationshipAttribute("sibling"));
    assertNotNull(mikeSiblingId);
    assertObjectIdEquals(mikeSiblingId, juliusId);
    // Jane's sibling is still Julius (soft delete)
    AtlasObjectId janeSiblingId = toAtlasObjectId(jane.getRelationshipAttribute("sibling"));
    assertNotNull(janeSiblingId);
    assertObjectIdEquals(janeSiblingId, juliusId);
}
Also used : AtlasTypeUtil.getAtlasObjectId(org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 98 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class AtlasRelationshipStoreV2Test method testRelationshipAttributeUpdate_NonComposite_OneToMany.

// Seeing intermittent failures with janus profile, disabling it until its fixed.
@Test(enabled = false)
public void testRelationshipAttributeUpdate_NonComposite_OneToMany() throws Exception {
    AtlasObjectId maxId = employeeNameIdMap.get("Max");
    AtlasObjectId juliusId = employeeNameIdMap.get("Julius");
    AtlasObjectId janeId = employeeNameIdMap.get("Jane");
    AtlasObjectId mikeId = employeeNameIdMap.get("Mike");
    AtlasObjectId johnId = employeeNameIdMap.get("John");
    // Change Max's Employee.manager reference to Julius and apply the change as a partial update.
    // This should also update Julius to add Max to the inverse Manager.subordinates reference.
    AtlasEntity maxEntityForUpdate = new AtlasEntity(EMPLOYEE_TYPE);
    maxEntityForUpdate.setRelationshipAttribute("manager", juliusId);
    AtlasEntityType employeeType = typeRegistry.getEntityTypeByName(EMPLOYEE_TYPE);
    Map<String, Object> uniqAttributes = Collections.<String, Object>singletonMap("name", "Max");
    EntityMutationResponse updateResponse = entityStore.updateByUniqueAttributes(employeeType, uniqAttributes, new AtlasEntityWithExtInfo(maxEntityForUpdate));
    List<AtlasEntityHeader> partialUpdatedEntities = updateResponse.getPartialUpdatedEntities();
    assertEquals(partialUpdatedEntities.size(), 3);
    // 3 entities should have been updated:
    // * Max to change the Employee.manager reference
    // * Julius to add Max to Manager.subordinates
    // * Jane to remove Max from Manager.subordinates
    AtlasEntitiesWithExtInfo updatedEntities = entityStore.getByIds(ImmutableList.of(maxId.getGuid(), juliusId.getGuid(), janeId.getGuid()));
    // Max's manager updated as Julius
    AtlasEntity maxEntity = updatedEntities.getEntity(maxId.getGuid());
    verifyRelationshipAttributeValue(maxEntity, "manager", juliusId.getGuid());
    // Max added to the subordinate list of Julius, existing subordinate is Mike
    AtlasEntity juliusEntity = updatedEntities.getEntity(juliusId.getGuid());
    verifyRelationshipAttributeList(juliusEntity, "subordinates", ImmutableList.of(maxId, mikeId));
    // Max removed from the subordinate list of Julius
    AtlasEntity janeEntity = updatedEntities.getEntity(janeId.getGuid());
    // Jane's subordinates list includes John and Max for soft delete
    // Jane's subordinates list includes only John for hard delete
    verifyRelationshipAttributeUpdate_NonComposite_OneToMany(janeEntity);
    // Remove Mike from Max's friends list
    // Max's current friends: [Mike, John]
    // Max's updated friends: [Julius, John]
    maxEntityForUpdate = new AtlasEntity(EMPLOYEE_TYPE);
    maxEntityForUpdate.setRelationshipAttribute("friends", ImmutableList.of(johnId, juliusId));
    init();
    updateResponse = entityStore.updateByUniqueAttributes(employeeType, uniqAttributes, new AtlasEntityWithExtInfo(maxEntityForUpdate));
    partialUpdatedEntities = updateResponse.getPartialUpdatedEntities();
    assertEquals(partialUpdatedEntities.size(), 3);
    // 3 entities should have been updated:
    // * Max added Julius and removed Mike from Employee.friends
    // * Mike removed Max from Employee.friends
    // * Julius added Max in Employee.friends
    updatedEntities = entityStore.getByIds(ImmutableList.of(maxId.getGuid(), mikeId.getGuid(), johnId.getGuid(), juliusId.getGuid()));
    maxEntity = updatedEntities.getEntity(maxId.getGuid());
    juliusEntity = updatedEntities.getEntity(juliusId.getGuid());
    AtlasEntity mikeEntity = updatedEntities.getEntity(mikeId.getGuid());
    AtlasEntity johnEntity = updatedEntities.getEntity(johnId.getGuid());
    verifyRelationshipAttributeUpdate_ManyToMany_Friends(maxEntity, juliusEntity, mikeEntity, johnEntity);
    // Remove Julius from Jane's sibling and add Mike as new sibling
    AtlasEntity juliusEntityForUpdate = new AtlasEntity(EMPLOYEE_TYPE);
    juliusEntityForUpdate.setRelationshipAttribute("sibling", mikeId);
    init();
    updateResponse = entityStore.updateByUniqueAttributes(employeeType, Collections.<String, Object>singletonMap("name", "Julius"), new AtlasEntityWithExtInfo(juliusEntityForUpdate));
    partialUpdatedEntities = updateResponse.getPartialUpdatedEntities();
    assertEquals(partialUpdatedEntities.size(), 3);
    updatedEntities = entityStore.getByIds(ImmutableList.of(juliusId.getGuid(), janeId.getGuid(), mikeId.getGuid()));
    juliusEntity = updatedEntities.getEntity(juliusId.getGuid());
    janeEntity = updatedEntities.getEntity(janeId.getGuid());
    mikeEntity = updatedEntities.getEntity(mikeId.getGuid());
    verifyRelationshipAttributeUpdate_OneToOne_Sibling(juliusEntity, janeEntity, mikeEntity);
}
Also used : AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) AtlasTypeUtil.getAtlasObjectId(org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 99 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class AtlasEntityStoreV2Test method testUpdateEntityWithMap.

@Test(dependsOnMethods = "testCreate")
public void testUpdateEntityWithMap() throws Exception {
    AtlasEntity tableEntity = new AtlasEntity(tblEntity.getEntity());
    AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity);
    Map<String, AtlasStruct> partsMap = new HashMap<>();
    partsMap.put("part0", new AtlasStruct(TestUtilsV2.PARTITION_STRUCT_TYPE, NAME, "test"));
    tableEntity.setAttribute("partitionsMap", partsMap);
    init();
    EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
    AtlasEntityHeader tableDefinition1 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
    AtlasEntity updatedTableDef1 = getEntityFromStore(tableDefinition1);
    validateEntity(entitiesInfo, updatedTableDef1);
    Assert.assertTrue(partsMap.get("part0").equals(((Map<String, AtlasStruct>) updatedTableDef1.getAttribute("partitionsMap")).get("part0")));
    // update map - add a map key
    partsMap.put("part1", new AtlasStruct(TestUtilsV2.PARTITION_STRUCT_TYPE, NAME, "test1"));
    tableEntity.setAttribute("partitionsMap", partsMap);
    init();
    response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
    AtlasEntityHeader tableDefinition2 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
    AtlasEntity updatedTableDef2 = getEntityFromStore(tableDefinition2);
    validateEntity(entitiesInfo, updatedTableDef2);
    assertEquals(((Map<String, AtlasStruct>) updatedTableDef2.getAttribute("partitionsMap")).size(), 2);
    Assert.assertTrue(partsMap.get("part1").equals(((Map<String, AtlasStruct>) updatedTableDef2.getAttribute("partitionsMap")).get("part1")));
    // update map - remove a key and add another key
    partsMap.remove("part0");
    partsMap.put("part2", new AtlasStruct(TestUtilsV2.PARTITION_STRUCT_TYPE, NAME, "test2"));
    tableEntity.setAttribute("partitionsMap", partsMap);
    init();
    response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
    AtlasEntityHeader tableDefinition3 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
    AtlasEntity updatedTableDef3 = getEntityFromStore(tableDefinition3);
    validateEntity(entitiesInfo, updatedTableDef3);
    assertEquals(((Map<String, AtlasStruct>) updatedTableDef3.getAttribute("partitionsMap")).size(), 2);
    Assert.assertNull(((Map<String, AtlasStruct>) updatedTableDef3.getAttribute("partitionsMap")).get("part0"));
    Assert.assertTrue(partsMap.get("part2").equals(((Map<String, AtlasStruct>) updatedTableDef3.getAttribute("partitionsMap")).get("part2")));
    // update struct value for existing map key
    AtlasStruct partition2 = partsMap.get("part2");
    partition2.setAttribute(NAME, "test2Updated");
    init();
    response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
    AtlasEntityHeader tableDefinition4 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
    AtlasEntity updatedTableDef4 = getEntityFromStore(tableDefinition4);
    validateEntity(entitiesInfo, updatedTableDef4);
    assertEquals(((Map<String, AtlasStruct>) updatedTableDef4.getAttribute("partitionsMap")).size(), 2);
    Assert.assertNull(((Map<String, AtlasStruct>) updatedTableDef4.getAttribute("partitionsMap")).get("part0"));
    Assert.assertTrue(partsMap.get("part2").equals(((Map<String, AtlasStruct>) updatedTableDef4.getAttribute("partitionsMap")).get("part2")));
    // Test map pointing to a class
    AtlasEntity col0 = new AtlasEntity(COLUMN_TYPE, NAME, "test1");
    col0.setAttribute("type", "string");
    col0.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity));
    AtlasEntityWithExtInfo col0WithExtendedInfo = new AtlasEntityWithExtInfo(col0);
    col0WithExtendedInfo.addReferredEntity(tableEntity);
    col0WithExtendedInfo.addReferredEntity(dbEntity.getEntity());
    init();
    entityStore.createOrUpdate(new AtlasEntityStream(col0WithExtendedInfo), false);
    AtlasEntity col1 = new AtlasEntity(COLUMN_TYPE, NAME, "test2");
    col1.setAttribute("type", "string");
    col1.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity));
    AtlasEntityWithExtInfo col1WithExtendedInfo = new AtlasEntityWithExtInfo(col1);
    col1WithExtendedInfo.addReferredEntity(tableEntity);
    col1WithExtendedInfo.addReferredEntity(dbEntity.getEntity());
    init();
    entityStore.createOrUpdate(new AtlasEntityStream(col1WithExtendedInfo), false);
    Map<String, AtlasObjectId> columnsMap = new HashMap<String, AtlasObjectId>();
    columnsMap.put("col0", AtlasTypeUtil.getAtlasObjectId(col0));
    columnsMap.put("col1", AtlasTypeUtil.getAtlasObjectId(col1));
    tableEntity.setAttribute(TestUtilsV2.COLUMNS_MAP, columnsMap);
    entitiesInfo.addReferredEntity(col0);
    entitiesInfo.addReferredEntity(col1);
    init();
    response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
    AtlasEntityHeader tableDefinition5 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
    validateEntity(entitiesInfo, getEntityFromStore(tableDefinition5));
    // Swap elements
    columnsMap.clear();
    columnsMap.put("col0", AtlasTypeUtil.getAtlasObjectId(col1));
    columnsMap.put("col1", AtlasTypeUtil.getAtlasObjectId(col0));
    tableEntity.setAttribute(TestUtilsV2.COLUMNS_MAP, columnsMap);
    init();
    response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
    AtlasEntityHeader tableDefinition6 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
    validateEntity(entitiesInfo, getEntityFromStore(tableDefinition6));
    Assert.assertEquals(entityStore.getById(col0.getGuid()).getEntity().getStatus(), AtlasEntity.Status.ACTIVE);
    Assert.assertEquals(entityStore.getById(col1.getGuid()).getEntity().getStatus(), AtlasEntity.Status.ACTIVE);
    // Drop the first key and change the class type as well to col0
    columnsMap.clear();
    columnsMap.put("col0", AtlasTypeUtil.getAtlasObjectId(col0));
    tableEntity.setAttribute(TestUtilsV2.COLUMNS_MAP, columnsMap);
    init();
    response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
    AtlasEntityHeader tableDefinition7 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
    validateEntity(entitiesInfo, getEntityFromStore(tableDefinition7));
    // Clear state
    tableEntity.setAttribute(TestUtilsV2.COLUMNS_MAP, null);
    init();
    response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
    AtlasEntityHeader tableDefinition8 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
    validateEntity(entitiesInfo, getEntityFromStore(tableDefinition8));
}
Also used : AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) HashMap(java.util.HashMap) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) AtlasStruct(org.apache.atlas.model.instance.AtlasStruct) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 100 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class AtlasEntityStoreV2Test method testPartialUpdateAttr.

@Test
public void testPartialUpdateAttr() throws Exception {
    // Update optional attribute
    init();
    AtlasEntity dbEntity = new AtlasEntity(TestUtilsV2.DATABASE_TYPE);
    dbEntity.setAttribute("name", TestUtilsV2.randomString(10));
    dbEntity.setAttribute("description", "us db");
    dbEntity.setAttribute("isReplicated", false);
    dbEntity.setAttribute("created", "09081988");
    dbEntity.setAttribute("namespace", "db namespace");
    dbEntity.setAttribute("cluster", "Fenton_Cluster");
    dbEntity.setAttribute("colo", "10001");
    EntityStream dbStream = new AtlasEntityStream(new AtlasEntitiesWithExtInfo(dbEntity));
    EntityMutationResponse response = entityStore.createOrUpdate(dbStream, false);
    AtlasEntityHeader dbHeader = response.getFirstEntityCreated();
    AtlasEntity createdDbEntity = getEntityFromStore(dbHeader);
    // update the db entity
    dbEntity = new AtlasEntity(TestUtilsV2.DATABASE_TYPE);
    dbEntity.setGuid(createdDbEntity.getGuid());
    // dbEntity.setAttribute("name", createdDbEntity.getAttribute("name"));
    // dbEntity.setAttribute("description", "another db"); // required attr
    // optional attr
    dbEntity.setAttribute("created", "08151947");
    // optional attr
    dbEntity.setAttribute("isReplicated", true);
    dbStream = new AtlasEntityStream(new AtlasEntitiesWithExtInfo(dbEntity));
    // fail full update if required attributes are not specified.
    try {
        entityStore.createOrUpdate(dbStream, false);
    } catch (AtlasBaseException ex) {
        Assert.assertEquals(ex.getAtlasErrorCode(), AtlasErrorCode.INSTANCE_CRUD_INVALID_PARAMS);
    }
    // do partial update without providing required attributes
    dbStream.reset();
    response = entityStore.createOrUpdate(dbStream, true);
    dbHeader = response.getFirstEntityPartialUpdated();
    AtlasEntity updatedDbEntity = getEntityFromStore(dbHeader);
    assertEquals(updatedDbEntity.getAttribute("name"), createdDbEntity.getAttribute("name"));
    assertEquals(updatedDbEntity.getAttribute("description"), createdDbEntity.getAttribute("description"));
    assertEquals(updatedDbEntity.getAttribute("isReplicated"), true);
    assertEquals(updatedDbEntity.getAttribute("created"), "08151947");
    assertEquals(updatedDbEntity.getAttribute("namespace"), createdDbEntity.getAttribute("namespace"));
    assertEquals(updatedDbEntity.getAttribute("cluster"), createdDbEntity.getAttribute("cluster"));
    assertEquals(updatedDbEntity.getAttribute("colo"), createdDbEntity.getAttribute("colo"));
    // create a new table type
    AtlasEntity tblEntity = new AtlasEntity(TABLE_TYPE);
    tblEntity.setAttribute("name", TestUtilsV2.randomString(10));
    tblEntity.setAttribute("type", "type");
    tblEntity.setAttribute("tableType", "MANAGED");
    tblEntity.setAttribute("database", AtlasTypeUtil.getAtlasObjectId(updatedDbEntity));
    // create new column entity
    AtlasEntity col1 = TestUtilsV2.createColumnEntity(tblEntity);
    AtlasEntity col2 = TestUtilsV2.createColumnEntity(tblEntity);
    col1.setAttribute(NAME, "col1");
    col2.setAttribute(NAME, "col2");
    List<AtlasObjectId> columns = new ArrayList<>();
    columns.add(AtlasTypeUtil.getAtlasObjectId(col1));
    columns.add(AtlasTypeUtil.getAtlasObjectId(col2));
    tblEntity.setAttribute(COLUMNS_ATTR_NAME, columns);
    AtlasEntitiesWithExtInfo tableEntityInfo = new AtlasEntitiesWithExtInfo(tblEntity);
    tableEntityInfo.addReferredEntity(col1.getGuid(), col1);
    tableEntityInfo.addReferredEntity(col2.getGuid(), col2);
    EntityStream tblStream = new AtlasEntityStream(tableEntityInfo);
    response = entityStore.createOrUpdate(tblStream, false);
    AtlasEntityHeader tblHeader = response.getFirstEntityCreated();
    AtlasEntity createdTblEntity = getEntityFromStore(tblHeader);
    columns = (List<AtlasObjectId>) createdTblEntity.getAttribute(COLUMNS_ATTR_NAME);
    assertEquals(columns.size(), 2);
    // update - add 2 more columns to table
    AtlasEntity col3 = TestUtilsV2.createColumnEntity(createdTblEntity);
    col3.setAttribute(NAME, "col3");
    col3.setAttribute("description", "description col3");
    AtlasEntity col4 = TestUtilsV2.createColumnEntity(createdTblEntity);
    col4.setAttribute(NAME, "col4");
    col4.setAttribute("description", "description col4");
    columns.clear();
    columns.add(AtlasTypeUtil.getAtlasObjectId(col3));
    columns.add(AtlasTypeUtil.getAtlasObjectId(col4));
    tblEntity = new AtlasEntity(TABLE_TYPE);
    tblEntity.setGuid(createdTblEntity.getGuid());
    tblEntity.setAttribute(COLUMNS_ATTR_NAME, columns);
    tableEntityInfo = new AtlasEntitiesWithExtInfo(tblEntity);
    tableEntityInfo.addReferredEntity(col3.getGuid(), col3);
    tableEntityInfo.addReferredEntity(col4.getGuid(), col4);
    tblStream = new AtlasEntityStream(tableEntityInfo);
    response = entityStore.createOrUpdate(tblStream, true);
    tblHeader = response.getFirstEntityPartialUpdated();
    AtlasEntity updatedTblEntity = getEntityFromStore(tblHeader);
    columns = (List<AtlasObjectId>) updatedTblEntity.getAttribute(COLUMNS_ATTR_NAME);
    // deleted columns are included in the attribute; hence use >=
    assertTrue(columns.size() >= 2);
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)255 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)124 Test (org.testng.annotations.Test)70 ArrayList (java.util.ArrayList)69 Map (java.util.Map)47 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)44 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)41 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)41 HashMap (java.util.HashMap)40 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)38 List (java.util.List)36 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)33 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)32 BeforeTest (org.testng.annotations.BeforeTest)32 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)29 AtlasTypeUtil.getAtlasObjectId (org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId)24 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)22 AtlasExportRequest (org.apache.atlas.model.impexp.AtlasExportRequest)14 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)13 AtlasType (org.apache.atlas.type.AtlasType)11