Package org.activejpa.examples.petclinic.model

Examples of org.activejpa.examples.petclinic.model.Pet


  @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.getId(), "Pet Id should have been generated");
  }
View Full Code Here


  }

  @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());
  }
View Full Code Here

  }

  @Test
  @Transactional
  public void insertVisit() {
      Pet pet7 = this.clinicService.findPetById(7);
      int found = pet7.getVisits().size();
      Visit visit = new Visit();
      pet7.addVisit(visit);
      visit.setDescription("test");
      // both storeVisit and storePet are necessary to cover all ORM tools
      this.clinicService.saveVisit(visit);
      this.clinicService.savePet(pet7);
      pet7 = this.clinicService.findPetById(7);
      assertEquals(found + 1, pet7.getVisits().size());
      assertNotNull(visit.getId(), "Visit Id should have been generated");
  }
View Full Code Here

    }

    @RequestMapping(value = "/owners/{ownerId}/pets/new", method = RequestMethod.GET)
    public String initCreationForm(@PathVariable("ownerId") int ownerId, Map<String, Object> model) {
        Owner owner = this.clinicService.findOwnerById(ownerId);
        Pet pet = new Pet();
        owner.addPet(pet);
        model.put("pet", pet);
        return "pets/createOrUpdatePetForm";
    }
View Full Code Here

        }
    }

    @RequestMapping(value = "/owners/*/pets/{petId}/edit", method = RequestMethod.GET)
    public String initUpdateForm(@PathVariable("petId") int petId, Map<String, Object> model) {
        Pet pet = this.clinicService.findPetById(petId);
        model.put("pet", pet);
        return "pets/createOrUpdatePetForm";
    }
View Full Code Here

    }

  @Test
  public void findPet() {
      Collection<PetType> types = this.clinicService.findPetTypes();
      Pet pet7 = this.clinicService.findPetById(7);
      assertTrue(pet7.getName().startsWith("Samantha"));
      assertEquals(EntityUtils.getById(types, PetType.class, 1).getId(), pet7.getType().getId());
      assertEquals("Jean", pet7.getOwner().getFirstName());
      Pet pet6 = this.clinicService.findPetById(6);
      assertEquals("George", pet6.getName());
      assertEquals(EntityUtils.getById(types, PetType.class, 4).getId(), pet6.getType().getId());
      assertEquals("Peter", pet6.getOwner().getFirstName());
  }
View Full Code Here

        dataBinder.setDisallowedFields("id");
    }

    @RequestMapping(value = "/owners/*/pets/{petId}/visits/new", method = RequestMethod.GET)
    public String initNewVisitForm(@PathVariable("petId") int petId, Map<String, Object> model) {
        Pet pet = this.clinicService.findPetById(petId);
        Visit visit = new Visit();
        pet.addVisit(visit);
        model.put("visit", visit);
        return "pets/createOrUpdateVisitForm";
    }
View Full Code Here

TOP

Related Classes of org.activejpa.examples.petclinic.model.Pet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.