mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
Fix the display of pet type when using the JDBC profile
Steps to reproduce: Set the web.xml context-param spring.profiles.active to jdbc. Run app and navigate to Find owners > Find Owner > Betty Davis. Notice that poor little Basil the hamster doesn't have his Type displayed.
This commit is contained in:
parent
e0be3a39b6
commit
dda105599b
2 changed files with 5 additions and 0 deletions
|
@ -35,6 +35,7 @@ import org.springframework.samples.petclinic.model.Pet;
|
|||
import org.springframework.samples.petclinic.model.PetType;
|
||||
import org.springframework.samples.petclinic.model.Visit;
|
||||
import org.springframework.samples.petclinic.repository.OwnerRepository;
|
||||
import org.springframework.samples.petclinic.util.EntityUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
|
@ -114,8 +115,10 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
|||
params,
|
||||
new JdbcPetVisitExtractor()
|
||||
);
|
||||
Collection<PetType> petTypes = getPetTypes();
|
||||
for (JdbcPet pet : pets) {
|
||||
owner.addPet(pet);
|
||||
pet.setType(EntityUtils.getById(petTypes, PetType.class, pet.getTypeId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,8 @@ public abstract class AbstractClinicServiceTests {
|
|||
Owner owner = this.clinicService.findOwnerById(1);
|
||||
assertThat(owner.getLastName()).startsWith("Franklin");
|
||||
assertThat(owner.getPets().size()).isEqualTo(1);
|
||||
assertThat(owner.getPets().get(0).getType()).isNotNull();
|
||||
assertThat(owner.getPets().get(0).getType().getName()).isEqualTo("cat");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue