Commit ae6d61e4 authored by 9731050's avatar 9731050

3th

parent 1ab10fd8
......@@ -12,6 +12,7 @@ public class Department {
this.name=name;
students=new ArrayList<Student>();
courses=new ArrayList<Course>();
professors=new ArrayList<Professor>();
}
public String getName(){
......
......@@ -7,36 +7,54 @@ import com.university.Student;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DepartmentTest {
static Department department;
static Student student;
static Course course;
static Professor professor;
static Student student,s2;
static Course course,c2;
static Professor professor,p2;
static ArrayList<Course>courses;
static ArrayList<Professor>professors;
static ArrayList<Student>students;
@BeforeAll
public static void creatStudent()
{
courses=new ArrayList<>();
professors=new ArrayList<>();
students=new ArrayList<>();
department=new Department("abc");
professor=new Professor(department,"kz");
course=new Course("123","math",department,professor,3);
student=new Student("ali","1234","abc",department);
s2=new Student("Mohammad","124","b",new Department("aa"));
department.addCourse(course);
department.addProfessor(professor);
department.addStudent(student);
department.addStudent(s2);
for(int i=0;i<department.getStudents().size();i++)
students.add(department.getStudents().get(i));
for(int j=0;j<department.getProfessors().size();j++)
professors.add(department.getProfessors().get(j));
for(int z=0;z<department.getCourses().size();z++)
courses.add(department.getCourses().get(z));
}
@Test
public void Test(){
assertEquals("abc",department.getName());
assertEquals(professor,department.getProfessors().get(0));
assertEquals(course,department.getCourses().get(0));
assertEquals(student,department.getStudents().get(0));
assertEquals(professors,department.getProfessors());
assertEquals(courses,department.getCourses());
assertEquals(students,department.getStudents());
department.removeCourse(course);
courses.remove(course);
department.removeProfessor(professor);
professors.remove(professor);
department.removeStudent(student);
assertEquals(0,department.getProfessors().get(0));
assertEquals(0,department.getCourses().get(0));
assertEquals(0,department.getStudents().get(0));
students.remove(student);
assertEquals(professors,department.getProfessors());
assertEquals(courses,department.getCourses());
assertEquals(students,department.getStudents());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment