@@ -3406,6 +3406,37 @@ public void should_fully_rename_a_collection() {
3406
3406
assertThat (dbObjects ).containsExactly (new BasicDBObject ("_id" , 1 ).append ("tags" , new BasicDBList ()));
3407
3407
}
3408
3408
3409
+ @ Test
3410
+ public void should_$ne_on_empty_array_works () {
3411
+ // Given
3412
+ DBCollection collection = fongoRule .newCollection ("db" );
3413
+ collection .insert (new BasicDBObject ("_id" , 1 ).append ("tags" , new BasicDBList ()));
3414
+ collection .insert (new BasicDBObject ("_id" , 2 ).append ("tags" , Util .list ("Hi" )));
3415
+
3416
+ // When
3417
+ final List <DBObject > dbObjects = collection .find (new BasicDBObject ("tags" , new BasicDBObject ("$ne" , new BasicDBList ()))).toArray ();
3418
+
3419
+ // Then
3420
+ assertThat (dbObjects ).containsExactly (new BasicDBObject ("_id" , 2 ).append ("tags" , Util .list ("Hi" )));
3421
+ }
3422
+
3423
+ // https://github.com/fakemongo/fongo/issues/201
3424
+ @ Test
3425
+ public void should_$and_have_more_than_2_operands () {
3426
+ // Given
3427
+ DBCollection collection = fongoRule .newCollection ("db" );
3428
+ collection .insert (new BasicDBObject ("_id" , 1 ).append ("tags" , new BasicDBList ()));
3429
+ collection .insert (new BasicDBObject ("_id" , 2 ).append ("tags" , Util .list ("2" )));
3430
+ collection .insert (new BasicDBObject ("_id" , 3 ).append ("tags" , Util .list ("4" )));
3431
+ collection .insert (new BasicDBObject ("_id" , 5 ).append ("ntags" , Util .list ("4" )));
3432
+
3433
+ // When
3434
+ final List <DBObject > dbObjects = collection .find (new BasicDBObject ("tags" , new BasicDBObject ("$exists" , true ).append ("$ne" , new BasicDBList ()).append ("$nin" , Util .list ("1" , "2" )))).toArray ();
3435
+
3436
+ // Then
3437
+ assertThat (dbObjects ).containsExactly (new BasicDBObject ("_id" , 3 ).append ("tags" , Util .list ("4" )));
3438
+ }
3439
+
3409
3440
@ Test
3410
3441
public void should_ping_fongo () {
3411
3442
// Given
0 commit comments