GraphBackedMetadataRepository implements MetadataRepository { @Override @GraphTransaction public List<String> getTraitNames(String guid) throws AtlasException { if (LOG.isDebugEnabled()) { LOG.debug("Retrieving trait names for entity={}", guid); } AtlasVertex instanceVertex = graphHelper.getVertexForGUID(guid); return GraphHelper.getTraitNames(instanceVertex); } @Inject  GraphBackedMetadataRepository(DeleteHandler deleteHandler, AtlasGraph atlasGraph); GraphToTypedInstanceMapper getGraphToInstanceMapper(); @Override String getTypeAttributeName(); @Override String getStateAttributeName(); @Override String getSuperTypeAttributeName(); String getIdAttributeName(); @Override String getVersionAttributeName(); @Override String getTraitLabel(IDataType<?> dataType, String traitName); @Override String getFieldNameInVertex(IDataType<?> dataType, AttributeInfo aInfo); String getFieldNameInVertex(IDataType<?> dataType, String attrName); @Override String getEdgeLabel(IDataType<?> dataType, AttributeInfo aInfo); @Override @GraphTransaction CreateUpdateEntitiesResult createEntities(ITypedReferenceableInstance... entities); @Override @GraphTransaction ITypedReferenceableInstance getEntityDefinition(String guid); @Override @GraphTransaction List<ITypedReferenceableInstance> getEntityDefinitions(String... guids); @Override @GraphTransaction ITypedReferenceableInstance getEntityDefinition(String entityType, String attribute, Object value); @Override @GraphTransaction List<String> getEntityList(String entityType); @Override @GraphTransaction List<String> getTraitNames(String guid); @Override @GraphTransaction void addTrait(List<String> entityGuids, ITypedStruct traitInstance); @Override @GraphTransaction void addTrait(String guid, ITypedStruct traitInstance); @Override @GraphTransaction void deleteTrait(String guid, String traitNameToBeDeleted); @Override @GraphTransaction CreateUpdateEntitiesResult updateEntities(ITypedReferenceableInstance... entitiesUpdated); @Override @GraphTransaction CreateUpdateEntitiesResult updatePartial(ITypedReferenceableInstance entity); @Override @GraphTransaction EntityResult deleteEntities(List<String> guids); AtlasGraph getGraph();  }
@Test(dependsOnMethods = "testCreateEntity") public void testGetTraitNames() throws Exception { final List<String> traitNames = repositoryService.getTraitNames(getGUID()); Assert.assertEquals(traitNames.size(), 1); Assert.assertEquals(traitNames, Arrays.asList(new String[]{TestUtils.CLASSIFICATION})); }
@Test public void testGetTraitNamesForEmptyTraits() throws Exception { final List<String> traitNames = repositoryService.getTraitNames(guid); Assert.assertEquals(traitNames.size(), 0); }
@Test(expectedExceptions = EntityNotFoundException.class) public void testGetTraitNamesForBadEntity() throws Exception { repositoryService.getTraitNames(UUID.randomUUID().toString()); Assert.fail(); }