Search in sources :

Example 11 with JudgeReply

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

the class SubmissionPersistenceImplTest method testUpdateJudgeReply.

/**
	 * Tests updateJudgeReply method
	 * @throws Exception to JUnit
	 */
public void testUpdateJudgeReply() throws Exception {
    List judgeReplies = persistence.getAllJudgeReplies();
    for (int i = 0; i < 3; ++i) {
        JudgeReply judgeReply = (JudgeReply) judgeReplies.get(i);
        long id = judgeReply.getId();
        persistence.updateJudgeReply(new JudgeReply(id, "new judgeReply" + id, "new JudgeReply " + id, "new style" + id, i % 2 == 1), 10);
    }
    judgeReplies = persistence.getAllJudgeReplies();
    for (int i = 0; i < 3; ++i) {
        JudgeReply judgeReply = (JudgeReply) judgeReplies.get(i);
        long id = judgeReply.getId();
        assertEquals("wrong name", "new judgeReply" + id, judgeReply.getName());
        assertEquals("wrong desc", "new JudgeReply " + id, judgeReply.getDescription());
        assertEquals("wrong options", "new style" + id, judgeReply.getStyle());
        assertEquals("wrong compiler", i % 2 == 1, judgeReply.isCommitted());
    }
}
Also used : JudgeReply(cn.edu.zju.acm.onlinejudge.bean.enumeration.JudgeReply) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with JudgeReply

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

the class SubmissionPersistenceImplTest method testGetJudgeReply3.

/**
	 * Tests getJudgeReply method
	 * @throws Exception to JUnit
	 */
public void testGetJudgeReply3() throws Exception {
    JudgeReply judgeReply = persistence.getJudgeReply(judgeReply1.getId());
    checkJudgeReply(judgeReply1, judgeReply);
}
Also used : JudgeReply(cn.edu.zju.acm.onlinejudge.bean.enumeration.JudgeReply)

Example 13 with JudgeReply

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

the class SubmissionPersistenceImplTest method testGetJudgeReply2.

/**
	 * Tests getJudgeReply method
	 * @throws Exception to JUnit
	 */
public void testGetJudgeReply2() throws Exception {
    JudgeReply judgeReply = persistence.getJudgeReply(judgeReply1.getId());
    checkJudgeReply(judgeReply1, judgeReply);
}
Also used : JudgeReply(cn.edu.zju.acm.onlinejudge.bean.enumeration.JudgeReply)

Example 14 with JudgeReply

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

the class SubmissionPersistenceImpl method populateSubmission.

/**
     * Populates an ExtendedSubmission with given ResultSet.
     * 
     * @param rs
     * @return an ExtendedSubmission instance
     * @throws SQLException
     */
private Submission populateSubmission(ResultSet rs, boolean withContent, Map<Long, Language> languageMap) throws SQLException {
    Submission submission = new Submission();
    submission.setId(rs.getLong(DatabaseConstants.SUBMISSION_SUBMISSION_ID));
    submission.setProblemId(rs.getLong(DatabaseConstants.SUBMISSION_PROBLEM_ID));
    submission.setUserProfileId(rs.getLong(DatabaseConstants.SUBMISSION_USER_PROFILE_ID));
    submission.setJudgeComment(rs.getString(DatabaseConstants.SUBMISSION_JUDGE_COMMENT));
    submission.setJudgeDate(Database.getDate(rs, DatabaseConstants.SUBMISSION_JUDGE_DATE));
    submission.setSubmitDate(Database.getDate(rs, DatabaseConstants.SUBMISSION_SUBMISSION_DATE));
    submission.setMemoryConsumption(rs.getInt(DatabaseConstants.SUBMISSION_MEMORY_CONSUMPTION));
    submission.setTimeConsumption(rs.getInt(DatabaseConstants.SUBMISSION_TIME_CONSUMPTION));
    submission.setUserName(rs.getString(DatabaseConstants.USER_PROFILE_NICKNAME));
    if (submission.getUserName().equals("")) {
        submission.setUserName(rs.getString(DatabaseConstants.USER_PROFILE_HANDLE));
    }
    submission.setProblemCode(rs.getString(DatabaseConstants.PROBLEM_CODE));
    submission.setContestId(rs.getLong("contest_id"));
    submission.setContestOrder(rs.getLong("contest_order"));
    if (withContent) {
        submission.setContent(rs.getString("content"));
    }
    // set language
    long languageId = rs.getLong(DatabaseConstants.SUBMISSION_LANGUAGE_ID);
    Language language = languageMap.get(languageId);
    submission.setLanguage(language);
    // set judge reply
    long judgeReplyId = rs.getLong(DatabaseConstants.SUBMISSION_JUDGE_REPLY_ID);
    JudgeReply judgeReply = JudgeReply.findById(judgeReplyId);
    submission.setJudgeReply(judgeReply);
    return submission;
}
Also used : Submission(cn.edu.zju.acm.onlinejudge.bean.Submission) Language(cn.edu.zju.acm.onlinejudge.bean.enumeration.Language) JudgeReply(cn.edu.zju.acm.onlinejudge.bean.enumeration.JudgeReply)

Aggregations

JudgeReply (cn.edu.zju.acm.onlinejudge.bean.enumeration.JudgeReply)14 ArrayList (java.util.ArrayList)7 List (java.util.List)5 Language (cn.edu.zju.acm.onlinejudge.bean.enumeration.Language)3 SubmissionCriteria (cn.edu.zju.acm.onlinejudge.bean.request.SubmissionCriteria)2 Submission (cn.edu.zju.acm.onlinejudge.bean.Submission)1 LanguagePersistence (cn.edu.zju.acm.onlinejudge.persistence.LanguagePersistence)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 HashSet (java.util.HashSet)1 ActionForward (org.apache.struts.action.ActionForward)1