/** Test comparator */ public void testComparator() { Exception exception = null; student = new Student(); student.setList(songList); student.setMajor(major); student.setHobby(hobby); student.setRegion(region); student.setHeard(num1); student.setLikes(num3); Student student2 = new Student(); student2.setList(songList); student2.setMajor("asdf"); student2.setHobby("asdf"); student2.setRegion("asd"); student2.setHeard(num3); student2.setLikes(num1); Type type = Type.ARTIST; try { student.compare(student2, type); } catch (Exception e) { exception = e; } assertNotNull(exception); assertTrue(exception instanceof UnsupportedOperationException); }
/** test equals */ public void testEquals() { Student student3 = null; assertFalse(student.equals(student3)); assertTrue(student.equals(student)); assertFalse(student.equals(new Object())); Student sameStudent = new Student(); sameStudent.setHobby(hobby); sameStudent.setMajor(major); sameStudent.setRegion(region); assertTrue(student.equals(sameStudent)); Student diffStudent = new Student(); diffStudent.setHobby("x"); diffStudent.setMajor(major); diffStudent.setRegion(region); assertFalse(student.equals(diffStudent)); diffStudent.setMajor("x"); assertFalse(student.equals(diffStudent)); diffStudent.setRegion("x"); assertFalse(student.equals(diffStudent)); diffStudent.setHobby(hobby); assertFalse(student.equals(diffStudent)); diffStudent.setRegion(region); assertFalse(student.equals(diffStudent)); diffStudent.setHobby(hobby); assertFalse(student.equals(diffStudent)); }
/** setup test */ public void setUp() { student = new Student(); songList = new SongList(); songList.add(new Song("Hotline Bling", "Drake", 2015, "Rap", 0)); student.setList(songList); student.setMajor(major); student.setHobby(hobby); student.setRegion(region); student.setHeard(num1); student.setLikes(num3); }
/** test set region */ public void testSetRegion() { student.setRegion(region); assertTrue(student.getRegion().equals(region)); }