use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertPropertyWillKeepTrackOfThePredicate.
@Test
public void assertPropertyWillKeepTrackOfThePredicate() {
TinkerPopOperations instance = TinkerPopOperationsStubs.newInstance();
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
instance.addPredicateValueTypeVertexToVre(vre);
vre = instance.loadVres().getVre("vre");
Collection defaultCollection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
instance.assertProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
instance.assertProperty(vre, "http://example.org/2", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/2001/XMLSchema#float"));
List<PredicateInUse> predicates = instance.getPredicatesFor(defaultCollection);
assertThat(predicates, contains(hasProperty("predicateUri", equalTo("http://example.org/propName"))));
List<ValueTypeInUse> valueTypes = predicates.get(0).getValueTypes();
assertThat(valueTypes, containsInAnyOrder(allOf(hasProperty("typeUri", equalTo("http://www.w3.org/2001/XMLSchema#float")), hasProperty("entitiesConnected", contains("http://example.org/2"))), allOf(hasProperty("typeUri", equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")), hasProperty("entitiesConnected", contains("http://example.org/1")))));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getCollectionReturnsAllTheLatestEntitiesOfACollection.
@Test
public void getCollectionReturnsAllTheLatestEntitiesOfACollection() {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id1 = UUID.randomUUID();
UUID id2 = UUID.randomUUID();
UUID id3 = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withLabel("testthing").withType("thing").withVre("test").isLatest(true).withTimId(id1.toString())).withVertex(v -> v.withLabel("testthing").withType("thing").withVre("test").isLatest(true).withTimId(id2.toString())).withVertex(v -> v.withLabel("testthing").withType("thing").withVre("test").isLatest(false).withTimId(id2.toString())).withVertex(v -> v.withLabel("testthing").withType("thing").withVre("test").isLatest(true).withTimId(id3.toString())).withVertex(v -> v.withLabel("teststuff").withType("stuff").withVre("test").isLatest(true).withTimId(UUID.randomUUID().toString())).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
DataStream<ReadEntity> entities = instance.getCollection(collection, 0, 3, false, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
List<UUID> ids = entities.map(ReadEntity::getId);
assertThat(ids, hasSize(3));
assertThat(ids, containsInAnyOrder(id1, id2, id3));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityThrowsNotFoundIfTheEntityDoesNotContainTheRequestType.
@Test(expected = NotFoundException.class)
public void getEntityThrowsNotFoundIfTheEntityDoesNotContainTheRequestType() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id.toString()).withType("thing").withVre("other").withProperty("isLatest", true).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method deleteVreRemovesAllTheVresCollectionsFromDatabase.
@Test
public void deleteVreRemovesAllTheVresCollectionsFromDatabase() {
TinkerPopGraphManager graphManager = newGraph().withVertex("vreName", v -> v.withLabel("VRE").withProperty(Vre.VRE_NAME_PROPERTY_NAME, "vreName").withOutgoingRelation(HAS_COLLECTION_RELATION_NAME, "collection1").withOutgoingRelation(HAS_COLLECTION_RELATION_NAME, "collection2")).withVertex("collection1", v -> v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "collection1").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "entityType1").withProperty(IS_RELATION_COLLECTION_PROPERTY_NAME, true).withOutgoingRelation(HAS_DISPLAY_NAME_RELATION_NAME, "displayName").withOutgoingRelation(HAS_PROPERTY_RELATION_NAME, "property").withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityNode")).withVertex("displayName", v -> v.withProperty("displayName", true).withProperty("propertyType", "string")).withVertex("property", v -> v.withProperty("property", true).withProperty("propertyType", "string")).withVertex("entityNode", v -> v.withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity")).withVertex("entity", v -> v.withProperty("entity", true)).withVertex("collection2", v -> v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "collection2").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "entityType2").withProperty(IS_RELATION_COLLECTION_PROPERTY_NAME, false)).withVertex("otherVreCollection", v -> v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "otherVreCollection").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "entityType3").withProperty(IS_RELATION_COLLECTION_PROPERTY_NAME, false)).wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
instance.deleteVre("vreName");
Graph graph = graphManager.getGraph();
assertThat(graph.traversal().V().has(Vre.VRE_NAME_PROPERTY_NAME, "vreName").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has(COLLECTION_NAME_PROPERTY_NAME, "collection1").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has(COLLECTION_NAME_PROPERTY_NAME, "collection2").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has(COLLECTION_NAME_PROPERTY_NAME, "otherVreCollection").hasNext(), equalTo(true));
assertThat(graph.traversal().V().has("entity").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has("displayName").hasNext(), equalTo(false));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveCreatesARelationToAnEntityHolderVertex.
@Test
public void saveCreatesARelationToAnEntityHolderVertex() {
final Vre vre = new Vre(vreName);
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(), likeVertex().withLabel(Collection.COLLECTION_ENTITIES_LABEL));
}
Aggregations