use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityOmitsDeletedRelations.
@Test
public void getEntityOmitsDeletedRelations() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
UUID relatedId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex("source", v -> v.withOutgoingRelation("isRelatedTo", "relatedThing", rel -> rel.withDeleted(true)).withOutgoingRelation("hasOtherRelationWith", "relatedThing").withVre("test").withVre("").withType("thing").isLatest(true).withTimId(id.toString())).withVertex("relatedThing", v -> v.withVre("test").withVre("").withType("thing").withTimId(relatedId.toString()).withProperty("testthing_displayName", "displayName")).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getRelations(), hasSize(1));
assertThat(entity.getRelations(), contains(hasProperty("relationType", equalTo("hasOtherRelationWith"))));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveThrowsWhenTheCollectionNameIsNotUniqueToThisVre.
@Test(expected = IllegalArgumentException.class)
public void saveThrowsWhenTheCollectionNameIsNotUniqueToThisVre() {
Graph graph = newGraph().withVertex(v -> {
v.withLabel(Collection.DATABASE_LABEL).withProperty(COLLECTION_NAME_PROPERTY_NAME, "persons").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "person").withIncomingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "vre");
}).withVertex("vre", v -> {
v.withLabel(Vre.DATABASE_LABEL).withProperty(Vre.VRE_NAME_PROPERTY_NAME, "OtherVreName");
}).build();
save(new Collection("person", "person", null, Maps.newLinkedHashMap(), "persons", new Vre(vreName), null, false, false, null), graph);
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveCreatesAVertexForTheCollection.
@Test
public void saveCreatesAVertexForTheCollection() {
final Vre vre = new Vre(vreName);
timbuctooCollection("persons", "").build(vre);
final Vertex result = save(vre.getCollectionForCollectionName("persons").get(), graph);
assertThat(result, likeVertex().withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "person").withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, "persons").withProperty(Collection.IS_RELATION_COLLECTION_PROPERTY_NAME, false));
// Unprefixed collection is considered an archetype
assertThat(result.vertices(Direction.OUT, Collection.HAS_ARCHETYPE_RELATION_NAME).hasNext(), equalTo(false));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveDoesNotCreateARelationToAnEntityHolderVertexIfItAlreadyExists.
@Test
public void saveDoesNotCreateARelationToAnEntityHolderVertexIfItAlreadyExists() {
final Vre vre = new Vre(vreName);
final Vertex existingVertex = graph.addVertex(DATABASE_LABEL);
final Vertex existingEntityHolderVertex = graph.addVertex(Collection.COLLECTION_ENTITIES_LABEL);
existingVertex.property(Collection.COLLECTION_NAME_PROPERTY_NAME, "persons");
existingVertex.addEdge(Collection.HAS_ENTITY_NODE_RELATION_NAME, existingEntityHolderVertex);
timbuctooCollection("persons", "").build(vre);
final Vertex result = save(vre.getCollectionForCollectionName("persons").get(), graph);
assertThat(result.vertices(Direction.OUT, Collection.HAS_ENTITY_NODE_RELATION_NAME).next(), equalTo(existingEntityHolderVertex));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveDoesNotDropUnRelatedExistingPropertyVertices.
@Test
public void saveDoesNotDropUnRelatedExistingPropertyVertices() {
final Vre vre = new Vre(vreName);
final Vertex existingVertex = graph.addVertex(DATABASE_LABEL);
graph.addVertex(ReadableProperty.DATABASE_LABEL);
existingVertex.property(Collection.COLLECTION_NAME_PROPERTY_NAME, "persons");
timbuctooCollection("persons", "").build(vre);
save(vre.getCollectionForCollectionName("persons").get(), graph);
assertThat(graph.traversal().V().hasLabel(ReadableProperty.DATABASE_LABEL).hasNext(), equalTo(true));
}
Aggregations