use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class ExportServiceTest method getRequestForEmployee.
private AtlasExportRequest getRequestForEmployee() {
AtlasExportRequest request = new AtlasExportRequest();
List<AtlasObjectId> itemsToExport = new ArrayList<>();
itemsToExport.add(new AtlasObjectId("Employee", "name", "Max"));
request.setItemsToExport(itemsToExport);
setOptionsMap(request, true, "CONNECTED", false, "");
return request;
}
use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class ExportIncrementalTest method getExportRequestForHiveTable.
private AtlasExportRequest getExportRequestForHiveTable(String name, String fetchType, long changeMarker, boolean skipLineage) {
AtlasExportRequest request = new AtlasExportRequest();
List<AtlasObjectId> itemsToExport = new ArrayList<>();
itemsToExport.add(new AtlasObjectId("hive_table", "qualifiedName", name));
request.setItemsToExport(itemsToExport);
request.setOptions(getOptionsMap(fetchType, changeMarker, skipLineage));
return request;
}
use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class RelationshipAttributesExtractorTest method getExportRequestForHiveTable.
private AtlasExportRequest getExportRequestForHiveTable(String hiveTableName, String fetchType, boolean skipLineage) {
AtlasExportRequest request = new AtlasExportRequest();
List<AtlasObjectId> itemsToExport = new ArrayList<>();
itemsToExport.add(new AtlasObjectId("hive_table", "qualifiedName", hiveTableName));
request.setItemsToExport(itemsToExport);
request.setOptions(getOptionsMap(fetchType, skipLineage));
return request;
}
use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class StartEntityFetchByExportRequestTest method fetchTypeGuid.
@Test
public void fetchTypeGuid() {
String exportRequestJson = "{ \"itemsToExport\": [ { \"typeName\": \"hive_db\", \"guid\": \"111-222-333\" } ]}";
AtlasExportRequest exportRequest = AtlasType.fromJson(exportRequestJson, AtlasExportRequest.class);
List<AtlasObjectId> objectGuidMap = startEntityFetchByExportRequestSpy.get(exportRequest);
assertEquals(objectGuidMap.get(0).getGuid(), "111-222-333");
}
use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class InverseReferenceUpdateV2Test method testInverseReferenceAutoUpdate_Map.
@Test
public void testInverseReferenceAutoUpdate_Map() throws Exception {
AtlasEntity a1 = new AtlasEntity("A");
a1.setAttribute(NAME, TestUtilsV2.randomString());
AtlasEntity b1 = new AtlasEntity("B");
b1.setAttribute(NAME, TestUtilsV2.randomString());
AtlasEntity b2 = new AtlasEntity("B");
b2.setAttribute(NAME, TestUtilsV2.randomString());
AtlasEntity b3 = new AtlasEntity("B");
b3.setAttribute(NAME, TestUtilsV2.randomString());
AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo();
atlasEntitiesWithExtInfo.addEntity(a1);
atlasEntitiesWithExtInfo.addEntity(b1);
atlasEntitiesWithExtInfo.addEntity(b2);
atlasEntitiesWithExtInfo.addEntity(b3);
AtlasEntityStream entityStream = new AtlasEntityStream(atlasEntitiesWithExtInfo);
EntityMutationResponse response = entityStore.createOrUpdate(entityStream, false);
AtlasEntityType aType = typeRegistry.getEntityTypeByName("A");
AtlasEntity aForPartialUpdate = new AtlasEntity("A");
aForPartialUpdate.setAttribute("mapToB", ImmutableMap.<String, AtlasObjectId>of("b1", AtlasTypeUtil.getAtlasObjectId(b1), "b2", AtlasTypeUtil.getAtlasObjectId(b2)));
init();
response = entityStore.updateByUniqueAttributes(aType, Collections.<String, Object>singletonMap(NAME, a1.getAttribute(NAME)), new AtlasEntityWithExtInfo(aForPartialUpdate));
List<AtlasEntityHeader> partialUpdatedEntities = response.getPartialUpdatedEntities();
// Verify 3 entities were updated:
// * set a1.mapToB to "b1"->b1, "b2"->b2
// * set b1.mappedFromA to a1
// * set b2.mappedFromA to a1
assertEquals(partialUpdatedEntities.size(), 3);
AtlasEntitiesWithExtInfo storedEntities = entityStore.getByIds(ImmutableList.of(a1.getGuid(), b2.getGuid(), b1.getGuid()));
AtlasEntity storedEntity = storedEntities.getEntity(a1.getGuid());
Object value = storedEntity.getAttribute("mapToB");
assertTrue(value instanceof Map);
Map<String, AtlasObjectId> refMap = (Map<String, AtlasObjectId>) value;
assertEquals(refMap.size(), 2);
AtlasObjectId referencedEntityId = refMap.get("b1");
assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b1));
referencedEntityId = refMap.get("b2");
assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b2));
storedEntity = storedEntities.getEntity(b1.getGuid());
verifyReferenceValue(storedEntity, "mappedFromA", a1.getGuid());
storedEntity = storedEntities.getEntity(b2.getGuid());
verifyReferenceValue(storedEntity, "mappedFromA", a1.getGuid());
aForPartialUpdate.setAttribute("mapToB", ImmutableMap.<String, AtlasObjectId>of("b3", AtlasTypeUtil.getAtlasObjectId(b3)));
init();
response = entityStore.updateByUniqueAttributes(aType, Collections.<String, Object>singletonMap(NAME, a1.getAttribute(NAME)), new AtlasEntityWithExtInfo(aForPartialUpdate));
partialUpdatedEntities = response.getPartialUpdatedEntities();
// Verify 4 entities were updated:
// * set a1.mapToB to "b3"->b3
// * set b3.mappedFromA to a1
// * disconnect b1.mappedFromA
// * disconnect b2.mappedFromA
assertEquals(partialUpdatedEntities.size(), 4);
storedEntities = entityStore.getByIds(ImmutableList.of(a1.getGuid(), b2.getGuid(), b1.getGuid(), b3.getGuid()));
AtlasEntity storedB3 = storedEntities.getEntity(b3.getGuid());
verifyReferenceValue(storedB3, "mappedFromA", a1.getGuid());
verify_testInverseReferenceAutoUpdate_Map(storedEntities.getEntity(a1.getGuid()), storedEntities.getEntity(b1.getGuid()), storedEntities.getEntity(b2.getGuid()), storedB3);
}
Aggregations