Package org.activejpa.examples.petclinic.model

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


        dataBinder.setDisallowedFields("id");
    }

    @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


        assertEquals(0, owners.size());
    }

    @Test
    public void findSingleOwner() {
        Owner owner1 = this.clinicService.findOwnerById(1);
        assertTrue(owner1.getLastName().startsWith("Franklin"));
        Owner owner10 = this.clinicService.findOwnerById(10);
        assertEquals("Carlos", owner10.getFirstName());

        assertEquals(owner1.getPets().size(), 1);
    }
View Full Code Here

    @Test
    @Transactional
    public void insertOwner() {
        Collection<Owner> owners = this.clinicService.findOwnerByLastName("Schultz");
        int found = owners.size();
        Owner owner = new Owner();
        owner.setFirstName("Sam");
        owner.setLastName("Schultz");
        owner.setAddress("4, Evans Street");
        owner.setCity("Wollongong");
        owner.setTelephone("4444444444");
        this.clinicService.saveOwner(owner);
        assertNotEquals(owner.getId().longValue(), 0, "Owner Id should have been generated");
        owners = this.clinicService.findOwnerByLastName("Schultz");
        assertEquals(found + 1, owners.size(), "Verifying number of owners after inserting a new one.");
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void updateOwner() throws Exception {
        Owner o1 = this.clinicService.findOwnerById(1);
        String old = o1.getLastName();
        o1.setLastName(old + "X");
        this.clinicService.saveOwner(o1);
        o1 = this.clinicService.findOwnerById(1);
        assertEquals(old + "X", o1.getLastName());
    }
View Full Code Here

  }

  @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

        dataBinder.setDisallowedFields("id");
    }

    @RequestMapping(value = "/owners/new", method = RequestMethod.GET)
    public String initCreationForm(Map<String, Object> model) {
        Owner owner = new Owner();
        model.put("owner", owner);
        return "owners/createOrUpdateOwnerForm";
    }
View Full Code Here

        }
    }

    @RequestMapping(value = "/owners/find", method = RequestMethod.GET)
    public String initFindForm(Map<String, Object> model) {
        model.put("owner", new Owner());
        return "owners/findOwners";
    }
View Full Code Here

        }
    }

    @RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.GET)
    public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
        Owner owner = this.clinicService.findOwnerById(ownerId);
        model.addAttribute(owner);
        return "owners/createOrUpdateOwnerForm";
    }
View Full Code Here

TOP

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

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.