|
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.querymap.BeanQueryMapEncoder; |
@@ -916,14 +917,39 @@ public void queryMap_with_child_pojo() throws Exception { |
916 | 917 | childPojo.setChildPrivateProperty("first"); |
917 | 918 | childPojo.setParentProtectedProperty("second"); |
918 | 919 | childPojo.setParentPublicProperty("third"); |
| 920 | + childPojo.setParentPrivatePropertyAlteredByGetter("fourth"); |
919 | 921 |
|
920 | 922 | server.enqueue(new MockResponse()); |
921 | 923 | api.queryMapPropertyInheritence(childPojo); |
922 | 924 | assertThat(server.takeRequest()) |
923 | 925 | .hasQueryParams( |
924 | 926 | "parentPublicProperty=third", |
925 | 927 | "parentProtectedProperty=second", |
926 | | - "childPrivateProperty=first"); |
| 928 | + "childPrivateProperty=first", |
| 929 | + "parentPrivatePropertyAlteredByGetter=fourth"); |
| 930 | + } |
| 931 | + |
| 932 | + @Test |
| 933 | + public void queryMap_with_child_pojo_altered_by_getter_while_using_overriding_encoder() |
| 934 | + throws Exception { |
| 935 | + TestInterface api = new TestInterfaceBuilder() |
| 936 | + .queryMapEndcoder(new FieldQueryMapEncoder()) |
| 937 | + .target("http://localhost:" + server.getPort()); |
| 938 | + |
| 939 | + ChildPojo childPojo = new ChildPojo(); |
| 940 | + childPojo.setChildPrivateProperty("first"); |
| 941 | + childPojo.setParentProtectedProperty("second"); |
| 942 | + childPojo.setParentPublicProperty("third"); |
| 943 | + childPojo.setParentPrivatePropertyAlteredByGetter("fourth"); |
| 944 | + |
| 945 | + server.enqueue(new MockResponse()); |
| 946 | + api.queryMapPropertyInheritenceWithBeanMapEncoder(childPojo); |
| 947 | + assertThat(server.takeRequest()) |
| 948 | + .hasQueryParams( |
| 949 | + "parentPublicProperty=third", |
| 950 | + "parentProtectedProperty=second", |
| 951 | + "childPrivateProperty=first", |
| 952 | + "parentPrivatePropertyAlteredByGetter=fourthFromGetter"); |
927 | 953 | } |
928 | 954 |
|
929 | 955 | @Test |
@@ -1084,6 +1110,10 @@ void queryMapWithQueryParams(@Param("name") String name, |
1084 | 1110 | @RequestLine("GET /") |
1085 | 1111 | void queryMapPropertyPojo(@QueryMap PropertyPojo object); |
1086 | 1112 |
|
| 1113 | + @RequestLine("GET /") |
| 1114 | + void queryMapPropertyInheritenceWithBeanMapEncoder(@QueryMap( |
| 1115 | + mapEncoder = MapEncoder.BEAN) ChildPojo object); |
| 1116 | + |
1087 | 1117 | @RequestLine("GET /") |
1088 | 1118 | void queryMapPropertyInheritence(@QueryMap ChildPojo object); |
1089 | 1119 |
|
|
0 commit comments