Skip to content

Commit

Permalink
#186 IllegalStateException on Duplicate Method Key Parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergii Karpenko authored and kptfh committed Apr 16, 2020
1 parent 15b4e56 commit 8817d49
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Mono<List<Long>> mirrorListHeaders(
Mono<Map<String, List<String>>> mirrorMultiMapHeaders(
Map<String, List<String>> headerMap);

Mono<String[]> mirrorHeaderAndRequestWithSameName(String header, String requestParam);

Mono<String> mirrorBody(String body);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@

package reactivefeign.allfeatures;

import feign.Param;
import feign.RequestLine;
import org.reactivestreams.Publisher;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.nio.ByteBuffer;
import java.time.Duration;
Expand Down Expand Up @@ -108,6 +105,11 @@ public Mono<Map<String, List<String>>> mirrorMultiMapHeaders(
throw new UnsupportedOperationException();
}

@Override
public Mono<String[]> mirrorHeaderAndRequestWithSameName(String header, String requestParam) {
return just(new String[]{header, requestParam});
}

@Override
public Mono<MultiValueMap<String, String>> mirrorMultiMapHeaders(
//Spring can't treat Map<String, List<String>> correctly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,16 @@ Mono<List<Long>> mirrorListHeaders(

@Override
@RequestLine("GET /mirrorMultiMapHeaders")
@Headers({ "Method-Header: {headerValue}" })
Mono<Map<String, List<String>>> mirrorMultiMapHeaders(
@HeaderMap Map<String, List<String>> headerMap);

@Override
@RequestLine("GET /mirrorHeaderAndRequestWithSameName")
@Headers({ "username: {headerValue}" })
Mono<String[]> mirrorHeaderAndRequestWithSameName(
@Param("headerValue") String header,
@Param("username") String requestParam);

@Override
@RequestLine("POST " + "/mirrorBody")
Mono<String> mirrorBody(String body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ Mono<MultiValueMap<String, String>> mirrorMultiMapHeaders(
//Spring can't treat Map<String, List<String>> correctly
@RequestHeader MultiValueMap<String, String> param);

@Override
@GetMapping(path = "/mirrorHeaderAndRequestWithSameName")
Mono<String[]> mirrorHeaderAndRequestWithSameName(
@RequestHeader("username") String header,
@RequestParam("username") String requestParam);

@Override
@PostMapping(path = "/mirrorBody")
Mono<String> mirrorBody(@RequestBody String body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ public void shouldReturnAllPassedMultiMapHeaders() {
assertThat(toLowerCaseKeys(returned)).containsAllEntriesOf(toLowerCaseKeys(headersMap));
}

@Test
public void shouldPassHeaderAndRequestParameterWithSameName() {
String[] returned = client.mirrorHeaderAndRequestWithSameName("1", "2")
.subscribeOn(testScheduler()).block();

assertThat(returned).containsExactly("1", "2");
}

@Test
public void shouldReturnBody() {
String returned = client.mirrorBody("Test Body")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ Mono<List<Long>> mirrorListHeaders(
Mono<Map<String, List<String>>> mirrorMultiMapHeaders(
@RequestHeader Map<String, List<String>> param);

@Override
@GetMapping(path = "/mirrorHeaderAndRequestWithSameName")
Mono<String[]> mirrorHeaderAndRequestWithSameName(
@RequestHeader("username") String header,
@RequestParam("username") String requestParam);

@Override
@PostMapping(path = "/mirrorBody")
Mono<String> mirrorBody(@RequestBody String body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,11 @@ public void shouldFailIfNoSubstitutionForPath(){
.verifyComplete();
}

//TODO https://github.com/Playtika/feign-reactive/issues/186
//should be fixed in RequestHeaderParameterProcessor
@Override
@Test(expected = IllegalStateException.class)
public void shouldPassHeaderAndRequestParameterWithSameName() {
super.shouldPassHeaderAndRequestParameterWithSameName();
}
}

0 comments on commit 8817d49

Please sign in to comment.