mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:55:49 +00:00
Merge pull request #2 from jadmalek/rogerDev
Adding more tests to the Owner class methods
This commit is contained in:
commit
f00cd1233a
1 changed files with 45 additions and 0 deletions
|
@ -2,6 +2,7 @@ package org.springframework.samples.petclinic.owner;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
|
@ -55,6 +56,7 @@ public class OwnerTest {
|
|||
@Test
|
||||
public void setPetgetPetsTest() {
|
||||
Pet pet = new Pet();
|
||||
|
||||
pet.setName("Pogo");
|
||||
ownerInstance.addPet(pet);
|
||||
List<Pet> result = ownerInstance.getPets();
|
||||
|
@ -65,4 +67,47 @@ public class OwnerTest {
|
|||
assertEquals(pet.getName(), onlyPet.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPetExistsTest() {
|
||||
Pet pet = new Pet();
|
||||
pet.setName("Pochi");
|
||||
ownerInstance.addPet(pet);
|
||||
|
||||
//tests pet object exists
|
||||
assertEquals(pet, ownerInstance.getPet("Pochi"));
|
||||
assertEquals(pet, ownerInstance.getPet("Pochi", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPetDoesntExistsTest() {
|
||||
Pet pet = new Pet();
|
||||
pet.setName("Pochi");
|
||||
ownerInstance.addPet(pet);
|
||||
//tests pet object doesn't exist
|
||||
assertEquals(null, ownerInstance.getPet("Pochi", true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPetsTest() {
|
||||
Pet pet = new Pet();
|
||||
List<Pet> list = new ArrayList<>();
|
||||
list.add(pet);
|
||||
ownerInstance.addPet(pet);
|
||||
|
||||
assertEquals(list, ownerInstance.getPets());
|
||||
assertEquals(1, list.size());
|
||||
|
||||
Pet pet2 = new Pet();
|
||||
list.add(pet2);
|
||||
ownerInstance.addPet(pet2);
|
||||
|
||||
assertEquals(list, ownerInstance.getPets());
|
||||
assertEquals(2, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setGetAddress() {
|
||||
ownerInstance.setAddress("123 FakeStreet");
|
||||
assertEquals("123 FakeStreet", ownerInstance.getAddress());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue