コード例 #1
0
 @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());
 }
コード例 #2
0
 @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());
   assertNotNull("Pet Id should have been generated", pet.getId());
 }