use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class FulltextIndexChangeListenerTest method onCreateHandlesWwDocumentsUsingCustomLogic.
@Test
public void onCreateHandlesWwDocumentsUsingCustomLogic() {
IndexHandler indexHandler = mock(IndexHandler.class);
GraphWrapper graphWrapper = newGraph().withVertex("doc", v -> v.withProperty("wwdocument_name", "foo").withOutgoingRelation("isCreatedBy", "authorA", r -> r.withAccepted("wwrelation", true).withIsLatest(true)).withOutgoingRelation("isCreatedBy", "authorB", r -> r.withAccepted("wwrelation", true).withIsLatest(true))).withVertex("authorA", v -> v.withProperty("wwperson_name", "authorA")).withVertex("authorB", v -> v.withProperty("wwperson_name", "authorB")).wrap();
FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper);
Collection collection = new VresBuilder().withVre("womenwriters", "ww", vre -> vre.withCollection("wwdocuments", coll -> coll.withDisplayName(localProperty("wwdocument_name"))).withCollection("wwpersons", coll -> coll.withDisplayName(localProperty("wwperson_name")))).build().getCollection("wwdocuments").get();
Vertex vertex = graphWrapper.getGraph().traversal().V().next();
instance.onCreate(collection, vertex);
verify(indexHandler).upsertIntoQuickSearchIndex(collection, "authorA; authorB foo", vertex, null);
}
use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class TinkerPopOperationsForMigrationsTest method itGIvesYouAnInitDb.
@Test
public void itGIvesYouAnInitDb() throws JsonProcessingException {
final TinkerPopGraphManager graphManager = newGraph().wrap();
TinkerPopOperations ops = forInitDb(graphManager);
assertThat(ops.databaseIsEmptyExceptForMigrations(), is(true));
ops.initDb(new VresBuilder().withVre("Admin", "", vre -> vre.withCollection("relations", CollectionBuilder::isRelationCollection)).build(), relationType("concept", "hasFirstPerson", "person", "someRel", false, false, false, UUID.randomUUID()));
assertThat(graphManager.getGraph().traversal().V().count().next(), is(4L));
}
use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newUpdateEntityIgnoresThePrefixedFields.
@Test
public void newUpdateEntityIgnoresThePrefixedFields() throws Exception {
Collection collection = new VresBuilder().withVre("WomenWriters", "ww", vre -> vre.withCollection("wwpersons")).build().getCollection("wwpersons").get();
ObjectNode input = JsonBuilder.jsnO("_id", jsn("id"), "^rev", jsn(1), "@type", jsn("wwperson"));
JsonToEntityMapper instance = new JsonToEntityMapper();
UpdateEntity updateEntity = instance.newUpdateEntity(collection, UUID.randomUUID(), input);
assertThat(updateEntity.getProperties(), not(containsInAnyOrder(hasProperty("name", equalTo("_id")), hasProperty("name", equalTo("^rev")), hasProperty("name", equalTo("@type")))));
}
use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newCreateEntityIgnoresThePrefixedFields.
@Test
public void newCreateEntityIgnoresThePrefixedFields() throws Exception {
Collection collection = new VresBuilder().withVre("WomenWriters", "ww", vre -> vre.withCollection("wwpersons")).build().getCollection("wwpersons").get();
ObjectNode input = JsonBuilder.jsnO("_id", jsn("id"), "^rev", jsn(1), "@type", jsn("wwperson"));
JsonToEntityMapper instance = new JsonToEntityMapper();
List<TimProperty<?>> properties = instance.getDataProperties(collection, input);
assertThat(properties, not(containsInAnyOrder(hasProperty("name", equalTo("_id")), hasProperty("name", equalTo("^rev")), hasProperty("name", equalTo("@type")))));
}
use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newCreateEntityMapsTheJsonObjectToACreateEntity.
@Test
public void newCreateEntityMapsTheJsonObjectToACreateEntity() throws Exception {
Collection collection = new VresBuilder().withVre("WomenWriters", "ww", vre -> vre.withCollection("wwpersons", c -> c.withProperty("name", localProperty("wwname")).withProperty("age", localProperty("wwage")))).build().getCollection("wwpersons").get();
ObjectNode input = JsonBuilder.jsnO("name", jsn("Hans"), "age", jsn("12"));
JsonToEntityMapper instance = new JsonToEntityMapper();
List<TimProperty<?>> properties = instance.getDataProperties(collection, input);
assertThat(properties, containsInAnyOrder(allOf(hasProperty("name", equalTo("name")), hasProperty("value", equalTo("Hans"))), allOf(hasProperty("name", equalTo("age")), hasProperty("value", equalTo("12")))));
}
Aggregations