use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retrievePropertyReturnsThePropertyOfTheEntity.
@Test
public void retrievePropertyReturnsThePropertyOfTheEntity() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
String vreName = "vre";
Vre vre = minimalCorrectVre(instance, vreName);
String entityRdfUri = "http://example.org/1";
String predicateUri = "http://example.org/propName";
String value = "value";
instance.assertProperty(vre, entityRdfUri, new RdfProperty(predicateUri, value, "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
Optional<RdfReadProperty> rdfProperty = instance.retrieveProperty(vre, entityRdfUri, predicateUri);
assertThat(rdfProperty, is(present()));
assertThat(rdfProperty.get().getValue(), is(value));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertEntityAddsCreatedEntitiesToTheDefaultCollection.
@Test
public void assertEntityAddsCreatedEntitiesToTheDefaultCollection() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = minimalCorrectVre(instance, "vre");
instance.assertEntity(vre, "http://example.org/1");
assertThat(graphManager.getGraph().traversal().V().has(ENTITY_TYPE_NAME_PROPERTY_NAME, defaultEntityTypeName(vre)).out(HAS_ENTITY_NODE_RELATION_NAME).out(HAS_ENTITY_RELATION_NAME).count().next(), is(1L));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre 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.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method addCollectionToVreDoesNotAddTheCollectionWhenTheVreAlreadyHasACollectionWithTheSameName.
@Test
public void addCollectionToVreDoesNotAddTheCollectionWhenTheVreAlreadyHasACollectionWithTheSameName() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = instance.ensureVreExists("vre");
CreateCollection collection = CreateCollection.forEntityTypeName("entityTypeName");
instance.addCollectionToVre(vre, collection);
instance.addCollectionToVre(vre, collection);
assertThat(graphManager.getGraph().traversal().V().hasLabel(Collection.DATABASE_LABEL).has(ENTITY_TYPE_NAME_PROPERTY_NAME, collection.getEntityTypeName(vre)).count().next(), is(1L));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retractPropertyWillBeANoopIfTheEntityDoesNotYetExist.
@Test
public void retractPropertyWillBeANoopIfTheEntityDoesNotYetExist() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = instance.ensureVreExists("vre");
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").count().next();
assertThat(entitiesWithPropName, is(0L));
}
Aggregations