mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-10-24 19:28:45 +00:00
import Assertions.assertThat
This adds a static import for assertThat in the Kotlin docs code
This commit is contained in:
parent
523222c24d
commit
62b5b1a77c
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.kt.docs.servlet.test.testmethod
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
@ -50,7 +50,7 @@ class HelloServiceTests {
|
||||
|
||||
@Test
|
||||
fun helloServiceTest() {
|
||||
Assertions.assertThat(messageService.message)
|
||||
assertThat(messageService.message)
|
||||
.contains("user")
|
||||
.contains("ROLE_USER")
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.kt.docs.servlet.test.testmethodmetaannotations
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@ -39,7 +39,7 @@ class WithMockAdminTests {
|
||||
@WithMockAdmin
|
||||
fun getMessageWithMockUserAdminRoles() {
|
||||
val message = messageService.message
|
||||
Assertions.assertThat(message)
|
||||
assertThat(message)
|
||||
.contains("rob")
|
||||
.contains("ROLE_ADMIN")
|
||||
.contains("ROLE_USER")
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.kt.docs.servlet.test.testmethodmetaannotations
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@ -42,7 +42,7 @@ class WithMockUserTests {
|
||||
// end::snippet[]
|
||||
fun getMessageWithMockUserAdminRoles() {
|
||||
val message = messageService.message
|
||||
Assertions.assertThat(message)
|
||||
assertThat(message)
|
||||
.contains("admin")
|
||||
.contains("ROLE_ADMIN")
|
||||
.contains("ROLE_USER")
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.kt.docs.servlet.test.testmethodsetup
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@ -39,7 +39,7 @@ class WithMockUserSampleTests {
|
||||
// tag::snippet[]
|
||||
@Test
|
||||
fun getMessageUnauthenticated() {
|
||||
Assertions.assertThatExceptionOfType(AuthenticationCredentialsNotFoundException::class.java)
|
||||
assertThatExceptionOfType(AuthenticationCredentialsNotFoundException::class.java)
|
||||
.isThrownBy { messageService.getMessage() }
|
||||
}
|
||||
// end::snippet[]
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.kt.docs.servlet.test.testmethodwithmockuser
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@ -41,7 +41,7 @@ class WithMockUserTests {
|
||||
@WithMockUser
|
||||
fun getMessageWithMockUser() {
|
||||
val message = messageService.message
|
||||
Assertions.assertThat(message).contains("user")
|
||||
assertThat(message).contains("user")
|
||||
}
|
||||
// end::mock-user[]
|
||||
|
||||
@ -50,7 +50,7 @@ class WithMockUserTests {
|
||||
@WithMockUser("customUser")
|
||||
fun getMessageWithMockUserCustomUsername() {
|
||||
val message = messageService.message
|
||||
Assertions.assertThat(message).contains("customUser")
|
||||
assertThat(message).contains("customUser")
|
||||
}
|
||||
// end::custom-user[]
|
||||
|
||||
@ -59,7 +59,7 @@ class WithMockUserTests {
|
||||
@WithMockUser(username = "admin", roles = ["USER", "ADMIN"])
|
||||
fun getMessageWithMockUserCustomRoles() {
|
||||
val message = messageService.message
|
||||
Assertions.assertThat(message)
|
||||
assertThat(message)
|
||||
.contains("admin")
|
||||
.contains("ROLE_ADMIN")
|
||||
.contains("ROLE_USER")
|
||||
@ -71,7 +71,7 @@ class WithMockUserTests {
|
||||
@WithMockUser(username = "admin", authorities = ["ADMIN", "USER"])
|
||||
fun getMessageWithMockUserCustomAuthorities() {
|
||||
val message = messageService.message
|
||||
Assertions.assertThat(message)
|
||||
assertThat(message)
|
||||
.contains("admin")
|
||||
.contains("ADMIN")
|
||||
.contains("USER")
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.kt.docs.servlet.test.testmethodwithuserdetails
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@ -46,9 +46,9 @@ class WithCustomUserDetailsTests {
|
||||
@WithUserDetails(value = "customUsername", userDetailsServiceBeanName = "myUserDetailsService")
|
||||
fun getMessageWithUserDetailsServiceBeanName() {
|
||||
val message: String = messageService.getMessage()
|
||||
Assertions.assertThat(message).contains("customUsername");
|
||||
assertThat(message).contains("customUsername");
|
||||
val principal = SecurityContextHolder.getContext().authentication.principal
|
||||
Assertions.assertThat(principal).isInstanceOf(CustomUserDetails::class.java)
|
||||
assertThat(principal).isInstanceOf(CustomUserDetails::class.java)
|
||||
}
|
||||
// end::custom-user-details-service[]
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.kt.docs.servlet.test.testmethodwithuserdetails
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@ -44,7 +44,7 @@ class WithUserDetailsTests {
|
||||
@WithUserDetails
|
||||
fun getMessageWithUserDetails() {
|
||||
val message: String = messageService.message
|
||||
Assertions.assertThat(message).contains("user")
|
||||
assertThat(message).contains("user")
|
||||
}
|
||||
// end::user-details[]
|
||||
|
||||
@ -53,7 +53,7 @@ class WithUserDetailsTests {
|
||||
@WithUserDetails("customUsername")
|
||||
fun getMessageWithUserDetailsCustomUsername() {
|
||||
val message: String = messageService.message
|
||||
Assertions.assertThat(message).contains("customUsername")
|
||||
assertThat(message).contains("customUsername")
|
||||
}
|
||||
// end::user-details-custom-username[]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user