summaryrefslogtreecommitdiff
path: root/src/integrationTest/kotlin/dev/dnpm/etl
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2026-03-07 11:09:38 +0100
committerGitHub2026-03-07 10:09:38 +0000
commit17262ea8cf9478bab2b5c34d814c8e1519adf33a (patch)
tree3abd2928ea19f8790fc523fa0f54a6ed6bec9c04 /src/integrationTest/kotlin/dev/dnpm/etl
parentee5f9096c85f6789078597ba19f7c02e6b24d2c5 (diff)
feat: search by patient pseudonym and TAN (#256)
Diffstat (limited to 'src/integrationTest/kotlin/dev/dnpm/etl')
-rw-r--r--src/integrationTest/kotlin/dev/dnpm/etl/processor/web/HomeControllerTest.kt81
1 files changed, 79 insertions, 2 deletions
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 b0b4ecb..2a8ce81 100644
--- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/HomeControllerTest.kt
+++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/HomeControllerTest.kt
@@ -41,6 +41,9 @@ import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.kotlin.any
+import org.mockito.kotlin.anyValueClass
+import org.mockito.kotlin.times
+import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest
@@ -48,6 +51,8 @@ import org.springframework.data.domain.Page
import org.springframework.data.domain.PageImpl
import org.springframework.data.domain.Pageable
import org.springframework.security.test.context.support.WithMockUser
+import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.anonymous
+import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.bean.override.mockito.MockitoBean
@@ -259,7 +264,7 @@ class HomeControllerTest {
@Test
fun testShouldShowHomePage() {
val page = webClient.getPage<HtmlPage>("http://localhost/")
- assertThat(page.querySelectorAll("tbody tr")).isEmpty()
+ assertThat(page.querySelectorAll("div.card")).isEmpty()
assertThat(page.querySelectorAll("div.notification.info")).hasSize(1)
}
@@ -283,7 +288,7 @@ class HomeControllerTest {
.thenReturn(Page.empty())
val page = webClient.getPage<HtmlPage>("http://localhost/patient/PSEUDO1")
- assertThat(page.querySelectorAll("tbody tr")).isEmpty()
+ assertThat(page.querySelectorAll("div.card")).isEmpty()
assertThat(page.querySelectorAll("div.notification.info")).hasSize(1)
}
@@ -313,5 +318,77 @@ class HomeControllerTest {
assertThat(page.querySelectorAll("div.card div").first().textContent)
.isEqualTo("Gestoppt: Kein Consent")
}
+
+ @Test
+ fun testSearchAsLoggedInAdmin() {
+ whenever(requestService.searchRequestLike(anyValueClass(), anyValueClass(), any<Pageable>()))
+ .thenReturn(Page.empty())
+
+ mockMvc.get("/") {
+ queryParam("q", "test")
+ with(user("admin").roles("ADMIN"))
+ }.andExpect {
+ status { isOk() }
+ view { name("index") }
+ }
+
+ verify(requestService, times(1))
+ .searchRequestLike(
+ anyValueClass<PatientPseudonym>(),
+ anyValueClass<Tan>(),
+ any<Pageable>()
+ )
+
+ verify(requestService, times(0))
+ .findAll(any<Pageable>())
+ }
+
+ @Test
+ fun testSearchAsLoggedInUser() {
+ whenever(requestService.searchRequestLike(anyValueClass(), anyValueClass(), any<Pageable>()))
+ .thenReturn(Page.empty())
+
+ mockMvc.get("/") {
+ queryParam("q", "test")
+ with(user("user").roles("USER"))
+ }.andExpect {
+ status { isOk() }
+ view { name("index") }
+ }
+
+ verify(requestService, times(1))
+ .searchRequestLike(
+ anyValueClass<PatientPseudonym>(),
+ anyValueClass<Tan>(),
+ any<Pageable>()
+ )
+
+ verify(requestService, times(0))
+ .findAll(any<Pageable>())
+ }
+
+ @Test
+ fun testNotSearchAsAnonymousUser() {
+ whenever(requestService.searchRequestLike(anyValueClass(), anyValueClass(), any<Pageable>()))
+ .thenReturn(Page.empty())
+
+ mockMvc.get("/") {
+ queryParam("q", "test")
+ with(anonymous())
+ }.andExpect {
+ status { isOk() }
+ view { name("index") }
+ }
+
+ verify(requestService, times(0))
+ .searchRequestLike(
+ anyValueClass<PatientPseudonym>(),
+ anyValueClass<Tan>(),
+ any<Pageable>()
+ )
+
+ verify(requestService, times(1))
+ .findAll(any<Pageable>())
+ }
}
}