use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method finishEntitiesDuplicatesTheVertices.
@Test
public void finishEntitiesDuplicatesTheVertices() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
vre = instance.loadVres().getVre("vre");
Vertex orig = instance.assertEntity(vre, "http://example.org/entity1");
instance.finishEntities(vre, new EntityFinisherHelper());
assertThat(orig.edges(Direction.OUT, VERSION_OF).hasNext(), is(true));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retractPropertyRemovesTheProperty.
@Test
public void retractPropertyRemovesTheProperty() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = minimalCorrectVre(instance, "vre");
instance.assertEntity(vre, "http://example.org/1");
long minimalPropertyCount = graphManager.getGraph().traversal().V().has(RDF_URI_PROP, "http://example.org/1").properties().count().next();
instance.assertProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
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").properties().count().next() - minimalPropertyCount;
assertThat(entitiesWithPropName, is(0L));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertPropertyAddsThePropertyOnTheEntity.
@Test
public void assertPropertyAddsThePropertyOnTheEntity() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
String vreName = "vre";
Vre vre = minimalCorrectVre(instance, vreName);
instance.assertProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
List<Object> values = graphManager.getGraph().traversal().V().values(defaultEntityTypeName(vre) + "_" + "http://example.org/propName").toList();
assertThat(values, contains("value"));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre 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.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertEntitySetsTheRdfUriProperty.
@Test
public void assertEntitySetsTheRdfUriProperty() {
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().values(RDF_SYNONYM_PROP).next(), is(new String[] { "http://example.org/1" }));
}
Aggregations