use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class LoadSaveVreTest method loadLoadsInheritingCollections.
@Test
public void loadLoadsInheritingCollections() {
final String entityTypeName = "wwperson";
final String collectionName = "wwpersons";
final String archetypeName = "person";
final String archetypeCollectionName = "persons";
final Vre instance = load(initGraph(g -> g.withVertex("vre", v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(VRE_NAME_PROPERTY_NAME, "VreName")).withVertex("collection", v -> v.withLabel(Collection.DATABASE_LABEL).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, collectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName).withProperty(Collection.IS_RELATION_COLLECTION_PROPERTY_NAME, false).withIncomingRelation(HAS_COLLECTION_RELATION_NAME, "vre")).withVertex("archetype", v -> v.withLabel(Collection.DATABASE_LABEL).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, archetypeCollectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, archetypeName).withIncomingRelation(HAS_ARCHETYPE_RELATION_NAME, "collection"))));
assertThat(instance.getImplementerOf("person").get().getEntityTypeName(), equalTo(entityTypeName));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method findByQuickSearchReturnsAnEmtptyTraversalWhenNoVerticesAreFound.
@Test
public void findByQuickSearchReturnsAnEmtptyTraversalWhenNoVerticesAreFound() {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1).withProperty("displayName", "query")).withVertex(v -> v.withTimId(id2).withProperty("displayName", "query2")).withVertex(v -> v.withTimId(id3).withProperty("displayName", "other")).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id1).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id2).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id3).next());
QuickSearch quickSearch = QuickSearch.fromQueryString("queryWithoutResult");
GraphTraversal<Vertex, Vertex> vertices = instance.findByQuickSearch(collection, quickSearch);
assertThat(vertices.map(v -> v.get().value("tim_id")).toList(), is(empty()));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method hasQuickSearchForReturnsFalseIfTheIndexDoesNotExist.
@Test
public void hasQuickSearchForReturnsFalseIfTheIndexDoesNotExist() {
TinkerPopGraphManager tinkerPopGraphManager = newGraph().wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
Collection collectionWithoutIndex = mock(Collection.class);
when(collectionWithoutIndex.getCollectionName()).thenReturn(COLLECTION);
boolean existingIndex = instance.hasQuickSearchIndexFor(collectionWithoutIndex);
assertThat(existingIndex, is(false));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method findByQuickSearchIsCaseInsensitive.
@Test
public void findByQuickSearchIsCaseInsensitive() {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1).withProperty("displayName", "query")).withVertex(v -> v.withTimId(id2).withProperty("displayName", "QUERY2")).withVertex(v -> v.withTimId(id3).withProperty("displayName", "notmatching")).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id1).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id2).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id3).next());
QuickSearch quickSearch = QuickSearch.fromQueryString("query*");
GraphTraversal<Vertex, Vertex> vertices = instance.findByQuickSearch(collection, quickSearch);
assertThat(vertices.map(v -> v.get().value("tim_id")).toList(), containsInAnyOrder(id1, id2));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class ChangeListenerTest method callsOnRemoveFromCollectionOnDeleteEntity.
@Test
public void callsOnRemoveFromCollectionOnDeleteEntity() throws Exception {
ChangeListener changeListener = new ChangeListenerImpl(vertex -> {
assertThat(vertex, likeVertex().withProperty("isLatest", true).withProperty("rev", 2));
Long prevVersions = stream(vertex.vertices(Direction.BOTH, VERSION_OF)).collect(Collectors.counting());
assertThat(prevVersions, is(1L));
});
UUID id = UUID.randomUUID();
ChangeListener spy = spy(changeListener);
DataStoreOperations instance = forDeleteCall(spy, id, 1, "someName");
Collection collection = mock(Collection.class);
when(collection.getEntityTypeName()).thenReturn("someName");
when(collection.getVre()).thenReturn(mock(Vre.class));
instance.deleteEntity(collection, id, new Change());
verify(spy).onRemoveFromCollection(same(collection), any(), any());
}
Aggregations