Java Code Examples for org.springframework.samples.petclinic.model.Pet#addVisit()

The following examples show how to use org.springframework.samples.petclinic.model.Pet#addVisit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractClinicServiceTests.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@Test
@Transactional
public void shouldAddNewVisitForPet() {
    Pet pet7 = this.clinicService.findPetById(7);
    int found = pet7.getVisits().size();
    Visit visit = new Visit();
    pet7.addVisit(visit);
    visit.setDescription("test");
    this.clinicService.saveVisit(visit);
    this.clinicService.savePet(pet7);

    pet7 = this.clinicService.findPetById(7);
    assertThat(pet7.getVisits().size()).isEqualTo(found + 1);
    assertThat(visit.getId()).isNotNull();
}
 
Example 2
Source File: AbstractClinicServiceTests.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@Test
@Transactional
public void shouldAddNewVisitForPet() {
    Pet pet7 = this.clinicService.findPetById(7);
    int found = pet7.getVisits().size();
    Visit visit = new Visit();
    pet7.addVisit(visit);
    visit.setDescription("test");
    this.clinicService.saveVisit(visit);
    this.clinicService.savePet(pet7);

    pet7 = this.clinicService.findPetById(7);
    assertThat(pet7.getVisits().size()).isEqualTo(found + 1);
    assertThat(visit.getId()).isNotNull();
}
 
Example 3
Source File: AbstractClinicServiceTests.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
@Test
@Transactional
public void shouldAddNewVisitForPet() {
    Pet pet7 = this.clinicService.findPetById(7);
    int found = pet7.getVisits().size();
    Visit visit = new Visit();
    pet7.addVisit(visit);
    visit.setDescription("test");	    
    this.clinicService.saveVisit(visit);
    this.clinicService.savePet(pet7);

    pet7 = this.clinicService.findPetById(7);
    assertThat(pet7.getVisits().size()).isEqualTo(found + 1);
    assertThat(visit.getId()).isNotNull();
}
 
Example 4
Source File: AbstractClinicServiceTests.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
public void shouldAddNewVisitForPet() {
    Pet pet7 = this.clinicService.findPetById(7);
    int found = pet7.getVisits().size();
    Visit visit = new Visit();
    pet7.addVisit(visit);
    visit.setDescription("test");	    
    this.clinicService.saveVisit(visit);
    this.clinicService.savePet(pet7);

    pet7 = this.clinicService.findPetById(7);
    assertThat(pet7.getVisits().size()).isEqualTo(found + 1);
    assertThat(visit.getId()).isNotNull();
}
 
Example 5
Source File: VisitController.java    From DevOps-for-Web-Development with MIT License 3 votes vote down vote up
/**
 * Called before each and every @RequestMapping annotated method.
 * 2 goals:
 * - Make sure we always have fresh data
 * - Since we do not use the session scope, make sure that Pet object always has an id
 * (Even though id is not part of the form fields)
 *
 * @param petId
 * @return Pet
 */
@ModelAttribute("visit")
public Visit loadPetWithVisit(@PathVariable("petId") int petId) {
    Pet pet = this.clinicService.findPetById(petId);
    Visit visit = new Visit();
    pet.addVisit(visit);
    return visit;
}
 
Example 6
Source File: VisitController.java    From DevOps-for-Web-Development with MIT License 3 votes vote down vote up
/**
 * Called before each and every @RequestMapping annotated method.
 * 2 goals:
 * - Make sure we always have fresh data
 * - Since we do not use the session scope, make sure that Pet object always has an id
 * (Even though id is not part of the form fields)
 *
 * @param petId
 * @return Pet
 */
@ModelAttribute("visit")
public Visit loadPetWithVisit(@PathVariable("petId") int petId) {
    Pet pet = this.clinicService.findPetById(petId);
    Visit visit = new Visit();
    pet.addVisit(visit);
    return visit;
}
 
Example 7
Source File: VisitController.java    From docker-workflow-plugin with MIT License 3 votes vote down vote up
/**
 *  Called before each and every @RequestMapping annotated method.
 *  2 goals:
 *  - Make sure we always have fresh data
 *  - Since we do not use the session scope, make sure that Pet object always has an id 
 *    (Even though id is not part of the form fields)
 * @param petId
 * @return Pet
 */
@ModelAttribute("visit")
public Visit loadPetWithVisit(@PathVariable("petId") int petId) {
    Pet pet = this.clinicService.findPetById(petId);
    Visit visit = new Visit();
    pet.addVisit(visit);  
    return visit;
}
 
Example 8
Source File: VisitController.java    From audit4j-demo with Apache License 2.0 3 votes vote down vote up
/**
 *  Called before each and every @RequestMapping annotated method.
 *  2 goals:
 *  - Make sure we always have fresh data
 *  - Since we do not use the session scope, make sure that Pet object always has an id 
 *    (Even though id is not part of the form fields)
 * @param petId
 * @return Pet
 */
@ModelAttribute("visit")
public Visit loadPetWithVisit(@PathVariable("petId") int petId) {
    Pet pet = this.clinicService.findPetById(petId);
    Visit visit = new Visit();
    pet.addVisit(visit);  
    return visit;
}