Hey Channel! I need help! Test by kotlin and Sprin...
# spring
s
Hey Channel! I need help! Test by kotlin and Spring Web Flux, service by react Code of AbstractClass with some initialization
Copy code
@ActiveProfiles("test")
@ExtendWith(SpringExtension::class)
@SpringBootTest(classes = [ApiApplication::class], webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWireMock(port = 0)
@ContextConfiguration(initializers = [DBInitializer::class, KeyCloakInitializer::class])
abstract class BaseIntegrationTest {

    @Autowired
    lateinit var webClient: WebTestClient

    @Autowired
    lateinit var applicationContext: ApplicationContext

    @BeforeEach
    fun setUp() {
        webClient = WebTestClient.bindToApplicationContext(applicationContext)
            .apply(springSecurity())
            .configureClient()
            .build()
    }

    fun getTestJwt() = Jwt(
        "token",
        Instant.now(),
        Instant.now().plusSeconds(100),
        mapOf("testHeader" to "testHeader"),
        mapOf("clientId" to "TestExternalSystemCode")
    )

}
Code of TestMethod
Copy code
val request = EmailVerificationStateRequestDto(cus = cusAX, email = testEmail)

        val response = webClient
            .mutateWith(
                mockJwt()
                    .jwt(getTestJwt())
                    .authorities(SimpleGrantedAuthority("emailVerificationState"))
            )
            .post()
            .uri("/emailVerificationState")
            .contentType(MediaType.APPLICATION_JSON)
            .body(Mono.just(request), EmailVerificationStateRequestDto::class.java)
            .exchange()
            .expectStatus().is2xxSuccessful
            .returnResult(EmailVerificationStateResponseDto::class.java)
and i got error log: https://kotlinlang.slack.com/files/T09229ZC6/F04K4PBAR24 please tell my why? oh yes, method controller
Copy code
@PreAuthorize("hasAuthority('emailVerificationState')")
    @PostMapping("/emailVerificationState")
    fun emailVerificationState(
        @AuthenticationPrincipal currentUser: Jwt?,
        @RequestBody @Validated emailVerificationStateRequestDto: EmailVerificationStateRequestDto
    ): Mono<EmailVerificationStateResponseDto> {
        return verificationService.getEmailStatusVerification(emailVerificationStateRequestDto)
    }
s
I would guess this is an issue with dependency versions
👍🏻 1
Are you using Spring Boot for dependency management?
s
Boot
s
As a first step I would check that you are following one of the dependency management approaches given in the docs
s
Thanks
I will check and write message here
this
Copy code
testImplementation("io.projectreactor:reactor-core:3.5.0")
change to this
Copy code
testImplementation("io.projectreactor:reactor-core:3.4.24")
and all ok!
thank you