use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class TestGeoQueries method testGeoWithinBox.
@Test
public void testGeoWithinBox() {
final Place place1 = new Place("place1", new double[] { 1, 1 });
getDs().save(place1);
final Place found = getDs().find(Place.class).filter(box("loc", new Point(new Position(0, 0)), new Point(new Position(2, 2)))).iterator(new FindOptions().limit(1)).next();
Assert.assertNotNull(found);
}
use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class TestGeoQueries method testGeoWithinRadius.
@Test
public void testGeoWithinRadius() {
final Place place1 = new Place("place1", new double[] { 1, 1 });
getDs().save(place1);
final Place found = getDs().find(Place.class).filter(center("loc", new Point(new Position(0, 1)), 1.1)).iterator(new FindOptions().limit(1)).next();
Assert.assertNotNull(found);
}
use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class TestMapperOptions method shouldNotFindField.
private void shouldNotFindField(Datastore datastore, HasList hl) {
datastore.save(hl);
Document document = getDocumentCollection(HasList.class).find().first();
assertFalse(document.containsKey("names"), "field should not exist, value = " + document.get("names"));
HasList hasList = datastore.find(HasList.class).iterator(new FindOptions().limit(1)).tryNext();
assertNull(hasList.names);
cleanup();
}
use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class TestGeoQueries method testNearNoIndex.
@Test(expectedExceptions = MongoQueryException.class)
public void testNearNoIndex() {
getDs().getCollection(Place.class).drop();
final Place place1 = new Place("place1", new double[] { 1, 1 });
getDs().save(place1);
Place found = getDs().find(Place.class).filter(near("loc", new Point(new Position(0, 0)))).iterator(new FindOptions().limit(1)).tryNext();
Assert.assertNull(found);
}
use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class TestGeoQueries method testGeoWithinRadiusSphere.
@Test
public void testGeoWithinRadiusSphere() {
final Place place1 = new Place("place1", new double[] { 1, 1 });
getDs().save(place1);
final Place found = getDs().find(Place.class).filter(centerSphere("loc", new Point(new Position(0, 1)), 1)).iterator(new FindOptions().limit(1)).next();
Assert.assertNotNull(found);
}
Aggregations