use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class WomenWritersJsonCrudServiceTest method getReturnsAJsonNodeWithARelationsPropertyWithAuthorsWithTheirGenderOfEachCreatedWork.
@Test
public void getReturnsAJsonNodeWithARelationsPropertyWithAuthorsWithTheirGenderOfEachCreatedWork() throws Exception {
UUID pers1Id = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex("work1", v -> v.withOutgoingRelation("isCreatedBy", "pers1", 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("isCreatedBy", "pers2", 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("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("wwpersons", pers1Id);
assertThat(result.toString(), sameJSONAs(jsnO("@relations", jsnO("isCreatorOf", jsnA(jsnO("authors", jsnA(jsnO("displayName", jsn("author1"), "gender", jsn("FEMALE")))), jsnO("authors", jsnA(jsnO("displayName", jsn("author1"), "gender", jsn("FEMALE")), jsnO("displayName", jsn("author2"), "gender", jsn("FEMALE"))))))).toString()).allowingExtraUnexpectedFields().allowingAnyArrayOrdering());
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class DatabaseValidatorTest method checkRunsAllTheDatabaseChecksForEachVertex.
@Test
public void checkRunsAllTheDatabaseChecksForEachVertex() {
String id1 = "id1";
String id2 = "id2";
TinkerPopGraphManager graph = makeGraph(id1, id2);
DatabaseCheck databaseCheck1 = mock(DatabaseCheck.class);
DatabaseCheck databaseCheck2 = mock(DatabaseCheck.class);
DatabaseValidator instance = new DatabaseValidator(graph, databaseCheck1, databaseCheck2);
instance.check();
verify(databaseCheck1).check(argThat(likeVertex().withTimId(id1)));
verify(databaseCheck1).check(argThat(likeVertex().withTimId(id2)));
verify(databaseCheck2).check(argThat(likeVertex().withTimId(id1)));
verify(databaseCheck2).check(argThat(likeVertex().withTimId(id2)));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class DatabaseValidatorTest method checkReturnsTheValidationResult.
@Test
public void checkReturnsTheValidationResult() {
TinkerPopGraphManager graph = makeGraph("id1", "id2");
DatabaseValidator instance = new DatabaseValidator(graph);
ValidationResult result = instance.check();
assertThat(result, is(notNullValue()));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class DatabaseValidatorTest method checkReturnsAValidValidationResultWhenAllOfTheChecksSucceed.
@Test
public void checkReturnsAValidValidationResultWhenAllOfTheChecksSucceed() {
TinkerPopGraphManager graph = makeGraph("id", "id2");
DatabaseValidator instance = new DatabaseValidator(graph, validDatabaseCheck());
ValidationResult result = instance.check();
assertThat(result.isValid(), is(true));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class DatabaseValidatorTest method checkCallsInitAndFinish.
@Test
public void checkCallsInitAndFinish() {
TinkerPopGraphManager graph = makeGraph("1");
DatabaseCheck databaseCheck1 = mock(DatabaseCheck.class);
DatabaseCheck databaseCheck2 = mock(DatabaseCheck.class);
DatabaseValidator instance = new DatabaseValidator(graph, databaseCheck1, databaseCheck2);
instance.check();
InOrder inOrder = inOrder(databaseCheck1, databaseCheck2);
inOrder.verify(databaseCheck1).init(any(Graph.class), any(GraphDatabaseService.class));
inOrder.verify(databaseCheck2).init(any(Graph.class), any(GraphDatabaseService.class));
inOrder.verify(databaseCheck1).check(any(Vertex.class));
inOrder.verify(databaseCheck2).check(any(Vertex.class));
inOrder.verify(databaseCheck1).finish();
inOrder.verify(databaseCheck2).finish();
}
Aggregations