Skip to content

refactor(rest): replace MockBean with MockitoBean #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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