use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class IndexHelperTest method calculateBadKeys.
@Test
public void calculateBadKeys() {
MappedClass mappedClass = getMorphia().getMapper().getMappedClass(IndexedClass.class);
IndexBuilder index = new IndexBuilder().fields(new FieldBuilder().value("texting").type(IndexType.TEXT).weight(1), new FieldBuilder().value("nest").type(IndexType.DESC));
try {
indexHelper.calculateKeys(mappedClass, index);
fail("Validation should have failed on the bad key");
} catch (MappingException e) {
// all good
}
index.options(new IndexOptionsBuilder().disableValidation(true));
indexHelper.calculateKeys(mappedClass, index);
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class QueryValidatorTest method shouldNotAllowOtherValuesForInOperator.
@Test
public void shouldNotAllowOtherValuesForInOperator() {
// expect
MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("name");
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, String.class, IN, "value", new ArrayList<ValidationFailure>()), is(false));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class QueryValidatorTest method shouldNotAllowOtherValuesForAllOperator.
@Test
public void shouldNotAllowOtherValuesForAllOperator() {
// given
MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("name");
// expect
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, SimpleEntity.class, ALL, "value", new ArrayList<ValidationFailure>()), is(false));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class QueryValidatorTest method shouldNotAllowNonIntegerTypeIfValueIsInt.
@Test
public void shouldNotAllowNonIntegerTypeIfValueIsInt() {
// expect
MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
MappedField mappedField = mappedClass.getMappedField("name");
assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, SimpleEntity.class, EQUAL, 1, new ArrayList<ValidationFailure>()), is(false));
}
use of org.mongodb.morphia.mapping.MappedClass in project morphia by mongodb.
the class QueryValidatorTest method shouldNotAllowGeoOperatorIfValueDoesNotContainCorrectField.
@Test
public void shouldNotAllowGeoOperatorIfValueDoesNotContainCorrectField() {
// 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("name", "value"), new ArrayList<ValidationFailure>()), is(false));
}
Aggregations