Skip to content
Snippets Groups Projects
Commit 4bb829cb authored by Antoine Rey's avatar Antoine Rey
Browse files

Fix #101 display the pet type when using the JDBC profile

parent cb0504ee
No related branches found
No related tags found
No related merge requests found
......@@ -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,7 +115,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
params,
new JdbcPetVisitExtractor()
);
Collection<PetType> petTypes = getPetTypes();
for (JdbcPet pet : pets) {
pet.setType(EntityUtils.getById(petTypes, PetType.class, pet.getTypeId()));
owner.addPet(pet);
}
}
......
......@@ -58,7 +58,7 @@ public class PetValidator implements Validator {
*/
@Override
public boolean supports(Class<?> clazz) {
return Pet.class.equals(clazz);
return Pet.class.isAssignableFrom(clazz);
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment