Merge pull request #1 from shrirangjoshi94/feature/persistent-assignment

Code rearranged. Signed-off-by: Shrirang <shrirangjoshi94@gmail.com>
This commit is contained in:
Shrirang Joshi 2025-05-20 15:35:25 +05:30 committed by GitHub
commit 569cc89c3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 121 additions and 76 deletions

BIN
src.zip Normal file

Binary file not shown.

View file

@ -18,9 +18,9 @@ package org.springframework.samples.petclinic;
import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.samples.petclinic.model.BaseEntity; import org.springframework.samples.petclinic.common.model.BaseEntity;
import org.springframework.samples.petclinic.model.Person; import org.springframework.samples.petclinic.common.model.Person;
import org.springframework.samples.petclinic.vet.Vet; import org.springframework.samples.petclinic.vet.model.Vet;
public class PetClinicRuntimeHints implements RuntimeHintsRegistrar { public class PetClinicRuntimeHints implements RuntimeHintsRegistrar {

View file

@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.common.formatter;
import org.springframework.format.Formatter; import org.springframework.format.Formatter;
import org.springframework.samples.petclinic.owner.model.PetType;
import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.text.ParseException; import java.text.ParseException;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.model; package org.springframework.samples.petclinic.common.model;
import java.io.Serializable; import java.io.Serializable;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.model; package org.springframework.samples.petclinic.common.model;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass; import jakarta.persistence.MappedSuperclass;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.model; package org.springframework.samples.petclinic.common.model;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass; import jakarta.persistence.MappedSuperclass;

View file

@ -1,20 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The classes in this package represent utilities used by the domain.
*/
package org.springframework.samples.petclinic.model;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.controller;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -21,6 +21,8 @@ import java.util.Optional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.samples.petclinic.owner.model.Owner;
import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
@ -44,7 +46,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
* @author Wick Dynex * @author Wick Dynex
*/ */
@Controller @Controller
class OwnerController { public class OwnerController {
private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm"; private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";

View file

@ -13,12 +13,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.controller;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import org.springframework.samples.petclinic.owner.model.Owner;
import org.springframework.samples.petclinic.owner.model.Pet;
import org.springframework.samples.petclinic.owner.model.PetType;
import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
import org.springframework.samples.petclinic.owner.validation.PetValidator;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -42,7 +47,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
*/ */
@Controller @Controller
@RequestMapping("/owners/{ownerId}") @RequestMapping("/owners/{ownerId}")
class PetController { public class PetController {
private static final String VIEWS_PETS_CREATE_OR_UPDATE_FORM = "pets/createOrUpdatePetForm"; private static final String VIEWS_PETS_CREATE_OR_UPDATE_FORM = "pets/createOrUpdatePetForm";
@ -67,7 +72,7 @@ class PetController {
@ModelAttribute("pet") @ModelAttribute("pet")
public Pet findPet(@PathVariable("ownerId") int ownerId, public Pet findPet(@PathVariable("ownerId") int ownerId,
@PathVariable(name = "petId", required = false) Integer petId) { @PathVariable(name = "petId", required = false) Integer petId) {
if (petId == null) { if (petId == null) {
return new Pet(); return new Pet();

View file

@ -13,11 +13,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.controller;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import org.springframework.samples.petclinic.owner.model.Owner;
import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
import org.springframework.samples.petclinic.owner.model.Pet;
import org.springframework.samples.petclinic.owner.model.Visit;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.WebDataBinder;
@ -39,7 +43,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
* @author Wick Dynex * @author Wick Dynex
*/ */
@Controller @Controller
class VisitController { public class VisitController {
private final OwnerRepository owners; private final OwnerRepository owners;
@ -61,7 +65,7 @@ class VisitController {
*/ */
@ModelAttribute("visit") @ModelAttribute("visit")
public Visit loadPetWithVisit(@PathVariable("ownerId") int ownerId, @PathVariable("petId") int petId, public Visit loadPetWithVisit(@PathVariable("ownerId") int ownerId, @PathVariable("petId") int petId,
Map<String, Object> model) { Map<String, Object> model) {
Optional<Owner> optionalOwner = owners.findById(ownerId); Optional<Owner> optionalOwner = owners.findById(ownerId);
Owner owner = optionalOwner.orElseThrow(() -> new IllegalArgumentException( Owner owner = optionalOwner.orElseThrow(() -> new IllegalArgumentException(
"Owner not found with id: " + ownerId + ". Please ensure the ID is correct ")); "Owner not found with id: " + ownerId + ". Please ensure the ID is correct "));

View file

@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.core.style.ToStringCreator; import org.springframework.core.style.ToStringCreator;
import org.springframework.samples.petclinic.model.Person; import org.springframework.samples.petclinic.common.model.Person;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.model;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
@ -21,7 +21,7 @@ import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.samples.petclinic.model.NamedEntity; import org.springframework.samples.petclinic.common.model.NamedEntity;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Column; import jakarta.persistence.Column;

View file

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.model;
import org.springframework.samples.petclinic.model.NamedEntity; import org.springframework.samples.petclinic.common.model.NamedEntity;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Table; import jakarta.persistence.Table;

View file

@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.model;
import java.time.LocalDate; import java.time.LocalDate;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.samples.petclinic.model.BaseEntity; import org.springframework.samples.petclinic.common.model.BaseEntity;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.repository;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -23,6 +23,8 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.samples.petclinic.owner.model.Owner;
import org.springframework.samples.petclinic.owner.model.PetType;
/** /**
* Repository class for <code>Owner</code> domain objects All method names are compliant * Repository class for <code>Owner</code> domain objects All method names are compliant

View file

@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.samples.petclinic.owner.validation;
import org.springframework.samples.petclinic.owner.model.Pet;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.validation.Validator; import org.springframework.validation.Validator;

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.system; package org.springframework.samples.petclinic.system.config;
import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer; import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;

View file

@ -1,4 +1,4 @@
package org.springframework.samples.petclinic.system; package org.springframework.samples.petclinic.system.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.system; package org.springframework.samples.petclinic.system.controller;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.GetMapping;
* Also see how a view that resolves to "error" has been added ("error.html"). * Also see how a view that resolves to "error" has been added ("error.html").
*/ */
@Controller @Controller
class CrashController { public class CrashController {
@GetMapping("/oups") @GetMapping("/oups")
public String triggerException() { public String triggerException() {

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.system; package org.springframework.samples.petclinic.system.controller;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;

View file

@ -13,13 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.vet; package org.springframework.samples.petclinic.vet.controller;
import java.util.List; import java.util.List;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.samples.petclinic.vet.model.Vet;
import org.springframework.samples.petclinic.vet.repository.VetRepository;
import org.springframework.samples.petclinic.vet.model.Vets;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -33,7 +36,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @author Arjen Poutsma * @author Arjen Poutsma
*/ */
@Controller @Controller
class VetController { public class VetController {
private final VetRepository vetRepository; private final VetRepository vetRepository;

View file

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.vet; package org.springframework.samples.petclinic.vet.model;
import org.springframework.samples.petclinic.model.NamedEntity; import org.springframework.samples.petclinic.common.model.NamedEntity;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Table; import jakarta.persistence.Table;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.vet; package org.springframework.samples.petclinic.vet.model;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
@ -21,8 +21,8 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.samples.petclinic.model.NamedEntity; import org.springframework.samples.petclinic.common.model.NamedEntity;
import org.springframework.samples.petclinic.model.Person; import org.springframework.samples.petclinic.common.model.Person;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.vet; package org.springframework.samples.petclinic.vet.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.vet; package org.springframework.samples.petclinic.vet.repository;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import org.springframework.samples.petclinic.vet.model.Vet;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Collection; import java.util.Collection;

View file

@ -1,7 +1,22 @@
# database init, supports mysql too # database init, supports mysql too
database=h2 #database=jdbc:mysql://localhost:3306/petclinic?useSSL=false&serverTimezone=UTC
spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql #spring.datasource.username=root
spring.sql.init.data-locations=classpath*:db/${database}/data.sql #spring.datasource.password=testA@123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# database init, supports mysql too
database=mysql
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/petclinic}
spring.datasource.username=root
spring.datasource.password=testA@123
# SQL is written to be idempotent so this is safe
spring.sql.init.mode=always
# Hibernate Dialect (important for compatibility)
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.sql.init.schema-locations=classpath*:db/mysql/schema.sql
spring.sql.init.data-locations=classpath*:db/mysql/data.sql
# Web # Web
spring.thymeleaf.mode=HTML spring.thymeleaf.mode=HTML

View file

@ -29,7 +29,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity; import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.samples.petclinic.vet.VetRepository; import org.springframework.samples.petclinic.vet.repository.VetRepository;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.aot.DisabledInAotMode; import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;

View file

@ -28,7 +28,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity; import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.samples.petclinic.vet.VetRepository; import org.springframework.samples.petclinic.vet.repository.VetRepository;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)

View file

@ -43,7 +43,7 @@ import org.springframework.core.env.PropertySource;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity; import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.samples.petclinic.vet.VetRepository; import org.springframework.samples.petclinic.vet.repository.VetRepository;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.testcontainers.DockerClientFactory; import org.testcontainers.DockerClientFactory;

View file

@ -23,6 +23,7 @@ import java.util.Set;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.samples.petclinic.common.model.Person;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import jakarta.validation.ConstraintViolation; import jakarta.validation.ConstraintViolation;

View file

@ -24,6 +24,12 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.samples.petclinic.owner.controller.OwnerController;
import org.springframework.samples.petclinic.owner.model.Owner;
import org.springframework.samples.petclinic.owner.model.Pet;
import org.springframework.samples.petclinic.owner.model.PetType;
import org.springframework.samples.petclinic.owner.model.Visit;
import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
import org.springframework.test.context.aot.DisabledInAotMode; import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;

View file

@ -24,6 +24,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.FilterType;
import org.springframework.samples.petclinic.common.formatter.PetTypeFormatter;
import org.springframework.samples.petclinic.owner.controller.PetController;
import org.springframework.samples.petclinic.owner.controller.PetController;
import org.springframework.samples.petclinic.owner.model.Owner;
import org.springframework.samples.petclinic.owner.model.Pet;
import org.springframework.samples.petclinic.owner.model.PetType;
import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
import org.springframework.test.context.aot.DisabledInAotMode; import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;

View file

@ -32,6 +32,9 @@ import org.junit.jupiter.api.condition.DisabledInNativeImage;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.samples.petclinic.common.formatter.PetTypeFormatter;
import org.springframework.samples.petclinic.owner.model.PetType;
import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
/** /**
* Test class for {@link PetTypeFormatter} * Test class for {@link PetTypeFormatter}

View file

@ -22,6 +22,9 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.junit.jupiter.api.condition.DisabledInNativeImage;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.samples.petclinic.owner.model.Pet;
import org.springframework.samples.petclinic.owner.model.PetType;
import org.springframework.samples.petclinic.owner.validation.PetValidator;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.validation.MapBindingResult; import org.springframework.validation.MapBindingResult;

View file

@ -28,6 +28,10 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.junit.jupiter.api.condition.DisabledInNativeImage;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.samples.petclinic.owner.controller.VisitController;
import org.springframework.samples.petclinic.owner.model.Owner;
import org.springframework.samples.petclinic.owner.model.Pet;
import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
import org.springframework.test.context.aot.DisabledInAotMode; import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;

View file

@ -29,13 +29,13 @@ import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabas
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.samples.petclinic.owner.Owner; import org.springframework.samples.petclinic.owner.model.Owner;
import org.springframework.samples.petclinic.owner.OwnerRepository; import org.springframework.samples.petclinic.owner.repository.OwnerRepository;
import org.springframework.samples.petclinic.owner.Pet; import org.springframework.samples.petclinic.owner.model.Pet;
import org.springframework.samples.petclinic.owner.PetType; import org.springframework.samples.petclinic.owner.model.PetType;
import org.springframework.samples.petclinic.owner.Visit; import org.springframework.samples.petclinic.owner.model.Visit;
import org.springframework.samples.petclinic.vet.Vet; import org.springframework.samples.petclinic.vet.model.Vet;
import org.springframework.samples.petclinic.vet.VetRepository; import org.springframework.samples.petclinic.vet.repository.VetRepository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
/** /**

View file

@ -17,7 +17,7 @@
package org.springframework.samples.petclinic.service; package org.springframework.samples.petclinic.service;
import org.springframework.orm.ObjectRetrievalFailureException; import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.samples.petclinic.model.BaseEntity; import org.springframework.samples.petclinic.common.model.BaseEntity;
import java.util.Collection; import java.util.Collection;
@ -27,7 +27,7 @@ import java.util.Collection;
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Sam Brannen * @author Sam Brannen
* @see org.springframework.samples.petclinic.model.BaseEntity * @see BaseEntity
* @since 29.10.2003 * @since 29.10.2003
*/ */
public abstract class EntityUtils { public abstract class EntityUtils {

View file

@ -41,7 +41,7 @@ import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
/** /**
* Integration Test for {@link CrashController}. * Integration Test for {@link org.springframework.samples.petclinic.system.controller.CrashController}.
* *
* @author Alex Lutz * @author Alex Lutz
*/ */

View file

@ -19,9 +19,10 @@ package org.springframework.samples.petclinic.system;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.springframework.samples.petclinic.system.controller.CrashController;
/** /**
* Test class for {@link CrashController} * Test class for {@link org.springframework.samples.petclinic.system.controller.CrashController}
* *
* @author Colin But * @author Colin But
* @author Alex Lutz * @author Alex Lutz

View file

@ -25,6 +25,10 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.samples.petclinic.vet.controller.VetController;
import org.springframework.samples.petclinic.vet.model.Specialty;
import org.springframework.samples.petclinic.vet.model.Vet;
import org.springframework.samples.petclinic.vet.repository.VetRepository;
import org.springframework.test.context.aot.DisabledInAotMode; import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;

View file

@ -16,6 +16,7 @@
package org.springframework.samples.petclinic.vet; package org.springframework.samples.petclinic.vet;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.samples.petclinic.vet.model.Vet;
import org.springframework.util.SerializationUtils; import org.springframework.util.SerializationUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;