use of dev.morphia.query.ValidationException in project morphia by mongodb.
the class TestQuery method testMixedProjection.
@Test
public void testMixedProjection() {
getDs().save(new ContainsRenamedFields("Frank", "Zappa"));
try {
getDs().find(ContainsRenamedFields.class).iterator(new FindOptions().projection().include("first_name").projection().exclude("last_name"));
fail("An exception should have been thrown indication a mixed projection");
} catch (ValidationException e) {
// all good
}
try {
getDs().find(ContainsRenamedFields.class).iterator(new FindOptions().projection().include("first_name", "last_name").projection().exclude("_id"));
} catch (ValidationException e) {
fail("An exception should not have been thrown indication a mixed projection because _id suppression is a special case");
}
try {
getDs().find(ContainsRenamedFields.class).iterator(new FindOptions().projection().exclude("first_name", "last_name").projection().include("_id"));
fail("An exception should have been thrown indication a mixed projection");
} catch (ValidationException e) {
// all good
}
try {
getDs().find(IntVector.class).iterator(new FindOptions().projection().exclude("name").projection().project("scalars", new ArraySlice(5)));
fail("An exception should have been thrown indication a mixed projection");
} catch (ValidationException e) {
// all good
}
}
Aggregations