use of nl.knaw.huygens.timbuctoo.crud.conversion.JsonToEntityMapper 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.crud.conversion.JsonToEntityMapper 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.crud.conversion.JsonToEntityMapper 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")))));
}
use of nl.knaw.huygens.timbuctoo.crud.conversion.JsonToEntityMapper in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newUpdateEntityThrowsAnIoExceptionWhenThePropertyCannotBeConverted.
@Test(expected = IOException.class)
public void newUpdateEntityThrowsAnIoExceptionWhenThePropertyCannotBeConverted() 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), "^rev", jsn(2));
JsonToEntityMapper instance = new JsonToEntityMapper();
instance.newUpdateEntity(collection, UUID.randomUUID(), input);
}
use of nl.knaw.huygens.timbuctoo.crud.conversion.JsonToEntityMapper in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newUpdateEntityThrowsAnIoExceptionWhenItDoesNotContainARevProperty.
@Test
public void newUpdateEntityThrowsAnIoExceptionWhenItDoesNotContainARevProperty() 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"), "^rev", jsn(2));
JsonToEntityMapper instance = new JsonToEntityMapper();
instance.newUpdateEntity(collection, UUID.randomUUID(), input);
}
Aggregations