@@ -589,19 +589,24 @@ public void jsonObjectByBean2() {
589
589
jsonObject .has ("someString" ));
590
590
assertFalse ("Normal field name (myDouble) processing did not work" ,
591
591
jsonObject .has ("myDouble" ));
592
- assertFalse ("Normal field name (someFloat) found " ,
592
+ assertFalse ("Normal field name (someFloat) processing did not work " ,
593
593
jsonObject .has ("someFloat" ));
594
- assertFalse ("Ignored field found!" ,
594
+ assertFalse ("Ignored field not found!" ,
595
595
jsonObject .has ("ignoredInt" ));
596
- assertTrue ("Normal field name (someInt) processing did not work" ,
596
+ // getSomeInt() has no user-defined annotation
597
+ assertTrue ("Normal field name (someInt) should have been found" ,
597
598
jsonObject .has ("someInt" ));
598
- assertTrue ("Normal field name (someLong) processing did not work" ,
599
+ // the user-defined annotation does not replace any value, so someLong should be found
600
+ assertTrue ("Normal field name (someLong) should have been found" ,
599
601
jsonObject .has ("someLong" ));
600
- assertTrue ("Overridden String field name (myStringField) not found" ,
602
+ // myStringField replaces someString property name via user-defined annotation
603
+ assertTrue ("Overridden String field name (myStringField) should have been found" ,
601
604
jsonObject .has ("myStringField" ));
602
- assertTrue ("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) not found" ,
605
+ // weird name replaces myDouble property name via user-defined annotation
606
+ assertTrue ("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) should have been found" ,
603
607
jsonObject .has ("Some Weird NAme that Normally Wouldn't be possible!" ));
604
- assertTrue ("Overridden String field name (InterfaceField) not found" ,
608
+ // InterfaceField replaces someFloat property name via user-defined annotation
609
+ assertTrue ("Overridden String field name (InterfaceField) should have been found" ,
605
610
jsonObject .has ("InterfaceField" ));
606
611
}
607
612
@@ -619,26 +624,39 @@ public void jsonObjectByBean3() {
619
624
jsonObject .has ("someInt" ));
620
625
assertFalse ("Normal field name (myDouble) processing did not work" ,
621
626
jsonObject .has ("myDouble" ));
622
- assertFalse ("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) FOUND!" ,
627
+ // myDouble was replaced by weird name, and then replaced again by AMoreNormalName via user-defined annotation
628
+ assertFalse ("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) should not be FOUND!" ,
623
629
jsonObject .has ("Some Weird NAme that Normally Wouldn't be possible!" ));
624
- assertFalse ("Normal field name (someFloat) found" ,
630
+ assertFalse ("Normal field name (someFloat) found, but was overridden " ,
625
631
jsonObject .has ("someFloat" ));
626
- assertFalse ("Ignored field found!" ,
632
+ assertFalse ("Ignored field found! but was overridden " ,
627
633
jsonObject .has ("ignoredInt" ));
628
- assertFalse ("Ignored field at the same level as forced name found" ,
634
+ // shouldNotBeJSON property name was first ignored, then replaced by ShouldBeIgnored via user-defined annotations
635
+ assertFalse ("Ignored field at the same level as forced name should not have been found" ,
629
636
jsonObject .has ("ShouldBeIgnored" ));
630
- assertTrue ("Overridden int field name (newIntFieldName) not found" ,
637
+ // able property name was replaced by Getable via user-defined annotation
638
+ assertFalse ("Normally ignored field (able) with explicit property name should not have been found" ,
639
+ jsonObject .has ("able" ));
640
+ // property name someInt was replaced by newIntFieldName via user-defined annotation
641
+ assertTrue ("Overridden int field name (newIntFieldName) should have been found" ,
631
642
jsonObject .has ("newIntFieldName" ));
632
- assertTrue ("Normal field name (someLong) processing did not work" ,
643
+ // property name someLong was not replaced via user-defined annotation
644
+ assertTrue ("Normal field name (someLong) should have been found" ,
633
645
jsonObject .has ("someLong" ));
634
- assertTrue ("Overridden String field name (myStringField) not found" ,
646
+ // property name someString was replaced by myStringField via user-defined annotation
647
+ assertTrue ("Overridden String field name (myStringField) should have been found" ,
635
648
jsonObject .has ("myStringField" ));
636
- assertTrue (jsonObject .has ("AMoreNormalName" ));
637
- assertTrue ("Overridden String field name (InterfaceField) not found" ,
649
+ // property name myDouble was replaced by a weird name, followed by AMoreNormalName via user-defined annotations
650
+ assertTrue ("Overridden double field name (AMoreNormalName) should have been found" ,
651
+ jsonObject .has ("AMoreNormalName" ));
652
+ // property name someFloat was replaced by InterfaceField via user-defined annotation
653
+ assertTrue ("Overridden String field name (InterfaceField) should have been found" ,
638
654
jsonObject .has ("InterfaceField" ));
639
- assertTrue ("Forced field not found!" ,
655
+ // property name ignoredInt was replaced by none, followed by forcedInt via user-defined annotations
656
+ assertTrue ("Forced field should have been found!" ,
640
657
jsonObject .has ("forcedInt" ));
641
- assertTrue ("Normally ignored field (getable) with explicit property name not found" ,
658
+ // property name able was replaced by Getable via user-defined annotation
659
+ assertTrue ("Overridden boolean field name (Getable) should have been found" ,
642
660
jsonObject .has ("Getable" ));
643
661
}
644
662
0 commit comments