use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertPropertyWillKeepTrackOfThePredicate.
@Test
public void assertPropertyWillKeepTrackOfThePredicate() {
TinkerPopOperations instance = TinkerPopOperationsStubs.newInstance();
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
instance.addPredicateValueTypeVertexToVre(vre);
vre = instance.loadVres().getVre("vre");
Collection defaultCollection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
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.assertProperty(vre, "http://example.org/2", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/2001/XMLSchema#float"));
List<PredicateInUse> predicates = instance.getPredicatesFor(defaultCollection);
assertThat(predicates, contains(hasProperty("predicateUri", equalTo("http://example.org/propName"))));
List<ValueTypeInUse> valueTypes = predicates.get(0).getValueTypes();
assertThat(valueTypes, containsInAnyOrder(allOf(hasProperty("typeUri", equalTo("http://www.w3.org/2001/XMLSchema#float")), hasProperty("entitiesConnected", contains("http://example.org/2"))), allOf(hasProperty("typeUri", equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")), hasProperty("entitiesConnected", contains("http://example.org/1")))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty 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.core.dto.rdf.RdfProperty 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.core.dto.rdf.RdfProperty in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retractPropertyRemovesTheValueTypeFromThePredicateIfItDoesNotApplyToAnyEntity.
@Test
public void retractPropertyRemovesTheValueTypeFromThePredicateIfItDoesNotApplyToAnyEntity() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = minimalCorrectVre(instance, "vre");
Collection defaultCollection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
RdfProperty stringProperty = new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");
RdfProperty floatProperty = new RdfProperty("http://example.org/propName", "1.5", "http://www.w3.org/2001/XMLSchema#float");
instance.assertProperty(vre, "http://example.org/1", stringProperty);
instance.assertProperty(vre, "http://example.org/2", floatProperty);
instance.assertProperty(vre, "http://example.org/3", floatProperty);
instance.retractProperty(vre, "http://example.org/1", stringProperty);
instance.retractProperty(vre, "http://example.org/2", floatProperty);
List<PredicateInUse> predicates = instance.getPredicatesFor(defaultCollection);
assertThat(predicates, hasSize(1));
assertThat(predicates.get(0).getValueTypes(), contains(hasProperty("typeUri", equalTo("http://www.w3.org/2001/XMLSchema#float"))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.rdf.RdfProperty in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertPropertyOverwritesThePropertyOnTheEntity.
@Test
public void assertPropertyOverwritesThePropertyOnTheEntity() {
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"));
instance.assertProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "somethingCompletelyDifferent", "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("somethingCompletelyDifferent"));
}
Aggregations