use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyAddsHasNextEdgeBetweenTheProperties.
@Test
public void addPropertyAddsHasNextEdgeBetweenTheProperties() {
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
instance.addProperty(mock(Vertex.class), "prop1", "val1", type);
instance.addProperty(mock(Vertex.class), "prop2", "val2", type);
instance.addProperty(mock(Vertex.class), "prop3", "val3", type);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_INITIAL_PROPERTY_RELATION_NAME).out(HAS_NEXT_PROPERTY_RELATION_NAME).out(HAS_NEXT_PROPERTY_RELATION_NAME).count().next(), is(1L));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyDoesNotAddAPropConfigWhenTheCollectionIsAnArchetype.
@Test
public void addPropertyDoesNotAddAPropConfigWhenTheCollectionIsAnArchetype() {
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept").withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts")).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().next();
CollectionDescription collectionDescription = CollectionDescription.createForAdmin("concept");
Collection instance = new Collection("Admin", collectionVertex, graphWrapper, collectionDescription);
Vertex entityVertex = mock(Vertex.class);
instance.addProperty(entityVertex, "prop1", "val1", type);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_PROPERTY_RELATION_NAME).count().next(), is(0L));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class CollectionTest method setArchetypeSetsTheUriOfTheOriginalArchetypeToEdgeToTheArchetype.
@Test
public void setArchetypeSetsTheUriOfTheOriginalArchetypeToEdgeToTheArchetype() {
String newArchetypeEntity = "newArchetype";
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity)).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).has(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
Vertex archetypeVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).has(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity).next();
Collection archetype = new Collection("", archetypeVertex, graphWrapper);
String originalArchetypeUri = "http://example.com/originalArchetype";
instance.setArchetype(archetype, originalArchetypeUri);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).outE(HAS_ARCHETYPE_RELATION_NAME).toList(), hasItem(likeEdge().withProperty(RDF_URI_PROP, originalArchetypeUri)));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class CollectionTest method removeDoesNothingWhenTheEntityIsNotPartOfTheCollection.
@Test
public void removeDoesNothingWhenTheEntityIsNotPartOfTheCollection() {
GraphWrapper graphWrapper = newGraph().withVertex("collection", v -> v.withLabel(DATABASE_LABEL).withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityNode").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).withVertex("entityNode", v -> {
}).withVertex("entity", v -> v.withLabel("entity")).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).next();
Vertex entityVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("entity")).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
try {
instance.remove(entityVertex);
} catch (FastNoSuchElementException e) {
fail("Should not throw an exception.");
}
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class CollectionTest method removeRemovesEdgeBetweenTheVertexAndTheCollection.
@Test
public void removeRemovesEdgeBetweenTheVertexAndTheCollection() {
GraphWrapper graphWrapper = newGraph().withVertex("collection", v -> v.withLabel(DATABASE_LABEL).withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityNode").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).withVertex("entityNode", v -> v.withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity")).withVertex("entity", v -> v.withLabel("entity")).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("collection")).next();
Vertex entityVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("entity")).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper, mock(CollectionDescription.class), mock(PropertyHelper.class));
instance.remove(entityVertex);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_ENTITY_NODE_RELATION_NAME).out(HAS_ENTITY_RELATION_NAME).hasId(entityVertex.id()).hasNext(), is(false));
}
Aggregations