use of org.springframework.samples.petclinic.owner.Owner in project spring-petclinic by spring-projects.
the class ClinicServiceTests method shouldUpdateOwner.
@Test
@Transactional
public void shouldUpdateOwner() {
Owner owner = this.owners.findById(1);
String oldLastName = owner.getLastName();
String newLastName = oldLastName + "X";
owner.setLastName(newLastName);
this.owners.save(owner);
// retrieving new name from database
owner = this.owners.findById(1);
assertThat(owner.getLastName()).isEqualTo(newLastName);
}
use of org.springframework.samples.petclinic.owner.Owner in project spring-petclinic by spring-projects.
the class ClinicServiceTests method shouldFindSingleOwnerWithPet.
@Test
public void shouldFindSingleOwnerWithPet() {
Owner owner = this.owners.findById(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");
}
use of org.springframework.samples.petclinic.owner.Owner in project spring-petclinic by spring-projects.
the class ClinicServiceTests method shouldInsertOwner.
@Test
@Transactional
public void shouldInsertOwner() {
Collection<Owner> owners = this.owners.findByLastName("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.owners.save(owner);
assertThat(owner.getId().longValue()).isNotEqualTo(0);
owners = this.owners.findByLastName("Schultz");
assertThat(owners.size()).isEqualTo(found + 1);
}
use of org.springframework.samples.petclinic.owner.Owner in project spring-petclinic by spring-projects.
the class OwnerControllerTests method setup.
@Before
public void setup() {
george = new Owner();
george.setId(TEST_OWNER_ID);
george.setFirstName("George");
george.setLastName("Franklin");
george.setAddress("110 W. Liberty St.");
george.setCity("Madison");
george.setTelephone("6085551023");
given(this.owners.findById(TEST_OWNER_ID)).willReturn(george);
}
use of org.springframework.samples.petclinic.owner.Owner in project spring-petclinic by spring-projects.
the class PetControllerTests method setup.
@Before
public void setup() {
PetType cat = new PetType();
cat.setId(3);
cat.setName("hamster");
given(this.pets.findPetTypes()).willReturn(Lists.newArrayList(cat));
given(this.owners.findById(TEST_OWNER_ID)).willReturn(new Owner());
given(this.pets.findById(TEST_PET_ID)).willReturn(new Pet());
}
Aggregations