diff --git a/src/test/kotlin/org/springframework/samples/petclinic/model/ValidatorTests.kt b/src/test/kotlin/org/springframework/samples/petclinic/model/ValidatorTests.kt index 3f648d9..9d1836a 100644 --- a/src/test/kotlin/org/springframework/samples/petclinic/model/ValidatorTests.kt +++ b/src/test/kotlin/org/springframework/samples/petclinic/model/ValidatorTests.kt @@ -32,7 +32,7 @@ class ValidatorTests { val validator = createValidator() val constraintViolations = validator.validate(person) - assertThat(constraintViolations.size).isEqualTo(1) + assertThat(constraintViolations).hasSize(1) val violation = constraintViolations.iterator().next() assertThat(violation.propertyPath.toString()).isEqualTo("firstName") assertThat(violation.message).isEqualTo("must not be empty") diff --git a/src/test/kotlin/org/springframework/samples/petclinic/owner/OwnerControllerTest.kt b/src/test/kotlin/org/springframework/samples/petclinic/owner/OwnerControllerTest.kt index 3ab9ce1..c4df90d 100644 --- a/src/test/kotlin/org/springframework/samples/petclinic/owner/OwnerControllerTest.kt +++ b/src/test/kotlin/org/springframework/samples/petclinic/owner/OwnerControllerTest.kt @@ -193,8 +193,8 @@ class OwnerControllerTest { @Suppress("UNCHECKED_CAST") override fun matches(item: Any?): Boolean { - val pets : List = item as List - val pet = pets.get(0) + val pets : Set = item as Set + val pet = pets.iterator().next() return !pet.getVisits().isEmpty() } }))) .andExpect(view().name("owners/ownerDetails")) diff --git a/src/test/kotlin/org/springframework/samples/petclinic/owner/PetTypeFormatterTest.kt b/src/test/kotlin/org/springframework/samples/petclinic/owner/PetTypeFormatterTest.kt index 9944548..b868b43 100644 --- a/src/test/kotlin/org/springframework/samples/petclinic/owner/PetTypeFormatterTest.kt +++ b/src/test/kotlin/org/springframework/samples/petclinic/owner/PetTypeFormatterTest.kt @@ -1,13 +1,13 @@ package org.springframework.samples.petclinic.owner -import org.junit.jupiter.api.Assertions.assertEquals +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Assertions.assertThrows import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.mockito.Mock -import org.mockito.Mockito +import org.mockito.BDDMockito.given import org.springframework.test.context.junit.jupiter.SpringExtension import java.text.ParseException import java.util.* @@ -35,21 +35,21 @@ class PetTypeFormatterTest { val petType = PetType() petType.name = "Hamster" val petTypeName = this.petTypeFormatter.print(petType, Locale.ENGLISH) - assertEquals("Hamster", petTypeName) + assertThat("Hamster").isEqualTo(petTypeName) } @Test @Throws(ParseException::class) fun shouldParse() { - Mockito.`when`(this.pets.findPetTypes()).thenReturn(makePetTypes()) + given(this.pets.findPetTypes()).willReturn(makePetTypes()) val petType = petTypeFormatter.parse("Bird", Locale.ENGLISH) - assertEquals("Bird", petType.name) + assertThat("Bird").isEqualTo(petType.name) } @Test @Throws(ParseException::class) fun shouldThrowParseException() { - Mockito.`when`(this.pets.findPetTypes()).thenReturn(makePetTypes()) + given(this.pets.findPetTypes()).willReturn(makePetTypes()) assertThrows(ParseException::class.java, { petTypeFormatter.parse("Fish", Locale.ENGLISH) }) }