use of org.apache.atlas.CreateUpdateEntitiesResult in project incubator-atlas by apache.
the class GraphBackedMetadataRepositoryTest method testCreateEntityWithOneNestingLevel.
@Test
public void testCreateEntityWithOneNestingLevel() throws AtlasException {
List<Referenceable> toValidate = new ArrayList<>();
Referenceable dept = new Referenceable(TestUtils.DEPARTMENT_TYPE);
toValidate.add(dept);
dept.set(TestUtils.NAME, "test1");
Referenceable mike = new Referenceable(TestUtils.PERSON_TYPE);
toValidate.add(mike);
mike.set(TestUtils.NAME, "Mike");
mike.set(TestUtils.DEPARTMENT_ATTR, dept);
Referenceable mark = new Referenceable(TestUtils.PERSON_TYPE);
toValidate.add(mark);
mark.set(TestUtils.NAME, "Mark");
mark.set(TestUtils.DEPARTMENT_ATTR, dept);
dept.set(TestUtils.EMPLOYEES_ATTR, ImmutableList.of(mike, mark));
Map<String, Referenceable> positions = new HashMap<>();
final String JANITOR = "janitor";
final String RECEPTIONIST = "receptionist";
positions.put(JANITOR, mike);
positions.put(RECEPTIONIST, mark);
dept.set(TestUtils.POSITIONS_ATTR, positions);
ClassType deptType = TypeSystem.getInstance().getDataType(ClassType.class, TestUtils.DEPARTMENT_TYPE);
ITypedReferenceableInstance deptInstance = deptType.convert(dept, Multiplicity.REQUIRED);
CreateUpdateEntitiesResult result = repositoryService.createEntities(deptInstance);
validateGuidMapping(toValidate, result);
}
use of org.apache.atlas.CreateUpdateEntitiesResult in project incubator-atlas by apache.
the class GraphBackedMetadataRepositoryDeleteTestBase method createInstance.
private String createInstance(Referenceable entity) throws Exception {
ClassType dataType = typeSystem.getDataType(ClassType.class, entity.getTypeName());
ITypedReferenceableInstance instance = dataType.convert(entity, Multiplicity.REQUIRED);
CreateUpdateEntitiesResult result = repositoryService.createEntities(instance);
List<String> results = result.getCreatedEntities();
return results.get(results.size() - 1);
}
Aggregations