From faca0eb1c2a1830c268c8847944f8f70bb1f57eb Mon Sep 17 00:00:00 2001
From: Mic <misvy@vmware.com>
Date: Tue, 26 Feb 2013 17:38:06 +0800
Subject: [PATCH] moved to tests to service level package

---
 .../AbstractPetRepositoryTests.java           | 103 ------------------
 .../AbstractVetRepositoryTests.java           |  60 ----------
 .../AbstractVisitRepositoryTests.java         |  59 ----------
 .../jdbc/JdbcPetRepositoryImplTests.java      |  21 ----
 .../jdbc/JdbcVetRepositoryImplTests.java      |  21 ----
 .../jdbc/JdbcVisitRepositoryImplTests.java    |  21 ----
 .../jpa/JpaPetRepositoryImplTests.java        |  21 ----
 .../jpa/JpaVetRepositoryImplTests.java        |  21 ----
 .../jpa/JpaVisitRepositoryImplTests.java      |  21 ----
 .../JpaOwnerRepositoryImplTests.java          |  26 -----
 .../JpaPetRepositoryImplTests.java            |  21 ----
 .../JpaVetRepositoryImplTests.java            |  21 ----
 .../JpaVisitRepositoryImplTests.java          |  21 ----
 .../AbstractClinicServiceTests.java}          |  93 +++++++++++++++-
 .../ClinicServiceJdbcTests.java}              |   5 +-
 .../ClinicServiceJpaTests.java}               |   5 +-
 .../ClinicServiceSpringDataJpaTests.java}     |   5 +-
 17 files changed, 97 insertions(+), 448 deletions(-)
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/AbstractPetRepositoryTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/AbstractVetRepositoryTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/AbstractVisitRepositoryTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaOwnerRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaPetRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaVetRepositoryImplTests.java
 delete mode 100644 src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaVisitRepositoryImplTests.java
 rename src/test/java/org/springframework/samples/petclinic/{repository/AbstractOwnerRepositoryTests.java => service/AbstractClinicServiceTests.java} (53%)
 rename src/test/java/org/springframework/samples/petclinic/{repository/jdbc/JdbcOwnerRepositoryImplTests.java => service/ClinicServiceJdbcTests.java} (83%)
 rename src/test/java/org/springframework/samples/petclinic/{repository/jpa/JpaOwnerRepositoryImplTests.java => service/ClinicServiceJpaTests.java} (80%)
 rename src/test/java/org/springframework/samples/petclinic/{repository/springdatajpa/SpringDataOwnerRepositoryTests.java => service/ClinicServiceSpringDataJpaTests.java} (63%)

diff --git a/src/test/java/org/springframework/samples/petclinic/repository/AbstractPetRepositoryTests.java b/src/test/java/org/springframework/samples/petclinic/repository/AbstractPetRepositoryTests.java
deleted file mode 100644
index d1c715d..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/AbstractPetRepositoryTests.java
+++ /dev/null
@@ -1,103 +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.repository;
-
-import org.joda.time.DateTime;
-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.service.ClinicService;
-import org.springframework.samples.petclinic.util.EntityUtils;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Collection;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * <p> Base class for {@link OwnerRepository} integration tests. </p>
- * <p/>
- * see javadoc inside {@link AbstractOwnerRepositoryTests} for more details
- *
- * @author Ken Krebs
- * @author Rod Johnson
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @author Michael Isvy
- */
-public abstract class AbstractPetRepositoryTests {
-
-	@Autowired
-    protected ClinicService clinicService;
-
-
-    @Test
-    public void getPetTypes() {
-        Collection<PetType> petTypes = this.clinicService.findPetTypes();
-
-        PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1);
-        assertEquals("cat", petType1.getName());
-        PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4);
-        assertEquals("snake", petType4.getName());
-    }
-
-    @Test
-    public void findPet() {
-        Collection<PetType> types = this.clinicService.findPetTypes();
-        Pet pet7 = this.clinicService.findPetById(7);
-        assertTrue(pet7.getName().startsWith("Samantha"));
-        assertEquals(EntityUtils.getById(types, PetType.class, 1).getId(), pet7.getType().getId());
-        assertEquals("Jean", pet7.getOwner().getFirstName());
-        Pet pet6 = this.clinicService.findPetById(6);
-        assertEquals("George", pet6.getName());
-        assertEquals(EntityUtils.getById(types, PetType.class, 4).getId(), pet6.getType().getId());
-        assertEquals("Peter", pet6.getOwner().getFirstName());
-    }
-
-    @Test
-    @Transactional
-    public void insertPet() {
-        Owner owner6 = this.clinicService.findOwnerById(6);
-        int found = owner6.getPets().size();
-        Pet pet = new Pet();
-        pet.setName("bowser");
-        Collection<PetType> types = this.clinicService.findPetTypes();
-        pet.setType(EntityUtils.getById(types, PetType.class, 2));
-        pet.setBirthDate(new DateTime());
-        owner6.addPet(pet);
-        assertEquals(found + 1, owner6.getPets().size());
-        // both storePet and storeOwner are necessary to cover all ORM tools
-        this.clinicService.savePet(pet);
-        this.clinicService.saveOwner(owner6);
-        owner6 = this.clinicService.findOwnerById(6);
-        assertEquals(found + 1, owner6.getPets().size());
-    }
-
-    @Test
-    @Transactional
-    public void updatePet() throws Exception {
-        Pet pet7 = this.clinicService.findPetById(7);
-        String old = pet7.getName();
-        pet7.setName(old + "X");
-        this.clinicService.savePet(pet7);
-        pet7 = this.clinicService.findPetById(7);
-        assertEquals(old + "X", pet7.getName());
-    }
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/AbstractVetRepositoryTests.java b/src/test/java/org/springframework/samples/petclinic/repository/AbstractVetRepositoryTests.java
deleted file mode 100644
index 6e25f9b..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/AbstractVetRepositoryTests.java
+++ /dev/null
@@ -1,60 +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.repository;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Collection;
-
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.samples.petclinic.model.Vet;
-import org.springframework.samples.petclinic.service.ClinicService;
-import org.springframework.samples.petclinic.util.EntityUtils;
-
-/**
- * <p> Base class for {@link OwnerRepository} integration tests. </p>
- * <p/>
- * see javadoc inside {@link AbstractVetRepositoryTests} for more details
- *
- * @author Ken Krebs
- * @author Rod Johnson
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @author Michael Isvy
- */
-public abstract class AbstractVetRepositoryTests {
-
-	@Autowired
-    protected ClinicService clinicService;
-
-
-    @Test
-    public void findVets() {
-        Collection<Vet> vets = this.clinicService.findVets();
-
-        Vet v1 = EntityUtils.getById(vets, Vet.class, 2);
-        assertEquals("Leary", v1.getLastName());
-        assertEquals(1, v1.getNrOfSpecialties());
-        assertEquals("radiology", (v1.getSpecialties().get(0)).getName());
-        Vet v2 = EntityUtils.getById(vets, Vet.class, 3);
-        assertEquals("Douglas", v2.getLastName());
-        assertEquals(2, v2.getNrOfSpecialties());
-        assertEquals("dentistry", (v2.getSpecialties().get(0)).getName());
-        assertEquals("surgery", (v2.getSpecialties().get(1)).getName());
-    }
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/AbstractVisitRepositoryTests.java b/src/test/java/org/springframework/samples/petclinic/repository/AbstractVisitRepositoryTests.java
deleted file mode 100644
index 0d122a6..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/AbstractVisitRepositoryTests.java
+++ /dev/null
@@ -1,59 +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.repository;
-
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.samples.petclinic.model.Pet;
-import org.springframework.samples.petclinic.model.Visit;
-import org.springframework.samples.petclinic.service.ClinicService;
-import org.springframework.transaction.annotation.Transactional;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * <p> Base class for {@link OwnerRepository} integration tests. </p>
- * <p/>
- * see javadoc inside {@link AbstractVetRepositoryTests} for more details
- *
- * @author Ken Krebs
- * @author Rod Johnson
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @author Michael Isvy
- */
-public abstract class AbstractVisitRepositoryTests {
-
-	@Autowired
-    protected ClinicService clinicService;
-
-
-    @Test
-    @Transactional
-    public void insertVisit() {
-        Pet pet7 = this.clinicService.findPetById(7);
-        int found = pet7.getVisits().size();
-        Visit visit = new Visit();
-        pet7.addVisit(visit);
-        visit.setDescription("test");
-        // both storeVisit and storePet are necessary to cover all ORM tools
-        this.clinicService.saveVisit(visit);
-        this.clinicService.savePet(pet7);
-        pet7 = this.clinicService.findPetById(7);
-        assertEquals(found + 1, pet7.getVisits().size());
-    }
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImplTests.java
deleted file mode 100644
index 403d5f2..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.jdbc;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractPetRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("jdbc")
-public class JdbcPetRepositoryImplTests extends AbstractPetRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImplTests.java
deleted file mode 100644
index dd94080..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.jdbc;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractVetRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("jdbc")
-public class JdbcVetRepositoryImplTests extends AbstractVetRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImplTests.java
deleted file mode 100644
index 43c5036..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.jdbc;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractVisitRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("jdbc")
-public class JdbcVisitRepositoryImplTests extends AbstractVisitRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImplTests.java
deleted file mode 100644
index 96b8df3..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.jpa;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractPetRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("jpa")
-public class JpaPetRepositoryImplTests extends AbstractPetRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImplTests.java
deleted file mode 100644
index 3289153..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.jpa;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractVetRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("jpa")
-public class JpaVetRepositoryImplTests extends AbstractVetRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImplTests.java
deleted file mode 100644
index dbaffde..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.jpa;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractVisitRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("jpa")
-public class JpaVisitRepositoryImplTests extends AbstractVisitRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaOwnerRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaOwnerRepositoryImplTests.java
deleted file mode 100644
index 1cb385a..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaOwnerRepositoryImplTests.java
+++ /dev/null
@@ -1,26 +0,0 @@
-
-package org.springframework.samples.petclinic.repository.springdatajpa;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractOwnerRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Provides the following services: <ul> <li>Injects test dependencies, meaning that we don't need to perform
- * application context lookups. See the setClinic() method. Injection uses autowiring by type.</li> <li>Executes each
- * test method in its own transaction, which is automatically rolled back by default. This means that even if tests
- * insert or otherwise change database state, there is no need for a teardown or cleanup script.</li> </ul> <p> </p>
- *
- * @author Rod Johnson
- * @author Sam Brannen
- * @author Michael Isvy
- */
-
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("spring-data-jpa")
-public class JpaOwnerRepositoryImplTests extends AbstractOwnerRepositoryTests {
-
-}
\ No newline at end of file
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaPetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaPetRepositoryImplTests.java
deleted file mode 100644
index f3fefda..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaPetRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.springdatajpa;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractPetRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("spring-data-jpa")
-public class JpaPetRepositoryImplTests extends AbstractPetRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaVetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaVetRepositoryImplTests.java
deleted file mode 100644
index f3583b1..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaVetRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.springdatajpa;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractVetRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("spring-data-jpa")
-public class JpaVetRepositoryImplTests extends AbstractVetRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaVisitRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaVisitRepositoryImplTests.java
deleted file mode 100644
index a3b37ed..0000000
--- a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/JpaVisitRepositoryImplTests.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.springframework.samples.petclinic.repository.springdatajpa;
-
-import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractVisitRepositoryTests;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * <p> Integration tests for the {@link JdbcClinicImpl} implementation. </p> <p> </p>
- *
- * @author Thomas Risberg
- * @author Michael Isvy
- */
-@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
-@RunWith(SpringJUnit4ClassRunner.class)
-@ActiveProfiles("spring-data-jpa")
-public class JpaVisitRepositoryImplTests extends AbstractVisitRepositoryTests {
-
-
-}
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/AbstractOwnerRepositoryTests.java b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java
similarity index 53%
rename from src/test/java/org/springframework/samples/petclinic/repository/AbstractOwnerRepositoryTests.java
rename to src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java
index 57a5784..e0571f7 100644
--- a/src/test/java/org/springframework/samples/petclinic/repository/AbstractOwnerRepositoryTests.java
+++ b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java
@@ -13,12 +13,18 @@
  * 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.service;
 
+import org.joda.time.DateTime;
 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.service.ClinicService;
+import org.springframework.samples.petclinic.util.EntityUtils;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -46,7 +52,7 @@ import static org.junit.Assert.assertTrue;
  * @author Sam Brannen
  * @author Michael Isvy
  */
-public abstract class AbstractOwnerRepositoryTests {
+public abstract class AbstractClinicServiceTests {
 
     @Autowired
     protected ClinicService clinicService;
@@ -97,5 +103,88 @@ public abstract class AbstractOwnerRepositoryTests {
         assertEquals(old + "X", o1.getLastName());
     }
 
+	@Test
+	public void findPet() {
+	    Collection<PetType> types = this.clinicService.findPetTypes();
+	    Pet pet7 = this.clinicService.findPetById(7);
+	    assertTrue(pet7.getName().startsWith("Samantha"));
+	    assertEquals(EntityUtils.getById(types, PetType.class, 1).getId(), pet7.getType().getId());
+	    assertEquals("Jean", pet7.getOwner().getFirstName());
+	    Pet pet6 = this.clinicService.findPetById(6);
+	    assertEquals("George", pet6.getName());
+	    assertEquals(EntityUtils.getById(types, PetType.class, 4).getId(), pet6.getType().getId());
+	    assertEquals("Peter", pet6.getOwner().getFirstName());
+	}
+
+	@Test
+	public void getPetTypes() {
+	    Collection<PetType> petTypes = this.clinicService.findPetTypes();
+	
+	    PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1);
+	    assertEquals("cat", petType1.getName());
+	    PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4);
+	    assertEquals("snake", petType4.getName());
+	}
+
+	@Test
+	@Transactional
+	public void insertPet() {
+	    Owner owner6 = this.clinicService.findOwnerById(6);
+	    int found = owner6.getPets().size();
+	    Pet pet = new Pet();
+	    pet.setName("bowser");
+	    Collection<PetType> types = this.clinicService.findPetTypes();
+	    pet.setType(EntityUtils.getById(types, PetType.class, 2));
+	    pet.setBirthDate(new DateTime());
+	    owner6.addPet(pet);
+	    assertEquals(found + 1, owner6.getPets().size());
+	    // both storePet and storeOwner are necessary to cover all ORM tools
+	    this.clinicService.savePet(pet);
+	    this.clinicService.saveOwner(owner6);
+	    owner6 = this.clinicService.findOwnerById(6);
+	    assertEquals(found + 1, owner6.getPets().size());
+	}
+
+	@Test
+	@Transactional
+	public void updatePet() throws Exception {
+	    Pet pet7 = this.clinicService.findPetById(7);
+	    String old = pet7.getName();
+	    pet7.setName(old + "X");
+	    this.clinicService.savePet(pet7);
+	    pet7 = this.clinicService.findPetById(7);
+	    assertEquals(old + "X", pet7.getName());
+	}
+
+	@Test
+	public void findVets() {
+	    Collection<Vet> vets = this.clinicService.findVets();
+	
+	    Vet v1 = EntityUtils.getById(vets, Vet.class, 2);
+	    assertEquals("Leary", v1.getLastName());
+	    assertEquals(1, v1.getNrOfSpecialties());
+	    assertEquals("radiology", (v1.getSpecialties().get(0)).getName());
+	    Vet v2 = EntityUtils.getById(vets, Vet.class, 3);
+	    assertEquals("Douglas", v2.getLastName());
+	    assertEquals(2, v2.getNrOfSpecialties());
+	    assertEquals("dentistry", (v2.getSpecialties().get(0)).getName());
+	    assertEquals("surgery", (v2.getSpecialties().get(1)).getName());
+	}
+
+	@Test
+	@Transactional
+	public void insertVisit() {
+	    Pet pet7 = this.clinicService.findPetById(7);
+	    int found = pet7.getVisits().size();
+	    Visit visit = new Visit();
+	    pet7.addVisit(visit);
+	    visit.setDescription("test");
+	    // both storeVisit and storePet are necessary to cover all ORM tools
+	    this.clinicService.saveVisit(visit);
+	    this.clinicService.savePet(pet7);
+	    pet7 = this.clinicService.findPetById(7);
+	    assertEquals(found + 1, pet7.getVisits().size());
+	}
+
 
 }
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJdbcTests.java
similarity index 83%
rename from src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImplTests.java
rename to src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJdbcTests.java
index f821dbf..787733c 100644
--- a/src/test/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImplTests.java
+++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJdbcTests.java
@@ -13,10 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.springframework.samples.petclinic.repository.jdbc;
+package org.springframework.samples.petclinic.service;
 
 import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractOwnerRepositoryTests;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -30,7 +29,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
 @RunWith(SpringJUnit4ClassRunner.class)
 @ActiveProfiles("jdbc")
-public class JdbcOwnerRepositoryImplTests extends AbstractOwnerRepositoryTests {
+public class ClinicServiceJdbcTests extends AbstractClinicServiceTests {
 
 
 }
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJpaTests.java
similarity index 80%
rename from src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImplTests.java
rename to src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJpaTests.java
index 77462cd..2a3d544 100644
--- a/src/test/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImplTests.java
+++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJpaTests.java
@@ -1,8 +1,7 @@
 
-package org.springframework.samples.petclinic.repository.jpa;
+package org.springframework.samples.petclinic.service;
 
 import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractOwnerRepositoryTests;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -21,6 +20,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
 @RunWith(SpringJUnit4ClassRunner.class)
 @ActiveProfiles("jpa")
-public class JpaOwnerRepositoryImplTests extends AbstractOwnerRepositoryTests {
+public class ClinicServiceJpaTests extends AbstractClinicServiceTests {
 
 }
\ No newline at end of file
diff --git a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepositoryTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceSpringDataJpaTests.java
similarity index 63%
rename from src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepositoryTests.java
rename to src/test/java/org/springframework/samples/petclinic/service/ClinicServiceSpringDataJpaTests.java
index 28fc5f1..b624abc 100644
--- a/src/test/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepositoryTests.java
+++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceSpringDataJpaTests.java
@@ -1,8 +1,7 @@
 
-package org.springframework.samples.petclinic.repository.springdatajpa;
+package org.springframework.samples.petclinic.service;
 
 import org.junit.runner.RunWith;
-import org.springframework.samples.petclinic.repository.AbstractOwnerRepositoryTests;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -14,6 +13,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
 @RunWith(SpringJUnit4ClassRunner.class)
 @ActiveProfiles("spring-data-jpa")
-public class SpringDataOwnerRepositoryTests extends AbstractOwnerRepositoryTests {
+public class ClinicServiceSpringDataJpaTests extends AbstractClinicServiceTests {
 
 }
\ No newline at end of file
-- 
GitLab