use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class CollectionNameHelperTest method collectionNameDoesPostfixesTheNameWithAnS.
@Test
public void collectionNameDoesPostfixesTheNameWithAnS() {
Vre vre = VreStubs.withName(ADMIN_VRE);
String collectionName = CollectionNameHelper.collectionName(UNPREFIXED_ENTITY_NAME, vre);
assertThat(collectionName, endsWith("s"));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityThrowsNotFoundIfTheEntityIsDeleted.
@Test(expected = NotFoundException.class)
public void getEntityThrowsNotFoundIfTheEntityIsDeleted() 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("deleted", true).withProperty("rev", 1)).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method addPropertiesToCollectionsAddsPropertyDescriptionsToTheCollection.
@Test
public void addPropertiesToCollectionsAddsPropertyDescriptionsToTheCollection() {
TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
vre = instance.loadVres().getVre("vre");
Collection collection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
ImmutableCreateProperty prop1 = ImmutableCreateProperty.builder().clientName("clientName1").propertyType("string").rdfUri("http://example.org/pred1").typeUri("http://example.org/string").build();
ImmutableCreateProperty prop2 = ImmutableCreateProperty.builder().clientName("clientName2").propertyType("string").rdfUri("http://example.org/pred2").typeUri("http://example.org/string").build();
instance.addPropertiesToCollection(collection, Lists.newArrayList(prop1, prop2));
collection = instance.loadVres().getCollectionForType(defaultEntityTypeName(vre)).get();
assertThat(collection.getReadableProperties().values(), hasSize(2));
List<Vertex> properties = graphManager.getGraph().traversal().V().hasLabel("property").toList();
assertThat(properties, containsInAnyOrder(likeVertex().withProperty("clientName", "@displayName"), likeVertex().withProperty("clientName", "clientName1").withProperty("dbName", collection.getEntityTypeName() + "_" + "http://example.org/pred1").withProperty("propertyType", "string").withProperty("rdfUri", "http://example.org/pred1").withProperty("typeUri", "http://example.org/string"), likeVertex().withProperty("clientName", "clientName2").withProperty("dbName", collection.getEntityTypeName() + "_" + "http://example.org/pred2").withProperty("propertyType", "string").withProperty("rdfUri", "http://example.org/pred2").withProperty("typeUri", "http://example.org/string")));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method retrievePropertyReturnsAnEmptyOptionalWhenTheEntityDoesNotExist.
@Test
public void retrievePropertyReturnsAnEmptyOptionalWhenTheEntityDoesNotExist() {
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";
Optional<RdfReadProperty> rdfProperty = instance.retrieveProperty(vre, entityRdfUri, predicateUri);
assertThat(rdfProperty, is(not(present())));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntitiesWithUnknownTypeReturnsAllTheEntitiesInTheDefaultCollectionOfTheVre.
@Test
public void getEntitiesWithUnknownTypeReturnsAllTheEntitiesInTheDefaultCollectionOfTheVre() {
TinkerPopOperations instance = TinkerPopOperationsStubs.newInstance();
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
vre = instance.loadVres().getVre("vre");
instance.assertEntity(vre, "http://example.org/entity1");
instance.assertEntity(vre, "http://example.org/entity2");
List<String> entitiesWithUnknownType = instance.getEntitiesWithUnknownType(vre);
assertThat(entitiesWithUnknownType, containsInAnyOrder("http://example.org/entity1", "http://example.org/entity2"));
}
Aggregations