diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/HomeControllerTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/HomeControllerTest.kt index 80c17d2..82835b4 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/HomeControllerTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/HomeControllerTest.kt @@ -201,6 +201,39 @@ class HomeControllerTest { assertThat(page.querySelectorAll("div.notification.info")).isEmpty() } + @Test + @WithMockUser(username = "admin", roles = ["ADMIN"]) + fun testShouldShowPatientPseudonym() { + whenever(requestService.findRequestByPatientId(anyValueClass(), any())).thenReturn( + PageImpl( + listOf( + Request( + 2L, + randomRequestId(), + PatientPseudonym("PSEUDO1"), + PatientId("PATIENT1"), + Fingerprint("ashdkasdh"), + RequestType.MTB_FILE, + RequestStatus.SUCCESS + ), + Request( + 1L, + randomRequestId(), + PatientPseudonym("PSEUDO1"), + PatientId("PATIENT1"), + Fingerprint("asdasdasd"), + RequestType.MTB_FILE, + RequestStatus.ERROR + ) + ) + ) + ) + + val page = webClient.getPage("http://localhost/patient/PSEUDO1") + assertThat(page.querySelectorAll("h2 > span")).hasSize(1) + assertThat(page.querySelectorAll("h2 > span").first().textContent).isEqualTo("PSEUDO1") + } + } @Nested diff --git a/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt b/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt index 5419477..54920b1 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt @@ -53,12 +53,12 @@ class HomeController( @GetMapping(path = ["patient/{patientPseudonym}"]) fun byPatient( - @PathVariable patientPseudonym: String, + @PathVariable patientPseudonym: PatientPseudonym, @PageableDefault(page = 0, size = 20, sort = ["processedAt"], direction = Sort.Direction.DESC) pageable: Pageable, model: Model ): String { - val requests = requestService.findRequestByPatientId(PatientPseudonym(patientPseudonym), pageable) - model.addAttribute("patientPseudonym", patientPseudonym) + val requests = requestService.findRequestByPatientId(patientPseudonym, pageable) + model.addAttribute("patientPseudonym", patientPseudonym.value) model.addAttribute("requests", requests) return "index"