1414
1515package org .httprpc ;
1616
17+ import org .httprpc .beans .BeanAdapter ;
1718import org .junit .jupiter .api .Test ;
1819
1920import javax .imageio .ImageIO ;
@@ -59,6 +60,13 @@ interface AttachmentInfo {
5960 int getChecksum ();
6061 }
6162
63+ interface Body {
64+ String getString ();
65+ List <String > getStrings ();
66+ int getNumber ();
67+ boolean getFlag ();
68+ }
69+
6270 @ RequestMethod ("GET" )
6371 @ ResourcePath ("a/?:a/b/?:b/c/?:c/d/?:d" )
6472 Map <String , ?> testGetKeys () throws IOException ;
@@ -73,7 +81,7 @@ Response testMultipartPost(String string, List<String> strings, int number, bool
7381 List <URL > attachments ) throws IOException ;
7482
7583 @ RequestMethod ("POST" )
76- Map < String , ?> testBodyPost (int id ) throws IOException ;
84+ Body testBodyPost (int id ) throws IOException ;
7785
7886 @ RequestMethod ("GET" )
7987 @ ResourcePath ("headers" )
@@ -252,25 +260,25 @@ public void testMultipartPost() throws IOException {
252260
253261 @ Test
254262 public void testCustomBodyPost () throws IOException {
255- Map < String , ?> content = mapOf (
263+ TestService . Body body = BeanAdapter . adapt ( mapOf (
256264 entry ("string" , "héllo&gøod+bye?" ),
257265 entry ("strings" , listOf ("a" , "b" , "c" )),
258266 entry ("number" , 123L ),
259267 entry ("flag" , true )
260- );
268+ ), TestService . Body . class ) ;
261269
262270 TestService testService = WebServiceProxy .adapt (new URL (serverURL , "test/" ), TestService .class ,
263271 (resourcePath ) -> null , (method , url ) -> {
264272 WebServiceProxy webServiceProxy = new WebServiceProxy (method , url );
265273
266- webServiceProxy .setBody (content );
274+ webServiceProxy .setBody (body );
267275
268276 return webServiceProxy ;
269277 });
270278
271- Map < String , ?> result = testService .testBodyPost (101 );
279+ TestService . Body result = testService .testBodyPost (101 );
272280
273- assertEquals (content , result );
281+ assertEquals (body , result );
274282 }
275283
276284 @ Test
0 commit comments