use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class TestMapping method testToMongoObjectCorrectlyMapsSerializableListOfObjectsForIssue591.
@Test
public void testToMongoObjectCorrectlyMapsSerializableListOfObjectsForIssue591() {
// given
Mapper mapper = new Mapper();
ListEntity user = new ListEntity();
user.id = 1;
List<Object> list = new ArrayList<Object>();
list.add("value");
user.list = list;
MappedClass mc = new MappedClass(ListEntity.class, mapper);
MappedField mf = mc.getMappedField("list");
// when
Object dbValue = mapper.toMongoObject(mf, null, user.list);
Class<byte[]> byteArrayClass = byte[].class;
// then
assertThat(dbValue, is(instanceOf(byteArrayClass)));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class QueryValidatorTest method shouldNotAllowGeoWithinWhenValueDoesNotContainKeyword.
@Test
public void shouldNotAllowGeoWithinWhenValueDoesNotContainKeyword() {
// 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("notValidKey", 1), new ArrayList<ValidationFailure>()), is(false));
}
use of org.mongodb.morphia.mapping.MappedClass 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.MappedClass 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.MappedClass 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