use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityOnlyReturnsAcceptedRelations.
@Test
public void getEntityOnlyReturnsAcceptedRelations() 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.withIsLatest(true).withAccepted("testrelation", true)).withOutgoingRelation("hasOtherRelation", "relatedThing", rel -> rel.withIsLatest(true).withAccepted("testrelation", false)).withVre("test").withVre("").withType("thing").isLatest(true).withTimId(id.toString())).withVertex("relatedThing", v -> v.withVre("test").withVre("").withType("thing").withTimId(relatedId.toString())).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("isRelatedTo"))));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntitiesWithUnknownTypeDoesNotReturnEntitiesWithACollection.
@Test
public void getEntitiesWithUnknownTypeDoesNotReturnEntitiesWithACollection() {
TinkerPopGraphManager wrap = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(wrap);
final Database legacyRdfDatabase = new Database(wrap);
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
Vre admin = instance.ensureVreExists("Admin");
instance.addCollectionToVre(admin, CreateCollection.defaultCollection("Admin"));
vre = instance.loadVres().getVre("vre");
instance.assertEntity(vre, "http://example.org/entity1");
instance.assertEntity(vre, "http://example.org/entity2");
nl.knaw.huygens.timbuctoo.rdf.Collection collection = legacyRdfDatabase.findOrCreateCollection("vre", NodeFactory.createURI("http://example.org/myCollection").getURI(), NodeFactory.createURI("http://example.org/myCollection").getLocalName());
Optional<Entity> entity = legacyRdfDatabase.findEntity("vre", NodeFactory.createURI("http://example.org/entity1"));
entity.get().addToCollection(collection);
List<String> entitiesWithUnknownType = instance.getEntitiesWithUnknownType(vre);
assertThat(entitiesWithUnknownType, containsInAnyOrder("http://example.org/entity2"));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getCollectionReturnsTheKnowsDisplayNameForEachItem.
@Test
public void getCollectionReturnsTheKnowsDisplayNameForEachItem() {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id1 = UUID.randomUUID();
UUID id2 = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withLabel("testthing").withVre("test").withType("thing").isLatest(true).withTimId(id1.toString()).withProperty("testthing_displayName", // configured in JsonCrudServiceBuilder
"displayName1")).withVertex(v -> v.withLabel("testthing").withVre("test").withType("thing").isLatest(true).withTimId(id2.toString()).withProperty("testthing_displayName", // configured in JsonCrudServiceBuilder
"displayName2")).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
DataStream<ReadEntity> entities = instance.getCollection(collection, 0, 2, true, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
List<String> displayNames = entities.map(ReadEntity::getDisplayName);
assertThat(displayNames, containsInAnyOrder("displayName1", "displayName2"));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retrievePropertyReturnsAnEmtptyOptionWhenTheVertexDoesNotContainTheProperty.
@Test
public void retrievePropertyReturnsAnEmtptyOptionWhenTheVertexDoesNotContainTheProperty() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
String vreName = "vre";
Vre vre = minimalCorrectVre(instance, vreName);
String entityRdfUri = "http://example.org/1";
String predicateUri = "http://example.org/propName";
// make sure the vertex exist
instance.assertEntity(vre, entityRdfUri);
Optional<RdfReadProperty> rdfProperty = instance.retrieveProperty(vre, entityRdfUri, predicateUri);
assertThat(rdfProperty, is(not(present())));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertEntityCreatesANewEntityIfTheEntityDoesNotExist.
@Test
public void assertEntityCreatesANewEntityIfTheEntityDoesNotExist() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = minimalCorrectVre(instance, "vre");
instance.assertEntity(vre, "http://example.org/1");
assertThat(instance.getVertexByRdfUri(vre, "http://example.org/1"), is(present()));
}
Aggregations