use of org.mongodb.morphia.mapping.Mapper 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.Mapper 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.Mapper 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));
}
use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class SizeOperationValidatorTest method shouldAllowSizeOperatorForListTypesAndIntValues.
@Test
public void shouldAllowSizeOperatorForListTypesAndIntValues() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("listOfIntegers");
List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
// when
boolean validationApplied = SizeOperationValidator.getInstance().apply(mappedField, SIZE, 3, validationFailures);
// then
assertThat(validationApplied, is(true));
assertThat(validationFailures.size(), is(0));
}
use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class SizeOperationValidatorTest method shouldAllowSizeOperatorForArrayTypeAndLongValues.
@Test
public void shouldAllowSizeOperatorForArrayTypeAndLongValues() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("arrayOfInts");
List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
// when
boolean validationApplied = SizeOperationValidator.getInstance().apply(mappedField, SIZE, 3L, validationFailures);
// then
assertThat(validationApplied, is(true));
assertThat(validationFailures.size(), is(0));
}
Aggregations