PolymorphicResource { @POST("/polymorphic") public A post(A a) { return a; }  @GET("/polymorphic/single/{type}") A bytype(String type); @GET("/polymorphic/list/{type}") Iterable<A> findAllByType(String type); @POST("/polymorphic") A post(A a);  }
@Test public void should_post_B() throws Exception { HttpRequest httpRequest = server.client().authenticatedAs("admin") .POST("/api/polymorphic") .contentType("application/json") .send("{\"@class\":\".PolymorphicResource$B\",\"a\":\"a3\",\"b\":\"b\"}"); assertThat(httpRequest.code()).isEqualTo(200); assertThat(httpRequest.body().trim()).isEqualTo("{\n" + " \"@class\" : \".PolymorphicResource$B\",\n" + " \"a\" : \"a3\",\n" + " \"b\" : \"b\"\n" + "}"); }
@Test public void should_post_A() throws Exception { HttpTestClient httpTestClient = HttpTestClient.withBaseUrl("http: httpTestClient = server.client(); HttpRequest httpRequest = httpTestClient.authenticatedAs("admin") .POST("/api/polymorphic") .contentType("application/json") .send("{\"@class\":\".PolymorphicResource$A\",\"a\":\"a3\"}"); assertThat(httpRequest.code()).isEqualTo(200); assertThat(httpRequest.body().trim()).isEqualTo("{\n" + " \"@class\" : \".PolymorphicResource$A\",\n" + " \"a\" : \"a3\"\n" + "}"); }