use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class DatabaseTest method findEntitiesByCollectionReturnsAllTheEntitiesOfTheCollection.
@Test
public void findEntitiesByCollectionReturnsAllTheEntitiesOfTheCollection() {
CollectionDescription desc = CollectionDescription.createCollectionDescription("collection", VRE_NAME);
TinkerPopGraphManager graphWrapper = newGraph().withVertex("collection", v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, desc.getEntityTypeName()).withProperty(COLLECTION_NAME_PROPERTY_NAME, desc.getCollectionName()).withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityVertex")).withVertex("entityVertex", v -> v.withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity1").withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity2")).withVertex("entity1", v -> {
}).withVertex("entity2", v -> {
}).withVertex("entityOfOtherCollection", v -> {
}).wrap();
Database instance = new Database(graphWrapper);
Collection collection = mock(Collection.class);
when(collection.getDescription()).thenReturn(desc);
Set<Entity> entitiesByCollection = instance.findEntitiesByCollection(collection);
assertThat(entitiesByCollection, hasSize(2));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class PropertyHelperTest method movePropertiesMovesThePropertiesToTheNewCollection.
@Test
public void movePropertiesMovesThePropertiesToTheNewCollection() {
String vreName = "vreName";
TinkerPopGraphManager graphManager = newGraph().wrap();
Vertex oldColVertex = graphManager.getGraph().addVertex(ENTITY_TYPE_NAME_PROPERTY_NAME, "oldCollection");
Collection oldCollection = new Collection(vreName, oldColVertex, graphManager);
Vertex newColVertex = graphManager.getGraph().addVertex(ENTITY_TYPE_NAME_PROPERTY_NAME, "newCollection");
Collection newCollection = new Collection(vreName, newColVertex, graphManager);
Vertex vertex = graphManager.getGraph().addVertex("vreNameoldCollection_prop", "value1", "vreNameoldCollection2_prop", "value1");
Entity entity = new Entity(vertex, Sets.newHashSet(oldCollection, newCollection));
new PropertyHelper().movePropertiesToNewCollection(entity, oldCollection, newCollection);
assertThat(vertex.value("vreNameoldCollection2_prop"), is("value1"));
assertThat(vertex.value("vreNamenewCollection_prop"), is("value1"));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class RdfImporterTest method importRdfReloadsTheDatabaseConfigurationAfterImport.
@Test
public void importRdfReloadsTheDatabaseConfigurationAfterImport() {
TinkerPopGraphManager graphWrapper = newGraph().wrap();
TripleImporter tripleImporter = mock(TripleImporter.class);
final Vres vres = mock(DatabaseConfiguredVres.class);
RdfImporter instance = new RdfImporter(graphWrapper, VRE_NAME, vres, tripleImporter);
instance.importRdf(getTripleStream(EXAMPLE_TRIPLE_STRING), "application/n-quads");
InOrder inOrder = inOrder(tripleImporter, vres);
inOrder.verify(tripleImporter).importTriple(eq(true), any(Triple.class));
inOrder.verify(vres).reload();
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class WomenWritersJsonCrudServiceTest method getReturnsAJsonNodeWithARelationsPropertyWithTheGenderOfTheAuthors.
@Test
public void getReturnsAJsonNodeWithARelationsPropertyWithTheGenderOfTheAuthors() throws InvalidCollectionException, NotFoundException {
UUID workId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex("work1", v -> {
v.withOutgoingRelation("isCreatedBy", "pers1").withOutgoingRelation("isCreatedBy", "pers2").withVre("ww").withVre("").withType("document").isLatest(true).withTimId(workId.toString());
}).withVertex("pers1", v -> v.withVre("ww").withVre("").withType("person").withProperty("displayName", "author1").withProperty("wwperson_gender", "FEMALE").isLatest(true).withTimId(UUID.randomUUID().toString())).withVertex("pers2", v -> v.withVre("ww").withVre("").withType("person").withProperty("displayName", "author2").withProperty("wwperson_gender", "FEMALE").isLatest(true).withTimId(UUID.randomUUID().toString())).withVertex("relationType", v -> v.withType("relationType").withVre("").withProperty("relationtype_regularName", "isCreatedBy").withProperty("relationtype_inverseName", "isCreatorOf")).wrap();
WomenWritersJsonCrudService instance = createInstance(graphManager);
JsonNode result = instance.get("wwdocuments", workId);
assertThat(result.toString(), sameJSONAs(jsnO("@relations", jsnO("isCreatedBy", jsnA(jsnO("displayName", jsn("author1"), "gender", jsn("FEMALE")), jsnO("displayName", jsn("author2"), "gender", jsn("FEMALE"))))).toString()).allowingAnyArrayOrdering().allowingExtraUnexpectedFields());
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class WomenWritersJsonCrudServiceTest method getReturnsTheLanguagesOfTheDocumentsWrittenByAPerson.
@Test
public void getReturnsTheLanguagesOfTheDocumentsWrittenByAPerson() throws InvalidCollectionException, NotFoundException {
UUID pers1Id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex("work1", v -> v.withOutgoingRelation("isCreatedBy", "pers1", r -> r.withIsLatest(true).withAccepted("wwrelation", true)).withOutgoingRelation("hasWorkLanguage", "lang1", r -> r.withIsLatest(true).withAccepted("wwrelation", true)).withVre("ww").withVre("").withType("document").isLatest(true).withTimId(UUID.randomUUID().toString())).withVertex("work2", v -> v.withOutgoingRelation("isCreatedBy", "pers1", r -> r.withIsLatest(true).withAccepted("wwrelation", true)).withOutgoingRelation("hasWorkLanguage", "lang2", r -> r.withIsLatest(true).withAccepted("wwrelation", true)).withVre("ww").withVre("").withType("document").isLatest(true).withTimId(UUID.randomUUID().toString())).withVertex("pers1", v -> v.withVre("ww").withVre("").withType("person").withProperty("displayName", "author1").withProperty("wwperson_gender", "FEMALE").isLatest(true).withTimId(pers1Id.toString())).withVertex("lang1", v -> v.withVre("ww").withVre("").withType("language").withProperty("wwlanguage_name", "French").isLatest(true).withTimId(UUID.randomUUID().toString())).withVertex("lang2", v -> v.withVre("ww").withVre("").withType("language").withProperty("wwlanguage_name", "Dutch").isLatest(true).withTimId(UUID.randomUUID().toString())).withVertex("relationType1", v -> v.withType("relationType").withVre("").withProperty("relationtype_regularName", "isCreatedBy").withProperty("relationtype_inverseName", "isCreatorOf")).withVertex("relationType2", v -> v.withType("relationType").withVre("").withProperty("relationtype_regularName", "hasWorkLanguage").withProperty("relationtype_inverseName", "isWorkLanguageOf")).wrap();
WomenWritersJsonCrudService instance = createInstance(graphManager);
JsonNode result = instance.get("wwpersons", pers1Id);
assertThat(result.toString(), sameJSONAs(jsnO("@authorLanguages", jsnA(jsn("French"), jsn("Dutch"))).toString()).allowingAnyArrayOrdering().allowingExtraUnexpectedFields());
}
Aggregations