@@ -504,4 +504,101 @@ public void registersMultiplePullAllClauses() {
504
504
assertThat (pullAll .get ("field1" ), is (notNullValue ()));
505
505
assertThat (pullAll .get ("field2" ), is (notNullValue ()));
506
506
}
507
+
508
+
509
+ /**
510
+ * @see DATAMONGO-1404
511
+ */
512
+ @ Test (expected = IllegalArgumentException .class )
513
+ public void maxShouldThrowExceptionForNullMultiplier () {
514
+ new Update ().max ("key" , null );
515
+ }
516
+
517
+ /**
518
+ * @see DATAMONGO-1404
519
+ */
520
+ @ Test (expected = IllegalArgumentException .class )
521
+ public void minShouldThrowExceptionForNullMultiplier () {
522
+ new Update ().min ("key" , null );
523
+ }
524
+
525
+ /**
526
+ * @see DATAMONGO-1404
527
+ */
528
+ @ Test
529
+ public void getUpdateObjectShouldReturnCorrectRepresentationForMax () {
530
+
531
+ Update update = new Update ().max ("key" , 10 );
532
+
533
+ assertThat (update .getUpdateObject (), equalTo (new BasicDBObjectBuilder ().add ("$max" , new BasicDBObject ("key" , 10 ))
534
+ .get ()));
535
+ }
536
+
537
+ /**
538
+ * @see DATAMONGO-1404
539
+ */
540
+ @ Test
541
+ public void getUpdateObjectShouldReturnCorrectRepresentationForMin () {
542
+
543
+ Update update = new Update ().min ("key" , 10 );
544
+
545
+ assertThat (update .getUpdateObject (), equalTo (new BasicDBObjectBuilder ().add ("$min" , new BasicDBObject ("key" , 10 ))
546
+ .get ()));
547
+ }
548
+
549
+ /**
550
+ * @see DATAMONGO-1404
551
+ */
552
+ @ Test
553
+ public void shouldSuppressPreviousValueForMax () {
554
+
555
+ Update update = new Update ().max ("key" , 10 );
556
+
557
+ update .max ("key" , 99 );
558
+
559
+ assertThat (update .getUpdateObject (), equalTo (new BasicDBObjectBuilder ().add ("$max" , new BasicDBObject ("key" , 99 ))
560
+ .get ()));
561
+ }
562
+
563
+ /**
564
+ * @see DATAMONGO-1404
565
+ */
566
+ @ Test
567
+ public void shouldSuppressPreviousValueForMin () {
568
+
569
+ Update update = new Update ().min ("key" , 10 );
570
+
571
+ update .max ("key" , 99 );
572
+
573
+ assertThat (update .getUpdateObject (), equalTo (new BasicDBObjectBuilder ().add ("$min9" , new BasicDBObject ("key" , 99 ))
574
+ .get ()));
575
+ }
576
+
577
+ /**
578
+ * @see DATAMONGO-1404
579
+ */
580
+ @ Test
581
+ public void getUpdateObjectShouldReturnCorrectDateRepresentationForMax () {
582
+
583
+ final java .util .Date date = new java .util .Date ();
584
+
585
+ Update update = new Update ().max ("key" , date );
586
+
587
+ assertThat (update .getUpdateObject (), equalTo (new BasicDBObjectBuilder ().add ("$max" , new BasicDBObject ("key" , date ))
588
+ .get ()));
589
+ }
590
+
591
+ /**
592
+ * @see DATAMONGO-1404
593
+ */
594
+ @ Test
595
+ public void getUpdateObjectShouldReturnCorrectDateRepresentationForMin () {
596
+
597
+ final java .util .Date date = new java .util .Date ();
598
+
599
+ Update update = new Update ().min ("key" , date );
600
+
601
+ assertThat (update .getUpdateObject (), equalTo (new BasicDBObjectBuilder ().add ("$min" , new BasicDBObject ("key" , date ))
602
+ .get ()));
603
+ }
507
604
}
0 commit comments