use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityIgnoresThePropertiesWithAWrongValue.
@Test
public void getEntityIgnoresThePropertiesWithAWrongValue() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id.toString()).withProperty("isLatest", true).withProperty("rev", 1).withType("thing").withVre("test").withProperty("testthing_prop2", // should be a string
42)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getProperties(), emptyIterable());
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityOnlyMapsTheKnownProperties.
@Test
public void getEntityOnlyMapsTheKnownProperties() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id.toString()).withProperty("isLatest", true).withProperty("rev", 1).withType("thing").withVre("test").withProperty("testthing_prop1", "val1").withProperty("testthing_prop2", "val2").withProperty("testthing_unknownProp", "val")).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getProperties(), containsInAnyOrder(allOf(hasProperty("name", equalTo("prop1")), hasProperty("value", equalTo("val1"))), allOf(hasProperty("name", equalTo("prop2")), hasProperty("value", equalTo("val2")))));
assertThat(entity.getProperties(), not(contains(allOf(hasProperty("name", equalTo("unknownProp")), hasProperty("value", equalTo("val"))))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityReturnsTheTypesOfTheEntity.
@Test
public void getEntityReturnsTheTypesOfTheEntity() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id.toString()).withProperty("isLatest", true).withProperty("rev", 1).withProperty("types", "[\"testthing\", \"otherthing\"]")).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getTypes(), containsInAnyOrder("testthing", "otherthing"));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getCollectionReturnsRelationsIfRequested.
@Test
public void getCollectionReturnsRelationsIfRequested() {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID thingId = UUID.randomUUID();
UUID stuffId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex("v1", v -> v.withLabel("testthing").withVre("test").withType("thing").isLatest(true).withTimId(thingId.toString()).withOutgoingRelation("isCreatorOf", "stuff")).withVertex("stuff", v -> v.withVre("test").withType("stuff").withTimId(stuffId.toString())).withVertex(v -> v.withProperty("relationtype_regularName", "isCreatedBy").withProperty("relationtype_inverseName", "isCreatorOf")).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
DataStream<ReadEntity> entities = instance.getCollection(collection, 0, 1, true, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
ReadEntity readEntity = entities.map(entity -> entity).get(0);
assertThat(readEntity.getRelations(), contains(allOf(hasProperty("entityId", equalTo(stuffId.toString())), hasProperty("collectionName", equalTo("teststuffs")), hasProperty("entityType", equalTo("teststuff")), hasProperty("relationType", equalTo("isCreatorOf")))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityUsesTheInverseRelationName.
@Test
public void getEntityUsesTheInverseRelationName() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
UUID stuffId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex("source", v -> v.withIncomingRelation("isCreatedBy", "stuff").withVre("test").withVre("").withType("thing").isLatest(true).withTimId(id.toString())).withVertex("stuff", v -> v.withVre("test").withVre("").withType("stuff").withTimId(stuffId.toString())).withVertex(v -> v.withProperty("relationtype_regularName", "isCreatedBy").withProperty("relationtype_inverseName", "isCreatorOf")).withVertex(v -> v.withProperty("relationtype_regularName", "otherRelationType").withProperty("relationtype_inverseName", "otherInverseType")).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(stuffId.toString())), hasProperty("relationType", equalTo("isCreatorOf")))));
}
Aggregations