GraphBackedMetadataRepository implements MetadataRepository { public AtlasGraph getGraph() throws RepositoryException { return atlasGraph; } @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 testBug37860() throws Exception { String dslQuery = "hive_table as t where name = 'bar' " + "database where name = 'foo' and description = 'foo database' select t"; TestUtils.dumpGraph(TestUtils.getGraph()); System.out.println("Executing dslQuery = " + dslQuery); String jsonResults = discoveryService.searchByDSL(dslQuery, queryParams); Assert.assertNotNull(jsonResults); JSONObject results = new JSONObject(jsonResults); Assert.assertEquals(results.length(), 3); System.out.println("results = " + results); Object query = results.get("query"); Assert.assertNotNull(query); JSONObject dataType = results.getJSONObject("dataType"); Assert.assertNotNull(dataType); JSONArray rows = results.getJSONArray("rows"); Assert.assertEquals(rows.length(), 1); }
@Test(dependsOnMethods = "testSubmitEntity") public void testFullTextSearch() throws Exception { long sleepInterval = 1000; TestUtils.dumpGraph(TestUtils.getGraph()); Thread.sleep(sleepInterval); String response = discoveryService.searchByFullText("john", queryParams); Assert.assertNotNull(response); JSONArray results = new JSONArray(response); Assert.assertEquals(results.length(), 1); JSONObject row = (JSONObject) results.get(0); Assert.assertEquals(row.get("typeName"), "Person"); response = discoveryService.searchByFullText("Jane AND santa AND clara", queryParams); Assert.assertNotNull(response); results = new JSONArray(response); Assert.assertEquals(results.length(), 1); row = (JSONObject) results.get(0); Assert.assertEquals(row.get("typeName"), "Manager"); response = discoveryService.searchByFullText("hr AND (john OR jahn)", queryParams); Assert.assertNotNull(response); results = new JSONArray(response); Assert.assertEquals(results.length(), 1); row = (JSONObject) results.get(0); Assert.assertEquals(row.get("typeName"), "Person"); results = new JSONArray(discoveryService.searchByFullText("Department", queryParams)); assertEquals(results.length(), 5); results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(2, 0))); assertEquals(results.length(), 2); results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(5, 2))); assertEquals(results.length(), 3); results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(2, 6))); assertEquals(results.length(), 0); }