Please make sure test cases pass import static org.junit.jupiter.api.Assertions.*; import java.util.*; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class CSDTest { @Test @Order(1) void CheckChairEmployeeID100(){ ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road"); CSD csd = new CSD(chair); assertEquals(100, chair.getEmployeeID(), "ChairPerson getID Fail"); } @Test @Order(2) void ShouldCompareDeptChairPerson(){ ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road"); CSD csd = new CSD(chair); assertEquals(chair, csd.getChairPerson(), "CS Dept getChairPerson Fail"); } @Test @Order(3) void CheckChairID102AndFacultyID103(){ ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road"); CSD csd = new CSD(chair); Faculty f = new Faculty("Elizabeth", "Smith", 53, "Female", "Lawrence Avenue East"); f.setProgram("Computer Science"); assertEquals(102, chair.getEmployeeID(), "ChairPerson getID Fail"); assertEquals(103, f.getEmployeeID(), "Faculty getID Fail"); } @Test @Order(4) void CheckProgramNameCorrect(){ ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road"); CSD csd = new CSD(chair); Faculty f = new Faculty("Elizabeth", "Smith", 53, "Female", "Lawrence Avenue East"); f.setProgram("Computer Science"); assertEquals("Computer Science", f.getProgram(), "CS Dept getProgram Fail"); assertFalse(f.getProgram().equals("Computer"), "CS Dept getProgram Fail"); } @Test @Order(5) void CheckToStringChair(){ ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road"); chair.setSalary(12345.6); assertEquals("Chair Person [[[106, 12345.6[Rebert, Jack, 59, Male, Birchmount Road]]]]", chair.toString()); } @Test @Order(6) void CheckToStringFaculty(){ Faculty f = new Faculty("Rebert", "Jack", 59, "Male", "Birchmount Road"); f.setProgram("Computer Science"); f.setSalary(123.4); assertEquals("Faculty Computer Science[[107, 123.4[Rebert, Jack, 59, Male, Birchmount Road]]]", f.toString()); } @Test @Order(7) void CheckToStringUgrad(){ UGrad s = new UGrad("Rebert", "Jack", 59, "Male", "Birchmount Road") {}; assertEquals("Undergraduate [1000[[Rebert, Jack, 59, Male, Birchmount Road]]]", s.toString()); } @Test @Order(8) void CheckToStringGrad(){ Grad s = new Grad("Rebert", "Jack", 59, "Male", "Birchmount Road") {}; assertEquals("Graduate [1001[[Rebert, Jack, 59, Male, Birchmount Road]]]", s.toString()); } @Test @Order(9) void HireFaculty(){ ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road"); CSD csd = new CSD(chair); Faculty f = new Faculty("Elizabeth", "Smith", 53, "Female","Lawrence Avenue East"); f.setProgram("Software Engineering"); UGrad s = new UGrad("Ryan", "Mark", 35, "Male", "Canlish Road"); try{ csd.HireFaculty(f); } catch(NoSpaceException e){ } assertEquals(f, csd.getFaculty().get(0), "Hire Faculty Failed"); assertEquals(1, csd.getNumOfFaculty(), "Hire Faculty Failed"); } @Test @Order(10) void HireFacultyDuplicate(){ ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road"); CSD csd = new CSD(chair); Faculty f = new Faculty("Elizabeth", "Smith", 53, "Female","Lawrence Avenue East"); f.setProgram("Software Engineering"); UGrad s = new UGrad("Ryan", "Mark", 35, "Male", "Canlish Road"); try{ csd.HireFaculty(f); csd.HireFaculty(f); } catch(NoSpaceException e){ } assertEquals(f, csd.getFaculty().get(0), "Hire Faculty Failed"); assertEquals(1, csd.getNumOfFaculty(), "Hire Faculty Failed"); }
Please make sure test cases pass
import static org.junit.jupiter.api.Assertions.*;
import java.util.*;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class CSDTest {
@Test
@Order(1)
void CheckChairEmployeeID100(){
ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road");
CSD csd = new CSD(chair);
assertEquals(100, chair.getEmployeeID(), "ChairPerson getID Fail");
}
@Test
@Order(2)
void ShouldCompareDeptChairPerson(){
ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road");
CSD csd = new CSD(chair);
assertEquals(chair, csd.getChairPerson(), "CS Dept getChairPerson Fail");
}
@Test
@Order(3)
void CheckChairID102AndFacultyID103(){
ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road");
CSD csd = new CSD(chair);
Faculty f = new Faculty("Elizabeth", "Smith", 53, "Female",
"Lawrence Avenue East");
f.setProgram("Computer Science");
assertEquals(102, chair.getEmployeeID(), "ChairPerson getID Fail");
assertEquals(103, f.getEmployeeID(), "Faculty getID Fail");
}
@Test
@Order(4)
void CheckProgramNameCorrect(){
ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road");
CSD csd = new CSD(chair);
Faculty f = new Faculty("Elizabeth", "Smith", 53, "Female",
"Lawrence Avenue East");
f.setProgram("Computer Science");
assertEquals("Computer Science", f.getProgram(), "CS Dept getProgram Fail");
assertFalse(f.getProgram().equals("Computer"), "CS Dept getProgram Fail");
}
@Test
@Order(5)
void CheckToStringChair(){
ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road");
chair.setSalary(12345.6);
assertEquals("Chair Person [[[106, 12345.6[Rebert, Jack, 59, Male, Birchmount Road]]]]", chair.toString());
}
@Test
@Order(6)
void CheckToStringFaculty(){
Faculty f = new Faculty("Rebert", "Jack", 59, "Male", "Birchmount Road");
f.setProgram("Computer Science");
f.setSalary(123.4);
assertEquals("Faculty Computer Science[[107, 123.4[Rebert, Jack, 59, Male, Birchmount Road]]]", f.toString());
}
@Test
@Order(7)
void CheckToStringUgrad(){
UGrad s = new UGrad("Rebert", "Jack", 59, "Male", "Birchmount Road") {};
assertEquals("Undergraduate [1000[[Rebert, Jack, 59, Male, Birchmount Road]]]", s.toString());
}
@Test
@Order(8)
void CheckToStringGrad(){
Grad s = new Grad("Rebert", "Jack", 59, "Male", "Birchmount Road") {};
assertEquals("Graduate [1001[[Rebert, Jack, 59, Male, Birchmount Road]]]", s.toString());
}
@Test
@Order(9)
void HireFaculty(){
ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road");
CSD csd = new CSD(chair);
Faculty f = new Faculty("Elizabeth", "Smith", 53, "Female","Lawrence Avenue East");
f.setProgram("Software Engineering");
UGrad s = new UGrad("Ryan", "Mark", 35, "Male", "Canlish Road");
try{
csd.HireFaculty(f);
}
catch(NoSpaceException e){
}
assertEquals(f, csd.getFaculty().get(0), "Hire Faculty Failed");
assertEquals(1, csd.getNumOfFaculty(), "Hire Faculty Failed");
}
@Test
@Order(10)
void HireFacultyDuplicate(){
ChairPerson chair = new ChairPerson("Rebert", "Jack", 59, "Male", "Birchmount Road");
CSD csd = new CSD(chair);
Faculty f = new Faculty("Elizabeth", "Smith", 53, "Female","Lawrence Avenue East");
f.setProgram("Software Engineering");
UGrad s = new UGrad("Ryan", "Mark", 35, "Male", "Canlish Road");
try{
csd.HireFaculty(f);
csd.HireFaculty(f);
}
catch(NoSpaceException e){
}
assertEquals(f, csd.getFaculty().get(0), "Hire Faculty Failed");
assertEquals(1, csd.getNumOfFaculty(), "Hire Faculty Failed");
}
Step by step
Solved in 2 steps