* the difference is in convertToBasicHeaders vs basicHeaders
*/
val convertedHeaders: Array<BasicHeader> = convertToBasicHeaders(headers)
- val encodedPath = UriUtils.encodePath(path, StandardCharsets.UTF_8.name())
+ val encodedPath = UriUtils.encodeQuery(path, StandardCharsets.UTF_8.name())
return when (HttpMethod.resolve(methodType)) {
HttpMethod.DELETE -> delete(encodedPath, convertedHeaders, String::class.java)
HttpMethod.GET -> get(encodedPath, convertedHeaders, String::class.java)
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PatchMapping
+import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
this.http.stop()
}
+ @Test
+ fun testGetQueryParam() {
+ val restClientService = bluePrintRestLibPropertyService
+ .blueprintWebClientService("sample")
+ val response = restClientService.exchangeResource(
+ HttpMethod.GET.name, "/sample/query?id=3", ""
+ )
+ assertEquals(
+ "query with id:3", response.body,
+ "failed to get query param response"
+ )
+ }
+
+ @Test
+ fun testGetPathParamWithWhitespace() {
+ val restClientService = bluePrintRestLibPropertyService
+ .blueprintWebClientService("sample")
+ val response = restClientService.exchangeResource(
+ HttpMethod.GET.name, "/sample/path/id 3/get", ""
+ )
+ assertEquals(
+ "path param id:id 3", response.body,
+ "failed to get query param response"
+ )
+ }
+
@Test
fun testPatch() {
val restClientService = bluePrintRestLibPropertyService
@GetMapping("/name")
fun getName(): String = "Sample Controller"
+ @GetMapping("/query")
+ fun getQuery(@RequestParam("id") id: String): String =
+ "query with id:$id"
+
+ @GetMapping("/path/{id}/get")
+ fun getPathParam(@PathVariable("id") id: String): String =
+ "path param id:$id"
+
@PatchMapping("/name")
fun patchName(): String = "Patch request successful"