use of org.mongodb.morphia.testmodel.Rectangle in project morphia by mongodb.
the class TestQuery method testCompoundSort.
@Test
public void testCompoundSort() {
getDs().save(asList(new Rectangle(1, 10), new Rectangle(3, 8), new Rectangle(6, 10), new Rectangle(10, 10), new Rectangle(10, 1)));
Rectangle r1 = getDs().find(Rectangle.class).order("width,-height").get();
assertNotNull(r1);
assertEquals(1, r1.getWidth(), 0);
assertEquals(10, r1.getHeight(), 0);
r1 = getDs().find(Rectangle.class).order("-height,-width").get();
assertNotNull(r1);
assertEquals(10, r1.getWidth(), 0);
assertEquals(10, r1.getHeight(), 0);
}
use of org.mongodb.morphia.testmodel.Rectangle in project morphia by mongodb.
the class TestQuery method testSimpleSort.
@Test
public void testSimpleSort() {
getDs().save(asList(new Rectangle(1, 10), new Rectangle(3, 8), new Rectangle(6, 10), new Rectangle(10, 10), new Rectangle(10, 1)));
Rectangle r1 = getDs().find(Rectangle.class).order("width").get();
assertNotNull(r1);
assertEquals(1, r1.getWidth(), 0);
r1 = getDs().find(Rectangle.class).order("-width").get();
assertNotNull(r1);
assertEquals(10, r1.getWidth(), 0);
}
use of org.mongodb.morphia.testmodel.Rectangle in project morphia by mongodb.
the class TestQuery method testAliasedFieldSort.
@Test
public void testAliasedFieldSort() {
getDs().save(asList(new Rectangle(1, 10), new Rectangle(3, 8), new Rectangle(6, 10), new Rectangle(10, 10), new Rectangle(10, 1)));
Rectangle r1 = getDs().find(Rectangle.class).order("w").get(new FindOptions().limit(1));
assertNotNull(r1);
assertEquals(1, r1.getWidth(), 0);
r1 = getDs().find(Rectangle.class).order("-w").get(new FindOptions().limit(1));
assertNotNull(r1);
assertEquals(10, r1.getWidth(), 0);
}
Aggregations