|
16 | 16 | import com.google.gson.Gson; |
17 | 17 | import com.google.gson.reflect.TypeToken; |
18 | 18 | import feign.Feign.ResponseMappingDecoder; |
| 19 | +import feign.QueryMap.MapEncoder; |
19 | 20 | import feign.Request.HttpMethod; |
20 | 21 | import feign.Target.HardCodedTarget; |
21 | 22 | import feign.codec.DecodeException; |
@@ -924,14 +925,39 @@ public void queryMap_with_child_pojo() throws Exception { |
924 | 925 | childPojo.setChildPrivateProperty("first"); |
925 | 926 | childPojo.setParentProtectedProperty("second"); |
926 | 927 | childPojo.setParentPublicProperty("third"); |
| 928 | + childPojo.setParentPrivatePropertyAlteredByGetter("fourth"); |
927 | 929 |
|
928 | 930 | server.enqueue(new MockResponse()); |
929 | 931 | api.queryMapPropertyInheritence(childPojo); |
930 | 932 | assertThat(server.takeRequest()) |
931 | 933 | .hasQueryParams( |
932 | 934 | "parentPublicProperty=third", |
933 | 935 | "parentProtectedProperty=second", |
934 | | - "childPrivateProperty=first"); |
| 936 | + "childPrivateProperty=first", |
| 937 | + "parentPrivatePropertyAlteredByGetter=fourth"); |
| 938 | + } |
| 939 | + |
| 940 | + @Test |
| 941 | + public void queryMap_with_child_pojo_altered_by_getter_while_using_overriding_encoder() |
| 942 | + throws Exception { |
| 943 | + TestInterface api = new TestInterfaceBuilder() |
| 944 | + .queryMapEncoder(new FieldQueryMapEncoder()) |
| 945 | + .target("http://localhost:" + server.getPort()); |
| 946 | + |
| 947 | + ChildPojo childPojo = new ChildPojo(); |
| 948 | + childPojo.setChildPrivateProperty("first"); |
| 949 | + childPojo.setParentProtectedProperty("second"); |
| 950 | + childPojo.setParentPublicProperty("third"); |
| 951 | + childPojo.setParentPrivatePropertyAlteredByGetter("fourth"); |
| 952 | + |
| 953 | + server.enqueue(new MockResponse()); |
| 954 | + api.queryMapPropertyInheritenceWithBeanMapEncoder(childPojo); |
| 955 | + assertThat(server.takeRequest()) |
| 956 | + .hasQueryParams( |
| 957 | + "parentPublicProperty=third", |
| 958 | + "parentProtectedProperty=second", |
| 959 | + "childPrivateProperty=first", |
| 960 | + "parentPrivatePropertyAlteredByGetter=fourthFromGetter"); |
935 | 961 | } |
936 | 962 |
|
937 | 963 | @Test |
@@ -1210,6 +1236,10 @@ void queryMapWithQueryParams(@Param("name") String name, |
1210 | 1236 | @RequestLine("GET /") |
1211 | 1237 | void queryMapPropertyPojo(@QueryMap PropertyPojo object); |
1212 | 1238 |
|
| 1239 | + @RequestLine("GET /") |
| 1240 | + void queryMapPropertyInheritenceWithBeanMapEncoder(@QueryMap( |
| 1241 | + mapEncoder = MapEncoder.BEAN) ChildPojo object); |
| 1242 | + |
1213 | 1243 | @RequestLine("GET /") |
1214 | 1244 | void queryMapPropertyInheritence(@QueryMap ChildPojo object); |
1215 | 1245 |
|
|
0 commit comments