From 22025326e77ff1fc82a560b5ddaa60c1a4618c6f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 17:52:01 +0000 Subject: [PATCH] fix: align search test and available-films error handling Agent-Logs-Url: https://github.com/devitq/movienight-backend/sessions/42b7a686-07a7-41f5-baf7-737b968e12cf Co-authored-by: devitq <118541411+devitq@users.noreply.github.com> --- .../movienight/adapters/web/FilmLibraryController.kt | 8 +++----- .../movienight/adapters/web/FilmControllerSearchTest.kt | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/project/movienight/adapters/web/FilmLibraryController.kt b/src/main/kotlin/com/project/movienight/adapters/web/FilmLibraryController.kt index 5a9f002..998a330 100644 --- a/src/main/kotlin/com/project/movienight/adapters/web/FilmLibraryController.kt +++ b/src/main/kotlin/com/project/movienight/adapters/web/FilmLibraryController.kt @@ -110,13 +110,11 @@ class FilmLibraryController( getFilmLibraryUseCase.getLibrary( GetFilmLibraryQuery(userId = userId), ) - }.getOrElse { exception -> - if (exception is EntityNotFoundException) { - null - } else { + }.onFailure { exception -> + if (exception !is EntityNotFoundException) { throw exception } - } + }.getOrNull() val allFilms = getAllFilmsUseCase.getAll() diff --git a/src/test/kotlin/com/project/movienight/adapters/web/FilmControllerSearchTest.kt b/src/test/kotlin/com/project/movienight/adapters/web/FilmControllerSearchTest.kt index dd6bd33..033cccd 100644 --- a/src/test/kotlin/com/project/movienight/adapters/web/FilmControllerSearchTest.kt +++ b/src/test/kotlin/com/project/movienight/adapters/web/FilmControllerSearchTest.kt @@ -59,7 +59,7 @@ class FilmControllerSearchTest { } @Test - fun `search returns empty body when title is missing`() { + fun `search returns 404 when title is not found`() { val title = "Unknown Title" every { searchFilmByTitleUseCase.searchByTitle(title) } returns null @@ -68,7 +68,7 @@ class FilmControllerSearchTest { .get("/api/films/search") { param("title", title) }.andExpect { - status { isOk() } + status { isNotFound() } content { string("") } }