mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 07:15:49 +00:00
Add @Tag and refactoring directories
This commit is contained in:
parent
e041803e58
commit
20cfa0a078
40 changed files with 334 additions and 239 deletions
|
@ -6,21 +6,45 @@ package org.springframework.samples.petclinic.common;
|
|||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
public final class CommonAttribute {
|
||||
|
||||
public static final String DESCRIPTION = "description";
|
||||
|
||||
public static final String NAME = "name";
|
||||
public static final String SELECTIONS = "selections";
|
||||
|
||||
public static final String NEW = "new";
|
||||
|
||||
public static final String OWNER = "owner";
|
||||
|
||||
public static final String OWNER_ID = "id";
|
||||
|
||||
public static final String OWNER_LAST_NAME = "lastName";
|
||||
|
||||
public static final String OWNER_FIRST_NAME = "firstName";
|
||||
|
||||
public static final String OWNER_PHONE = "telephone";
|
||||
|
||||
public static final String OWNER_ADDRESS = "address";
|
||||
|
||||
public static final String OWNER_CITY = "city";
|
||||
|
||||
public static final String OWNER_PETS = "pets";
|
||||
|
||||
public static final String PET = "pet";
|
||||
|
||||
public static final String SELECTIONS = "selections";
|
||||
|
||||
public static final String PET_BIRTH_DATE = "birthDate";
|
||||
|
||||
public static final String PET_NAME = "name";
|
||||
|
||||
public static final String PET_TYPE = "type";
|
||||
|
||||
public static final String VETS = "vets";
|
||||
|
||||
public static final String VISIT = "visit";
|
||||
|
||||
private CommonAttribute() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,13 +6,31 @@ package org.springframework.samples.petclinic.common;
|
|||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
public final class CommonEndPoint {
|
||||
|
||||
public static final String OWNERS = "/owners";
|
||||
|
||||
public static final String OWNERS_FIND = "/owners/find";
|
||||
|
||||
public static final String OWNERS_ID = "/owners/{ownerId}";
|
||||
|
||||
public static final String OWNERS_ID_EDIT = "/owners/{ownerId}/edit";
|
||||
|
||||
public static final String OWNERS_NEW = "/owners/new";
|
||||
|
||||
public static final String PETS_NEW = "/pets/new";
|
||||
|
||||
public static final String PETS_ID_EDIT = "/pets/{petId}/edit";
|
||||
|
||||
public static final String VETS = "/vets";
|
||||
|
||||
public static final String VETS_HTML = "/vets.html";
|
||||
|
||||
public static final String VISITS_NEW = "/owners/*/pets/{petId}/visits/new";
|
||||
|
||||
public static final String VISITS_EDIT = "/owners/{ownerId}/pets/{petId}/visits/new";
|
||||
|
||||
private CommonEndPoint() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,12 +6,21 @@ package org.springframework.samples.petclinic.common;
|
|||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
public final class CommonError {
|
||||
|
||||
public static final String DUPLICATE_ARGS = "duplicate";
|
||||
|
||||
public static final String DUPLICATE_MESSAGE = "already exists";
|
||||
|
||||
public static final String NOT_FOUND_ARGS = "notFound";
|
||||
|
||||
public static final String NOT_FOUND_MESSAGE = "notFound";
|
||||
|
||||
public static final String REQUIRED_ARGS = "required";
|
||||
|
||||
public static final String REQUIRED_MESSAGE = "required";
|
||||
|
||||
private CommonError() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,14 +6,27 @@ package org.springframework.samples.petclinic.common;
|
|||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
public final class CommonView {
|
||||
|
||||
public static final String OWNER_OWNERS_R = "redirect:/owners/";
|
||||
|
||||
public static final String OWNER_OWNERS_ID_R = "redirect:/owners/{ownerId}";
|
||||
|
||||
public static final String OWNER_CREATE_OR_UPDATE = "owners/createOrUpdateOwnerForm";
|
||||
|
||||
public static final String OWNER_FIND_OWNERS = "owners/findOwners";
|
||||
|
||||
public static final String OWNER_OWNERS_LIST = "owners/ownersList";
|
||||
|
||||
public static final String OWNER_DETAILS = "owners/ownerDetails";
|
||||
|
||||
public static final String PET_CREATE_OR_UPDATE = "pets/createOrUpdatePetForm";
|
||||
|
||||
public static final String VET_VETS_LIST = "vets/vetList";
|
||||
|
||||
public static final String VISIT_CREATE_OR_UPDATE = "pets/createOrUpdateVisitForm";
|
||||
|
||||
private CommonView() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.common.CommonAttribute;
|
||||
import org.springframework.samples.petclinic.common.CommonEndPoint;
|
||||
import org.springframework.samples.petclinic.common.CommonError;
|
||||
|
@ -43,7 +42,9 @@ import java.util.Map;
|
|||
*/
|
||||
@Controller
|
||||
class OwnerController {
|
||||
|
||||
private final OwnerService ownerService;
|
||||
|
||||
private final VisitService visitService;
|
||||
|
||||
OwnerController(OwnerService ownerService, VisitService visitService) {
|
||||
|
@ -64,7 +65,8 @@ class OwnerController {
|
|||
}
|
||||
|
||||
@PostMapping(CommonEndPoint.OWNERS_NEW)
|
||||
public String processCreationForm(@ModelAttribute(CommonAttribute.OWNER) @Valid OwnerDTO owner, BindingResult result) {
|
||||
public String processCreationForm(@ModelAttribute(CommonAttribute.OWNER) @Valid OwnerDTO owner,
|
||||
BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return CommonView.OWNER_CREATE_OR_UPDATE;
|
||||
}
|
||||
|
@ -81,7 +83,8 @@ class OwnerController {
|
|||
}
|
||||
|
||||
@GetMapping(CommonEndPoint.OWNERS)
|
||||
public String processFindForm(@ModelAttribute(CommonAttribute.OWNER) OwnerDTO owner, BindingResult result, Map<String, Object> model) {
|
||||
public String processFindForm(@ModelAttribute(CommonAttribute.OWNER) OwnerDTO owner, BindingResult result,
|
||||
Map<String, Object> model) {
|
||||
|
||||
// allow parameterless GET request for /owners to return all records
|
||||
if (owner.getLastName() == null) {
|
||||
|
@ -92,7 +95,8 @@ class OwnerController {
|
|||
Collection<OwnerDTO> results = this.ownerService.findByLastName(owner.getLastName());
|
||||
if (results.isEmpty()) {
|
||||
// no owners found
|
||||
result.rejectValue(CommonAttribute.OWNER_LAST_NAME, CommonError.NOT_FOUND_ARGS, CommonError.NOT_FOUND_MESSAGE);
|
||||
result.rejectValue(CommonAttribute.OWNER_LAST_NAME, CommonError.NOT_FOUND_ARGS,
|
||||
CommonError.NOT_FOUND_MESSAGE);
|
||||
return CommonView.OWNER_FIND_OWNERS;
|
||||
}
|
||||
else if (results.size() == 1) {
|
||||
|
@ -115,8 +119,8 @@ class OwnerController {
|
|||
}
|
||||
|
||||
@PostMapping(CommonEndPoint.OWNERS_ID_EDIT)
|
||||
public String processUpdateOwnerForm(@ModelAttribute(CommonAttribute.OWNER) @Valid OwnerDTO owner, BindingResult result,
|
||||
@PathVariable("ownerId") int ownerId) {
|
||||
public String processUpdateOwnerForm(@ModelAttribute(CommonAttribute.OWNER) @Valid OwnerDTO owner,
|
||||
BindingResult result, @PathVariable("ownerId") int ownerId) {
|
||||
if (result.hasErrors()) {
|
||||
return CommonView.OWNER_CREATE_OR_UPDATE;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@ package org.springframework.samples.petclinic.controller;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.common.CommonAttribute;
|
||||
import org.springframework.samples.petclinic.common.CommonEndPoint;
|
||||
import org.springframework.samples.petclinic.common.CommonError;
|
||||
import org.springframework.samples.petclinic.common.CommonView;
|
||||
import org.springframework.samples.petclinic.dto.*;
|
||||
import org.springframework.samples.petclinic.validator.PetDTOValidator;
|
||||
import org.springframework.samples.petclinic.service.*;
|
||||
|
@ -38,11 +40,9 @@ import java.util.Collection;
|
|||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/owners/{ownerId}")
|
||||
@RequestMapping(CommonEndPoint.OWNERS_ID)
|
||||
class PetController {
|
||||
|
||||
private static final String VIEWS_PETS_CREATE_OR_UPDATE_FORM = "pets/createOrUpdatePetForm";
|
||||
|
||||
private final OwnerService ownerService;
|
||||
|
||||
private final PetService petService;
|
||||
|
@ -76,48 +76,50 @@ class PetController {
|
|||
dataBinder.setValidator(new PetDTOValidator());
|
||||
}
|
||||
|
||||
@GetMapping("/pets/new")
|
||||
@GetMapping(CommonEndPoint.PETS_NEW)
|
||||
public String initCreationForm(@ModelAttribute(CommonAttribute.OWNER) OwnerDTO owner, ModelMap model) {
|
||||
PetDTO pet = new PetDTO();
|
||||
owner.addPet(pet);
|
||||
model.put(CommonAttribute.PET, pet);
|
||||
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
|
||||
return CommonView.PET_CREATE_OR_UPDATE;
|
||||
}
|
||||
|
||||
@PostMapping("/pets/new")
|
||||
@PostMapping(CommonEndPoint.PETS_NEW)
|
||||
public String processCreationForm(@ModelAttribute(CommonAttribute.OWNER) OwnerDTO owner,
|
||||
@ModelAttribute(CommonAttribute.PET) @Valid PetDTO pet, BindingResult result, ModelMap model) {
|
||||
@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);
|
||||
}
|
||||
owner.addPet(pet);
|
||||
if (result.hasErrors()) {
|
||||
model.put(CommonAttribute.PET, pet);
|
||||
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
|
||||
} else {
|
||||
return CommonView.PET_CREATE_OR_UPDATE;
|
||||
}
|
||||
else {
|
||||
this.petService.save(pet);
|
||||
return "redirect:/owners/{ownerId}";
|
||||
return CommonView.OWNER_OWNERS_ID_R;
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/pets/{petId}/edit")
|
||||
@GetMapping(CommonEndPoint.PETS_ID_EDIT)
|
||||
public String initUpdateForm(@PathVariable("petId") int petId, ModelMap model) {
|
||||
PetDTO pet = this.petService.findById(petId);
|
||||
model.put(CommonAttribute.PET, pet);
|
||||
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
|
||||
return CommonView.PET_CREATE_OR_UPDATE;
|
||||
}
|
||||
|
||||
@PostMapping("/pets/{petId}/edit")
|
||||
public String processUpdateForm(@ModelAttribute(CommonAttribute.PET) @Valid PetDTO pet, BindingResult result, OwnerDTO owner, ModelMap model) {
|
||||
@PostMapping(CommonEndPoint.PETS_ID_EDIT)
|
||||
public String processUpdateForm(@ModelAttribute(CommonAttribute.PET) @Valid PetDTO pet, BindingResult result,
|
||||
OwnerDTO owner, ModelMap model) {
|
||||
if (result.hasErrors()) {
|
||||
pet.setOwner(owner);
|
||||
model.put(CommonAttribute.PET, pet);
|
||||
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
|
||||
return CommonView.PET_CREATE_OR_UPDATE;
|
||||
}
|
||||
else {
|
||||
owner.addPet(pet);
|
||||
this.petService.save(pet);
|
||||
return "redirect:/owners/{ownerId}";
|
||||
return CommonView.OWNER_OWNERS_ID_R;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,11 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.controller;
|
||||
|
||||
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.VetsDTO;
|
||||
import org.springframework.samples.petclinic.service.VetService;
|
||||
import org.springframework.samples.petclinic.vet.Vets;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
@ -40,17 +42,17 @@ class VetController {
|
|||
this.vetService = vetService;
|
||||
}
|
||||
|
||||
@GetMapping("/vets.html")
|
||||
@GetMapping(CommonEndPoint.VETS_HTML)
|
||||
public String showVetList(Map<String, Object> model) {
|
||||
// Here we are returning an object of type 'Vets' rather than a collection of Vet
|
||||
// objects so it is simpler for Object-Xml mapping
|
||||
VetsDTO vets = new VetsDTO();
|
||||
vets.getVetList().addAll(this.vetService.findAll());
|
||||
model.put("vets", vets);
|
||||
return "vets/vetList";
|
||||
model.put(CommonAttribute.VETS, vets);
|
||||
return CommonView.VET_VETS_LIST;
|
||||
}
|
||||
|
||||
@GetMapping({ "/vets" })
|
||||
@GetMapping({ CommonEndPoint.VETS })
|
||||
public @ResponseBody VetsDTO showResourcesVetList() {
|
||||
// Here we are returning an object of type 'Vets' rather than a collection of Vet
|
||||
// objects so it is simpler for JSon/Object mapping
|
||||
|
|
|
@ -19,6 +19,9 @@ import java.util.Map;
|
|||
|
||||
import javax.validation.Valid;
|
||||
|
||||
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.PetDTO;
|
||||
import org.springframework.samples.petclinic.dto.VisitDTO;
|
||||
import org.springframework.samples.petclinic.service.PetService;
|
||||
|
@ -68,27 +71,28 @@ class VisitController {
|
|||
public VisitDTO loadPetWithVisit(@PathVariable("petId") int petId, Map<String, Object> model) {
|
||||
PetDTO pet = this.petService.findById(petId);
|
||||
pet.setVisitsInternal(this.visitService.findByPetId(petId));
|
||||
model.put("pet", pet);
|
||||
model.put(CommonAttribute.PET, pet);
|
||||
VisitDTO visit = new VisitDTO();
|
||||
pet.addVisit(visit);
|
||||
return visit;
|
||||
}
|
||||
|
||||
// Spring MVC calls method loadPetWithVisit(...) before initNewVisitForm is called
|
||||
@GetMapping("/owners/*/pets/{petId}/visits/new")
|
||||
@GetMapping(CommonEndPoint.VISITS_NEW)
|
||||
public String initNewVisitForm(@PathVariable("petId") int petId, Map<String, Object> model) {
|
||||
return "pets/createOrUpdateVisitForm";
|
||||
return CommonView.PET_CREATE_OR_UPDATE;
|
||||
}
|
||||
|
||||
// Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is called
|
||||
@PostMapping("/owners/{ownerId}/pets/{petId}/visits/new")
|
||||
public String processNewVisitForm(@ModelAttribute("visit") @Valid VisitDTO visit, BindingResult result) {
|
||||
@PostMapping(CommonEndPoint.VISITS_EDIT)
|
||||
public String processNewVisitForm(@ModelAttribute(CommonAttribute.VISIT) @Valid VisitDTO visit,
|
||||
BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return "pets/createOrUpdateVisitForm";
|
||||
return CommonView.VISIT_CREATE_OR_UPDATE;
|
||||
}
|
||||
else {
|
||||
this.visitService.save(visit);
|
||||
return "redirect:/owners/{ownerId}";
|
||||
return CommonView.OWNER_OWNERS_ID_R;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.samples.petclinic.dto;
|
|||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.samples.petclinic.common.CommonAttribute;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
@ -120,11 +121,11 @@ public class OwnerDTO extends PersonDTO {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
|
||||
.append("id", this.getId()).append("new", this.isNew()).append("lastName", this.getLastName())
|
||||
.append("firstName", this.getFirstName()).append("address", this.address).append("city", this.city)
|
||||
.append("telephone", this.telephone).toString();
|
||||
return new ToStringCreator(this).append(CommonAttribute.OWNER_ID, this.getId())
|
||||
.append(CommonAttribute.NEW, this.isNew()).append(CommonAttribute.OWNER_LAST_NAME, this.getLastName())
|
||||
.append(CommonAttribute.OWNER_FIRST_NAME, this.getFirstName())
|
||||
.append(CommonAttribute.OWNER_ADDRESS, this.address).append(CommonAttribute.OWNER_CITY, this.city)
|
||||
.append(CommonAttribute.OWNER_PHONE, this.telephone).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.springframework.samples.petclinic.dto;
|
|||
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.samples.petclinic.vet.Specialty;
|
||||
import org.springframework.samples.petclinic.model.Specialty;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.*;
|
||||
|
|
|
@ -13,13 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.owner;
|
||||
package org.springframework.samples.petclinic.formatter;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.Formatter;
|
||||
import org.springframework.samples.petclinic.dto.PetTypeDTO;
|
||||
import org.springframework.samples.petclinic.service.PetTypeService;
|
||||
|
@ -38,7 +37,6 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class PetTypeFormatter implements Formatter<PetTypeDTO> {
|
||||
|
||||
// private final PetRepository pets;
|
||||
private final PetTypeService petTypeService;
|
||||
|
||||
public PetTypeFormatter(PetTypeService petTypeService) {
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.owner;
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -32,7 +32,7 @@ import javax.validation.constraints.NotEmpty;
|
|||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.samples.petclinic.model.Person;
|
||||
import org.springframework.samples.petclinic.common.CommonAttribute;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing an owner.
|
||||
|
@ -140,11 +140,11 @@ public class Owner extends Person {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
|
||||
.append("id", this.getId()).append("new", this.isNew()).append("lastName", this.getLastName())
|
||||
.append("firstName", this.getFirstName()).append("address", this.address).append("city", this.city)
|
||||
.append("telephone", this.telephone).toString();
|
||||
return new ToStringCreator(this).append(CommonAttribute.OWNER_ID, this.getId())
|
||||
.append(CommonAttribute.NEW, this.isNew()).append(CommonAttribute.OWNER_LAST_NAME, this.getLastName())
|
||||
.append(CommonAttribute.OWNER_FIRST_NAME, this.getFirstName())
|
||||
.append(CommonAttribute.OWNER_ADDRESS, this.address).append(CommonAttribute.OWNER_CITY, this.city)
|
||||
.append(CommonAttribute.OWNER_PHONE, this.telephone).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.owner;
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,8 +34,6 @@ import javax.persistence.Transient;
|
|||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.samples.petclinic.model.NamedEntity;
|
||||
import org.springframework.samples.petclinic.visit.Visit;
|
||||
|
||||
/**
|
||||
* Simple business object representing a pet.
|
|
@ -13,13 +13,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.owner;
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.springframework.samples.petclinic.model.NamedEntity;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller Can be Cat, Dog, Hamster...
|
||||
*/
|
|
@ -13,15 +13,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.vet;
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.springframework.samples.petclinic.model.NamedEntity;
|
||||
|
||||
/**
|
||||
* Models a {@link Vet Vet's} specialty (for example, dentistry).
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.vet;
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -31,7 +31,6 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.samples.petclinic.model.Person;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing a veterinarian.
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.vet;
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.visit;
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
@ -23,7 +23,6 @@ import javax.persistence.Table;
|
|||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.samples.petclinic.model.BaseEntity;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing a visit.
|
|
@ -20,7 +20,7 @@ import java.util.Collection;
|
|||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.samples.petclinic.owner.Owner;
|
||||
import org.springframework.samples.petclinic.model.Owner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,8 +19,8 @@ import java.util.List;
|
|||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.samples.petclinic.owner.Pet;
|
||||
import org.springframework.samples.petclinic.owner.PetType;
|
||||
import org.springframework.samples.petclinic.model.Pet;
|
||||
import org.springframework.samples.petclinic.model.PetType;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Collection;
|
|||
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.samples.petclinic.vet.Vet;
|
||||
import org.springframework.samples.petclinic.model.Vet;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.samples.petclinic.model.BaseEntity;
|
||||
import org.springframework.samples.petclinic.visit.Visit;
|
||||
import org.springframework.samples.petclinic.model.Visit;
|
||||
|
||||
/**
|
||||
* Repository class for <code>Visit</code> domain objects All method names are compliant
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.springframework.samples.petclinic.service;
|
|||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.samples.petclinic.dto.OwnerDTO;
|
||||
import org.springframework.samples.petclinic.owner.Owner;
|
||||
import org.springframework.samples.petclinic.model.Owner;
|
||||
import org.springframework.samples.petclinic.repository.OwnerRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.springframework.samples.petclinic.service;
|
|||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.samples.petclinic.dto.PetDTO;
|
||||
import org.springframework.samples.petclinic.owner.Pet;
|
||||
import org.springframework.samples.petclinic.model.Pet;
|
||||
import org.springframework.samples.petclinic.repository.PetRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.springframework.samples.petclinic.service;
|
|||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.samples.petclinic.dto.PetTypeDTO;
|
||||
import org.springframework.samples.petclinic.owner.PetType;
|
||||
import org.springframework.samples.petclinic.model.PetType;
|
||||
import org.springframework.samples.petclinic.repository.PetRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.springframework.samples.petclinic.service;
|
|||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.samples.petclinic.dto.SpecialtyDTO;
|
||||
import org.springframework.samples.petclinic.vet.Specialty;
|
||||
import org.springframework.samples.petclinic.model.Specialty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.springframework.samples.petclinic.service;
|
|||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.samples.petclinic.dto.VetDTO;
|
||||
import org.springframework.samples.petclinic.repository.VetRepository;
|
||||
import org.springframework.samples.petclinic.vet.Vet;
|
||||
import org.springframework.samples.petclinic.model.Vet;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.springframework.samples.petclinic.service;
|
|||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.samples.petclinic.dto.VisitDTO;
|
||||
import org.springframework.samples.petclinic.visit.Visit;
|
||||
import org.springframework.samples.petclinic.model.Visit;
|
||||
import org.springframework.samples.petclinic.repository.VisitRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -34,9 +34,7 @@ class CacheConfiguration {
|
|||
|
||||
@Bean
|
||||
public JCacheManagerCustomizer petclinicCacheConfigurationCustomizer() {
|
||||
return cm -> {
|
||||
cm.createCache("vets", cacheConfiguration());
|
||||
};
|
||||
return cm -> cm.createCache("vets", cacheConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.validator;
|
||||
|
||||
import org.springframework.samples.petclinic.common.CommonAttribute;
|
||||
import org.springframework.samples.petclinic.common.CommonError;
|
||||
import org.springframework.samples.petclinic.dto.PetDTO;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.Errors;
|
||||
|
@ -29,28 +31,27 @@ import org.springframework.validation.Validator;
|
|||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
public class PetDTOValidator implements Validator {
|
||||
|
||||
private static final String REQUIRED = "required";
|
||||
|
||||
@Override
|
||||
public void validate(Object obj, Errors errors) {
|
||||
PetDTO pet = (PetDTO) obj;
|
||||
String name = pet.getName();
|
||||
// name validation
|
||||
if (!StringUtils.hasLength(name)) {
|
||||
errors.rejectValue("name", REQUIRED, REQUIRED);
|
||||
errors.rejectValue(CommonAttribute.PET_NAME, CommonError.REQUIRED_ARGS, CommonError.REQUIRED_MESSAGE);
|
||||
}
|
||||
|
||||
// type validation
|
||||
if (pet.isNew() && pet.getType() == null) {
|
||||
errors.rejectValue("type", REQUIRED, REQUIRED);
|
||||
errors.rejectValue(CommonAttribute.PET_TYPE, CommonError.REQUIRED_ARGS, CommonError.REQUIRED_MESSAGE);
|
||||
}
|
||||
|
||||
// birth date validation
|
||||
if (pet.getBirthDate() == null) {
|
||||
errors.rejectValue("birthDate", REQUIRED, REQUIRED);
|
||||
errors.rejectValue(CommonAttribute.PET_BIRTH_DATE, CommonError.REQUIRED_ARGS, CommonError.REQUIRED_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.validator;
|
||||
|
||||
import org.springframework.samples.petclinic.dto.PetDTO;
|
||||
import org.springframework.samples.petclinic.owner.Pet;
|
||||
import org.springframework.samples.petclinic.common.CommonAttribute;
|
||||
import org.springframework.samples.petclinic.common.CommonError;
|
||||
import org.springframework.samples.petclinic.model.Pet;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
@ -30,28 +31,27 @@ import org.springframework.validation.Validator;
|
|||
*
|
||||
* @author Ken Krebs
|
||||
* @author Juergen Hoeller
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
public class PetValidator implements Validator {
|
||||
|
||||
private static final String REQUIRED = "required";
|
||||
|
||||
@Override
|
||||
public void validate(Object obj, Errors errors) {
|
||||
Pet pet = (Pet) obj;
|
||||
String name = pet.getName();
|
||||
// name validation
|
||||
if (!StringUtils.hasLength(name)) {
|
||||
errors.rejectValue("name", REQUIRED, REQUIRED);
|
||||
errors.rejectValue(CommonAttribute.PET_NAME, CommonError.REQUIRED_ARGS, CommonError.REQUIRED_MESSAGE);
|
||||
}
|
||||
|
||||
// type validation
|
||||
if (pet.isNew() && pet.getType() == null) {
|
||||
errors.rejectValue("type", REQUIRED, REQUIRED);
|
||||
errors.rejectValue(CommonAttribute.PET_TYPE, CommonError.REQUIRED_ARGS, CommonError.REQUIRED_MESSAGE);
|
||||
}
|
||||
|
||||
// birth date validation
|
||||
if (pet.getBirthDate() == null) {
|
||||
errors.rejectValue("birthDate", REQUIRED, REQUIRED);
|
||||
errors.rejectValue(CommonAttribute.PET_BIRTH_DATE, CommonError.REQUIRED_ARGS, CommonError.REQUIRED_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
|
@ -96,142 +97,148 @@ class OwnerControllerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Tag("initCreationForm")
|
||||
void testInitCreationForm() throws Exception {
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_NEW))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(CommonAttribute.OWNER))
|
||||
.andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE));
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_NEW)).andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(CommonAttribute.OWNER))
|
||||
.andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processCreationForm")
|
||||
void testProcessCreationFormSuccess() throws Exception {
|
||||
mockMvc.perform(post("/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());
|
||||
mockMvc.perform(post("/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());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processCreationForm")
|
||||
void testProcessCreationFormHasErrors() throws Exception {
|
||||
mockMvc.perform(post(CommonEndPoint.OWNERS_NEW)
|
||||
.param(CommonAttribute.OWNER_FIRST_NAME, "Joe")
|
||||
.param(CommonAttribute.OWNER_LAST_NAME, "Bloggs")
|
||||
.param(CommonAttribute.OWNER_CITY, "London"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeHasErrors(CommonAttribute.OWNER))
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_ADDRESS))
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_PHONE))
|
||||
.andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE));
|
||||
mockMvc.perform(post(CommonEndPoint.OWNERS_NEW).param(CommonAttribute.OWNER_FIRST_NAME, "Joe")
|
||||
.param(CommonAttribute.OWNER_LAST_NAME, "Bloggs").param(CommonAttribute.OWNER_CITY, "London"))
|
||||
.andExpect(status().isOk()).andExpect(model().attributeHasErrors(CommonAttribute.OWNER))
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_ADDRESS))
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_PHONE))
|
||||
.andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("initFindForm")
|
||||
void testInitFindForm() throws Exception {
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_FIND))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(CommonAttribute.OWNER))
|
||||
.andExpect(view().name(CommonView.OWNER_FIND_OWNERS));
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_FIND)).andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(CommonAttribute.OWNER))
|
||||
.andExpect(view().name(CommonView.OWNER_FIND_OWNERS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processFindForm")
|
||||
void testProcessFindFormSuccess() throws Exception {
|
||||
given(this.owners.findByLastName("")).willReturn(Lists.newArrayList(george, new OwnerDTO()));
|
||||
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name(CommonView.OWNER_OWNERS_LIST));
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS)).andExpect(status().isOk())
|
||||
.andExpect(view().name(CommonView.OWNER_OWNERS_LIST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processFindForm")
|
||||
void testProcessFindFormByLastName() throws Exception {
|
||||
given(this.owners.findByLastName(george.getLastName())).willReturn(Lists.newArrayList(george));
|
||||
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS)
|
||||
.param(CommonAttribute.OWNER_LAST_NAME, "Franklin"))
|
||||
.andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name(CommonView.OWNER_OWNERS_R + TEST_OWNER_ID));
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS).param(CommonAttribute.OWNER_LAST_NAME, "Franklin"))
|
||||
.andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name(CommonView.OWNER_OWNERS_R + TEST_OWNER_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processFindForm")
|
||||
void testProcessFindFormNoOwnersFound() throws Exception {
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS)
|
||||
.param(CommonAttribute.OWNER_LAST_NAME,"Unknown Surname"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_LAST_NAME))
|
||||
.andExpect(model().attributeHasFieldErrorCode(CommonAttribute.OWNER, CommonAttribute.OWNER_LAST_NAME, "notFound"))
|
||||
.andExpect(view().name(CommonView.OWNER_FIND_OWNERS));
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS).param(CommonAttribute.OWNER_LAST_NAME, "Unknown Surname"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_LAST_NAME))
|
||||
.andExpect(model().attributeHasFieldErrorCode(CommonAttribute.OWNER, CommonAttribute.OWNER_LAST_NAME,
|
||||
"notFound"))
|
||||
.andExpect(view().name(CommonView.OWNER_FIND_OWNERS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("initUpdateOwnerForm")
|
||||
void testInitUpdateOwnerForm() throws Exception {
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_ID_EDIT, TEST_OWNER_ID))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(CommonAttribute.OWNER))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_LAST_NAME, is("Franklin"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_FIRST_NAME, is("George"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_ADDRESS, is("110 W. Liberty St."))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_CITY, is("Madison"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_PHONE, is("6085551023"))))
|
||||
.andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE));
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_ID_EDIT, TEST_OWNER_ID)).andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(CommonAttribute.OWNER))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_LAST_NAME, is("Franklin"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_FIRST_NAME, is("George"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_ADDRESS, is("110 W. Liberty St."))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_CITY, is("Madison"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_PHONE, is("6085551023"))))
|
||||
.andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processUpdateOwnerForm")
|
||||
void testProcessUpdateOwnerFormSuccess() throws Exception {
|
||||
mockMvc.perform(post(CommonEndPoint.OWNERS_ID_EDIT, TEST_OWNER_ID)
|
||||
.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, "01616291589"))
|
||||
.andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name(CommonView.OWNER_OWNERS_ID_R));
|
||||
.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, "01616291589")).andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name(CommonView.OWNER_OWNERS_ID_R));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processUpdateOwnerForm")
|
||||
void testProcessUpdateOwnerFormHasErrors() throws Exception {
|
||||
mockMvc.perform(post(CommonEndPoint.OWNERS_ID_EDIT, TEST_OWNER_ID)
|
||||
.param(CommonAttribute.OWNER_FIRST_NAME, "Joe")
|
||||
.param(CommonAttribute.OWNER_LAST_NAME, "Bloggs")
|
||||
.param(CommonAttribute.OWNER_CITY, "London"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeHasErrors(CommonAttribute.OWNER))
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_ADDRESS))
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_PHONE))
|
||||
.andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE));
|
||||
mockMvc.perform(
|
||||
post(CommonEndPoint.OWNERS_ID_EDIT, TEST_OWNER_ID).param(CommonAttribute.OWNER_FIRST_NAME, "Joe")
|
||||
.param(CommonAttribute.OWNER_LAST_NAME, "Bloggs").param(CommonAttribute.OWNER_CITY, "London"))
|
||||
.andExpect(status().isOk()).andExpect(model().attributeHasErrors(CommonAttribute.OWNER))
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_ADDRESS))
|
||||
.andExpect(model().attributeHasFieldErrors(CommonAttribute.OWNER, CommonAttribute.OWNER_PHONE))
|
||||
.andExpect(view().name(CommonView.OWNER_CREATE_OR_UPDATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processUpdateOwnerForm")
|
||||
void testShowOwner() throws Exception {
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_ID, TEST_OWNER_ID))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_LAST_NAME, is("Franklin"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_FIRST_NAME, is("George"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_ADDRESS, is("110 W. Liberty St."))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_CITY, is("Madison"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_PHONE, is("6085551023"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_PETS, not(empty()))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_PETS, new BaseMatcher<List<PetDTO>>() {
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_ID, TEST_OWNER_ID)).andExpect(status().isOk())
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_LAST_NAME, is("Franklin"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_FIRST_NAME, is("George"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_ADDRESS, is("110 W. Liberty St."))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_CITY, is("Madison"))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_PHONE, is("6085551023"))))
|
||||
.andExpect(
|
||||
model().attribute(CommonAttribute.OWNER, hasProperty(CommonAttribute.OWNER_PETS, not(empty()))))
|
||||
.andExpect(model().attribute(CommonAttribute.OWNER,
|
||||
hasProperty(CommonAttribute.OWNER_PETS, new BaseMatcher<List<PetDTO>>() {
|
||||
|
||||
@Override
|
||||
public boolean matches(Object item) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<PetDTO> pets = (List<PetDTO>) item;
|
||||
PetDTO pet = pets.get(0);
|
||||
if (pet.getVisits().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean matches(Object item) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<PetDTO> pets = (List<PetDTO>) item;
|
||||
PetDTO pet = pets.get(0);
|
||||
if (pet.getVisits().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("Max did not have any visits");
|
||||
}
|
||||
})))
|
||||
.andExpect(view().name(CommonView.OWNER_DETAILS));
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("Max did not have any visits");
|
||||
}
|
||||
})))
|
||||
.andExpect(view().name(CommonView.OWNER_DETAILS));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,16 +25,21 @@ 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.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.samples.petclinic.common.CommonAttribute;
|
||||
import org.springframework.samples.petclinic.common.CommonEndPoint;
|
||||
import org.springframework.samples.petclinic.common.CommonError;
|
||||
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.owner.PetTypeFormatter;
|
||||
import org.springframework.samples.petclinic.formatter.PetTypeFormatter;
|
||||
import org.springframework.samples.petclinic.service.OwnerService;
|
||||
import org.springframework.samples.petclinic.service.PetService;
|
||||
import org.springframework.samples.petclinic.service.PetTypeService;
|
||||
|
@ -44,6 +49,7 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||
* Test class for the {@link PetController}
|
||||
*
|
||||
* @author Colin But
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@WebMvcTest(value = PetController.class,
|
||||
includeFilters = @ComponentScan.Filter(value = PetTypeFormatter.class, type = FilterType.ASSIGNABLE_TYPE))
|
||||
|
@ -77,63 +83,60 @@ class PetControllerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Tag("initCreationForm")
|
||||
void testInitCreationForm() throws Exception {
|
||||
mockMvc.perform(get("/owners/{ownerId}/pets/new", TEST_OWNER_ID))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("pets/createOrUpdatePetForm"))
|
||||
.andExpect(model().attributeExists("pet"));
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_NEW, TEST_OWNER_ID))
|
||||
.andExpect(status().isOk()).andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE))
|
||||
.andExpect(model().attributeExists(CommonAttribute.PET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processCreationForm")
|
||||
void testProcessCreationFormSuccess() throws Exception {
|
||||
mockMvc.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID)
|
||||
.param("name", "Betty")
|
||||
.param("type", "hamster")
|
||||
.param("birthDate", "2015-02-12"))
|
||||
.andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name("redirect:/owners/{ownerId}"));
|
||||
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));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processCreationForm")
|
||||
void testProcessCreationFormHasErrors() throws Exception {
|
||||
mockMvc.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID)
|
||||
.param("name", "Betty")
|
||||
.param("birthDate","2015-02-12"))
|
||||
.andExpect(model().attributeHasNoErrors("owner"))
|
||||
.andExpect(model().attributeHasErrors("pet"))
|
||||
.andExpect(model().attributeHasFieldErrors("pet", "type"))
|
||||
.andExpect(model().attributeHasFieldErrorCode("pet", "type", "required"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("pets/createOrUpdatePetForm"));
|
||||
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("initUpdateForm")
|
||||
void testInitUpdateForm() throws Exception {
|
||||
mockMvc.perform(get("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists("pet"))
|
||||
.andExpect(view().name("pets/createOrUpdatePetForm"));
|
||||
mockMvc.perform(get(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_ID_EDIT, TEST_OWNER_ID, TEST_PET_ID))
|
||||
.andExpect(status().isOk()).andExpect(model().attributeExists(CommonAttribute.PET))
|
||||
.andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processUpdateForm")
|
||||
void testProcessUpdateFormSuccess() throws Exception {
|
||||
mockMvc.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID)
|
||||
.param("name", "Betty")
|
||||
.param("type", "hamster")
|
||||
.param("birthDate", "2015-02-12"))
|
||||
.andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name("redirect:/owners/{ownerId}"));
|
||||
mockMvc.perform(post(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_ID_EDIT, TEST_OWNER_ID, TEST_PET_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));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processUpdateForm")
|
||||
void testProcessUpdateFormHasErrors() throws Exception {
|
||||
mockMvc.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID)
|
||||
.param("name", "Betty")
|
||||
.param("birthDate", "2015/02/12"))
|
||||
.andExpect(model().attributeHasNoErrors("owner"))
|
||||
.andExpect(model().attributeHasErrors("pet"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("pets/createOrUpdatePetForm"));
|
||||
mockMvc.perform(post(CommonEndPoint.OWNERS_ID + CommonEndPoint.PETS_ID_EDIT, TEST_OWNER_ID, TEST_PET_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(status().isOk())
|
||||
.andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,19 +26,25 @@ 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.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.http.MediaType;
|
||||
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.VetDTO;
|
||||
import org.springframework.samples.petclinic.service.VetService;
|
||||
import org.springframework.samples.petclinic.vet.Specialty;
|
||||
import org.springframework.samples.petclinic.model.Specialty;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
|
||||
/**
|
||||
* Test class for the {@link VetController}
|
||||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@WebMvcTest(VetController.class)
|
||||
class VetControllerTests {
|
||||
|
@ -67,15 +73,19 @@ class VetControllerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Tag("showVetList")
|
||||
void testShowVetListHtml() throws Exception {
|
||||
mockMvc.perform(get("/vets.html")).andExpect(status().isOk()).andExpect(model().attributeExists("vets"))
|
||||
.andExpect(view().name("vets/vetList"));
|
||||
mockMvc.perform(get(CommonEndPoint.VETS_HTML)).andExpect(status().isOk())
|
||||
.andExpect(model().attributeExists(CommonAttribute.VETS))
|
||||
.andExpect(view().name(CommonView.VET_VETS_LIST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("showResourcesVetList")
|
||||
void testShowResourcesVetList() throws Exception {
|
||||
ResultActions actions = mockMvc.perform(get("/vets").accept(MediaType.APPLICATION_JSON))
|
||||
ResultActions actions = mockMvc.perform(get(CommonEndPoint.VETS).accept(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
actions.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath("$.vetList[0].id").value(1));
|
||||
}
|
||||
|
|
|
@ -24,10 +24,14 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
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.PetDTO;
|
||||
import org.springframework.samples.petclinic.service.PetService;
|
||||
import org.springframework.samples.petclinic.service.VisitService;
|
||||
|
@ -58,24 +62,26 @@ class VisitControllerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Tag("initNewVisitForm")
|
||||
void testInitNewVisitForm() throws Exception {
|
||||
mockMvc.perform(get("/owners/*/pets/{petId}/visits/new", TEST_PET_ID))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("pets/createOrUpdateVisitForm"));
|
||||
mockMvc.perform(get(CommonEndPoint.VISITS_NEW, TEST_PET_ID)).andExpect(status().isOk())
|
||||
.andExpect(view().name(CommonView.PET_CREATE_OR_UPDATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processNewVisitForm")
|
||||
void testProcessNewVisitFormSuccess() throws Exception {
|
||||
mockMvc.perform(post("/owners/*/pets/{petId}/visits/new", TEST_PET_ID).param("name", "George")
|
||||
.param("description", "Visit Description")).andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name("redirect:/owners/{ownerId}"));
|
||||
mockMvc.perform(post(CommonEndPoint.VISITS_NEW, TEST_PET_ID).param(CommonAttribute.NAME, "George")
|
||||
.param(CommonAttribute.DESCRIPTION, "Visit Description")).andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name(CommonView.OWNER_OWNERS_ID_R));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("processNewVisitForm")
|
||||
void testProcessNewVisitFormHasErrors() throws Exception {
|
||||
mockMvc.perform(post("/owners/*/pets/{petId}/visits/new", TEST_PET_ID).param("name", "George"))
|
||||
.andExpect(model().attributeHasErrors("visit")).andExpect(status().isOk())
|
||||
.andExpect(view().name("pets/createOrUpdateVisitForm"));
|
||||
mockMvc.perform(post(CommonEndPoint.VISITS_NEW, TEST_PET_ID).param(CommonAttribute.NAME, "George"))
|
||||
.andExpect(model().attributeHasErrors(CommonAttribute.VISIT)).andExpect(status().isOk())
|
||||
.andExpect(view().name(CommonView.VISIT_CREATE_OR_UPDATE));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.samples.petclinic.owner;
|
||||
package org.springframework.samples.petclinic.formater;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -23,6 +23,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.samples.petclinic.dto.PetTypeDTO;
|
||||
import org.springframework.samples.petclinic.formatter.PetTypeFormatter;
|
||||
import org.springframework.samples.petclinic.model.PetType;
|
||||
import org.springframework.samples.petclinic.service.PetTypeService;
|
||||
|
||||
import java.text.ParseException;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.samples.petclinic.owner;
|
||||
package org.springframework.samples.petclinic.formater;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -29,8 +29,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.samples.petclinic.dto.PetTypeDTO;
|
||||
import org.springframework.samples.petclinic.repository.PetRepository;
|
||||
import org.springframework.samples.petclinic.service.PetService;
|
||||
import org.springframework.samples.petclinic.formatter.PetTypeFormatter;
|
||||
import org.springframework.samples.petclinic.model.PetType;
|
||||
import org.springframework.samples.petclinic.service.PetTypeService;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.vet;
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
|
@ -25,14 +25,14 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.samples.petclinic.owner.Owner;
|
||||
import org.springframework.samples.petclinic.model.Owner;
|
||||
import org.springframework.samples.petclinic.repository.OwnerRepository;
|
||||
import org.springframework.samples.petclinic.owner.Pet;
|
||||
import org.springframework.samples.petclinic.model.Pet;
|
||||
import org.springframework.samples.petclinic.repository.PetRepository;
|
||||
import org.springframework.samples.petclinic.owner.PetType;
|
||||
import org.springframework.samples.petclinic.vet.Vet;
|
||||
import org.springframework.samples.petclinic.model.PetType;
|
||||
import org.springframework.samples.petclinic.model.Vet;
|
||||
import org.springframework.samples.petclinic.repository.VetRepository;
|
||||
import org.springframework.samples.petclinic.visit.Visit;
|
||||
import org.springframework.samples.petclinic.model.Visit;
|
||||
import org.springframework.samples.petclinic.repository.VisitRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.samples.petclinic.model;
|
||||
package org.springframework.samples.petclinic.validator;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
@ -24,6 +24,7 @@ import javax.validation.Validator;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.samples.petclinic.model.Person;
|
||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
Loading…
Reference in a new issue