Trying to pass list of Enum values as path variable
@GetMapping(path = ["/days"], produces = ["application/json;charset=UTF-8"])
@ApiOperation("Process by days of week")
fun processByDaysOfWeek(@PathVariable day: List<DayOfWeek>): {
...
}
enum class DayOfWeek {
MONDAY, WEDNESDAY, THURSDAY, FRIDAY;
}
When testing with RestAssured
val days = listOf(DayOfWeek.MONDAY, DayOfWeek.THURSDAY)
RestAssured
.given()
.spec(spec)
.pathParam("days", days)
.get("/engine/workday/{days}")
.then()
.statusCode(200)
.extract().`as`(JsonNode::class.java)
Request method: GET
Request URI: http://localhost:62938/engine/workday/%3D%5B%22MONDAY%22%2C%22THURSDAY%22%5D
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: days=["MONDAY","THURSDAY"]
Headers: Accept=*/*
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body: <none>
What is the best way to test this? I want the URL to look like
http://localhost:62938/engine/workday/MONDAY,THURSDAY