diff --git a/src/test/java/org/springframework/samples/petclinic/model/BaseEntityTest.java b/src/test/java/org/springframework/samples/petclinic/model/BaseEntityTest.java new file mode 100644 index 000000000..2dcbd8525 --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/model/BaseEntityTest.java @@ -0,0 +1,30 @@ +package org.springframework.samples.petclinic.model; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class BaseEntityTest { + + private BaseEntity baseEntityInstance; + + @Before + public void setUp(){ + baseEntityInstance = new BaseEntity(); + } + + // Expects the baseEntity to have Integer of 100 + @Test + public void testGetAndSetId() { + baseEntityInstance.setId(100); + assertEquals((Integer)100, baseEntityInstance.getId()); + } + + // Expects the baseEntity ID to be null + @Test + public void TestIsNew() { + baseEntityInstance.isNew(); + assertNull(baseEntityInstance.getId()); + } +} diff --git a/src/test/java/org/springframework/samples/petclinic/model/NamedEntityTest.java b/src/test/java/org/springframework/samples/petclinic/model/NamedEntityTest.java new file mode 100644 index 000000000..32315a5fb --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/model/NamedEntityTest.java @@ -0,0 +1,26 @@ +package org.springframework.samples.petclinic.model; + +import org.junit.Before; +import org.junit.Test; + +import javax.naming.Name; + +import static org.junit.Assert.*; + +public class NamedEntityTest { + + private NamedEntity namedObj; + + @Before + public void setUp(){ + namedObj = new NamedEntity(); + } + + // Testing the DAO of NamedEntity class by verifying the setter, getter and toString of Name + @Test + public void testSetAndGetName() { + namedObj.setName("Junior The Senior"); + assertEquals("Junior The Senior", namedObj.getName()); + assertEquals("Junior The Senior", namedObj.toString()); + } +} diff --git a/src/test/java/org/springframework/samples/petclinic/model/PersonTest.java b/src/test/java/org/springframework/samples/petclinic/model/PersonTest.java new file mode 100644 index 000000000..af8f7ac2b --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/model/PersonTest.java @@ -0,0 +1,29 @@ +package org.springframework.samples.petclinic.model; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class PersonTest { + + private Person personObj; + + @Before + public void setUp(){ + personObj = new Person(); + } + + // Testing the DAO of Person class by verifying the setter and getter of FirstName + @Test + public void testSetAndGetFirstName() { + personObj.setFirstName("Johnny"); + } + + // Testing the DAO of Person class by verifying the setter and getter of FirstName + @Test + public void testSetAndGetLastName() { + personObj.setLastName("Oliver"); + assertEquals("Oliver", personObj.getLastName()); + } +}