}
public void testGetPosts() {
School sc = schoolDAO
.getSchoolFromName("Jarvis Christian College");
assertNotNull(sc);
// assert that there are no posts for the school
PostsList threads = schoolDAO.getSchoolThreads(sc.getId(), 0, 10);
assertNotNull(threads);
assertEquals(0, threads.getTotalCount());
assertEquals(0, threads.getPosts().size());
User u = userDAO.getUserByUsername("test");
assertNotNull(u);
// Create a first thread for this school
ForumPost post = new SchoolForumPost(sc, u, A, A, null);
post = (ForumPost) schoolDAO.save(post);
threads = schoolDAO.getSchoolThreads(sc.getId(), 0, 10);
assertEquals(1, threads.getTotalCount());
assertEquals(1, threads.getPosts().size());
ForumPost saved = threads.getPosts().get(0);
assertNotNull(saved.getDate());
assertEquals(sc, saved.getTopic());
// save a second post in the same thread
ForumPost post2 = new SchoolForumPost(sc, u, null, A, saved);
post2 = (ForumPost) schoolDAO.save(post2);
// should only be 1 top level thread still.
threads = schoolDAO.getSchoolThreads(sc.getId(), 0, 10);
assertEquals(1, threads.getTotalCount());
assertEquals(1, threads.getPosts().size());
PostsList post1Thread = schoolDAO.getPostsForThread(post, 0, 10);
assertEquals(2, post1Thread.getTotalCount());