@Test public void testOrNegative() throws Exception { insertMockObject(); DBCursor<MockObject> cursor = coll.find().or(DBQuery.is("integer", 9), DBQuery.lessThan("integer", 9)); assertThat(cursor.hasNext(), equalTo(false)); }
@Test public void testNorNegative() throws Exception { insertMockObject(); DBCursor<MockObject> cursor = coll.find() .and( DBQuery.lessThan("integer", 9), DBQuery.is("string", "hello"), DBQuery.greaterThan("integer", 11)); assertThat(cursor.hasNext(), equalTo(false)); }
@Test public void testOrPositive() throws Exception { MockObject mockObject = insertMockObject(); DBCursor<MockObject> cursor = coll.find() .or( DBQuery.is("integer", 9), DBQuery.greaterThan("integer", 9), DBQuery.lessThan("integer", 9)); assertThat(cursor.hasNext(), equalTo(true)); assertThat(cursor.next(), equalTo(mockObject)); }
@Test public void testSimpleEquals() { coll.save(new MockObject()); String id = coll.findOne().id; assertNotNull(coll.findOne(DBQuery.is("_id", id))); }