use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class QueryValidatorTest method shouldAllowSizeOperatorForListTypesAndIntegerValues.
@Test
public void shouldAllowSizeOperatorForListTypesAndIntegerValues() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("listOfIntegers");
// expect
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, NullClass.class, SIZE, 3, new ArrayList<ValidationFailure>()), is(true));
}
use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class EntityTypeAndIdValueValidatorTest method shouldAllowTypeThatIsAMappedEntityAndAValueWithSameClassAsIdOfMappedEntity.
@Test
public void shouldAllowTypeThatIsAMappedEntityAndAValueWithSameClassAsIdOfMappedEntity() {
// given
ArrayList<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
// when
MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("_id");
boolean validationApplied = EntityTypeAndIdValueValidator.getInstance().apply(mappedClass, mappedField, new ObjectId(), 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 EntityTypeAndIdValueValidatorTest method shouldNotValidateIfEntityHasNoIdField.
@Test
public void shouldNotValidateIfEntityHasNoIdField() {
// given
ArrayList<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
// when
MappedClass mappedClass = new MappedClass(EntityWithNoId.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("_id");
boolean validationApplied = EntityTypeAndIdValueValidator.getInstance().apply(mappedClass, mappedField, "some non-null value", 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 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.Mapper 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));
}
Aggregations