use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getCollectionReturnsAllTheLatestEntitiesOfACollection.
@Test
public void getCollectionReturnsAllTheLatestEntitiesOfACollection() {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id1 = UUID.randomUUID();
UUID id2 = UUID.randomUUID();
UUID id3 = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> v.withLabel("testthing").withType("thing").withVre("test").isLatest(true).withTimId(id1.toString())).withVertex(v -> v.withLabel("testthing").withType("thing").withVre("test").isLatest(true).withTimId(id2.toString())).withVertex(v -> v.withLabel("testthing").withType("thing").withVre("test").isLatest(false).withTimId(id2.toString())).withVertex(v -> v.withLabel("testthing").withType("thing").withVre("test").isLatest(true).withTimId(id3.toString())).withVertex(v -> v.withLabel("teststuff").withType("stuff").withVre("test").isLatest(true).withTimId(UUID.randomUUID().toString())).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
DataStream<ReadEntity> entities = instance.getCollection(collection, 0, 3, false, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
List<UUID> ids = entities.map(ReadEntity::getId);
assertThat(ids, hasSize(3));
assertThat(ids, containsInAnyOrder(id1, id2, id3));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityThrowsNotFoundIfTheEntityDoesNotContainTheRequestType.
@Test(expected = NotFoundException.class)
public void getEntityThrowsNotFoundIfTheEntityDoesNotContainTheRequestType() 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("other").withProperty("isLatest", 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.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TripleImporterIntegrationTest method importAddsThePropertiesToTheArchetype.
@Test
public void importAddsThePropertiesToTheArchetype() throws Exception {
Triple t1 = createSingleTriple("http://timbuctoo.huygens.knaw.nl/mapping/DUMMY_demo-upload/Persons", "http://www.w3.org/2000/01/rdf-schema#subClassOf", "http://timbuctoo.huygens.knaw.nl/person");
Triple t2 = TripleCreator.createSingleTripleWithLiteralObject("http://timbuctoo.huygens.knaw.nl/mapping/DUMMY_demo-upload/Persons/PE00000001", "http://timbuctoo.huygens.knaw.nl/names", "{\"components\":[{\"type\":\"FORENAME\",\"value\":\"Christiaen\"},{\"type\":\"SURNAME\"," + "\"value\":\"Christiaensen\"}]}", "http://timbuctoo.huygens.knaw.nl/datatypes/person-name");
Triple t3 = createSingleTriple("http://timbuctoo.huygens.knaw.nl/mapping/DUMMY_demo-upload/Persons/PE00000001", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://timbuctoo.huygens.knaw.nl/mapping/DUMMY_demo-upload/Persons");
instance.importTriple(true, t1);
instance.importTriple(true, t2);
instance.importTriple(true, t3);
rdfImportSession.commit();
rdfImportSession.close();
Optional<ReadEntity> readEntity = getReadEntity("vreNamePersonss", "http://timbuctoo.huygens.knaw.nl/mapping/DUMMY_demo-upload/Persons/PE00000001");
assertThat(readEntity, is(present()));
assertThat(readEntity.get().getProperties(), contains(hasProperty("name", equalTo("names"))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TripleImporterIntegrationTest method importTripleShouldTheEntityAndItsPropertiesTheActualCollection.
@Test
public void importTripleShouldTheEntityAndItsPropertiesTheActualCollection() throws Exception {
final Triple abadanHasTypeFeature = createTripleIterator(ABADAN_HAS_TYPE_FEATURE_TRIPLE).next();
final Triple abadanPointTriple = createTripleIterator(ABADAN_POINT_TRIPLE).next();
instance.importTriple(true, abadanHasTypeFeature);
instance.importTriple(true, abadanPointTriple);
rdfImportSession.commit();
rdfImportSession.close();
Optional<ReadEntity> entityOpt = getReadEntity(COLLECTION_NAME, ABADAN_URI);
assertThat(entityOpt.get().getProperties(), contains(allOf(hasProperty("name", equalTo("point")), hasProperty("value", equalTo("30.35 48.28333333333333")))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.ReadEntity in project timbuctoo by HuygensING.
the class TripleImporterIntegrationTest method importTripleShouldSetThePropertiesForTheFirstCollection.
@Test
public void importTripleShouldSetThePropertiesForTheFirstCollection() throws Exception {
final Triple abadanIsAFeature = createTripleIterator(ABADAN_HAS_TYPE_FEATURE_TRIPLE).next();
final Triple abadanIsAFictionalFeature = createTripleIterator(ABADAN_HAS_TYPE_FICTIONAL_FEATURE_TRIPLE).next();
final Triple abadanHasPoint = createTripleIterator(ABADAN_POINT_TRIPLE).next();
instance.importTriple(true, abadanIsAFeature);
instance.importTriple(true, abadanIsAFictionalFeature);
instance.importTriple(true, abadanHasPoint);
rdfImportSession.commit();
rdfImportSession.close();
Optional<ReadEntity> featureEntity = getReadEntity(COLLECTION_NAME, ABADAN_URI);
assertThat(featureEntity.get().getProperties(), hasItem(allOf(hasProperty("name", equalTo("point")), hasProperty("value", equalTo("30.35 48.28333333333333")))));
}
Aggregations