From 536e7e9ae22880935bcd8f92b3b2dc3837fd1ac2 Mon Sep 17 00:00:00 2001
From: Maciej Szarlinski <mszarlinski@gmail.com>
Date: Sun, 30 Oct 2016 17:22:19 +0100
Subject: [PATCH] Repackage classes to be in accordance with DDD guidance

---
 readme.md                                     |   5 +
 .../petclinic/PetClinicApplication.java       |   8 +-
 .../web/owner}/OwnerResource.java             |  57 ++++------
 .../web/pet}/PetResource.java                 |  35 +++---
 .../web/pet}/PetValidator.java                |   4 +-
 .../web/vet}/VetResource.java                 |  24 ++--
 .../web/visit}/VisitResource.java             |  30 ++---
 .../{model => domain/model/owner}/Owner.java  |  21 ++--
 .../model/owner}/OwnerRepository.java         |  10 +-
 .../domain/model/owner/OwnerService.java      |  38 +++++++
 .../{model => domain/model/pet}/Pet.java      |  27 ++---
 .../model/pet}/PetRepository.java             |  10 +-
 .../domain/model/pet/PetService.java          |  37 +++++++
 .../{model => domain/model/pet}/PetType.java  |   4 +-
 .../model/vet}/Specialty.java                 |   4 +-
 .../{model => domain/model/vet}/Vet.java      |   3 +-
 .../model/vet}/VetRepository.java             |   7 +-
 .../domain/model/vet/VetService.java          |  29 +++++
 .../{model => domain/model/vet}/Vets.java     |   4 +-
 .../{model => domain/model/visit}/Visit.java  |  12 +-
 .../model/visit}/VisitRepository.java         |   6 +-
 .../domain/model/visit/VisitService.java      |  25 +++++
 .../{model => domain/shared}/Person.java      |   3 +-
 .../CallMonitoringAspect.java                 |   2 +-
 .../config/CacheConfig.java                   |   3 +-
 .../config/PetclinicProperties.java           |   2 +-
 .../config/WebConfig.java                     |   2 +-
 .../samples/petclinic/model/package-info.java |   8 --
 .../petclinic/service/ClinicService.java      |  50 ---------
 .../petclinic/service/ClinicServiceImpl.java  | 104 ------------------
 .../{model => support/jpa}/BaseEntity.java    |   2 +-
 .../{model => support/jpa}/NamedEntity.java   |   2 +-
 .../web/AbstractResourceController.java       |   4 +-
 .../web/pet}/PetResourceTests.java            |  36 +++---
 .../web/vet}/VetResourceTests.java            |  14 +--
 .../model}/AbstractClinicServiceTests.java    |  97 +++++++++-------
 .../model}/EntityUtils.java                   |   6 +-
 .../ValidatorTests.java                       |  11 +-
 38 files changed, 347 insertions(+), 399 deletions(-)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{web => boundary/web/owner}/OwnerResource.java (58%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{web => boundary/web/pet}/PetResource.java (78%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{web => boundary/web/pet}/PetValidator.java (92%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{web => boundary/web/vet}/VetResource.java (67%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{web => boundary/web/visit}/VisitResource.java (60%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => domain/model/owner}/Owner.java (91%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{repository => domain/model/owner}/OwnerRepository.java (73%)
 create mode 100644 springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/OwnerService.java
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => domain/model/pet}/Pet.java (78%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{repository => domain/model/pet}/PetRepository.java (86%)
 create mode 100644 springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetService.java
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => domain/model/pet}/PetType.java (86%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => domain/model/vet}/Specialty.java (86%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => domain/model/vet}/Vet.java (94%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{repository => domain/model/vet}/VetRepository.java (92%)
 create mode 100644 springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/VetService.java
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => domain/model/vet}/Vets.java (91%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => domain/model/visit}/Visit.java (89%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{repository => domain/model/visit}/VisitRepository.java (88%)
 create mode 100644 springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/VisitService.java
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => domain/shared}/Person.java (91%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{util => infrastructure}/CallMonitoringAspect.java (97%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{ => infrastructure}/config/CacheConfig.java (93%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{ => infrastructure}/config/PetclinicProperties.java (94%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{ => infrastructure}/config/WebConfig.java (86%)
 delete mode 100644 springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/package-info.java
 delete mode 100644 springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java
 delete mode 100644 springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/service/ClinicServiceImpl.java
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => support/jpa}/BaseEntity.java (95%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{model => support/jpa}/NamedEntity.java (95%)
 rename springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/{ => support}/web/AbstractResourceController.java (86%)
 rename springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/{web => boundary/web/pet}/PetResourceTests.java (55%)
 rename springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/{web => boundary/web/vet}/VetResourceTests.java (74%)
 rename springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/{service => domain/model}/AbstractClinicServiceTests.java (71%)
 rename springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/{service => domain/model}/EntityUtils.java (90%)
 rename springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/{model => infrastructure}/ValidatorTests.java (87%)

diff --git a/readme.md b/readme.md
index 1db67921..7ae1da37 100644
--- a/readme.md
+++ b/readme.md
@@ -3,6 +3,11 @@
 ## Understanding the Spring Petclinic application with a few diagrams
 <a href="https://speakerdeck.com/michaelisvy/spring-petclinic-sample-application">See the presentation here</a>
 
+## Implementation of Domain Driven Desing based on following samples
+* https://github.com/VaughnVernon/IDDD_Samples
+* https://github.com/citerus/dddsample-core
+* https://github.com/BottegaIT/ddd-leaven-v2
+
 ## Running petclinic locally
 ```
 	git clone https://github.com/spring-projects/spring-petclinic.git
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java
index c9b8e697..b9475fef 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java
@@ -3,13 +3,7 @@ package org.springframework.samples.petclinic;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.samples.petclinic.config.PetclinicProperties;
-import org.springframework.ui.ModelMap;
-import org.springframework.web.context.request.WebRequest;
-import org.springframework.web.context.request.WebRequestInterceptor;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.samples.petclinic.infrastructure.config.PetclinicProperties;
 
 @SpringBootApplication
 @EnableConfigurationProperties(PetclinicProperties.class)
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/owner/OwnerResource.java
similarity index 58%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/owner/OwnerResource.java
index e37ac350..c0fe34ac 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/owner/OwnerResource.java
@@ -13,25 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.web;
-
-import java.util.Collection;
+package org.springframework.samples.petclinic.boundary.web.owner;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
-import org.springframework.samples.petclinic.model.Owner;
-import org.springframework.samples.petclinic.service.ClinicService;
+import org.springframework.samples.petclinic.domain.model.owner.Owner;
+import org.springframework.samples.petclinic.domain.model.owner.OwnerService;
+import org.springframework.samples.petclinic.support.web.AbstractResourceController;
 import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.InitBinder;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.util.Collection;
 
 /**
  * @author Juergen Hoeller
@@ -42,21 +35,20 @@ import javax.validation.Valid;
 @RestController
 public class OwnerResource extends AbstractResourceController {
 
-    private final ClinicService clinicService;
-
+    private final OwnerService ownerService;
 
     @Autowired
-    public OwnerResource(ClinicService clinicService) {
-        this.clinicService = clinicService;
+    public OwnerResource(OwnerService ownerService) {
+        this.ownerService = ownerService;
     }
 
     @InitBinder
     public void setAllowedFields(WebDataBinder dataBinder) {
         dataBinder.setDisallowedFields("id");
     }
-    
+
     private Owner retrieveOwner(int ownerId) {
-        return this.clinicService.findOwnerById(ownerId);
+        return this.ownerService.findOwnerById(ownerId);
     }
 
     /**
@@ -65,9 +57,9 @@ public class OwnerResource extends AbstractResourceController {
     @RequestMapping(value = "/owner", method = RequestMethod.POST)
     @ResponseStatus(HttpStatus.CREATED)
     public void createOwner(@Valid @RequestBody Owner owner) {
-    	this.clinicService.saveOwner(owner);
+        this.ownerService.saveOwner(owner);
     }
-    
+
     /**
      * Read single Owner
      */
@@ -75,31 +67,30 @@ public class OwnerResource extends AbstractResourceController {
     public Owner findOwner(@PathVariable("ownerId") int ownerId) {
         return retrieveOwner(ownerId);
     }
-    
+
     /**
      * Read List of Owners
      */
     @GetMapping("/owner/list")
     public Collection<Owner> findAll() {
-        return clinicService.findAll();
+        return ownerService.findAll();
     }
-    
+
     /**
      * Update Owner
      */
     @RequestMapping(value = "/owner/{ownerId}", method = RequestMethod.PUT)
     public Owner updateOwner(@PathVariable("ownerId") int ownerId, @Valid @RequestBody Owner ownerRequest) {
-    	Owner ownerModel = retrieveOwner(ownerId);
-    	// This is done by hand for simplicity purpose. In a real life use-case we should consider using MapStruct.
-    	ownerModel.setFirstName(ownerRequest.getFirstName());
-    	ownerModel.setLastName(ownerRequest.getLastName());
-    	ownerModel.setCity(ownerRequest.getCity());
-    	ownerModel.setAddress(ownerRequest.getAddress());
-    	ownerModel.setTelephone(ownerRequest.getTelephone());
-        this.clinicService.saveOwner(ownerModel);
+        Owner ownerModel = retrieveOwner(ownerId);
+        // This is done by hand for simplicity purpose. In a real life use-case we should consider using MapStruct.
+        ownerModel.setFirstName(ownerRequest.getFirstName());
+        ownerModel.setLastName(ownerRequest.getLastName());
+        ownerModel.setCity(ownerRequest.getCity());
+        ownerModel.setAddress(ownerRequest.getAddress());
+        ownerModel.setTelephone(ownerRequest.getTelephone());
+        this.ownerService.saveOwner(ownerModel);
         return ownerModel;
     }
 
 
-
 }
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetResource.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/pet/PetResource.java
similarity index 78%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetResource.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/pet/PetResource.java
index 192bbfb2..a1d61178 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetResource.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/pet/PetResource.java
@@ -13,16 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.web;
+package org.springframework.samples.petclinic.boundary.web.pet;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.http.HttpStatus;
-import org.springframework.samples.petclinic.model.Owner;
-import org.springframework.samples.petclinic.model.Pet;
-import org.springframework.samples.petclinic.model.PetType;
-import org.springframework.samples.petclinic.service.ClinicService;
+import org.springframework.samples.petclinic.domain.model.owner.Owner;
+import org.springframework.samples.petclinic.domain.model.owner.OwnerService;
+import org.springframework.samples.petclinic.domain.model.pet.Pet;
+import org.springframework.samples.petclinic.domain.model.pet.PetService;
+import org.springframework.samples.petclinic.domain.model.pet.PetType;
+import org.springframework.samples.petclinic.support.web.AbstractResourceController;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.constraints.Size;
@@ -37,21 +39,24 @@ import java.util.Map;
 @RestController
 public class PetResource extends AbstractResourceController {
 
-    private final ClinicService clinicService;
+    private final PetService petService;
+
+    private final OwnerService ownerService;
 
     @Autowired
-    public PetResource(ClinicService clinicService) {
-        this.clinicService = clinicService;
+    public PetResource(PetService petService, OwnerService ownerService) {
+        this.petService = petService;
+        this.ownerService = ownerService;
     }
 
     @GetMapping("/petTypes")
     Object getPetTypes() {
-        return clinicService.findPetTypes();
+        return petService.findPetTypes();
     }
 
     @GetMapping("/owners/{ownerId}/pets/new")
     public String initCreationForm(@PathVariable("ownerId") int ownerId, Map<String, Object> model) {
-        Owner owner = this.clinicService.findOwnerById(ownerId);
+        Owner owner = this.ownerService.findOwnerById(ownerId);
         Pet pet = new Pet();
         owner.addPet(pet);
         model.put("pet", pet);
@@ -65,7 +70,7 @@ public class PetResource extends AbstractResourceController {
             @PathVariable("ownerId") int ownerId) {
 
         Pet pet = new Pet();
-        Owner owner = this.clinicService.findOwnerById(ownerId);
+        Owner owner = this.ownerService.findOwnerById(ownerId);
         owner.addPet(pet);
 
         save(pet, petRequest);
@@ -74,7 +79,7 @@ public class PetResource extends AbstractResourceController {
     @PutMapping("/owners/{ownerId}/pets/{petId}")
     @ResponseStatus(HttpStatus.NO_CONTENT)
     public void processUpdateForm(@RequestBody PetRequest petRequest) {
-        save(clinicService.findPetById(petRequest.getId()), petRequest);
+        save(petService.findPetById(petRequest.getId()), petRequest);
     }
 
     private void save(Pet pet, PetRequest petRequest) {
@@ -82,18 +87,18 @@ public class PetResource extends AbstractResourceController {
         pet.setName(petRequest.getName());
         pet.setBirthDate(petRequest.getBirthDate());
 
-        for (PetType petType : clinicService.findPetTypes()) {
+        for (PetType petType : petService.findPetTypes()) {
             if (petType.getId() == petRequest.getTypeId()) {
                 pet.setType(petType);
             }
         }
 
-        clinicService.savePet(pet);
+        petService.savePet(pet);
     }
 
     @GetMapping("/owner/*/pet/{petId}")
     public PetDetails findPet(@PathVariable("petId") int petId) {
-        Pet pet = this.clinicService.findPetById(petId);
+        Pet pet = this.petService.findPetById(petId);
         return new PetDetails(pet);
     }
 
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/pet/PetValidator.java
similarity index 92%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/pet/PetValidator.java
index fbb7dd5b..78fa4eff 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/pet/PetValidator.java
@@ -13,9 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.web;
+package org.springframework.samples.petclinic.boundary.web.pet;
 
-import org.springframework.samples.petclinic.model.Pet;
+import org.springframework.samples.petclinic.domain.model.pet.Pet;
 import org.springframework.util.StringUtils;
 import org.springframework.validation.Errors;
 
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VetResource.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/vet/VetResource.java
similarity index 67%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VetResource.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/vet/VetResource.java
index b476a43c..38254dde 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VetResource.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/vet/VetResource.java
@@ -13,19 +13,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.web;
-
-import java.util.Collection;
+package org.springframework.samples.petclinic.boundary.web.vet;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.samples.petclinic.model.Vet;
-import org.springframework.samples.petclinic.service.ClinicService;
+import org.springframework.samples.petclinic.domain.model.vet.Vet;
+import org.springframework.samples.petclinic.domain.model.vet.VetService;
+import org.springframework.samples.petclinic.support.web.AbstractResourceController;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Collection;
+
 /**
  * @author Juergen Hoeller
  * @author Mark Fisher
@@ -35,15 +33,15 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 public class VetResource extends AbstractResourceController {
 
-    private final ClinicService clinicService;
+    private final VetService vetService;
 
     @Autowired
-    public VetResource(ClinicService clinicService) {
-        this.clinicService = clinicService;
+    public VetResource(VetService vetService) {
+        this.vetService = vetService;
     }
-    
+
     @GetMapping("/vets")
     public Collection<Vet> showResourcesVetList() {
-        return this.clinicService.findVets();
+        return this.vetService.findVets();
     }
 }
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VisitResource.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/visit/VisitResource.java
similarity index 60%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VisitResource.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/visit/VisitResource.java
index 12db83c7..be857685 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VisitResource.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/boundary/web/visit/VisitResource.java
@@ -13,18 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.web;
+package org.springframework.samples.petclinic.boundary.web.visit;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
-import org.springframework.samples.petclinic.model.Visit;
-import org.springframework.samples.petclinic.service.ClinicService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.samples.petclinic.domain.model.pet.PetService;
+import org.springframework.samples.petclinic.domain.model.visit.Visit;
+import org.springframework.samples.petclinic.domain.model.visit.VisitService;
+import org.springframework.samples.petclinic.support.web.AbstractResourceController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 
@@ -37,11 +34,14 @@ import javax.validation.Valid;
 @RestController
 public class VisitResource extends AbstractResourceController {
 
-    private final ClinicService clinicService;
+    private final VisitService visitService;
+
+    private final PetService petService;
 
     @Autowired
-    public VisitResource(ClinicService clinicService) {
-        this.clinicService = clinicService;
+    public VisitResource(VisitService visitService, PetService petService) {
+        this.visitService = visitService;
+        this.petService = petService;
     }
 
     @PostMapping("/owners/{ownerId}/pets/{petId}/visits")
@@ -50,12 +50,12 @@ public class VisitResource extends AbstractResourceController {
             @Valid @RequestBody Visit visit,
             @PathVariable("petId") int petId) {
 
-        clinicService.findPetById(petId).addVisit(visit);
-        clinicService.saveVisit(visit);
+        petService.findPetById(petId).addVisit(visit);
+        visitService.saveVisit(visit);
     }
 
     @GetMapping("/owners/{ownerId}/pets/{petId}/visits")
     public Object visits(@PathVariable("petId") int petId) {
-        return clinicService.findPetById(petId).getVisits();
+        return petService.findPetById(petId).getVisits();
     }
 }
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Owner.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/Owner.java
similarity index 91%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Owner.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/Owner.java
index 840a965e..560ee262 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Owner.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/Owner.java
@@ -13,25 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.validation.constraints.Digits;
+package org.springframework.samples.petclinic.domain.model.owner;
 
 import org.hibernate.validator.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.domain.model.pet.Pet;
+import org.springframework.samples.petclinic.domain.shared.Person;
+
+import javax.persistence.*;
+import javax.validation.constraints.Digits;
+import java.util.*;
 
 /**
  * Simple JavaBean domain object representing an owner.
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/OwnerRepository.java
similarity index 73%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/OwnerRepository.java
index 4e0c7c4a..8c25b893 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/OwnerRepository.java
@@ -13,17 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.repository;
+package org.springframework.samples.petclinic.domain.model.owner;
 
-import java.util.Collection;
-
-import org.springframework.dao.DataAccessException;
 import org.springframework.data.jpa.repository.JpaRepository;
-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.model.BaseEntity;
-import org.springframework.samples.petclinic.model.Owner;
 
 /**
  * Repository class for <code>Owner</code> domain objects All method names are compliant with Spring Data naming
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/OwnerService.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/OwnerService.java
new file mode 100644
index 00000000..ca66e8b8
--- /dev/null
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/owner/OwnerService.java
@@ -0,0 +1,38 @@
+package org.springframework.samples.petclinic.domain.model.owner;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataAccessException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collection;
+
+/**
+ * @author mszarlinski on 2016-10-30.
+ */
+@Service
+public class OwnerService {
+
+    private final OwnerRepository ownerRepository;
+
+    @Autowired
+    public OwnerService(OwnerRepository ownerRepository) {
+        this.ownerRepository = ownerRepository;
+    }
+
+    @Transactional(readOnly = true)
+    public Owner findOwnerById(int id) throws DataAccessException {
+        return ownerRepository.findOne(id);
+    }
+
+    @Transactional(readOnly = true)
+    public Collection<Owner> findAll() throws DataAccessException {
+        return ownerRepository.findAll();
+    }
+
+    @Transactional
+    public void saveOwner(Owner owner) throws DataAccessException {
+        ownerRepository.save(owner);
+    }
+
+}
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Pet.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/Pet.java
similarity index 78%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Pet.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/Pet.java
index a121e7b8..7e5501f8 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Pet.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/Pet.java
@@ -13,28 +13,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.domain.model.pet;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import org.springframework.beans.support.MutableSortDefinition;
 import org.springframework.beans.support.PropertyComparator;
+import org.springframework.samples.petclinic.domain.model.owner.Owner;
+import org.springframework.samples.petclinic.domain.model.visit.Visit;
+import org.springframework.samples.petclinic.support.jpa.NamedEntity;
 
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import javax.persistence.*;
+import java.util.*;
 
 /**
  * Simple business object representing a pet.
@@ -80,7 +69,7 @@ public class Pet extends NamedEntity {
         return this.type;
     }
 
-    protected void setOwner(Owner owner) {
+    public void setOwner(Owner owner) {
         this.owner = owner;
     }
 
@@ -94,7 +83,7 @@ public class Pet extends NamedEntity {
 
     protected Set<Visit> getVisitsInternal() {
         if (this.visits == null) {
-            this.visits = new HashSet<Visit>();
+            this.visits = new HashSet<>();
         }
         return this.visits;
     }
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetRepository.java
similarity index 86%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetRepository.java
index 58e73d7f..d9893772 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetRepository.java
@@ -13,16 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.repository;
+package org.springframework.samples.petclinic.domain.model.pet;
 
-import java.util.List;
-
-import org.springframework.dao.DataAccessException;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.Repository;
-import org.springframework.samples.petclinic.model.BaseEntity;
-import org.springframework.samples.petclinic.model.Pet;
-import org.springframework.samples.petclinic.model.PetType;
+
+import java.util.List;
 
 /**
  * Repository class for <code>Pet</code> domain objects All method names are compliant with Spring Data naming
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetService.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetService.java
new file mode 100644
index 00000000..2a733a01
--- /dev/null
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetService.java
@@ -0,0 +1,37 @@
+package org.springframework.samples.petclinic.domain.model.pet;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataAccessException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collection;
+
+/**
+ * @author mszarlinski on 2016-10-30.
+ */
+@Service
+public class PetService {
+
+    private final PetRepository petRepository;
+
+    @Autowired
+    public PetService(PetRepository petRepository) {
+        this.petRepository = petRepository;
+    }
+
+    @Transactional(readOnly = true)
+    public Pet findPetById(int id) throws DataAccessException {
+        return petRepository.findById(id);
+    }
+
+    @Transactional
+    public void savePet(Pet pet) throws DataAccessException {
+        petRepository.save(pet);
+    }
+
+    @Transactional(readOnly = true)
+    public Collection<PetType> findPetTypes() throws DataAccessException {
+        return petRepository.findPetTypes();
+    }
+}
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/PetType.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetType.java
similarity index 86%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/PetType.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetType.java
index 99adf759..7692e8e7 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/PetType.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/pet/PetType.java
@@ -13,7 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.domain.model.pet;
+
+import org.springframework.samples.petclinic.support.jpa.NamedEntity;
 
 import javax.persistence.Entity;
 import javax.persistence.Table;
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Specialty.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Specialty.java
similarity index 86%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Specialty.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Specialty.java
index 6ea209cd..3d57d43a 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Specialty.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Specialty.java
@@ -13,7 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.domain.model.vet;
+
+import org.springframework.samples.petclinic.support.jpa.NamedEntity;
 
 import javax.persistence.Entity;
 import javax.persistence.Table;
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Vet.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Vet.java
similarity index 94%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Vet.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Vet.java
index c58bd85b..2e6fb04a 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Vet.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Vet.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.domain.model.vet;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlElement;
 
 import org.springframework.beans.support.MutableSortDefinition;
 import org.springframework.beans.support.PropertyComparator;
+import org.springframework.samples.petclinic.domain.shared.Person;
 
 /**
  * Simple JavaBean domain object representing a veterinarian.
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/VetRepository.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/VetRepository.java
similarity index 92%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/VetRepository.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/VetRepository.java
index aabdfd65..ecb986e8 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/VetRepository.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/VetRepository.java
@@ -13,13 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.repository;
-
-import java.util.Collection;
+package org.springframework.samples.petclinic.domain.model.vet;
 
 import org.springframework.dao.DataAccessException;
 import org.springframework.data.repository.Repository;
-import org.springframework.samples.petclinic.model.Vet;
+
+import java.util.Collection;
 
 /**
  * Repository class for <code>Vet</code> domain objects All method names are compliant with Spring Data naming
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/VetService.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/VetService.java
new file mode 100644
index 00000000..9c4b9740
--- /dev/null
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/VetService.java
@@ -0,0 +1,29 @@
+package org.springframework.samples.petclinic.domain.model.vet;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataAccessException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.cache.annotation.CacheResult;
+import java.util.Collection;
+
+/**
+ * @author mszarlinski on 2016-10-30.
+ */
+@Service
+public class VetService {
+
+    private final VetRepository vetRepository;
+
+    @Autowired
+    public VetService(VetRepository vetRepository) {
+        this.vetRepository = vetRepository;
+    }
+
+    @Transactional(readOnly = true)
+    @CacheResult(cacheName = "vets")
+    public Collection<Vet> findVets() throws DataAccessException {
+        return vetRepository.findAll();
+    }
+}
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Vets.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Vets.java
similarity index 91%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Vets.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Vets.java
index e8f44a7b..3a52aec6 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Vets.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/vet/Vets.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.domain.model.vet;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -36,7 +36,7 @@ public class Vets {
     @XmlElement
     public List<Vet> getVetList() {
         if (vets == null) {
-            vets = new ArrayList<Vet>();
+            vets = new ArrayList<>();
         }
         return vets;
     }
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Visit.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/Visit.java
similarity index 89%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Visit.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/Visit.java
index 4440c6f5..d2a90dc3 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Visit.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/Visit.java
@@ -13,18 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.domain.model.visit;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.springframework.samples.petclinic.domain.model.pet.Pet;
+import org.springframework.samples.petclinic.support.jpa.BaseEntity;
 
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
+import javax.persistence.*;
 import javax.validation.constraints.Size;
 import java.util.Date;
 
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/VisitRepository.java
similarity index 88%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/VisitRepository.java
index e734f327..6e8a91a7 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/VisitRepository.java
@@ -13,14 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.repository;
+package org.springframework.samples.petclinic.domain.model.visit;
 
 import java.util.List;
 
 import org.springframework.dao.DataAccessException;
 import org.springframework.data.repository.Repository;
-import org.springframework.samples.petclinic.model.BaseEntity;
-import org.springframework.samples.petclinic.model.Visit;
+import org.springframework.samples.petclinic.support.jpa.BaseEntity;
+import org.springframework.samples.petclinic.domain.model.visit.Visit;
 
 /**
  * Repository class for <code>Visit</code> domain objects All method names are compliant with Spring Data naming
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/VisitService.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/VisitService.java
new file mode 100644
index 00000000..997534c1
--- /dev/null
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/model/visit/VisitService.java
@@ -0,0 +1,25 @@
+package org.springframework.samples.petclinic.domain.model.visit;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataAccessException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author mszarlinski on 2016-10-30.
+ */
+@Service
+public class VisitService {
+
+    private final VisitRepository visitRepository;
+
+    @Autowired
+    public VisitService(VisitRepository visitRepository) {
+        this.visitRepository = visitRepository;
+    }
+
+    @Transactional
+    public void saveVisit(Visit visit) throws DataAccessException {
+        visitRepository.save(visit);
+    }
+}
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Person.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/shared/Person.java
similarity index 91%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Person.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/shared/Person.java
index d3e03c0d..631cd03f 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/Person.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/domain/shared/Person.java
@@ -13,12 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.domain.shared;
 
 import javax.persistence.Column;
 import javax.persistence.MappedSuperclass;
 
 import org.hibernate.validator.constraints.NotEmpty;
+import org.springframework.samples.petclinic.support.jpa.BaseEntity;
 
 /**
  * Simple JavaBean domain object representing an person.
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/CallMonitoringAspect.java
similarity index 97%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/CallMonitoringAspect.java
index 2ddcf5f6..c09e2214 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/CallMonitoringAspect.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.util;
+package org.springframework.samples.petclinic.infrastructure;
 
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/CacheConfig.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/CacheConfig.java
similarity index 93%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/CacheConfig.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/CacheConfig.java
index 512254b2..9e4786a0 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/CacheConfig.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/CacheConfig.java
@@ -1,4 +1,4 @@
-package org.springframework.samples.petclinic.config;
+package org.springframework.samples.petclinic.infrastructure.config;
 
 import org.ehcache.config.CacheConfiguration;
 import org.ehcache.config.builders.CacheConfigurationBuilder;
@@ -11,7 +11,6 @@ import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
 import org.springframework.cache.annotation.EnableCaching;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
 
 import javax.cache.CacheManager;
 import java.util.concurrent.TimeUnit;
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/PetclinicProperties.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/PetclinicProperties.java
similarity index 94%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/PetclinicProperties.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/PetclinicProperties.java
index 137529aa..0397aff7 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/PetclinicProperties.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/PetclinicProperties.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.config;
+package org.springframework.samples.petclinic.infrastructure.config;
 
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/WebConfig.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/WebConfig.java
similarity index 86%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/WebConfig.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/WebConfig.java
index ac207749..2d87a9c3 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/config/WebConfig.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/infrastructure/config/WebConfig.java
@@ -1,4 +1,4 @@
-package org.springframework.samples.petclinic.config;
+package org.springframework.samples.petclinic.infrastructure.config;
 
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/package-info.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/package-info.java
deleted file mode 100644
index 2723dc9a..00000000
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-
-/**
- *
- * The classes in this package represent PetClinic's business layer.
- *
- */
-package org.springframework.samples.petclinic.model;
-
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java
deleted file mode 100644
index d35e26bd..00000000
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2002-2013 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
- *
- *      http://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.
- */
-package org.springframework.samples.petclinic.service;
-
-import java.util.Collection;
-
-import org.springframework.samples.petclinic.model.Owner;
-import org.springframework.samples.petclinic.model.Pet;
-import org.springframework.samples.petclinic.model.PetType;
-import org.springframework.samples.petclinic.model.Vet;
-import org.springframework.samples.petclinic.model.Visit;
-
-
-/**
- * Mostly used as a facade so all controllers have a single point of entry
- *
- * @author Michael Isvy
- */
-public interface ClinicService {
-
-    Collection<PetType> findPetTypes();
-
-    Owner findOwnerById(int id);
-
-    Pet findPetById(int id);
-
-    void savePet(Pet pet);
-
-    void saveVisit(Visit visit);
-
-    Collection<Vet> findVets();
-
-    void saveOwner(Owner owner);
-
-    Collection<Owner> findAll();
-
-}
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/service/ClinicServiceImpl.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/service/ClinicServiceImpl.java
deleted file mode 100644
index 4c7218c2..00000000
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/service/ClinicServiceImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2002-2013 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
- *
- *      http://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.
- */
-package org.springframework.samples.petclinic.service;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataAccessException;
-import org.springframework.samples.petclinic.model.*;
-import org.springframework.samples.petclinic.repository.OwnerRepository;
-import org.springframework.samples.petclinic.repository.PetRepository;
-import org.springframework.samples.petclinic.repository.VetRepository;
-import org.springframework.samples.petclinic.repository.VisitRepository;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.cache.annotation.CacheResult;
-import java.util.Collection;
-
-/**
- * Mostly used as a facade for all Petclinic controllers
- * Also a placeholder for @Transactional and @Cacheable annotations
- *
- * @author Michael Isvy
- */
-@Service
-public class ClinicServiceImpl implements ClinicService {
-
-    private PetRepository petRepository;
-    private VetRepository vetRepository;
-    private OwnerRepository ownerRepository;
-    private VisitRepository visitRepository;
-
-    @Autowired
-    public ClinicServiceImpl(PetRepository petRepository, VetRepository vetRepository, OwnerRepository ownerRepository, VisitRepository visitRepository) {
-        this.petRepository = petRepository;
-        this.vetRepository = vetRepository;
-        this.ownerRepository = ownerRepository;
-        this.visitRepository = visitRepository;
-    }
-
-    @Override
-    @Transactional(readOnly = true)
-    public Collection<PetType> findPetTypes() throws DataAccessException {
-        return petRepository.findPetTypes();
-    }
-
-    @Override
-    @Transactional(readOnly = true)
-    public Owner findOwnerById(int id) throws DataAccessException {
-        return ownerRepository.findOne(id);
-    }
-
-    @Transactional(readOnly = true)
-    public Collection<Owner> findAll() throws DataAccessException {
-        return ownerRepository.findAll();
-    }
-
-    @Override
-    @Transactional
-    public void saveOwner(Owner owner) throws DataAccessException {
-        ownerRepository.save(owner);
-    }
-
-
-    @Override
-    @Transactional
-    public void saveVisit(Visit visit) throws DataAccessException {
-        visitRepository.save(visit);
-    }
-
-
-    @Override
-    @Transactional(readOnly = true)
-    public Pet findPetById(int id) throws DataAccessException {
-        return petRepository.findById(id);
-    }
-
-    @Override
-    @Transactional
-    public void savePet(Pet pet) throws DataAccessException {
-        petRepository.save(pet);
-    }
-
-    @Override
-    @Transactional(readOnly = true)
-    @CacheResult(cacheName = "vets")
-    public Collection<Vet> findVets() throws DataAccessException {
-        return vetRepository.findAll();
-    }
-
-
-}
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/jpa/BaseEntity.java
similarity index 95%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/jpa/BaseEntity.java
index 8dfbfe90..72bdac1f 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/jpa/BaseEntity.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.support.jpa;
 
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/jpa/NamedEntity.java
similarity index 95%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/jpa/NamedEntity.java
index cb36a626..f7244058 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/jpa/NamedEntity.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.support.jpa;
 
 import javax.persistence.Column;
 import javax.persistence.MappedSuperclass;
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/AbstractResourceController.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/web/AbstractResourceController.java
similarity index 86%
rename from springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/AbstractResourceController.java
rename to springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/web/AbstractResourceController.java
index 60fe88ca..d77808a5 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/AbstractResourceController.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/support/web/AbstractResourceController.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.web;
+package org.springframework.samples.petclinic.support.web;
 
 import org.springframework.web.bind.annotation.CrossOrigin;
 
@@ -21,5 +21,5 @@ import org.springframework.web.bind.annotation.CrossOrigin;
  * @author Antoine Rey
  */
 @CrossOrigin
-abstract class AbstractResourceController {
+public abstract class AbstractResourceController {
 }
diff --git a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/web/PetResourceTests.java b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/boundary/web/pet/PetResourceTests.java
similarity index 55%
rename from springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/web/PetResourceTests.java
rename to springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/boundary/web/pet/PetResourceTests.java
index 32a2bc7b..7c6e1db5 100644
--- a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/web/PetResourceTests.java
+++ b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/boundary/web/pet/PetResourceTests.java
@@ -1,4 +1,4 @@
-package org.springframework.samples.petclinic.web;
+package org.springframework.samples.petclinic.boundary.web.pet;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -6,18 +6,18 @@ 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.model.Owner;
-import org.springframework.samples.petclinic.model.Pet;
-import org.springframework.samples.petclinic.model.PetType;
-import org.springframework.samples.petclinic.service.ClinicService;
+import org.springframework.samples.petclinic.boundary.web.pet.PetResource;
+import org.springframework.samples.petclinic.domain.model.owner.Owner;
+import org.springframework.samples.petclinic.domain.model.owner.OwnerService;
+import org.springframework.samples.petclinic.domain.model.pet.Pet;
+import org.springframework.samples.petclinic.domain.model.pet.PetService;
+import org.springframework.samples.petclinic.domain.model.pet.PetType;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.servlet.MockMvc;
 
 import static org.mockito.BDDMockito.given;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 
 @RunWith(SpringRunner.class)
 @WebMvcTest(PetResource.class)
@@ -27,25 +27,29 @@ public class PetResourceTests {
     private MockMvc mvc;
 
     @MockBean
-    ClinicService clinicService;
+    PetService petService;
+
+    @MockBean
+    OwnerService ownerService;
 
     @Test
     public void shouldGetAPetInJSonFormat() throws Exception {
 
         Pet pet = setupPet();
 
-        given(clinicService.findPetById(2)).willReturn(pet);
+        given(petService.findPetById(2)).willReturn(pet);
 
 
         mvc.perform(get("/owner/2/pet/2.json").accept(MediaType.APPLICATION_JSON))
-                .andExpect(status().isOk())
-                .andExpect(content().contentType("application/json;charset=UTF-8"))
-                .andExpect(jsonPath("$.id").value(2))
-                .andExpect(jsonPath("$.name").value("Basil"))
-                .andExpect(jsonPath("$.type.id").value(6));
+            .andExpect(status().isOk())
+            .andExpect(content().contentType("application/json;charset=UTF-8"))
+            .andExpect(jsonPath("$.id").value(2))
+            .andExpect(jsonPath("$.name").value("Basil"))
+            .andExpect(jsonPath("$.type.id").value(6));
     }
 
-    private Pet setupPet() {Owner owner = new Owner();
+    private Pet setupPet() {
+        Owner owner = new Owner();
         owner.setFirstName("George");
         owner.setLastName("Bush");
 
diff --git a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/web/VetResourceTests.java b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/boundary/web/vet/VetResourceTests.java
similarity index 74%
rename from springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/web/VetResourceTests.java
rename to springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/boundary/web/vet/VetResourceTests.java
index 16c03574..56064f48 100644
--- a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/web/VetResourceTests.java
+++ b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/boundary/web/vet/VetResourceTests.java
@@ -1,4 +1,4 @@
-package org.springframework.samples.petclinic.web;
+package org.springframework.samples.petclinic.boundary.web.vet;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -6,13 +6,13 @@ 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.model.Vet;
-import org.springframework.samples.petclinic.service.ClinicService;
+import org.springframework.samples.petclinic.boundary.web.vet.VetResource;
+import org.springframework.samples.petclinic.domain.model.vet.Vet;
+import org.springframework.samples.petclinic.domain.model.vet.VetService;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.servlet.MockMvc;
 
-import java.util.Arrays;
-
+import static java.util.Arrays.asList;
 import static org.mockito.BDDMockito.given;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
@@ -26,7 +26,7 @@ public class VetResourceTests {
     private MockMvc mvc;
 
     @MockBean
-    ClinicService clinicService;
+    VetService vetService;
 
     @Test
     public void shouldGetAListOfVetsInJSonFormat() throws Exception {
@@ -34,7 +34,7 @@ public class VetResourceTests {
         Vet vet = new Vet();
         vet.setId(1);
 
-        given(clinicService.findVets()).willReturn(Arrays.asList(vet));
+        given(vetService.findVets()).willReturn(asList(vet));
 
         mvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON))
                 .andExpect(status().isOk())
diff --git a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/domain/model/AbstractClinicServiceTests.java
similarity index 71%
rename from springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java
rename to springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/domain/model/AbstractClinicServiceTests.java
index 50758829..fb871b91 100644
--- a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java
+++ b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/domain/model/AbstractClinicServiceTests.java
@@ -13,15 +13,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.service;
+package org.springframework.samples.petclinic.domain.model;
 
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.samples.petclinic.model.Owner;
-import org.springframework.samples.petclinic.model.Pet;
-import org.springframework.samples.petclinic.model.PetType;
-import org.springframework.samples.petclinic.model.Vet;
-import org.springframework.samples.petclinic.model.Visit;
+import org.springframework.samples.petclinic.domain.model.owner.Owner;
+import org.springframework.samples.petclinic.domain.model.owner.OwnerService;
+import org.springframework.samples.petclinic.domain.model.pet.Pet;
+import org.springframework.samples.petclinic.domain.model.pet.PetService;
+import org.springframework.samples.petclinic.domain.model.pet.PetType;
+import org.springframework.samples.petclinic.domain.model.vet.Vet;
+import org.springframework.samples.petclinic.domain.model.vet.VetService;
+import org.springframework.samples.petclinic.domain.model.visit.Visit;
+import org.springframework.samples.petclinic.domain.model.visit.VisitService;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -51,67 +55,76 @@ import static org.assertj.core.api.Assertions.assertThat;
 public abstract class AbstractClinicServiceTests {
 
     @Autowired
-    protected ClinicService clinicService;
+    protected OwnerService ownerService;
+
+    @Autowired
+    protected VetService vetService;
+
+    @Autowired
+    protected PetService petService;
+
+    @Autowired
+    protected VisitService visitService;
 
     @Test
     public void shouldFindSingleOwnerWithPet() {
-        Owner owner = this.clinicService.findOwnerById(1);
+        Owner owner = this.ownerService.findOwnerById(1);
         assertThat(owner.getLastName()).startsWith("Franklin");
         assertThat(owner.getPets().size()).isEqualTo(1);
     }
-    
+
     @Test
     public void shouldReturnAllOwnersInCaseLastNameIsEmpty() {
-        Collection<Owner> owners = this.clinicService.findAll();
-        assertThat(owners).extracting("lastName").contains("Davis", "Franklin");        
+        Collection<Owner> owners = this.ownerService.findAll();
+        assertThat(owners).extracting("lastName").contains("Davis", "Franklin");
     }
 
     @Test
     @Transactional
     public void shouldInsertOwner() {
-        Collection<Owner> owners = this.clinicService.findAll();
+        Collection<Owner> owners = this.ownerService.findAll();
         int found = owners.size();
-        
+
         Owner owner = new Owner();
         owner.setFirstName("Sam");
         owner.setLastName("Schultz");
         owner.setAddress("4, Evans Street");
         owner.setCity("Wollongong");
         owner.setTelephone("4444444444");
-        this.clinicService.saveOwner(owner);
+        this.ownerService.saveOwner(owner);
         assertThat(owner.getId().longValue()).isNotEqualTo(0);
 
-        owners = this.clinicService.findAll();
+        owners = this.ownerService.findAll();
         assertThat(owners.size()).isEqualTo(found + 1);
     }
 
     @Test
     @Transactional
     public void shouldUpdateOwner()  {
-        Owner owner = this.clinicService.findOwnerById(1);
+        Owner owner = this.ownerService.findOwnerById(1);
         String oldLastName = owner.getLastName();
         String newLastName = oldLastName + "X";
-        
+
         owner.setLastName(newLastName);
-        this.clinicService.saveOwner(owner);
+        this.ownerService.saveOwner(owner);
 
         // retrieving new name from database
-        owner = this.clinicService.findOwnerById(1);
+        owner = this.ownerService.findOwnerById(1);
         assertThat(owner.getLastName()).isEqualTo(newLastName);
     }
 
 	@Test
 	public void shouldFindPetWithCorrectId() {
-	    Pet pet7 = this.clinicService.findPetById(7);
+	    Pet pet7 = this.petService.findPetById(7);
 	    assertThat(pet7.getName()).startsWith("Samantha");
 	    assertThat(pet7.getOwner().getFirstName()).isEqualTo("Jean");
-	    
+
 	}
 
 	@Test
 	public void shouldFindAllPetTypes() {
-	    Collection<PetType> petTypes = this.clinicService.findPetTypes();
-	
+	    Collection<PetType> petTypes = this.petService.findPetTypes();
+
 	    PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1);
 	    assertThat(petType1.getName()).isEqualTo("cat");
 	    PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4);
@@ -121,21 +134,21 @@ public abstract class AbstractClinicServiceTests {
 	@Test
 	@Transactional
 	public void shouldInsertPetIntoDatabaseAndGenerateId() {
-	    Owner owner6 = this.clinicService.findOwnerById(6);
+	    Owner owner6 = this.ownerService.findOwnerById(6);
 	    int found = owner6.getPets().size();
-	    
+
 	    Pet pet = new Pet();
 	    pet.setName("bowser");
-	    Collection<PetType> types = this.clinicService.findPetTypes();
+	    Collection<PetType> types = this.petService.findPetTypes();
 	    pet.setType(EntityUtils.getById(types, PetType.class, 2));
 	    pet.setBirthDate(new Date());
 	    owner6.addPet(pet);
 	    assertThat(owner6.getPets().size()).isEqualTo(found + 1);
-	    
-	    this.clinicService.savePet(pet);
-	    this.clinicService.saveOwner(owner6);
-	    
-	    owner6 = this.clinicService.findOwnerById(6);
+
+	    this.petService.savePet(pet);
+	    this.ownerService.saveOwner(owner6);
+
+	    owner6 = this.ownerService.findOwnerById(6);
 	    assertThat(owner6.getPets().size()).isEqualTo(found + 1);
 	    // checks that id has been generated
 	    assertThat(pet.getId()).isNotNull();
@@ -144,21 +157,21 @@ public abstract class AbstractClinicServiceTests {
 	@Test
 	@Transactional
 	public void shouldUpdatePetName() throws Exception {
-	    Pet pet7 = this.clinicService.findPetById(7);
+	    Pet pet7 = this.petService.findPetById(7);
 	    String oldName = pet7.getName();
-	    
+
 	    String newName = oldName + "X";
 		pet7.setName(newName);
-	    this.clinicService.savePet(pet7);
+	    this.petService.savePet(pet7);
 
-	    pet7 = this.clinicService.findPetById(7);
+	    pet7 = this.petService.findPetById(7);
 	    assertThat(pet7.getName()).isEqualTo(newName);
 	}
 
 	@Test
 	public void shouldFindVets() {
-	    Collection<Vet> vets = this.clinicService.findVets();
-	
+	    Collection<Vet> vets = this.vetService.findVets();
+
 	    Vet vet = EntityUtils.getById(vets, Vet.class, 3);
 	    assertThat(vet.getLastName()).isEqualTo("Douglas");
 	    assertThat(vet.getNrOfSpecialties()).isEqualTo(2);
@@ -169,15 +182,15 @@ public abstract class AbstractClinicServiceTests {
 	@Test
 	@Transactional
 	public void shouldAddNewVisitForPet() {
-	    Pet pet7 = this.clinicService.findPetById(7);
+	    Pet pet7 = this.petService.findPetById(7);
 	    int found = pet7.getVisits().size();
 	    Visit visit = new Visit();
 	    pet7.addVisit(visit);
-	    visit.setDescription("test");	    
-	    this.clinicService.saveVisit(visit);
-	    this.clinicService.savePet(pet7);
+	    visit.setDescription("test");
+	    this.visitService.saveVisit(visit);
+	    this.petService.savePet(pet7);
 
-	    pet7 = this.clinicService.findPetById(7);
+	    pet7 = this.petService.findPetById(7);
 	    assertThat(pet7.getVisits().size()).isEqualTo(found + 1);
 	    assertThat(visit.getId()).isNotNull();
 	}
diff --git a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/domain/model/EntityUtils.java
similarity index 90%
rename from springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java
rename to springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/domain/model/EntityUtils.java
index 367aff37..a040266e 100644
--- a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java
+++ b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/domain/model/EntityUtils.java
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-package org.springframework.samples.petclinic.service;
+package org.springframework.samples.petclinic.domain.model;
 
 import java.util.Collection;
 
 import org.springframework.orm.ObjectRetrievalFailureException;
-import org.springframework.samples.petclinic.model.BaseEntity;
+import org.springframework.samples.petclinic.support.jpa.BaseEntity;
 
 /**
  * Utility methods for handling entities. Separate from the BaseEntity class mainly because of dependency on the
@@ -27,7 +27,7 @@ import org.springframework.samples.petclinic.model.BaseEntity;
  *
  * @author Juergen Hoeller
  * @author Sam Brannen
- * @see org.springframework.samples.petclinic.model.BaseEntity
+ * @see BaseEntity
  * @since 29.10.2003
  */
 public abstract class EntityUtils {
diff --git a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/infrastructure/ValidatorTests.java
similarity index 87%
rename from springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java
rename to springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/infrastructure/ValidatorTests.java
index f8582b5d..ced033fd 100644
--- a/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java
+++ b/springboot-petclinic-server/src/test/java/org/springframework/samples/petclinic/infrastructure/ValidatorTests.java
@@ -1,4 +1,4 @@
-package org.springframework.samples.petclinic.model;
+package org.springframework.samples.petclinic.infrastructure;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -10,17 +10,18 @@ import javax.validation.Validator;
 
 import org.junit.Test;
 import org.springframework.context.i18n.LocaleContextHolder;
+import org.springframework.samples.petclinic.domain.shared.Person;
 import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
 
 /**
- * 
+ *
  * @author Michael Isvy
- * Simple test to make sure that Bean Validation is working 
+ * Simple test to make sure that Bean Validation is working
  * (useful when upgrading to a new version of Hibernate Validator/ Bean Validation)
  *
  */
 public class ValidatorTests {
-	
+
 	private Validator createValidator() {
 	      LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
 	      localValidatorFactoryBean.afterPropertiesSet();
@@ -43,5 +44,5 @@ public class ValidatorTests {
         assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName");
         assertThat(violation.getMessage()).isEqualTo("may not be empty");
     }
-	
+
 }
-- 
GitLab