@@ -99,6 +99,24 @@ void checksIfHeHasNoName() throws IOException {
9999 );
100100 }
101101
102+ @ Test
103+ void hasNameReturnsFalseWhenNameIsNull () throws IOException {
104+ MatcherAssert .assertThat (
105+ "hasName() must return false when 'name' JSON value is null" ,
106+ RtUserTest .userWithNullName ().hasName (),
107+ Matchers .equalTo (false )
108+ );
109+ }
110+
111+ @ Test
112+ void nameThrowsIllegalStateWhenNameIsNull () throws IOException {
113+ Assertions .assertThrows (
114+ IllegalStateException .class ,
115+ RtUserTest .userWithNullName ()::name ,
116+ "name() must throw IllegalStateException when 'name' JSON value is null"
117+ );
118+ }
119+
102120 @ Test
103121 void describeAsJson () throws IOException {
104122 final RtUser user = new RtUser (
@@ -422,6 +440,25 @@ void markAsReadErrorIfResponseStatusIsNot205() throws IOException {
422440 }
423441 }
424442
443+ /**
444+ * Return User.Smart with a JSON null "name" property.
445+ * @return User.Smart whose JSON has "name":null.
446+ */
447+ private static User .Smart userWithNullName () {
448+ return new User .Smart (
449+ new RtUser (
450+ Mockito .mock (GitHub .class ),
451+ new FakeRequest ().withBody (
452+ Json .createObjectBuilder ()
453+ .addNull ("name" )
454+ .build ()
455+ .toString ()
456+ ),
457+ "octoc"
458+ )
459+ );
460+ }
461+
425462 /**
426463 * Return User.Smart with given property.
427464 * @param property The property as specified at https://developer.github.com/v3/users/#get-a-single-user
0 commit comments