@@ -1442,7 +1442,9 @@ public void serializeBooleanBean() {
14421442 public void serializeFloatBean () {
14431443 FloatBean bean = new FloatBean ();
14441444 bean .value = 0.5f ;
1445- assertJson ("{'value': 0.5}" , serialize (bean ));
1445+
1446+ // We don't use assertJson as it converts all floating point numbers to Double.
1447+ assertEquals (map ("value" , 0.5f ), serialize (bean ));
14461448 }
14471449
14481450 @ Test
@@ -1696,7 +1698,7 @@ public void shortsCantBeSerialized() {
16961698 ShortBean bean = new ShortBean ();
16971699 bean .value = 1 ;
16981700 assertExceptionContains (
1699- "Shorts are not supported, please use int or long (found in field 'value')" ,
1701+ "Numbers of type Short are not supported, please use an int, long, float or double (found in field 'value')" ,
17001702 () -> serialize (bean ));
17011703 }
17021704
@@ -1705,7 +1707,7 @@ public void bytesCantBeSerialized() {
17051707 ByteBean bean = new ByteBean ();
17061708 bean .value = 1 ;
17071709 assertExceptionContains (
1708- "Bytes are not supported, please use int or long (found in field 'value')" ,
1710+ "Numbers of type Byte are not supported, please use an int, long, float or double (found in field 'value')" ,
17091711 () -> serialize (bean ));
17101712 }
17111713
@@ -1714,7 +1716,7 @@ public void charsCantBeSerialized() {
17141716 CharBean bean = new CharBean ();
17151717 bean .value = 1 ;
17161718 assertExceptionContains (
1717- "Characters are not supported, please use Strings. (found in field 'value')" ,
1719+ "Characters are not supported, please use Strings (found in field 'value')" ,
17181720 () -> serialize (bean ));
17191721 }
17201722
@@ -1741,21 +1743,21 @@ public void objectArraysCantBeSerialized() {
17411743 @ Test
17421744 public void shortsCantBeDeserialized () {
17431745 assertExceptionContains (
1744- "Deserializing to shorts is not supported (found in field 'value')" ,
1746+ "Deserializing values to short is not supported (found in field 'value')" ,
17451747 () -> deserialize ("{'value': 1}" , ShortBean .class ));
17461748 }
17471749
17481750 @ Test
17491751 public void bytesCantBeDeserialized () {
17501752 assertExceptionContains (
1751- "Deserializing to bytes is not supported (found in field 'value')" ,
1753+ "Deserializing values to byte is not supported (found in field 'value')" ,
17521754 () -> deserialize ("{'value': 1}" , ByteBean .class ));
17531755 }
17541756
17551757 @ Test
17561758 public void charsCantBeDeserialized () {
17571759 assertExceptionContains (
1758- "Deserializing to chars is not supported (found in field 'value')" ,
1760+ "Deserializing values to char is not supported (found in field 'value')" ,
17591761 () -> deserialize ("{'value': '1'}" , CharBean .class ));
17601762 }
17611763
@@ -1862,21 +1864,21 @@ public void passingInMapTopLevelThrows() {
18621864 @ Test
18631865 public void passingInCharacterTopLevelThrows () {
18641866 assertExceptionContains (
1865- "Deserializing to chars is not supported" ,
1867+ "Deserializing values to Character is not supported" ,
18661868 () -> CustomClassMapper .convertToCustomClass ('1' , Character .class ));
18671869 }
18681870
18691871 @ Test
18701872 public void passingInShortTopLevelThrows () {
18711873 assertExceptionContains (
1872- "Deserializing to shorts is not supported" ,
1874+ "Deserializing values to Short is not supported" ,
18731875 () -> CustomClassMapper .convertToCustomClass (1 , Short .class ));
18741876 }
18751877
18761878 @ Test
18771879 public void passingInByteTopLevelThrows () {
18781880 assertExceptionContains (
1879- "Deserializing to bytes is not supported" ,
1881+ "Deserializing values to Byte is not supported" ,
18801882 () -> CustomClassMapper .convertToCustomClass (1 , Byte .class ));
18811883 }
18821884
@@ -2220,8 +2222,8 @@ public void serializationFailureIncludesPath() {
22202222 fail ("should have thrown" );
22212223 } catch (RuntimeException e ) {
22222224 assertEquals (
2223- "Could not serialize object. Shorts are not supported, please use int or "
2224- + "long (found in field 'value.inner.value.short')" ,
2225+ "Could not serialize object. Numbers of type Short are not supported, please use an int, "
2226+ + "long, float or double (found in field 'value.inner.value.short')" ,
22252227 e .getMessage ());
22262228 }
22272229 }
@@ -2235,7 +2237,7 @@ public void deserializationFailureIncludesPath() {
22352237 fail ("should have thrown" );
22362238 } catch (RuntimeException e ) {
22372239 assertEquals (
2238- "Could not deserialize object. Deserializing to shorts is not supported "
2240+ "Could not deserialize object. Deserializing values to short is not supported "
22392241 + "(found in field 'value')" ,
22402242 e .getMessage ());
22412243 }
0 commit comments