From 8a2daa4a0c59e0ae1bba40da8f6f4451b87018d6 Mon Sep 17 00:00:00 2001 From: Nate Danner Date: Thu, 18 Apr 2024 23:17:59 +0000 Subject: [PATCH] refactor: Common static analysis issues Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.CommonStaticAnalysis?organizationId=TW9kZXJuZQ%3D%3D Co-authored-by: Moderne --- .../samples/petclinic/owner/OwnerControllerTests.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 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 78b81237152..0ceec4714b9 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java @@ -142,14 +142,14 @@ void testInitFindForm() throws Exception { @Test void testProcessFindFormSuccess() throws Exception { - Page tasks = new PageImpl(Lists.newArrayList(george(), new Owner())); + Page tasks = new PageImpl<>(Lists.newArrayList(george(), new Owner())); Mockito.when(this.owners.findByLastName(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<>(Lists.newArrayList(george())); Mockito.when(this.owners.findByLastName(eq("Franklin"), any(Pageable.class))).thenReturn(tasks); mockMvc.perform(get("/owners?page=1").param("lastName", "Franklin")) .andExpect(status().is3xxRedirection()) @@ -158,7 +158,7 @@ void testProcessFindFormByLastName() throws Exception { @Test void testProcessFindFormNoOwnersFound() throws Exception { - Page tasks = new PageImpl(Lists.newArrayList()); + Page tasks = new PageImpl<>(Lists.newArrayList()); Mockito.when(this.owners.findByLastName(eq("Unknown Surname"), any(Pageable.class))).thenReturn(tasks); mockMvc.perform(get("/owners?page=1").param("lastName", "Unknown Surname")) .andExpect(status().isOk()) @@ -231,10 +231,7 @@ public boolean matches(Object item) { @SuppressWarnings("unchecked") List pets = (List) item; Pet pet = pets.get(0); - if (pet.getVisits().isEmpty()) { - return false; - } - return true; + return !pet.getVisits().isEmpty(); } @Override