diff --git a/pom.xml b/pom.xml index 4cc8bd611..4d07f379e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,13 +6,13 @@ org.springframework.samples spring-petclinic 2.3.0.BUILD-SNAPSHOT + petclinic org.springframework.boot spring-boot-starter-parent 2.3.3.RELEASE - petclinic @@ -144,11 +144,6 @@ 4.13 test - - junit - junit - test - org.projectlombok lombok @@ -301,6 +296,56 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + unit-tests + test + + test + + + false + + CET + + + **/*Test + + + **/*IntegrationTest + + + + + integration-tests + integration-test + + test + + + false + + CET + + + **/*IntegrationTest + + + **/*Test + + + + + @@ -405,4 +450,5 @@ + diff --git a/src/main/java/org/springframework/samples/petclinic/controller/PetController.java b/src/main/java/org/springframework/samples/petclinic/controller/PetController.java index d0d8ca9d7..17f11a3c4 100644 --- a/src/main/java/org/springframework/samples/petclinic/controller/PetController.java +++ b/src/main/java/org/springframework/samples/petclinic/controller/PetController.java @@ -47,13 +47,11 @@ class PetController { private final PetService petService; - private final PetTypeService petTypeService; @Autowired PetController(OwnerService ownerService, PetService petService, PetTypeService petTypeService) { this.ownerService = ownerService; this.petService = petService; - this.petTypeService = petTypeService; } @ModelAttribute("types") @@ -87,10 +85,16 @@ class PetController { @PostMapping(CommonEndPoint.PETS_NEW) public String processCreationForm(@ModelAttribute(CommonAttribute.OWNER) OwnerDTO owner, @ModelAttribute(CommonAttribute.PET) @Valid PetDTO pet, BindingResult result, ModelMap model) { - if (StringUtils.hasLength(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null) { - result.rejectValue(CommonAttribute.NAME, CommonError.DUPLICATE_ARGS, CommonError.DUPLICATE_MESSAGE); + if (owner == null) { + result.rejectValue(CommonAttribute.OWNER, CommonError.NOT_FOUND_ARGS, CommonError.NOT_FOUND_MESSAGE); + } else { + if (StringUtils.hasLength(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null) { + result.rejectValue(CommonAttribute.NAME, CommonError.DUPLICATE_ARGS, CommonError.DUPLICATE_MESSAGE); + } + owner.addPet(pet); } - owner.addPet(pet); + + if (result.hasErrors()) { model.put(CommonAttribute.PET, pet); return CommonView.PET_CREATE_OR_UPDATE; diff --git a/src/test/java/org/springframework/samples/petclinic/PetclinicIntegrationTests.java b/src/test/java/org/springframework/samples/petclinic/PetclinicIT.java similarity index 72% rename from src/test/java/org/springframework/samples/petclinic/PetclinicIntegrationTests.java rename to src/test/java/org/springframework/samples/petclinic/PetclinicIT.java index 90736badb..1eaf8a17d 100644 --- a/src/test/java/org/springframework/samples/petclinic/PetclinicIntegrationTests.java +++ b/src/test/java/org/springframework/samples/petclinic/PetclinicIT.java @@ -16,19 +16,24 @@ package org.springframework.samples.petclinic; +import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.samples.petclinic.repository.VetRepository; +@Slf4j @SpringBootTest -class PetclinicIntegrationTests { +class PetclinicIT { @Autowired private VetRepository vets; @Test void testFindAll() throws Exception { + log.info("==================================================================================================="); + log.info("=== in PetclinicIT ==="); + log.info("==================================================================================================="); vets.findAll(); vets.findAll(); // served from cache } diff --git a/src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerIntegrationTest.java b/src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerIntegrationTest.java new file mode 100644 index 000000000..245242588 --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerIntegrationTest.java @@ -0,0 +1,125 @@ +package org.springframework.samples.petclinic.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.samples.petclinic.common.CommonAttribute; +import org.springframework.samples.petclinic.common.CommonEndPoint; +import org.springframework.samples.petclinic.common.CommonView; +import org.springframework.samples.petclinic.dto.OwnerDTO; +import org.springframework.samples.petclinic.dto.PetDTO; +import org.springframework.samples.petclinic.dto.PetTypeDTO; +import org.springframework.samples.petclinic.dto.VisitDTO; +import org.springframework.samples.petclinic.model.Owner; +import org.springframework.samples.petclinic.repository.OwnerRepository; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +import java.nio.charset.StandardCharsets; +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +@Slf4j +@SpringBootTest +@AutoConfigureMockMvc +class OwnerControllerIntegrationTest { + + private static final int TEST_OWNER_ID = 1; + + @Autowired + private MockMvc mockMvc; + + @Autowired + private OwnerRepository ownerRepository; + + static private OwnerDTO george; + + @BeforeAll + static void beforeAll() { + george = new OwnerDTO(); + george.setFirstName("George"); + george.setLastName("Franklin"); + george.setAddress("110 W. Liberty St."); + george.setCity("Madison"); + george.setTelephone("6085551023"); + PetDTO max = new PetDTO(); + PetTypeDTO dog = new PetTypeDTO(); + dog.setName("dog"); + max.setType(dog); + max.setName("Max"); + max.setBirthDate(LocalDate.now()); + // george.setPetsInternal(Collections.singleton(max)); + VisitDTO visit = new VisitDTO(); + visit.setDate(LocalDate.now()); + } + + @Test + @Tag("initCreationForm") + @DisplayName("Verify that the view for new Owner is initialised with new OwnerDTO") + void testInitCreationForm() throws Exception { + final MvcResult result = mockMvc.perform(get(CommonEndPoint.OWNERS_NEW)).andExpect(status().isOk()) + .andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE)).andReturn(); + + OwnerDTO found = (OwnerDTO) Objects.requireNonNull(result.getModelAndView()).getModel() + .get(CommonAttribute.OWNER); + + assertThat(found).isEqualToComparingFieldByField(new OwnerDTO()); + } + + @Test + @Tag("processCreationForm") + void testProcessCreationFormSuccess() throws Exception { + ObjectMapper mapper = new ObjectMapper(); + + String json = mapper.writeValueAsString(george); + + final MvcResult result = mockMvc + .perform(post(CommonEndPoint.OWNERS_NEW).flashAttr(CommonAttribute.OWNER, george)) + .andExpect(status().is3xxRedirection()).andReturn(); + + json = result.getResponse().getContentAsString(StandardCharsets.UTF_8); + OwnerDTO found = mapper.readValue(json, OwnerDTO.class); + + assertThat(found).isEqualTo(george); + } + + @Test + @Disabled + @Tag("processFindForm") + @DisplayName("Verify that we get the right view and all Owners") + void testProcessFindFormSuccess() throws Exception { + List expected = ownerRepository.findAll(); + + final MvcResult result = mockMvc.perform(get(CommonEndPoint.OWNERS)) + .andExpect(MockMvcResultMatchers.status().isOk()).andExpect(view().name(CommonView.OWNER_OWNERS_LIST)) + .andReturn(); + + Collection founds = (Collection) result.getModelAndView().getModel() + .get(CommonAttribute.SELECTIONS); + + int[] position = new int[] { 0 }; + + founds.forEach(ownerDTO -> { + Owner owner = expected.get(position[0]++); + + assertThat(owner.getId()).isEqualTo(ownerDTO.getId()); + assertThat(owner.getFirstName()).isEqualTo(ownerDTO.getFirstName()); + assertThat(owner.getLastName()).isEqualTo(ownerDTO.getLastName()); + assertThat(owner.getTelephone()).isEqualTo(ownerDTO.getTelephone()); + assertThat(owner.getAddress()).isEqualTo(ownerDTO.getAddress()); + assertThat(owner.getCity()).isEqualTo(ownerDTO.getCity()); + }); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerTests.java b/src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerTest.java similarity index 96% rename from src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerTests.java rename to src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerTest.java index ac1018907..3f0c58a16 100644 --- a/src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/controller/OwnerControllerTest.java @@ -24,6 +24,7 @@ import org.assertj.core.util.Lists; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -58,7 +59,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * @author Paul-Emmanuel DOS SANTOS FACAO */ @WebMvcTest(OwnerController.class) -class OwnerControllerTests { +class OwnerControllerTest { private static final int TEST_OWNER_ID = 1; @@ -98,6 +99,7 @@ class OwnerControllerTests { @Test @Tag("initCreationForm") + @DisplayName("Verify that we get the right view and the right attribute name") void testInitCreationForm() throws Exception { mockMvc.perform(get(CommonEndPoint.OWNERS_NEW)).andExpect(status().isOk()) .andExpect(model().attributeExists(CommonAttribute.OWNER)) @@ -107,7 +109,7 @@ class OwnerControllerTests { @Test @Tag("processCreationForm") void testProcessCreationFormSuccess() throws Exception { - mockMvc.perform(post("/owners/new").param(CommonAttribute.OWNER_FIRST_NAME, "Joe") + mockMvc.perform(post(CommonEndPoint.OWNERS_NEW).param(CommonAttribute.OWNER_FIRST_NAME, "Joe") .param(CommonAttribute.OWNER_LAST_NAME, "Bloggs") .param(CommonAttribute.OWNER_ADDRESS, "123 Caramel Street").param(CommonAttribute.OWNER_CITY, "London") .param(CommonAttribute.OWNER_PHONE, "01316761638")).andExpect(status().is3xxRedirection()); @@ -134,6 +136,7 @@ class OwnerControllerTests { @Test @Tag("processFindForm") + @DisplayName("Verify that we get the right view and all Owners list") void testProcessFindFormSuccess() throws Exception { given(this.owners.findByLastName("")).willReturn(Lists.newArrayList(george, new OwnerDTO())); diff --git a/src/test/java/org/springframework/samples/petclinic/controller/PetControllerIntegrationTest.java b/src/test/java/org/springframework/samples/petclinic/controller/PetControllerIntegrationTest.java new file mode 100644 index 000000000..88266b3c5 --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/controller/PetControllerIntegrationTest.java @@ -0,0 +1,94 @@ +package org.springframework.samples.petclinic.controller; + +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.samples.petclinic.common.CommonAttribute; +import org.springframework.samples.petclinic.common.CommonEndPoint; +import org.springframework.samples.petclinic.common.CommonView; +import org.springframework.samples.petclinic.dto.OwnerDTO; +import org.springframework.samples.petclinic.dto.PetDTO; +import org.springframework.samples.petclinic.dto.PetTypeDTO; +import org.springframework.samples.petclinic.model.PetType; +import org.springframework.samples.petclinic.repository.OwnerRepository; +import org.springframework.samples.petclinic.repository.PetRepository; +import org.springframework.samples.petclinic.service.OwnerService; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; + +import java.time.LocalDate; +import java.util.List; +import java.util.Objects; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +@Slf4j +@SpringBootTest +@AutoConfigureMockMvc +class PetControllerIntegrationTest { + + private static final int TEST_OWNER_ID = 5; + + @Autowired + private MockMvc mockMvc; + + @Autowired + private OwnerService ownerService; + + @Autowired + private PetRepository petRepository; + + private OwnerDTO ownerDTO; + + private PetDTO petDTO; + + @BeforeEach + void beforeEach() { + ownerDTO = ownerService.findById(TEST_OWNER_ID); + petDTO = new PetDTO(); + PetType type = petRepository.findPetTypes().get(1); + PetTypeDTO typeDTO = new PetTypeDTO(); + typeDTO.setId(type.getId()); + typeDTO.setName(type.getName()); + petDTO.setType(typeDTO); + petDTO.setName("Max"); + petDTO.setBirthDate(LocalDate.now()); + } + + @Test + @Tag("initCreationForm") + @DisplayName("Verify that the view for new Pet is initialised with new PetDTO") + void testInitCreationForm() throws Exception { + + final MvcResult result = mockMvc + .perform(get(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, TEST_OWNER_ID) + .flashAttr(CommonAttribute.OWNER, ownerDTO)) + .andExpect(status().isOk()).andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE)).andReturn(); + + PetDTO petFound = (PetDTO) Objects.requireNonNull(result.getModelAndView()).getModel().get(CommonAttribute.PET); + + assertThat(petFound.getOwner()).isEqualTo(ownerDTO); + } + + @Test + @Tag("processCreationForm") + @DisplayName("Verify that save new Pet and display the view") + void testProcessCreationFormSuccess() throws Exception { + + final MvcResult result = mockMvc + .perform(post(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, TEST_OWNER_ID) + .flashAttr(CommonAttribute.OWNER, ownerDTO).flashAttr(CommonAttribute.PET, petDTO)) + .andExpect(status().is3xxRedirection()).andExpect(view().name(CommonView.OWNER_OWNERS_ID_R)) + .andReturn(); + + List found = ownerService.findById(TEST_OWNER_ID).getPets(); + + assertThat(found).contains(petDTO); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/controller/PetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/controller/PetControllerTest.java similarity index 58% rename from src/test/java/org/springframework/samples/petclinic/controller/PetControllerTests.java rename to src/test/java/org/springframework/samples/petclinic/controller/PetControllerTest.java index 717507c5b..4127dda58 100644 --- a/src/test/java/org/springframework/samples/petclinic/controller/PetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/controller/PetControllerTest.java @@ -25,6 +25,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -53,10 +54,9 @@ import org.springframework.test.web.servlet.MockMvc; */ @WebMvcTest(value = PetController.class, includeFilters = @ComponentScan.Filter(value = PetTypeFormatter.class, type = FilterType.ASSIGNABLE_TYPE)) -class PetControllerTests { +class PetControllerTest { private static final int TEST_OWNER_ID = 1; - private static final int TEST_PET_ID = 1; @Autowired @@ -72,7 +72,7 @@ class PetControllerTests { private OwnerService ownerService; @BeforeEach - void setup() { + void beforeEach() { PetTypeDTO cat = new PetTypeDTO(); cat.setId(3); cat.setName("hamster"); @@ -84,6 +84,7 @@ class PetControllerTests { @Test @Tag("initCreationForm") + @DisplayName("Verify that Pet creation form is initialized") void testInitCreationForm() throws Exception { mockMvc.perform(get(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, TEST_OWNER_ID)) .andExpect(status().isOk()).andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE)) @@ -92,24 +93,74 @@ class PetControllerTests { @Test @Tag("processCreationForm") - void testProcessCreationFormSuccess() throws Exception { + @DisplayName("Verify that call the right view with parameters when attempt to create Pet") + void givenPet_WhenPostPet_thenRedirectToOwnerForm() throws Exception { mockMvc.perform(post(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, TEST_OWNER_ID) - .param(CommonAttribute.PET_NAME, "Betty").param(CommonAttribute.PET_TYPE, "hamster") - .param(CommonAttribute.PET_BIRTH_DATE, "2015-02-12")).andExpect(status().is3xxRedirection()) - .andExpect(view().name(CommonView.OWNER_OWNERS_ID_R)); + .param(CommonAttribute.PET_NAME, "Betty") + .param(CommonAttribute.PET_TYPE, "hamster") + .param(CommonAttribute.PET_BIRTH_DATE, "2015-02-12")) + .andExpect(status().is3xxRedirection()) + .andExpect(view().name(CommonView.OWNER_OWNERS_ID_R)); } @Test @Tag("processCreationForm") - void testProcessCreationFormHasErrors() throws Exception { + @DisplayName("Verify that return to Pet creation form when pet has no name") + void givenPetWithNoName_WhenPostPet_thenReturnToCreationForm() throws Exception { mockMvc.perform(post(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, TEST_OWNER_ID) - .param(CommonAttribute.PET_NAME, "Betty").param(CommonAttribute.PET_BIRTH_DATE, "2015-02-12")) - .andExpect(model().attributeHasNoErrors(CommonAttribute.OWNER)) - .andExpect(model().attributeHasErrors(CommonAttribute.PET)) - .andExpect(model().attributeHasFieldErrors(CommonAttribute.PET, CommonAttribute.PET_TYPE)) - .andExpect(model().attributeHasFieldErrorCode(CommonAttribute.PET, CommonAttribute.PET_TYPE, - CommonError.REQUIRED_ARGS)) - .andExpect(status().isOk()).andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE)); + .param(CommonAttribute.PET_TYPE, "hamster") + .param(CommonAttribute.PET_BIRTH_DATE, "2015-02-12")) + .andExpect(model().attributeHasNoErrors(CommonAttribute.OWNER)) + .andExpect(model().attributeHasErrors(CommonAttribute.PET)) + .andExpect(model().attributeHasFieldErrors(CommonAttribute.PET, CommonAttribute.PET_NAME)) + .andExpect(model().attributeHasFieldErrorCode(CommonAttribute.PET, CommonAttribute.PET_NAME, CommonError.REQUIRED_ARGS)) + .andExpect(status().isOk()) + .andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE)); + } + + @Test + @Tag("processCreationForm") + @DisplayName("Verify that return to Pet creation form when pet has no type") + void givenPetWithNoType_WhenPostPet_thenReturnToCreationForm() throws Exception { + mockMvc.perform(post(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, TEST_OWNER_ID) + .param(CommonAttribute.PET_NAME, "Betty") + .param(CommonAttribute.PET_BIRTH_DATE, "2015-02-12")) + .andExpect(model().attributeHasNoErrors(CommonAttribute.OWNER)) + .andExpect(model().attributeHasErrors(CommonAttribute.PET)) + .andExpect(model().attributeHasFieldErrors(CommonAttribute.PET, CommonAttribute.PET_TYPE)) + .andExpect(model().attributeHasFieldErrorCode(CommonAttribute.PET, CommonAttribute.PET_TYPE, CommonError.REQUIRED_ARGS)) + .andExpect(status().isOk()) + .andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE)); + } + + @Test + @Tag("processCreationForm") + @DisplayName("Verify that return to Pet creation form when pet has wrong Owner ID") + void givenPetWithWrongOwnerId_WhenPostPet_thenReturnToCreationForm() throws Exception { + mockMvc.perform(post(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, 22) + .param(CommonAttribute.PET_NAME, "Betty") + .param(CommonAttribute.PET_TYPE, "hamster") + .param(CommonAttribute.PET_BIRTH_DATE, "2015-02-12")) + .andExpect(model().attributeHasErrors(CommonAttribute.PET)) + .andExpect(model().attributeHasFieldErrorCode(CommonAttribute.PET, CommonAttribute.OWNER, CommonError.NOT_FOUND_ARGS)) + .andExpect(status().isOk()) + .andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE)); + } + + @Test + @Tag("processCreationForm") + @DisplayName("Verify that return to Pet creation form when pet has no birth date") + void givenPetWithNoBirthDate_WhenPostPet_thenReturnToCreationForm() throws Exception { + + mockMvc.perform(post(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, TEST_OWNER_ID) + .param(CommonAttribute.PET_NAME, "Betty") + .param(CommonAttribute.PET_TYPE, "hamster")) + .andExpect(model().attributeHasNoErrors(CommonAttribute.OWNER)) + .andExpect(model().attributeHasErrors(CommonAttribute.PET)) + .andExpect(model().attributeHasFieldErrors(CommonAttribute.PET, CommonAttribute.PET_BIRTH_DATE)) + .andExpect(model().attributeHasFieldErrorCode(CommonAttribute.PET, CommonAttribute.PET_BIRTH_DATE, CommonError.REQUIRED_ARGS)) + .andExpect(status().isOk()) + .andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE)); } @Test diff --git a/src/test/java/org/springframework/samples/petclinic/controller/VetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/controller/VetControllerTest.java similarity index 99% rename from src/test/java/org/springframework/samples/petclinic/controller/VetControllerTests.java rename to src/test/java/org/springframework/samples/petclinic/controller/VetControllerTest.java index c3eef01b1..0b27dff3f 100644 --- a/src/test/java/org/springframework/samples/petclinic/controller/VetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/controller/VetControllerTest.java @@ -48,7 +48,7 @@ import org.springframework.test.web.servlet.ResultActions; * @author Paul-Emmanuel DOS SANTOS FACAO */ @WebMvcTest(VetController.class) -class VetControllerTests { +class VetControllerTest { @Autowired private MockMvc mockMvc; diff --git a/src/test/java/org/springframework/samples/petclinic/controller/VisitControllerTests.java b/src/test/java/org/springframework/samples/petclinic/controller/VisitControllerTest.java similarity index 99% rename from src/test/java/org/springframework/samples/petclinic/controller/VisitControllerTests.java rename to src/test/java/org/springframework/samples/petclinic/controller/VisitControllerTest.java index 718bab0f0..cd7d13927 100644 --- a/src/test/java/org/springframework/samples/petclinic/controller/VisitControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/controller/VisitControllerTest.java @@ -43,7 +43,7 @@ import org.springframework.test.web.servlet.MockMvc; * @author Colin But */ @WebMvcTest(VisitController.class) -class VisitControllerTests { +class VisitControllerTest { private static final int TEST_PET_ID = 1; diff --git a/src/test/java/org/springframework/samples/petclinic/formater/PetTypeDTOFormatterTests.java b/src/test/java/org/springframework/samples/petclinic/formater/PetTypeDTOFormatterTest.java similarity index 98% rename from src/test/java/org/springframework/samples/petclinic/formater/PetTypeDTOFormatterTests.java rename to src/test/java/org/springframework/samples/petclinic/formater/PetTypeDTOFormatterTest.java index a9e8f2e72..ab9b23748 100644 --- a/src/test/java/org/springframework/samples/petclinic/formater/PetTypeDTOFormatterTests.java +++ b/src/test/java/org/springframework/samples/petclinic/formater/PetTypeDTOFormatterTest.java @@ -43,7 +43,7 @@ import static org.mockito.BDDMockito.given; * @author Colin But */ @ExtendWith(MockitoExtension.class) -class PetTypeDTOFormatterTests { +class PetTypeDTOFormatterTest { @Mock private PetService petService; diff --git a/src/test/java/org/springframework/samples/petclinic/formater/PetTypeFormatterTests.java b/src/test/java/org/springframework/samples/petclinic/formater/PetTypeFormatterTest.java similarity index 98% rename from src/test/java/org/springframework/samples/petclinic/formater/PetTypeFormatterTests.java rename to src/test/java/org/springframework/samples/petclinic/formater/PetTypeFormatterTest.java index 902048f72..6404a7142 100644 --- a/src/test/java/org/springframework/samples/petclinic/formater/PetTypeFormatterTests.java +++ b/src/test/java/org/springframework/samples/petclinic/formater/PetTypeFormatterTest.java @@ -43,7 +43,7 @@ import static org.mockito.BDDMockito.given; * @author Colin But */ @ExtendWith(MockitoExtension.class) -class PetTypeFormatterTests { +class PetTypeFormatterTest { @Mock private PetService petService; diff --git a/src/test/java/org/springframework/samples/petclinic/model/VetTests.java b/src/test/java/org/springframework/samples/petclinic/model/VetTest.java similarity index 98% rename from src/test/java/org/springframework/samples/petclinic/model/VetTests.java rename to src/test/java/org/springframework/samples/petclinic/model/VetTest.java index 45066fe9c..65b50f5f7 100644 --- a/src/test/java/org/springframework/samples/petclinic/model/VetTests.java +++ b/src/test/java/org/springframework/samples/petclinic/model/VetTest.java @@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Dave Syer */ -class VetTests { +class VetTest { @Test void testSerialization() { diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTest.java similarity index 98% rename from src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java rename to src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTest.java index 6088c8ae0..691702635 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java +++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTest.java @@ -49,7 +49,7 @@ import org.springframework.transaction.annotation.Transactional; *
  • Dependency Injection of test fixture instances, meaning that we * don't need to perform application context lookups. See the use of * {@link Autowired @Autowired} on the {@link - * ClinicServiceTests#clinicService clinicService} instance variable, which uses + * ClinicServiceTest#clinicService clinicService} instance variable, which uses * autowiring by type. *
  • Transaction management, meaning each test method is executed in * its own transaction, which is automatically rolled back by default. Thus, even if tests @@ -67,7 +67,7 @@ import org.springframework.transaction.annotation.Transactional; * @author Dave Syer */ @DataJpaTest(includeFilters = @ComponentScan.Filter(Service.class)) -class ClinicServiceTests { +class ClinicServiceTest { @Autowired protected OwnerRepository owners; diff --git a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTest.java similarity index 98% rename from src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java rename to src/test/java/org/springframework/samples/petclinic/system/CrashControllerTest.java index 6bafc7499..aa68db2b0 100644 --- a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTest.java @@ -36,7 +36,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. // Waiting https://github.com/spring-projects/spring-boot/issues/5574 @Disabled @WebMvcTest(controllers = CrashController.class) -class CrashControllerTests { +class CrashControllerTest { @Autowired private MockMvc mockMvc; diff --git a/src/test/java/org/springframework/samples/petclinic/validator/ValidatorTests.java b/src/test/java/org/springframework/samples/petclinic/validator/ValidatorTest.java similarity index 98% rename from src/test/java/org/springframework/samples/petclinic/validator/ValidatorTests.java rename to src/test/java/org/springframework/samples/petclinic/validator/ValidatorTest.java index f22b9d6b4..79b06ff6f 100644 --- a/src/test/java/org/springframework/samples/petclinic/validator/ValidatorTests.java +++ b/src/test/java/org/springframework/samples/petclinic/validator/ValidatorTest.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Michael Isvy Simple test to make sure that Bean Validation is working (useful * when upgrading to a new version of Hibernate Validator/ Bean Validation) */ -class ValidatorTests { +class ValidatorTest { private Validator createValidator() { LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();