1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

Apply suggestions from code review

Co-Authored-By: Sean Leary <stleary@gmail.com>
This commit is contained in:
Alan Wang 2019-12-30 09:51:08 +08:00 committed by GitHub
parent 16da56eb34
commit 08719d4b3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -593,15 +593,20 @@ public class JSONObjectTest {
jsonObject.has("someFloat")); jsonObject.has("someFloat"));
assertFalse("Ignored field not found!", assertFalse("Ignored field not found!",
jsonObject.has("ignoredInt")); jsonObject.has("ignoredInt"));
assertTrue("Normal field name (someInt) found", // getSomeInt() has no user-defined annotation
assertTrue("Normal field name (someInt) should have been found",
jsonObject.has("someInt")); jsonObject.has("someInt"));
assertTrue("Normal field name (someLong) found", // the user-defined annotation does not replace any value, so someLong should be found
assertTrue("Normal field name (someLong) should have been found",
jsonObject.has("someLong")); jsonObject.has("someLong"));
assertTrue("Overridden String field name (myStringField) found", // myStringField replaces someString property name via user-defined annotation
assertTrue("Overridden String field name (myStringField) should have been found",
jsonObject.has("myStringField")); jsonObject.has("myStringField"));
assertTrue("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) found", // weird name replaces myDouble property name via user-defined annotation
assertTrue("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) should have been found",
jsonObject.has("Some Weird NAme that Normally Wouldn't be possible!")); jsonObject.has("Some Weird NAme that Normally Wouldn't be possible!"));
assertTrue("Overridden String field name (InterfaceField) found", // InterfaceField replaces someFloat property name via user-defined annotation
assertTrue("Overridden String field name (InterfaceField) should have been found",
jsonObject.has("InterfaceField")); jsonObject.has("InterfaceField"));
} }
@ -619,29 +624,39 @@ public class JSONObjectTest {
jsonObject.has("someInt")); jsonObject.has("someInt"));
assertFalse("Normal field name (myDouble) processing did not work", assertFalse("Normal field name (myDouble) processing did not work",
jsonObject.has("myDouble")); jsonObject.has("myDouble"));
assertFalse("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) not FOUND!", // myDouble was replaced by weird name, and then replaced again by AMoreNormalName via user-defined annotation
assertFalse("Overridden String field name (Some Weird NAme that Normally Wouldn't be possible!) should not be FOUND!",
jsonObject.has("Some Weird NAme that Normally Wouldn't be possible!")); jsonObject.has("Some Weird NAme that Normally Wouldn't be possible!"));
assertFalse("Normal field name (someFloat) found, but was overridden", assertFalse("Normal field name (someFloat) found, but was overridden",
jsonObject.has("someFloat")); jsonObject.has("someFloat"));
assertFalse("Ignored field found! but was overridden", assertFalse("Ignored field found! but was overridden",
jsonObject.has("ignoredInt")); jsonObject.has("ignoredInt"));
assertFalse("Ignored field at the same level as forced name not found", // shouldNotBeJSON property name was first ignored, then replaced by ShouldBeIgnored via user-defined annotations
assertFalse("Ignored field at the same level as forced name should not have been found",
jsonObject.has("ShouldBeIgnored")); jsonObject.has("ShouldBeIgnored"));
assertFalse("Normally ignored field (able) with explicit property name not found", // able property name was replaced by Getable via user-defined annotation
assertFalse("Normally ignored field (able) with explicit property name should not have been found",
jsonObject.has("able")); jsonObject.has("able"));
assertTrue("Overridden int field name (newIntFieldName) found", // property name someInt was replaced by newIntFieldName via user-defined annotation
assertTrue("Overridden int field name (newIntFieldName) should have been found",
jsonObject.has("newIntFieldName")); jsonObject.has("newIntFieldName"));
assertTrue("Normal field name (someLong) found", // property name someLong was not replaced via user-defined annotation
assertTrue("Normal field name (someLong) should have been found",
jsonObject.has("someLong")); jsonObject.has("someLong"));
assertTrue("Overridden String field name (myStringField) found", // property name someString was replaced by myStringField via user-defined annotation
assertTrue("Overridden String field name (myStringField) should have been found",
jsonObject.has("myStringField")); jsonObject.has("myStringField"));
assertTrue("Overridden double field name (AMoreNormalName) found", // property name myDouble was replaced by a weird name, followed by AMoreNormalName via user-defined annotations
assertTrue("Overridden double field name (AMoreNormalName) should have been found",
jsonObject.has("AMoreNormalName")); jsonObject.has("AMoreNormalName"));
assertTrue("Overridden String field name (InterfaceField) found", // property name someFloat was replaced by InterfaceField via user-defined annotation
assertTrue("Overridden String field name (InterfaceField) should have been found",
jsonObject.has("InterfaceField")); jsonObject.has("InterfaceField"));
assertTrue("Forced field found!", // property name ignoredInt was replaced by none, followed by forcedInt via user-defined annotations
assertTrue("Forced field should have been found!",
jsonObject.has("forcedInt")); jsonObject.has("forcedInt"));
assertTrue("Overridden boolean field name (Getable) found", // property name able was replaced by Getable via user-defined annotation
assertTrue("Overridden boolean field name (Getable) should have been found",
jsonObject.has("Getable")); jsonObject.has("Getable"));
} }