use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method getDataPropertiesIgnoresPropertiesWithValueEmptyString.
@Test
public void getDataPropertiesIgnoresPropertiesWithValueEmptyString() 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(""));
JsonToEntityMapper instance = new JsonToEntityMapper();
List<TimProperty<?>> properties = instance.getDataProperties(collection, input);
assertThat(properties, not(hasItem(hasProperty("name", equalTo("age")))));
}
use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newUpdateEntityThrowsAnIoExceptionWhenThePropertyIsUnknown.
@Test(expected = IOException.class)
public void newUpdateEntityThrowsAnIoExceptionWhenThePropertyIsUnknown() 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("unknownProperty", jsn("value"), "age", jsn("12"), "^rev", jsn(2));
JsonToEntityMapper instance = new JsonToEntityMapper();
instance.newUpdateEntity(collection, UUID.randomUUID(), input);
}
use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newCreateEntityThrowsAnIoExceptionWhenThePropertyCannotBeConverted.
@Test(expected = IOException.class)
public void newCreateEntityThrowsAnIoExceptionWhenThePropertyCannotBeConverted() 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();
instance.getDataProperties(collection, input);
}
use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newUpdateEntityMapsTheJsonObjectToAnUpdateEntity.
@Test
public void newUpdateEntityMapsTheJsonObjectToAnUpdateEntity() 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();
int rev = 2;
ObjectNode input = JsonBuilder.jsnO("name", jsn("Hans"), "age", jsn("12"), "^rev", jsn(rev));
JsonToEntityMapper instance = new JsonToEntityMapper();
UUID id = UUID.randomUUID();
UpdateEntity updateEntity = instance.newUpdateEntity(collection, id, input);
assertThat(updateEntity.getProperties(), containsInAnyOrder(allOf(hasProperty("name", equalTo("name")), hasProperty("value", equalTo("Hans"))), allOf(hasProperty("name", equalTo("age")), hasProperty("value", equalTo("12")))));
assertThat(updateEntity.getId(), is(id));
assertThat(updateEntity.getRev(), is(rev));
}
use of nl.knaw.huygens.timbuctoo.model.vre.vres.VresBuilder in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newCreateEntityThrowsAnIoExceptionWhenThePropertyIsUnknown.
@Test(expected = IOException.class)
public void newCreateEntityThrowsAnIoExceptionWhenThePropertyIsUnknown() 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("unknownProperty", jsn("value"), "age", jsn("12"));
JsonToEntityMapper instance = new JsonToEntityMapper();
instance.getDataProperties(collection, input);
}
Aggregations