use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityReturnsThePid.
@Test
public void getEntityReturnsThePid() 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).withProperty("pid", "pidValue")).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getPid(), is("pidValue"));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntitySetsTypesWithTheCollectionAndTheBaseCollection.
@Test
public void createEntitySetsTypesWithTheCollectionAndTheBaseCollection() 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();
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).next().value("types"), allOf(containsString("testthing"), containsString("thing")));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method finishEntitiesDuplicatesTheVertices.
@Test
public void finishEntitiesDuplicatesTheVertices() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
vre = instance.loadVres().getVre("vre");
Vertex orig = instance.assertEntity(vre, "http://example.org/entity1");
instance.finishEntities(vre, new EntityFinisherHelper());
assertThat(orig.edges(Direction.OUT, VERSION_OF).hasNext(), is(true));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retractPropertyRemovesTheProperty.
@Test
public void retractPropertyRemovesTheProperty() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = minimalCorrectVre(instance, "vre");
instance.assertEntity(vre, "http://example.org/1");
long minimalPropertyCount = graphManager.getGraph().traversal().V().has(RDF_URI_PROP, "http://example.org/1").properties().count().next();
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.retractProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "somethingCompletelyDifferent", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
Long entitiesWithPropName = graphManager.getGraph().traversal().V().has(RDF_URI_PROP, "http://example.org/1").properties().count().next() - minimalPropertyCount;
assertThat(entitiesWithPropName, is(0L));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method deletesAllRelationsOfCurrentVre.
@Test
public void deletesAllRelationsOfCurrentVre() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
String idString = id.toString();
final String testOnlyId = "10000000-0000-0000-0000-000000000000";
final String otherOnlyId = "20000000-0000-0000-0000-000000000000";
final String inBothId = "30000000-0000-0000-0000-000000000000";
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(idString).withVre("test").withType("thing").withProperty("isLatest", true).withProperty("rev", 1).withOutgoingRelation("hasWritten", "stuff", rel -> rel.withTim_id(UUID.fromString(testOnlyId)).removeType("other").withAccepted("testrelation", true)).withIncomingRelation("isFriendOf", "friend", rel -> rel.withTim_id(UUID.fromString(inBothId)).withAccepted("testrelation", true).withAccepted("otherrelation", true)).withIncomingRelation("isFriendOf", "friend", rel -> rel.withTim_id(UUID.fromString(otherOnlyId)).removeType("test").withAccepted("otherrelation", true))).withVertex("stuff", v -> v.withVre("test").withType("stuff").withProperty("isLatest", true).withProperty("rev", 1)).withVertex("friend", v -> v.withVre("test").withVre("other").withType("thing").withProperty("isLatest", true).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
instance.deleteEntity(collection, id, new Change(Instant.now().toEpochMilli(), "userId", null));
assertThat(graphManager.getGraph().traversal().E().has("tim_id", testOnlyId).has("isLatest", true).has("testrelation_accepted", false).not(has("otherrelation_accepted")).hasNext(), is(true));
assertThat(graphManager.getGraph().traversal().E().has("tim_id", inBothId).has("isLatest", true).has("testrelation_accepted", false).has("otherrelation_accepted", true).hasNext(), is(true));
assertThat(graphManager.getGraph().traversal().E().has("tim_id", otherOnlyId).has("isLatest", true).not(has("testrelation_accepted")).has("otherrelation_accepted", true).hasNext(), is(true));
}
Aggregations