use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityThrowsNotFoundIfTheEntityIsDeleted.
@Test(expected = NotFoundException.class)
public void getEntityThrowsNotFoundIfTheEntityIsDeleted() 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("deleted", 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.core.dto.ReadEntity 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));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity 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")))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityOnlyReturnsTheLatestRelations.
@Test
public void getEntityOnlyReturnsTheLatestRelations() 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).withRev(2)).withOutgoingRelation("isRelatedTo", "relatedThing", rel -> rel.withIsLatest(false).withRev(1)).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(allOf(hasProperty("entityId", equalTo(relatedId.toString())), hasProperty("relationType", equalTo("isRelatedTo")), hasProperty("relationRev", equalTo(2)))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity 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"));
}
Aggregations