Search in sources :

Example 6 with Post

use of cn.edu.zju.acm.onlinejudge.bean.Post in project zoj by licheng.

the class AuthorizationPersistenceImplTest method testCreatePost1.

/**
	 * Tests createPost method
	 * @throws Exception to JUnit
	 */
public void testCreatePost1() throws Exception {
    Post post = newPost(-1, thread1.getId(), profile.getId());
    persistence.createPost(post, 1);
    Post newPost = persistence.getPost(post.getId());
    checkPost(post, newPost);
}
Also used : Post(cn.edu.zju.acm.onlinejudge.bean.Post)

Example 7 with Post

use of cn.edu.zju.acm.onlinejudge.bean.Post in project zoj by licheng.

the class ForumPersistenceImplTest method setUp.

/**
	 * Setup.
	 * @throws Exception to JUnit
	 */
protected void setUp() throws Exception {
    DatabaseHelper.resetAllTables(false);
    profile.setHandle("myHandle");
    profile.setPassword("myPassword");
    profile.setEmail("myEmail");
    profile.setRegDate(new Date());
    profile.setFirstName("myFirstName");
    profile.setLastName("myLastName");
    profile.setAddressLine1("myAddressLine1");
    profile.setAddressLine2("myAddressLine2");
    profile.setCity("myCity");
    profile.setState("myState");
    profile.setCountry(new Country(1, "foo"));
    profile.setZipCode("myZipCode");
    profile.setPhoneNumber("myPhoneNumber");
    profile.setBirthDate(DateFormat.getDateInstance(DateFormat.SHORT, Locale.US).parse("1/1/1980"));
    profile.setGender('M');
    profile.setSchool("mySchool");
    profile.setMajor("myMajor");
    profile.setGraduateStudent(true);
    profile.setGraduationYear(2005);
    profile.setStudentNumber("myStudentNumber");
    profile.setConfirmed(false);
    new UserPersistenceImpl().createUserProfile(profile, 1);
    forum1 = newForum(1);
    forum2 = newForum(2);
    forum3 = newForum(3);
    persistence.createForum(forum1, 1);
    persistence.createForum(forum2, 1);
    persistence.createForum(forum3, 1);
    thread1 = newThread(1, forum1.getId(), profile.getId());
    thread2 = newThread(2, forum1.getId(), profile.getId());
    thread3 = newThread(3, forum2.getId(), profile.getId());
    persistence.createThread(thread1, 1);
    persistence.createThread(thread2, 1);
    persistence.createThread(thread3, 1);
    post1 = newPost(1, thread1.getId(), profile.getId());
    post2 = newPost(2, thread1.getId(), profile.getId());
    post3 = newPost(3, thread2.getId(), profile.getId());
    persistence.createPost(post1, 1);
    persistence.createPost(post2, 1);
    persistence.createPost(post3, 1);
    thread3Posts = new ArrayList();
    for (int i = 1; i <= 10; ++i) {
        Post post = newPost(i, thread3.getId(), profile.getId());
        thread3Posts.add(post);
        persistence.createPost(post, 1);
    }
}
Also used : Post(cn.edu.zju.acm.onlinejudge.bean.Post) ArrayList(java.util.ArrayList) Country(cn.edu.zju.acm.onlinejudge.bean.enumeration.Country) Date(java.util.Date)

Example 8 with Post

use of cn.edu.zju.acm.onlinejudge.bean.Post in project zoj by licheng.

the class ForumPersistenceImplTest method checkPostList.

/**
	 * Checks whether the two lists are same.
	 * @param posts1 the expected profile
	 * @param posts2 the profile to check
	 * @param offset1 the offset in post list 1.
	 * @param offset2 the offset in post list 2.
	 * @param count the count
	 */
private void checkPostList(List posts1, int offset1, List posts2, int offset2, int count) {
    for (int i = 0; i < count; ++i) {
        Post post1 = (Post) posts1.get(offset1 + i);
        Post post2 = (Post) posts2.get(offset2 + i);
        checkPost(post1, post2);
    }
}
Also used : Post(cn.edu.zju.acm.onlinejudge.bean.Post)

Example 9 with Post

use of cn.edu.zju.acm.onlinejudge.bean.Post in project zoj by licheng.

the class ForumPersistenceImplTest method testUpdatePost1.

/**
	 * Tests updatePost method
	 * @throws Exception to JUnit
	 */
public void testUpdatePost1() throws Exception {
    post1.setId(post2.getId());
    persistence.updatePost(post1, 1);
    Post post = persistence.getPost(post1.getId());
    checkPost(post1, post);
}
Also used : Post(cn.edu.zju.acm.onlinejudge.bean.Post)

Example 10 with Post

use of cn.edu.zju.acm.onlinejudge.bean.Post in project zoj by licheng.

the class ForumPersistenceImplTest method testCreatePost1.

/**
	 * Tests createPost method
	 * @throws Exception to JUnit
	 */
public void testCreatePost1() throws Exception {
    Post post = newPost(-1, thread1.getId(), profile.getId());
    persistence.createPost(post, 1);
    Post newPost = persistence.getPost(post.getId());
    checkPost(post, newPost);
}
Also used : Post(cn.edu.zju.acm.onlinejudge.bean.Post)

Aggregations

Post (cn.edu.zju.acm.onlinejudge.bean.Post)14 ArrayList (java.util.ArrayList)3 Country (cn.edu.zju.acm.onlinejudge.bean.enumeration.Country)2 PersistenceException (cn.edu.zju.acm.onlinejudge.persistence.PersistenceException)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Date (java.util.Date)2