use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class InstanceCreationTest method basicReference.
@Test
public void basicReference() {
final Author author = new Author("Jane Austen");
getDs().save(author);
final Author loaded = getDs().find(Author.class).iterator(new FindOptions().limit(1)).tryNext();
assertEquals(author, loaded);
}
use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class TestGeoQueries method testWithinRadius2.
@Test
public void testWithinRadius2() {
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.5, 0.5)), 0.77)).iterator(new FindOptions().limit(1)).next();
Assert.assertNotNull(found);
}
use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class TestGeoQueries method testGeoWithinPolygon2.
@Test
public void testGeoWithinPolygon2() {
final Place place1 = new Place("place1", new double[] { 10, 1 });
getDs().save(place1);
final Place found = getDs().find(Place.class).filter(polygon("loc", new Point(new Position(0, 0)), new Point(new Position(0, 5)), new Point(new Position(2, 3)), new Point(new Position(2, 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 testNear.
@Test
public void testNear() {
final Place place1 = new Place("place1", new double[] { 1, 1 });
getDs().save(place1);
final Place found = getDs().find(Place.class).filter(near("loc", new Point(new Position(0, 0)))).iterator(new FindOptions().limit(1)).next();
Assert.assertNotNull(found);
}
use of dev.morphia.query.FindOptions in project morphia by mongodb.
the class TestGeoQueries method testNearMaxDistance.
@Test
public void testNearMaxDistance() {
final Place place1 = new Place("place1", new double[] { 1, 1 });
getDs().save(place1);
FindOptions options = new FindOptions().logQuery().limit(1);
Query<Place> query = getDs().find(Place.class).filter(near("loc", new Point(new Position(1, 1))).maxDistance(2.0));
Assert.assertNotNull(query.iterator(options).tryNext(), query.getLoggedQuery());
query = getDs().find(Place.class).filter(near("loc", new Point(new Position(0, 0))).maxDistance(1.0));
Assert.assertNull(query.first(options), query.getLoggedQuery());
}
Aggregations