Browse Source

Use static imports for AssertJ assertions in Kotlin tests

pull/29928/head
Sam Brannen 3 years ago
parent
commit
70aaec2a8d
  1. 14
      spring-web/src/test/kotlin/org/springframework/http/KotlinResponseEntityTests.kt

14
spring-web/src/test/kotlin/org/springframework/http/KotlinResponseEntityTests.kt

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
package org.springframework.http
import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
/**
@ -30,17 +30,17 @@ class KotlinResponseEntityTests { @@ -30,17 +30,17 @@ class KotlinResponseEntityTests {
fun ofNullable() {
val entity = 42
val responseEntity = ResponseEntity.ofNullable(entity)
Assertions.assertThat(responseEntity).isNotNull()
Assertions.assertThat(responseEntity.statusCode).isEqualTo(HttpStatus.OK)
Assertions.assertThat(responseEntity.body as Int).isEqualTo(entity)
assertThat(responseEntity).isNotNull()
assertThat(responseEntity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(responseEntity.body as Int).isEqualTo(entity)
}
@Test
fun ofNullNullable() {
val responseEntity = ResponseEntity.ofNullable<Int>(null)
Assertions.assertThat(responseEntity).isNotNull()
Assertions.assertThat(responseEntity.statusCode).isEqualTo(HttpStatus.NOT_FOUND)
Assertions.assertThat(responseEntity.body).isNull()
assertThat(responseEntity).isNotNull()
assertThat(responseEntity.statusCode).isEqualTo(HttpStatus.NOT_FOUND)
assertThat(responseEntity.body).isNull()
}
}

Loading…
Cancel
Save