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 d1c715db0..000000000 --- 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; - -/** - *
Base class for {@link OwnerRepository} integration tests.
- * - * 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() { - CollectionBase class for {@link OwnerRepository} integration tests.
- * - * 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() { - CollectionBase class for {@link OwnerRepository} integration tests.
- * - * 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 403d5f219..000000000 --- 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; - -/** - *Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 dd94080eb..000000000 --- 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; - -/** - *
Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 43c503641..000000000 --- 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; - -/** - *
Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 96b8df349..000000000 --- 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; - -/** - *
Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 3289153ef..000000000 --- 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; - -/** - *
Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 dbaffde4b..000000000 --- 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; - -/** - *
Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 1cb385a73..000000000 --- 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; - -/** - *
Provides the following services:
- * - * @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 f3fefdaa6..000000000 --- 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; - -/** - *
Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 f3583b1b5..000000000 --- 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; - -/** - *
Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 a3b37ed00..000000000 --- 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; - -/** - *
Integration tests for the {@link JdbcClinicImpl} implementation.
- * - * @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 57a57844f..e0571f779 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