use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager 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.server.TinkerPopGraphManager 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"));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager 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.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntityMarksOneVertexAsLatest.
@Test
public void createEntityMarksOneVertexAsLatest() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).has("isLatest", true).count().next(), is(1L));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager 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"));
}
Aggregations