From d7cc02f3d7dc1205128f40dc433b2dfcfa1fca51 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 7 Mar 2025 08:26:12 +0100 Subject: [PATCH] Use the java.util List.of() instead of the AssetJ Lists class Signed-off-by: Antoine Rey --- .../petclinic/owner/OwnerControllerTests.java | 12 ++++++------ .../samples/petclinic/owner/PetControllerTests.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java b/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java index 426ca5c24..9b36dd451 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java @@ -16,7 +16,6 @@ package org.springframework.samples.petclinic.owner; -import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledInNativeImage; @@ -31,6 +30,7 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import java.time.LocalDate; +import java.util.List; import java.util.Optional; import static org.hamcrest.Matchers.empty; @@ -92,9 +92,9 @@ class OwnerControllerTests { Owner george = george(); given(this.owners.findByLastNameStartingWith(eq("Franklin"), any(Pageable.class))) - .willReturn(new PageImpl<>(Lists.newArrayList(george))); + .willReturn(new PageImpl<>(List.of(george))); - given(this.owners.findAll(any(Pageable.class))).willReturn(new PageImpl<>(Lists.newArrayList(george))); + given(this.owners.findAll(any(Pageable.class))).willReturn(new PageImpl<>(List.of(george))); given(this.owners.findById(TEST_OWNER_ID)).willReturn(Optional.of(george)); Visit visit = new Visit(); @@ -143,14 +143,14 @@ class OwnerControllerTests { @Test void testProcessFindFormSuccess() throws Exception { - Page tasks = new PageImpl<>(Lists.newArrayList(george(), new Owner())); + Page tasks = new PageImpl<>(List.of(george(), new Owner())); when(this.owners.findByLastNameStartingWith(anyString(), any(Pageable.class))).thenReturn(tasks); mockMvc.perform(get("/owners?page=1")).andExpect(status().isOk()).andExpect(view().name("owners/ownersList")); } @Test void testProcessFindFormByLastName() throws Exception { - Page tasks = new PageImpl<>(Lists.newArrayList(george())); + Page tasks = new PageImpl<>(List.of(george())); when(this.owners.findByLastNameStartingWith(eq("Franklin"), any(Pageable.class))).thenReturn(tasks); mockMvc.perform(get("/owners?page=1").param("lastName", "Franklin")) .andExpect(status().is3xxRedirection()) @@ -159,7 +159,7 @@ class OwnerControllerTests { @Test void testProcessFindFormNoOwnersFound() throws Exception { - Page tasks = new PageImpl<>(Lists.newArrayList()); + Page tasks = new PageImpl<>(List.of()); when(this.owners.findByLastNameStartingWith(eq("Unknown Surname"), any(Pageable.class))).thenReturn(tasks); mockMvc.perform(get("/owners?page=1").param("lastName", "Unknown Surname")) .andExpect(status().isOk()) diff --git a/src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java index 9a6134cbb..6fc9a849e 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java @@ -16,7 +16,6 @@ package org.springframework.samples.petclinic.owner; -import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -30,6 +29,7 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; import java.time.LocalDate; +import java.util.List; import java.util.Optional; import static org.mockito.BDDMockito.given; @@ -66,7 +66,7 @@ class PetControllerTests { PetType cat = new PetType(); cat.setId(3); cat.setName("hamster"); - given(this.owners.findPetTypes()).willReturn(Lists.newArrayList(cat)); + given(this.owners.findPetTypes()).willReturn(List.of(cat)); Owner owner = new Owner(); Pet pet = new Pet();