use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class GeoWithinOperationValidatorTest method shouldRejectGeoWithinOperatorWhenMappedFieldIsArrayThatDoesNotContainNumbers.
@Test
public void shouldRejectGeoWithinOperatorWhenMappedFieldIsArrayThatDoesNotContainNumbers() {
// given
List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
MappedClass mappedClass = new MappedClass(InvalidGeoEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("arrayOfStrings");
// when
boolean validationApplied = GeoWithinOperationValidator.getInstance().apply(mappedField, GEO_WITHIN, new BasicDBObject("$box", 1), validationFailures);
// then
assertThat(validationApplied, is(true));
assertThat(validationFailures.size(), is(1));
assertThat(validationFailures.get(0).toString(), containsString("is an array or iterable it should have numeric values"));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class GeoWithinOperationValidatorTest method shouldRejectGeoWithinOperatorWhenMappedFieldIsListThatDoesNotContainNumbers.
@Test
public void shouldRejectGeoWithinOperatorWhenMappedFieldIsListThatDoesNotContainNumbers() {
// given
List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
MappedClass mappedClass = new MappedClass(InvalidGeoEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("listOfStrings");
// when
boolean validationApplied = GeoWithinOperationValidator.getInstance().apply(mappedField, GEO_WITHIN, new BasicDBObject("$box", 1), validationFailures);
// then
assertThat(validationApplied, is(true));
assertThat(validationFailures.size(), is(1));
assertThat(validationFailures.get(0).toString(), containsString("is an array or iterable it should have numeric values"));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class MappedFieldTypeValidatorTest method shouldRejectAListThatDoesNotContainNumbers.
@Test
public void shouldRejectAListThatDoesNotContainNumbers() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("listOfStrings");
// expect
assertThat(MappedFieldTypeValidator.isIterableOfNumbers(mappedField), is(false));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class MappedFieldTypeValidatorTest method shouldRejectArraysOfStrings.
@Test
public void shouldRejectArraysOfStrings() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("arrayOfStrings");
// expect
assertThat(MappedFieldTypeValidator.isArrayOfNumbers(mappedField), is(false));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class SizeOperationValidatorTest method shouldNotApplyValidationToOperatorThatIsNotSize.
@Test
public void shouldNotApplyValidationToOperatorThatIsNotSize() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("list");
List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
// when
boolean validationApplied = SizeOperationValidator.getInstance().apply(mappedField, EQUAL, 1, validationFailures);
// then
assertThat(validationApplied, is(false));
assertThat(validationFailures.size(), is(0));
}
Aggregations