use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class GeoWithinOperationValidatorTest method shouldAllowGeoWithinOperatorWithAllAppropriateTrimmings.
@Test
public void shouldAllowGeoWithinOperatorWithAllAppropriateTrimmings() {
// given
List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
MappedClass mappedClass = new MappedClass(GeoEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("array");
// when
assertThat(GeoWithinOperationValidator.getInstance().apply(mappedField, GEO_WITHIN, new BasicDBObject("$box", 1), validationFailures), is(true));
}
use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class MappedFieldTypeValidatorTest method shouldAllowAListThatDoesNotContainNumbers.
@Test
public void shouldAllowAListThatDoesNotContainNumbers() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("listOfIntegers");
// expect
assertThat(MappedFieldTypeValidator.isIterableOfNumbers(mappedField), is(true));
}
use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class MappedFieldTypeValidatorTest method shouldAllowArraysOfNumbers.
@Test
public void shouldAllowArraysOfNumbers() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("arrayOfInts");
// expect
assertThat(MappedFieldTypeValidator.isArrayOfNumbers(mappedField), is(true));
}
use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class SizeOperationValidatorTest method shouldAllowSizeOperatorForIterableTypesAndIntegerValues.
@Test
public void shouldAllowSizeOperatorForIterableTypesAndIntegerValues() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("setOfIntegers");
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.MappedField in project morphia by mongodb.
the class IgnoreFieldsAnnotationTest method processIgnoreFieldsAnnotations.
//remove any MappedField specified in @IgnoreFields on the class.
private void processIgnoreFieldsAnnotations() {
for (final MappedClass mc : getMorphia().getMapper().getMappedClasses()) {
final IgnoreFields ignores = (IgnoreFields) mc.getAnnotation(IgnoreFields.class);
if (ignores != null) {
for (final String field : ignores.value().split(",")) {
final MappedField mf = mc.getMappedFieldByJavaField(field);
mc.getPersistenceFields().remove(mf);
}
}
}
}
Aggregations