This commit is contained in:
Aman Bhandal 2018-02-25 18:47:52 +00:00 committed by GitHub
commit d074a71d78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 0 deletions

View file

@ -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());
}
}

View file

@ -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());
}
}

View file

@ -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());
}
}