use of nl.knaw.huygens.timbuctoo.database.tinkerpop.VertexDuplicator.VERSION_OF in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method deleteEntitySetsDeletedToTrueWhenLastTypeIsRemoved.
@Test
public void deleteEntitySetsDeletedToTrueWhenLastTypeIsRemoved() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
String idString = id.toString();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(idString).withProperty("isLatest", true).withVre("test").withType("thing").withProperty("rev", 1).withIncomingRelation("VERSION_OF", "orig")).withVertex("orig", v -> v.withTimId(idString).withVre("test").withType("thing").withProperty("isLatest", false).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
instance.deleteEntity(collection, id, new Change(Instant.now().toEpochMilli(), "userId", null));
assertThat(graphManager.getGraph().traversal().V().has("tim_id", idString).has("deleted", true).hasNext(), is(true));
}
use of nl.knaw.huygens.timbuctoo.database.tinkerpop.VertexDuplicator.VERSION_OF in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method deleteEntitySetsModified.
@Test
public void deleteEntitySetsModified() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
String idString = id.toString();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(idString).withProperty("isLatest", true).withVre("test").withType("thing").withProperty("rev", 1).withIncomingRelation("VERSION_OF", "orig")).withVertex("orig", v -> v.withTimId(idString).withVre("test").withType("thing").withProperty("isLatest", false).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
long timeStamp = Instant.now().toEpochMilli();
String userId = "userId";
instance.deleteEntity(collection, id, new Change(timeStamp, userId, null));
assertThat(graphManager.getGraph().traversal().V().has("tim_id", idString).has("deleted", true).next().value("modified"), sameJSONAs(String.format("{\"timeStamp\": %s,\"userId\": \"%s\"}", timeStamp, userId)));
}
use of nl.knaw.huygens.timbuctoo.database.tinkerpop.VertexDuplicator.VERSION_OF in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method deleteEntityIncreasesTheRevision.
// TODO move increase of the rev to TimbuctooActions
@Test
public void deleteEntityIncreasesTheRevision() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
String idString = id.toString();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(idString).withProperty("isLatest", true).withVre("test").withType("thing").withProperty("rev", 1).withIncomingRelation("VERSION_OF", "orig")).withVertex("orig", v -> v.withTimId(idString).withVre("test").withType("thing").withProperty("isLatest", false).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
int rev = instance.deleteEntity(collection, id, new Change(Instant.now().toEpochMilli(), "userId", null));
assertThat(rev, is(2));
}
use of nl.knaw.huygens.timbuctoo.database.tinkerpop.VertexDuplicator.VERSION_OF 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.database.tinkerpop.VertexDuplicator.VERSION_OF in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityReturnsTheSpecifiedRevision.
@Test
public void getEntityReturnsTheSpecifiedRevision() 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("testthing_prop1", "old").withProperty("rev", 1).withProperty("isLatest", false).withOutgoingRelation("VERSION_OF", "replacement")).withVertex("replacement", v -> v.withTimId(id.toString()).withType("thing").withVre("test").withProperty("testthing_prop1", "new").withProperty("rev", 2).withProperty("isLatest", false).withOutgoingRelation("VERSION_OF", "dangling")).withVertex("dangling", v -> v.withTimId(id.toString()).withType("thing").withVre("test").withProperty("testthing_prop1", "new").withProperty("rev", 2).withProperty("isLatest", true)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, 1, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getRev(), is(1));
assertThat(entity.getProperties(), contains(allOf(hasProperty("name", equalTo("prop1")), hasProperty("value", equalTo("old")))));
}
Aggregations