mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-29 06:39:38 +00:00
Merge branch 'Cobertura'
This commit is contained in:
commit
b20ba1aeef
4 changed files with 36 additions and 4 deletions
33
pom.xml
33
pom.xml
|
@ -66,6 +66,8 @@
|
||||||
|
|
||||||
<mysql.version>5.1.22</mysql.version>
|
<mysql.version>5.1.22</mysql.version>
|
||||||
|
|
||||||
|
<cobertura.version>2.7</cobertura.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -442,8 +444,39 @@
|
||||||
<path>/petclinic</path>
|
<path>/petclinic</path>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
|
<version>${cobertura.version}</version>
|
||||||
|
<configuration>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>clean</goal>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
|
||||||
|
<!-- integrate maven-cobertura-plugin to project site -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
|
<version>${cobertura.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<formats>
|
||||||
|
<format>html</format>
|
||||||
|
</formats>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
<url>demopetclinic</url>
|
<url>demopetclinic</url>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -122,6 +122,7 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
);
|
);
|
||||||
for (JdbcPet pet : pets) {
|
for (JdbcPet pet : pets) {
|
||||||
owner.addPet(pet);
|
owner.addPet(pet);
|
||||||
|
// Pet types have not been loaded at this stage. They are loaded separately
|
||||||
pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
|
pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
|
||||||
List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
|
List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
|
||||||
for (Visit visit : visits) {
|
for (Visit visit : visits) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.springframework.samples.petclinic.model.Pet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of Pet that carries temporary id properties which are only relevant for a JDBC implementation of the
|
* Subclass of Pet that carries temporary id properties which are only relevant for a JDBC implementation of the
|
||||||
* ClinicService.
|
* PetRepository.
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,8 +8,6 @@ import java.util.Set;
|
||||||
import javax.validation.ConstraintViolation;
|
import javax.validation.ConstraintViolation;
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
|
|
||||||
import org.assertj.core.api.Assertions;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||||
|
@ -40,7 +38,7 @@ public class ValidatorTests {
|
||||||
Validator validator = createValidator();
|
Validator validator = createValidator();
|
||||||
Set<ConstraintViolation<Person>> constraintViolations = validator.validate(person);
|
Set<ConstraintViolation<Person>> constraintViolations = validator.validate(person);
|
||||||
|
|
||||||
Assert.assertEquals(1, constraintViolations.size());
|
assertThat(constraintViolations.size()).isEqualTo(1);
|
||||||
ConstraintViolation<Person> violation = constraintViolations.iterator().next();
|
ConstraintViolation<Person> violation = constraintViolations.iterator().next();
|
||||||
assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName");
|
assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName");
|
||||||
assertThat(violation.getMessage()).isEqualTo("may not be empty");
|
assertThat(violation.getMessage()).isEqualTo("may not be empty");
|
||||||
|
|
Loading…
Reference in a new issue