- Follow JB Nizet JPA guidelines - Use Mockk and SpringMockK - Document Maven configuration in addition to Gradle one - Leverage CrudRepository.findIdOrNull extension - Upgrade to Spring Boot 2.1.3 - Various refactoring and improvements Closes gh-22 Closes gh-23
43 lines
1.4 KiB
Kotlin
43 lines
1.4 KiB
Kotlin
package blog
|
|
|
|
import org.assertj.core.api.Assertions.*
|
|
import org.junit.jupiter.api.AfterAll
|
|
import org.junit.jupiter.api.BeforeAll
|
|
import org.junit.jupiter.api.Test
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
import org.springframework.boot.test.context.SpringBootTest
|
|
import org.springframework.boot.test.web.client.TestRestTemplate
|
|
import org.springframework.boot.test.web.client.getForEntity
|
|
import org.springframework.http.HttpStatus
|
|
|
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
class IntegrationTests(@Autowired val restTemplate: TestRestTemplate) {
|
|
|
|
@BeforeAll
|
|
fun setup() {
|
|
println(">> Setup")
|
|
}
|
|
|
|
@Test
|
|
fun `Assert blog page title, content and status code`() {
|
|
println(">> Assert blog page title, content and status code")
|
|
val entity = restTemplate.getForEntity<String>("/")
|
|
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
|
|
assertThat(entity.body).contains("<h1>Blog</h1>", "Reactor")
|
|
}
|
|
|
|
@Test
|
|
fun `Assert article page title, content and status code`() {
|
|
println(">> Assert article page title, content and status code")
|
|
val title = "Reactor Aluminium has landed"
|
|
val entity = restTemplate.getForEntity<String>("/article/${title.toSlug()}")
|
|
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
|
|
assertThat(entity.body).contains(title, "Lorem ipsum", "dolor sit amet")
|
|
}
|
|
|
|
@AfterAll
|
|
fun teardown() {
|
|
println(">> Tear down")
|
|
}
|
|
|
|
} |