use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retrievePropertyReturnsAnEmptyOptionalWhenTheEntityDoesNotExist.
@Test
public void retrievePropertyReturnsAnEmptyOptionalWhenTheEntityDoesNotExist() {
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";
Optional<RdfReadProperty> rdfProperty = instance.retrieveProperty(vre, entityRdfUri, predicateUri);
assertThat(rdfProperty, is(not(present())));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method addPidAddsAPidToEachVertexInTheCollectionWithTheIdAndRev.
@Test
public void addPidAddsAPidToEachVertexInTheCollectionWithTheIdAndRev() throws Exception {
Vres vres = createConfiguration();
UUID id = UUID.randomUUID();
int rev = 1;
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id.toString()).withType("relationtype").withProperty("relationtype_regularName", "regularName").withProperty("rev", rev).withProperty("isLatest", true).withIncomingRelation("VERSION_OF", "version")).withVertex("version", v -> v.withTimId(id.toString()).withType("relationtype").withProperty("relationtype_regularName", "regularName").withProperty("rev", rev).withProperty("isLatest", false)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
URI pidUri = new URI("http://example.com/pid");
instance.addPid(id, rev, pidUri);
assertThat(graphManager.getGraph().traversal().V().has("pid", pidUri.toString()).count().next(), is(2L));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getRelationTypesReturnsAllTheRelationTypesInTheDatabase.
@Test
public void getRelationTypesReturnsAllTheRelationTypesInTheDatabase() {
UUID id1 = UUID.randomUUID();
UUID id2 = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id1).withType("relationtype").withProperty("rdfUri", "http://example.com/entity1").withProperty("rev", 2).isLatest(true).withLabel("relationtype")).withVertex(v -> v.withTimId(id2).withType("relationstype").withVre("test").withProperty("rdfUri", "http://example.com/entity1").isLatest(false).withProperty("rev", 1).withLabel("relationtype")).withVertex(v -> v.withTimId(UUID.randomUUID()).withType("othertype").withVre("test").withProperty("rdfUri", "http://example.com/entity1").isLatest(false).withProperty("rev", 1).withLabel("othertype")).wrap();
Vres vres = createConfiguration();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<RelationType> relationTypes = instance.getRelationTypes();
assertThat(relationTypes, hasSize(2));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntitySetsCreatedAndModified.
@Test
public void createEntitySetsCreatedAndModified() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
String userId = "userId";
long timeStamp = Instant.now().toEpochMilli();
CreateEntity createEntity = withProperties(properties, userId, timeStamp);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).next().value("created"), sameJSONAs(String.format("{\"timeStamp\": %s,\"userId\": \"%s\"}", timeStamp, userId)));
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).next().value("modified"), sameJSONAs(String.format("{\"timeStamp\": %s,\"userId\": \"%s\"}", timeStamp, userId)));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityAlwaysReturnsTheDeletedProperty.
@Test
public void getEntityAlwaysReturnsTheDeletedProperty() 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("test").withProperty("isLatest", true).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getDeleted(), is(false));
}
Aggregations