use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class PathTargetTest method simpleResolution.
@Test
public void simpleResolution() {
getMorphia().map(ParentType.class, EmbeddedType.class);
Mapper mapper = getMorphia().getMapper();
MappedClass mappedClass = mapper.getMappedClass(ParentType.class);
PathTarget pathTarget = new PathTarget(mapper, mappedClass, "name");
Assert.assertEquals("n", pathTarget.translatedPath());
Assert.assertEquals(mappedClass.getMappedFieldByJavaField("name"), pathTarget.getTarget());
pathTarget = new PathTarget(mapper, mappedClass, "n");
Assert.assertEquals("n", pathTarget.translatedPath());
Assert.assertEquals(mappedClass.getMappedField("n"), pathTarget.getTarget());
}
use of org.mongodb.morphia.mapping.MappedClass 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.MappedClass 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.MappedClass 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));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class QueryValidatorTest method shouldAllowGeoWithinOperatorWithAllAppropriateTrimmings.
@Test
public void shouldAllowGeoWithinOperatorWithAllAppropriateTrimmings() {
// expect
MappedClass mappedClass = new MappedClass(GeoEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("array");
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, List.class, GEO_WITHIN, new BasicDBObject("$box", 1), new ArrayList<ValidationFailure>()), is(true));
}
Aggregations