use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class QueryValidatorTest method shouldReferToMappedClassInExceptionWhenQueryingPastSerializedField.
@Test
public void shouldReferToMappedClassInExceptionWhenQueryingPastSerializedField() {
thrown.expect(ValidationException.class);
thrown.expectMessage("Cannot use dot-notation past 'serialized' in " + "'org.mongodb.morphia.query.QueryValidatorTest$WithSerializedField'");
validateQuery(WithSerializedField.class, new Mapper(), new StringBuilder("serialized.name"), FilterOperator.EQUAL, "", true, true);
}
use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class QueryValidatorTest method shouldNotAllowValueWithoutEntityAnnotationAndTypeOfKey.
@Test
public void shouldNotAllowValueWithoutEntityAnnotationAndTypeOfKey() {
// expect
MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("name");
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, Key.class, EQUAL, "value", new ArrayList<ValidationFailure>()), is(false));
}
use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class QueryValidatorTest method shouldAllowValuesOfList.
@Test
public void shouldAllowValuesOfList() {
// expect
MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("name");
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, List.class, EQUAL, new ArrayList<String>(), new ArrayList<ValidationFailure>()), is(true));
}
use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class QueryValidatorTest method shouldReferToMappedClassInExceptionWhenFieldNotFound.
@Test
public void shouldReferToMappedClassInExceptionWhenFieldNotFound() {
thrown.expect(ValidationException.class);
thrown.expectMessage("The field 'notAField' could not be found in 'org.bson.types.ObjectId'");
validateQuery(SimpleEntity.class, new Mapper(), new StringBuilder("id.notAField"), FilterOperator.EQUAL, 1, true, true);
}
use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.
the class QueryValidatorTest method shouldNotAllowSizeOperatorForNonIntegerValues.
@Test
public void shouldNotAllowSizeOperatorForNonIntegerValues() {
// expect
MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("name");
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, ArrayList.class, SIZE, "value", new ArrayList<ValidationFailure>()), is(false));
}
Aggregations