use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class VersionTest method testVersionFieldNameContribution.
@Test
public void testVersionFieldNameContribution() throws Exception {
final MappedField mappedFieldByJavaField = getMorphia().getMapper().getMappedClass(ALong.class).getMappedFieldByJavaField("v");
Assert.assertEquals("versionNameContributedByAnnotation", mappedFieldByJavaField.getNameToStore());
}
use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class QueryForSubtypeTest method testIntSizeShouldBeCompatibleWithArrayList.
@Test
public void testIntSizeShouldBeCompatibleWithArrayList() {
MappedField attributes = jobMappedClass.getMappedField("attributes");
boolean compatible = isCompatibleForOperator(jobMappedClass, attributes, ArrayList.class, SIZE, 2, new ArrayList<ValidationFailure>());
assertThat(compatible, is(true));
}
use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class QueryValidatorTest method shouldAllowSizeOperatorForArrayListTypesAndIntegerValues.
@Test
public //this used to fail
void shouldAllowSizeOperatorForArrayListTypesAndIntegerValues() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("arrayListOfIntegers");
// expect
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, NullClass.class, SIZE, 3, new ArrayList<ValidationFailure>()), is(true));
}
use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class QueryValidatorTest method shouldNotAllowSizeOperatorForNonListTypes.
@Test
public void shouldNotAllowSizeOperatorForNonListTypes() {
// given
MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("notAnArrayOrList");
// expect
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, NullClass.class, SIZE, 3, new ArrayList<ValidationFailure>()), is(false));
}
use of org.mongodb.morphia.mapping.MappedField in project morphia by mongodb.
the class QueryValidatorTest method shouldRejectTypesAndValuesThatDoNotMatch.
@Test
public void shouldRejectTypesAndValuesThatDoNotMatch() {
// expect
MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("name");
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, String.class, EQUAL, 1, new ArrayList<ValidationFailure>()), is(false));
}
Aggregations