use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityReturnsANullPidWhenTheEntityDoesNotContainOne.
@Test
public void getEntityReturnsANullPidWhenTheEntityDoesNotContainOne() 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.getPid(), is(nullValue()));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityMapsTheId.
@Test
public void getEntityMapsTheId() 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.getId(), is(id));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityReturnsTheRelations.
@Test
public void getEntityReturnsTheRelations() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
GremlinEntityFetcher entityFetcher = new GremlinEntityFetcher();
UUID id = UUID.randomUUID();
UUID relatedId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex("source", v -> v.withOutgoingRelation("isRelatedTo", "relatedThing").withVre("test").withVre("").withType("thing").isLatest(true).withTimId(id.toString())).withVertex("relatedThing", v -> v.withVre("test").withVre("").withType("thing").withTimId(relatedId.toString()).withProperty("testthing_displayName", "displayName")).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getRelations(), contains(allOf(hasProperty("entityId", equalTo(relatedId.toString())), hasProperty("collectionName", equalTo("testthings")), hasProperty("entityType", equalTo("testthing")), hasProperty("relationType", equalTo("isRelatedTo")), hasProperty("displayName", equalTo("displayName")))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity 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.core.dto.ReadEntity 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"));
}
Aggregations