@@ -189,4 +189,44 @@ void stringPassedToObjectGetsPassedToString() {
189
189
Object value = request .getBody ().get ().uniPart ().getValue ();
190
190
assertEquals ("{\" body\" : \" sample\" }" , value );
191
191
}
192
+
193
+ @ Test
194
+ void jsonNodePassedToObjectGetsPassedToString () {
195
+ Object body = new JsonNode ("{\" body\" : \" sample\" }" );
196
+ RequestBodyEntity request = Unirest .post (MockServer .POST )
197
+ .basicAuth ("foo" , "bar" )
198
+ .header ("Content-Type" , "application/json" )
199
+ .queryString ("foo" , "bar" )
200
+ .body (body );
201
+
202
+ Object value = request .getBody ().get ().uniPart ().getValue ();
203
+ assertEquals ("{\" body\" :\" sample\" }" , value );
204
+ }
205
+
206
+ @ Test
207
+ void jsonObjectPassedToObjectGetsPassedToString () {
208
+ Object body = new JSONObject ("{\" body\" : \" sample\" }" );
209
+ RequestBodyEntity request = Unirest .post (MockServer .POST )
210
+ .basicAuth ("foo" , "bar" )
211
+ .header ("Content-Type" , "application/json" )
212
+ .queryString ("foo" , "bar" )
213
+ .body (body );
214
+
215
+ Object value = request .getBody ().get ().uniPart ().getValue ();
216
+ assertEquals ("{\" body\" :\" sample\" }" , value );
217
+ }
218
+
219
+ @ Test
220
+ void jsonArrayPassedToObjectGetsPassedToString () {
221
+ Object body = new JSONArray ("[\" body\" , \" sample\" ]" );
222
+ RequestBodyEntity request = Unirest .post (MockServer .POST )
223
+ .basicAuth ("foo" , "bar" )
224
+ .header ("Content-Type" , "application/json" )
225
+ .queryString ("foo" , "bar" )
226
+ .body (body );
227
+
228
+ Object value = request .getBody ().get ().uniPart ().getValue ();
229
+ assertEquals ("[\" body\" ,\" sample\" ]" , value );
230
+ }
231
+
192
232
}
0 commit comments