use of cn.edu.zju.acm.onlinejudge.bean.Forum in project zoj by licheng.
the class ForumPersistenceImplTest method testGetForum.
/**
* Tests getForum method
* @throws Exception to JUnit
*/
public void testGetForum() throws Exception {
List forums = persistence.getAllForums();
for (Iterator it = forums.iterator(); it.hasNext(); ) {
Forum forum = (Forum) it.next();
Forum forum1 = persistence.getForum(forum.getId());
checkForum(forum, forum1);
}
}
use of cn.edu.zju.acm.onlinejudge.bean.Forum in project zoj by licheng.
the class ForumPersistenceImplTest method newForum.
/**
* Creates a new forum.
* @param id the id
* @return a new forum instance
*/
private Forum newForum(long id) {
Forum forum = new Forum();
forum.setId(id);
forum.setName("forum" + id);
forum.setDescription("forum" + id + " description");
return forum;
}
use of cn.edu.zju.acm.onlinejudge.bean.Forum in project zoj by licheng.
the class SubmissionPersistenceImplTest method newForum.
/**
* Creates a new forum.
* @param id the id
* @return a new forum instance
*/
private Forum newForum(long id) {
Forum forum = new Forum();
forum.setId(id);
forum.setName("forum" + id);
forum.setDescription("forum" + id + " description");
return forum;
}
use of cn.edu.zju.acm.onlinejudge.bean.Forum in project zoj by licheng.
the class ForumPersistenceImplTest method testUpdateForum2.
/**
* Tests updateForum method
* @throws Exception to JUnit
*/
public void testUpdateForum2() throws Exception {
try {
Forum forum = new Forum();
forum.setName("foo");
forum.setDescription("bar");
persistence.updateForum(forum, 1);
fail("PersistenceException should be thrown");
} catch (PersistenceException pe) {
// ok
}
}
use of cn.edu.zju.acm.onlinejudge.bean.Forum in project zoj by licheng.
the class ForumPersistenceImplTest method testGetAllForums.
/**
* Tests getAllForums method
* @throws Exception to JUnit
*/
public void testGetAllForums() throws Exception {
List forums = persistence.getAllForums();
assertEquals("size is wrong", 3, forums.size());
Set nameSet = new HashSet(Arrays.asList(new String[] { "forum1", "forum2", "forum3" }));
Set descSet = new HashSet(Arrays.asList(new String[] { "forum1 description", "forum2 description", "forum3 description" }));
for (Iterator it = forums.iterator(); it.hasNext(); ) {
Forum forum = (Forum) it.next();
assertTrue("wrong name", nameSet.contains(forum.getName()));
assertTrue("wrong description", descSet.contains(forum.getDescription()));
nameSet.remove(forum.getName());
descSet.remove(forum.getDescription());
}
}
Aggregations