use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityReturnsANullPidWhenTheEntityDoesNotContainOne.
@Test
public void getEntityReturnsANullPidWhenTheEntityDoesNotContainOne() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id.toString()).withType("thing").withVre("test").withProperty("isLatest", true).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getPid(), is(nullValue()));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityMapsTheId.
@Test
public void getEntityMapsTheId() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withTimId(id.toString()).withType("thing").withVre("test").withProperty("isLatest", true).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getId(), is(id));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertPropertyAlsoAddsAnAdminVersionOfTheProperty.
@Test
public void assertPropertyAlsoAddsAnAdminVersionOfTheProperty() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = minimalCorrectVre(instance, "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"));
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 deleteVreRemovesAllTheVresRawCollectionsFromDatabase.
@Test
public void deleteVreRemovesAllTheVresRawCollectionsFromDatabase() {
TinkerPopGraphManager graphManager = newGraph().withVertex("vreName", v -> v.withLabel("VRE").withProperty(Vre.VRE_NAME_PROPERTY_NAME, "vreName").withOutgoingRelation(RAW_COLLECTION_EDGE_NAME, "rawCollection")).withVertex("rawCollection", v -> v.withProperty(RAW_COLLECTION_NAME_PROPERTY_NAME, "rawCollection").withOutgoingRelation(RAW_ITEM_EDGE_NAME, "rawItem").withOutgoingRelation(RAW_PROPERTY_EDGE_NAME, "rawProperty")).withVertex("rawProperty", v -> v.withProperty("tim_id", "a")).withVertex("rawItem", v -> v.withProperty("tim_id", "b")).withVertex("someThingFromDifferentVre", v -> v.withProperty("other", true)).wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
instance.deleteVre("vreName");
Graph graph = graphManager.getGraph();
assertThat(graph.traversal().V().has(Vre.VRE_NAME_PROPERTY_NAME, "vreName").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has(RAW_COLLECTION_NAME_PROPERTY_NAME, "rawCollection").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has("tim_id").hasNext(), equalTo(false));
assertThat(graph.traversal().V().has("other").hasNext(), equalTo(true));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retractRemovesThePredicateWhenNoValueTypesAreConnected.
@Test
public void retractRemovesThePredicateWhenNoValueTypesAreConnected() {
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");
instance.assertProperty(vre, "http://example.org/1", stringProperty);
instance.retractProperty(vre, "http://example.org/1", stringProperty);
List<PredicateInUse> predicates = instance.getPredicatesFor(defaultCollection);
assertThat(predicates, is(empty()));
}
Aggregations