### Question:
FulltextIndexChangeListener implements ChangeListener { @Override public void onCreate(Collection collection, Vertex vertex) { handleChange(collection, vertex, null); } FulltextIndexChangeListener(IndexHandler indexHandler, GraphWrapper graphWrapper); @Override void onCreate(Collection collection, Vertex vertex); @Override void onPropertyUpdate(Collection collection, Optional<Vertex> oldVertex, Vertex newVertex); @Override void onRemoveFromCollection(Collection collection, Optional<Vertex> oldVertex, Vertex newVertex); @Override void onAddToCollection(Collection collection, Optional<Vertex> oldVertex, Vertex newVertex); @Override void onCreateEdge(Collection collection, Edge edge); @Override void onEdgeUpdate(Collection collection, Edge oldEdge, Edge newEdge);  }### Answer:
@Test public void onCreateAddsItemsToTheIndexOfTheProvidedCollection() { IndexHandler indexHandler = mock(IndexHandler.class); GraphWrapper graphWrapper = newGraph() .withVertex(v -> v .withProperty("vrecoll_name", "foo") ) .wrap(); FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper); Collection collection = new VresBuilder() .withVre("thevre", "vre", vre -> vre .withCollection("vrecolls", coll -> coll .withDisplayName(localProperty("vrecoll_name")) ) ) .build().getCollection("vrecolls").get(); Vertex vertex = graphWrapper.getGraph().traversal().V().next(); instance.onCreate(collection, vertex); verify(indexHandler).upsertIntoQuickSearchIndex(collection, "foo", vertex, null); }
@Test public void onCreateHandlesWwDocumentsUsingCustomLogic() { IndexHandler indexHandler = mock(IndexHandler.class); GraphWrapper graphWrapper = newGraph() .withVertex("doc", v -> v .withProperty("wwdocument_name", "foo") .withOutgoingRelation("isCreatedBy", "authorA", r -> r.withAccepted("wwrelation", true).withIsLatest(true)) .withOutgoingRelation("isCreatedBy", "authorB", r -> r.withAccepted("wwrelation", true).withIsLatest(true)) ) .withVertex("authorA", v -> v .withProperty("wwperson_name", "authorA") ) .withVertex("authorB", v -> v .withProperty("wwperson_name", "authorB") ) .wrap(); FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper); Collection collection = new VresBuilder() .withVre("womenwriters", "ww", vre -> vre .withCollection("wwdocuments", coll -> coll .withDisplayName(localProperty("wwdocument_name")) ) .withCollection("wwpersons", coll -> coll .withDisplayName(localProperty("wwperson_name")) ) ) .build().getCollection("wwdocuments").get(); Vertex vertex = graphWrapper.getGraph().traversal().V().next(); instance.onCreate(collection, vertex); verify(indexHandler).upsertIntoQuickSearchIndex(collection, "authorA; authorB foo", vertex, null); }