mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:55:49 +00:00
[TEST] Added tests for Person, BaseEntity, and NamedEntity
This commit is contained in:
parent
6730a229a0
commit
d2637471be
3 changed files with 85 additions and 0 deletions
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue