https://kotlinlang.org logo
Title
d

dave

11/11/2021, 11:56 AM
you can create a RoutedRequest and use that to test, or send the incoming request through a routing block first..
m

MrNiamh

11/11/2021, 12:46 PM
Ah
RoutedRequest
is what I needed, thanks. For reference:
fun `Request with no contact id in path should return unauthorized`() {
    val next: HttpHandler = { Response(Status.OK).body("hello") }
    val r = RoutedRequest(Request(Method.GET, "/contact/$contactId"), UriTemplate.from("/contact/{notContactId}"))

    val response = service.isLinkedToContact.filter(next)(r)

    assertThat(response.status, equalTo(Status.UNAUTHORIZED))
    assertThat(response.bodyString(), equalTo("Contact id is required"))
}