Skip to content

Commit 08719d4

Browse files
Alan Wangstleary
andauthored
Apply suggestions from code review
Co-Authored-By: Sean Leary <[email protected]>
1 parent 16da56e commit 08719d4

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

src/test/java/org/json/junit/JSONObjectTest.java

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -593,15 +593,20 @@ public void jsonObjectByBean2() {
593593
jsonObject.has("someFloat"));
594594
assertFalse("Ignored field not found!",
595595
jsonObject.has("ignoredInt"));
596-
assertTrue("Normal field name (someInt) found",
596+
// getSomeInt() has no user-defined annotation
597+
assertTrue("Normal field name (someInt) should have been found",
597598
jsonObject.has("someInt"));
598-
assertTrue("Normal field name (someLong) found",
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",
599601
jsonObject.has("someLong"));
600-
assertTrue("Overridden String field name (myStringField) found",
602+
// myStringField replaces someString property name via user-defined annotation
603+
assertTrue("Overridden String field name (myStringField) should have been found",
601604
jsonObject.has("myStringField"));
602-
assertTrue("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) 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",
603607
jsonObject.has("Some Weird NAme that Normally Wouldn't be possible!"));
604-
assertTrue("Overridden String field name (InterfaceField) found",
608+
// InterfaceField replaces someFloat property name via user-defined annotation
609+
assertTrue("Overridden String field name (InterfaceField) should have been found",
605610
jsonObject.has("InterfaceField"));
606611
}
607612

@@ -619,29 +624,39 @@ public void jsonObjectByBean3() {
619624
jsonObject.has("someInt"));
620625
assertFalse("Normal field name (myDouble) processing did not work",
621626
jsonObject.has("myDouble"));
622-
assertFalse("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) not 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!",
623629
jsonObject.has("Some Weird NAme that Normally Wouldn't be possible!"));
624630
assertFalse("Normal field name (someFloat) found, but was overridden",
625631
jsonObject.has("someFloat"));
626632
assertFalse("Ignored field found! but was overridden",
627633
jsonObject.has("ignoredInt"));
628-
assertFalse("Ignored field at the same level as forced name not 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",
629636
jsonObject.has("ShouldBeIgnored"));
630-
assertFalse("Normally ignored field (able) with explicit property name 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",
631639
jsonObject.has("able"));
632-
assertTrue("Overridden int field name (newIntFieldName) found",
640+
// property name someInt was replaced by newIntFieldName via user-defined annotation
641+
assertTrue("Overridden int field name (newIntFieldName) should have been found",
633642
jsonObject.has("newIntFieldName"));
634-
assertTrue("Normal field name (someLong) found",
643+
// property name someLong was not replaced via user-defined annotation
644+
assertTrue("Normal field name (someLong) should have been found",
635645
jsonObject.has("someLong"));
636-
assertTrue("Overridden String field name (myStringField) found",
646+
// property name someString was replaced by myStringField via user-defined annotation
647+
assertTrue("Overridden String field name (myStringField) should have been found",
637648
jsonObject.has("myStringField"));
638-
assertTrue("Overridden double field name (AMoreNormalName) 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",
639651
jsonObject.has("AMoreNormalName"));
640-
assertTrue("Overridden String field name (InterfaceField) found",
652+
// property name someFloat was replaced by InterfaceField via user-defined annotation
653+
assertTrue("Overridden String field name (InterfaceField) should have been found",
641654
jsonObject.has("InterfaceField"));
642-
assertTrue("Forced field found!",
655+
// property name ignoredInt was replaced by none, followed by forcedInt via user-defined annotations
656+
assertTrue("Forced field should have been found!",
643657
jsonObject.has("forcedInt"));
644-
assertTrue("Overridden boolean field name (Getable) found",
658+
// property name able was replaced by Getable via user-defined annotation
659+
assertTrue("Overridden boolean field name (Getable) should have been found",
645660
jsonObject.has("Getable"));
646661
}
647662

0 commit comments

Comments
 (0)