AdministratorクラスのlistメソッドをJUnitを使ってテストしたいのですが、assertEqualsを使って結果を比べようとしても、型が違うと表示されてしまい上手くいきません。それと、リストの中身を全て比べたいのですが、それも良いアイデアがありません。どのように修正したらいいでしょうか?
@Test
public void listTest() {
Object[] expectedEmps = new Object[];
expectedEmps[0] = new Student("a", "a", "a", "a", "a", "uni");
expectedEmps[1] = new Student("2", "1", "2", "1", "2", "uni2");
Administrator.add("a", "a", "a", "a", "a", "uni", list);
Administrator.add("2", "1", "2", "1", "2", "uni2", list);
assertEquals(expectedEmps, Administrator.list(list));
}
Administratorクラスです
public static ArrayList<Student> list = new ArrayList<Student>();
public static ArrayList<Subject> listSub = new ArrayList<Subject>();
public static void list(ArrayList<Student> list) {
for(int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
System.out.print("<Subject>: ");
Administrator.listStr(Administrator.listCorrect(list.get(i).getID()));
System.out.println("");
}
}
public static ArrayList<String> listCorrect(String iden) {
ArrayList<String> templist = new ArrayList<String>();
for(int i = 0; i < Administrator.listSub.size(); i++) {
if(iden.equals(listSub.get(i).getID())){
templist.add(listSub.get(i).getSub());
}
}
return templist;
}
public static void add(String id, String password, String name,
String nationality,String address, String univeristy, ArrayList<Student> list) {
list.add(new Student(id, password, name, nationality, address, univeristy));
}
Studentクラスです
public Student(String id, String password, String name, String nationality,String address, String university){
this.id = id;
this.password = password;
this.name = name;
this.nationality = nationality;
this.address = address;
this.university = university;
}
public String getID() {
return this.id;
}