use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_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));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME in project timbuctoo by HuygensING.
the class DatabaseTest method findOrCreateCollectionReturnsTheNewlyAddedCollectionWithRdfUri.
@Test
public void findOrCreateCollectionReturnsTheNewlyAddedCollectionWithRdfUri() {
String vreName = "vreName";
String rdfUri = "http://www.example.com/entity";
String localName = "entity";
TinkerPopGraphManager graphWrapper = newGraph().withVertex(v -> v.withLabel(Vre.DATABASE_LABEL).withProperty("name", vreName)).withVertex(v -> {
v.withLabel(Vre.DATABASE_LABEL);
v.withProperty(Vre.VRE_NAME_PROPERTY_NAME, "Admin");
v.withOutgoingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "defaultArchetype");
}).withVertex("defaultArchetype", v -> {
v.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept");
v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts");
}).wrap();
Node collectionNode = mock(Node.class);
when(collectionNode.getLocalName()).thenReturn(localName);
when(collectionNode.getURI()).thenReturn(rdfUri);
Database instance = new Database(graphWrapper);
Collection collection = instance.findOrCreateCollection(vreName, collectionNode.getURI(), collectionNode.getLocalName());
assertThat(collection, hasProperty("vreName", equalTo(vreName)));
assertThat(graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(Vre.DATABASE_LABEL)).out(Vre.HAS_COLLECTION_RELATION_NAME).has(RDF_URI_PROP, rdfUri).hasNext(), is(true));
assertThat(graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(Vre.DATABASE_LABEL)).out(Vre.HAS_COLLECTION_RELATION_NAME).has(RDF_URI_PROP, rdfUri).out(HAS_ENTITY_NODE_RELATION_NAME).hasNext(), is(true));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME in project timbuctoo by HuygensING.
the class DatabaseTest method findOrCreateEntityAddsANewlyCreatedEntityToTheDefaultCollection.
@Test
public void findOrCreateEntityAddsANewlyCreatedEntityToTheDefaultCollection() {
TinkerPopGraphManager graphWrapper = newGraph().withVertex(v -> v.withLabel(Vre.DATABASE_LABEL).withProperty("name", VRE_NAME)).withVertex(v -> {
v.withLabel(Vre.DATABASE_LABEL);
v.withProperty(Vre.VRE_NAME_PROPERTY_NAME, "Admin");
v.withOutgoingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "defaultArchetype");
}).withVertex("defaultArchetype", v -> {
v.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept");
v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts");
v.withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityCollection");
}).withVertex("entityCollection", v -> {
}).wrap();
final Database instance = new Database(graphWrapper, modifier);
Entity entity = instance.findOrCreateEntity(VRE_NAME, entityNode);
assertThat(entity, is(notNullValue()));
assertThat(graphWrapper.getGraph().traversal().V(entity.vertex.id()).in(HAS_ENTITY_RELATION_NAME).in(HAS_ENTITY_NODE_RELATION_NAME).has(ENTITY_TYPE_NAME_PROPERTY_NAME, DEFAULT_COLLECTION).hasNext(), is(true));
assertThat(graphWrapper.getGraph().traversal().V(entity.vertex.id()).next(), is(likeVertex().withLabel(DEFAULT_COLLECTION).withType(DEFAULT_COLLECTION)));
}
Aggregations