@@ -9,6 +9,7 @@ import assertk.assertions.isTrue
9
9
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent
10
10
import io.mockk.mockk
11
11
import io.moia.router.Router.Companion.router
12
+ import org.junit.jupiter.api.Assertions.assertEquals
12
13
import org.junit.jupiter.api.Test
13
14
14
15
class RequestHandlerTest {
@@ -371,6 +372,17 @@ class RequestHandlerTest {
371
372
)
372
373
}
373
374
375
+ @Test
376
+ fun `Not existing path parameter should throw an error` () {
377
+ val response = testRequestHandler.handleRequest(
378
+ GET (" /non-existing-path-parameter" )
379
+ .withHeader(" accept" , " application/json" ),
380
+ mockk()
381
+ )
382
+ assertEquals(500 , response.statusCode)
383
+ assertEquals(" {\" message\" :\" Could not find path parameter 'foo\" ,\" code\" :\" INTERNAL_SERVER_ERROR\" ,\" details\" :{}}" , response.body)
384
+ }
385
+
374
386
class TestRequestHandlerAuthorization : RequestHandler () {
375
387
override val router = router {
376
388
GET (" /some" ) { _: Request <Unit > ->
@@ -475,6 +487,10 @@ class RequestHandlerTest {
475
487
DELETE (" /delete-me" ) { _: Request <Unit > ->
476
488
ResponseEntity .noContent()
477
489
}
490
+ GET (" /non-existing-path-parameter" ) { request: Request <Unit > ->
491
+ request.getPathParameter(" foo" )
492
+ ResponseEntity .ok(null )
493
+ }
478
494
}
479
495
}
480
496
0 commit comments