@Test public void findByIdReturnsAnEmptyTraversalWhenNoResultsAreFound() { UUID id1 = UUID.randomUUID(); TinkerPopGraphManager tinkerPopGraphManager = newGraph() .withVertex(v -> v .withTimId(id1.toString()) .withProperty("keyword_type", "keywordType") .withProperty("displayName", "query") ) .wrap(); Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager); Optional<Vertex> result = instance.findById(id1); assertThat(result.isPresent(), is(false)); }
@Override public Optional<Vertex> findById(UUID timId) { IndexHits<Node> hits = getIdIndex().query(TIM_ID, timId.toString()); return hits.hasNext() ? traversal().V(hits.next().getId()).tryNext() : Optional.empty(); }
Neo4jIndexHandler implements IndexHandler { @Override public Optional<Vertex> findById(UUID timId) { IndexHits<Node> hits = getIdIndex().query(TIM_ID, timId.toString()); return hits.hasNext() ? traversal().V(hits.next().getId()).tryNext() : Optional.empty(); } }
Neo4jIndexHandler implements IndexHandler { @Override public Optional<Vertex> findById(UUID timId) { IndexHits<Node> hits = getIdIndex().query(TIM_ID, timId.toString()); return hits.hasNext() ? traversal().V(hits.next().getId()).tryNext() : Optional.empty(); } Neo4jIndexHandler(TinkerPopGraphManager tinkerPopGraphManager); }
Neo4jIndexHandler implements IndexHandler { @Override public Optional<Vertex> findById(UUID timId) { IndexHits<Node> hits = getIdIndex().query(TIM_ID, timId.toString()); return hits.hasNext() ? traversal().V(hits.next().getId()).tryNext() : Optional.empty(); } Neo4jIndexHandler(TinkerPopGraphManager tinkerPopGraphManager); @Override boolean hasQuickSearchIndexFor(Collection collection); @Override GraphTraversal<Vertex, Vertex> findByQuickSearch(Collection collection, QuickSearch quickSearch); @Override GraphTraversal<Vertex, Vertex> findKeywordsByQuickSearch(Collection collection, QuickSearch quickSearch,
                                                                  String keywordType); @Override void removeFromQuickSearchIndex(Collection collection, Vertex vertex); @Override void upsertIntoQuickSearchIndex(Collection collection, String quickSearchValue, Vertex vertex,
                                         Vertex oldVertex); @Override void deleteQuickSearchIndex(Collection collection); @Override Optional<Vertex> findById(UUID timId); @Override @Deprecated void insertIntoIdIndex(UUID timId, Vertex vertex); @Override void upsertIntoIdIndex(UUID timId, Vertex vertex); @Override void removeFromIdIndex(Vertex vertex); @Override Optional<Edge> findEdgeById(UUID edgeId); @Override void upsertIntoEdgeIdIndex(UUID edgeId, Edge edge); @Override void removeEdgeFromIdIndex(Edge edge); }
Neo4jIndexHandler implements IndexHandler { @Override public Optional<Vertex> findById(UUID timId) { IndexHits<Node> hits = getIdIndex().query(TIM_ID, timId.toString()); return hits.hasNext() ? traversal().V(hits.next().getId()).tryNext() : Optional.empty(); } Neo4jIndexHandler(TinkerPopGraphManager tinkerPopGraphManager); @Override boolean hasQuickSearchIndexFor(Collection collection); @Override GraphTraversal<Vertex, Vertex> findByQuickSearch(Collection collection, QuickSearch quickSearch); @Override GraphTraversal<Vertex, Vertex> findKeywordsByQuickSearch(Collection collection, QuickSearch quickSearch,
                                                                  String keywordType); @Override void removeFromQuickSearchIndex(Collection collection, Vertex vertex); @Override void upsertIntoQuickSearchIndex(Collection collection, String quickSearchValue, Vertex vertex,
                                         Vertex oldVertex); @Override void deleteQuickSearchIndex(Collection collection); @Override Optional<Vertex> findById(UUID timId); @Override @Deprecated void insertIntoIdIndex(UUID timId, Vertex vertex); @Override void upsertIntoIdIndex(UUID timId, Vertex vertex); @Override void removeFromIdIndex(Vertex vertex); @Override Optional<Edge> findEdgeById(UUID edgeId); @Override void upsertIntoEdgeIdIndex(UUID edgeId, Edge edge); @Override void removeEdgeFromIdIndex(Edge edge);  }