From 608f8bdc5a9a99d323e3719d1a418602dda515a2 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sun, 20 Apr 2025 01:25:04 +0530 Subject: [PATCH] refactor(rest): replace MockBean with MockitoBean --- .../rest/ExamplePoetryRestTestConfiguration.kt | 8 +------- .../test/kotlin/packagename/rest/ExampleResourceTest.kt | 9 ++++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/rest-adapter/src/test/kotlin/packagename/rest/ExamplePoetryRestTestConfiguration.kt b/rest-adapter/src/test/kotlin/packagename/rest/ExamplePoetryRestTestConfiguration.kt index d00c9ec..375bc12 100644 --- a/rest-adapter/src/test/kotlin/packagename/rest/ExamplePoetryRestTestConfiguration.kt +++ b/rest-adapter/src/test/kotlin/packagename/rest/ExamplePoetryRestTestConfiguration.kt @@ -1,14 +1,8 @@ package packagename.rest import org.springframework.boot.SpringBootConfiguration -import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.context.annotation.ComponentScan -import packagename.domain.port.RequestExample @SpringBootConfiguration @ComponentScan(basePackages = ["packagename"]) -class ExamplePoetryRestTestConfiguration { - - @MockBean - private lateinit var requestExample: RequestExample -} +class ExamplePoetryRestTestConfiguration diff --git a/rest-adapter/src/test/kotlin/packagename/rest/ExampleResourceTest.kt b/rest-adapter/src/test/kotlin/packagename/rest/ExampleResourceTest.kt index 10f38c9..8895a88 100644 --- a/rest-adapter/src/test/kotlin/packagename/rest/ExampleResourceTest.kt +++ b/rest-adapter/src/test/kotlin/packagename/rest/ExampleResourceTest.kt @@ -5,18 +5,20 @@ import org.junit.jupiter.api.Test import org.mockito.Mockito import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest +import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.reactive.server.WebTestClient import packagename.domain.exception.ExampleNotFoundException import packagename.domain.model.Example -import packagename.rest.representation.ExampleInfo import packagename.domain.port.RequestExample import packagename.rest.exception.ExampleExceptionResponse +import packagename.rest.representation.ExampleInfo import reactor.core.publisher.Flux import reactor.core.publisher.Mono @WebFluxTest(ExampleResource::class) class ExampleResourceTest { - + @MockitoBean + private lateinit var requestExample: RequestExample companion object { private const val API_URI = "/api/v1/examples" @@ -25,9 +27,6 @@ class ExampleResourceTest { @Autowired private lateinit var webTestClient: WebTestClient - @Autowired - private lateinit var requestExample: RequestExample - @Test fun `should start the rest adapter application`() { assertThat(java.lang.Boolean.TRUE).isTrue