From f419acb924b30ff73d672475c6f726c8c6e92c3b Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 8 May 2024 10:28:11 +0200 Subject: [PATCH] test: mock UserRoleService only in nested test class --- .../etl/processor/web/ConfigControllerTest.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/ConfigControllerTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/ConfigControllerTest.kt index 4ac9db2..af4650d 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/ConfigControllerTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/ConfigControllerTest.kt @@ -89,7 +89,6 @@ abstract class MockSink : Sinks.Many TransformationService::class, GPasConnectionCheckService::class, RestConnectionCheckService::class, - UserRoleService::class ) class ConfigControllerTest { @@ -97,20 +96,17 @@ class ConfigControllerTest { private lateinit var webClient: WebClient private lateinit var requestProcessor: RequestProcessor - private lateinit var userRoleService: UserRoleService private lateinit var connectionCheckUpdateProducer: Sinks.Many @BeforeEach fun setup( @Autowired mockMvc: MockMvc, @Autowired requestProcessor: RequestProcessor, - @Autowired userRoleService: UserRoleService, @Autowired connectionCheckUpdateProducer: Sinks.Many ) { this.mockMvc = mockMvc this.webClient = MockMvcWebClientBuilder.mockMvcSetup(mockMvc).build() this.requestProcessor = requestProcessor - this.userRoleService = userRoleService this.connectionCheckUpdateProducer = connectionCheckUpdateProducer webClient.options.isThrowExceptionOnScriptError = false @@ -256,10 +252,19 @@ class ConfigControllerTest { "app.security.admin-password={noop}very-secret" ] ) + @MockBean( + UserRoleService::class + ) inner class WithUserRolesEnabled { + private lateinit var userRoleService: UserRoleService + @BeforeEach - fun setup() { + fun setup( + @Autowired userRoleService: UserRoleService + ) { webClient.options.isThrowExceptionOnScriptError = false + + this.userRoleService = userRoleService } @Test