use of cn.edu.zjnu.acm.judge.domain.Contest in project judge by zjnu-acm.
the class ContestMapperTest method testFindOneByIdAndDisabledFalse.
/**
* Test of findOneByIdAndNotDisabled method, of class ContestMapper.
*/
@Test
public void testFindOneByIdAndDisabledFalse() {
log.info("findOneByIdAndDisabledFalse");
long contestId = 0L;
Contest expResult = null;
Contest result = instance.findOneByIdAndNotDisabled(contestId);
assertEquals(expResult, result);
}
use of cn.edu.zjnu.acm.judge.domain.Contest in project judge by zjnu-acm.
the class ContestControllerTest method testSave.
/**
* Test of save method, of class ContestController.
*
* @see ContestController#save(Contest)
*/
@Test
public void testSave() throws Exception {
log.info("save");
Contest contest = mockDataService.contest(false);
MvcResult result = mvc.perform(post("/api/contests.json").content(objectMapper.writeValueAsString(contest)).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
use of cn.edu.zjnu.acm.judge.domain.Contest in project judge by zjnu-acm.
the class ContestControllerTest method testUpdate.
/**
* Test of update method, of class ContestController.
*
* @see ContestController#update(long, Contest)
*/
@Test
public void testUpdate() throws Exception {
log.info("update");
long id = mockDataService.contest().getId();
Contest request = new Contest();
MvcResult result = mvc.perform(patch("/api/contests/{id}.json", id).content(objectMapper.writeValueAsString(request)).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isNoContent()).andReturn();
}
use of cn.edu.zjnu.acm.judge.domain.Contest in project judge by zjnu-acm.
the class SubmissionService method canView.
public boolean canView(HttpServletRequest request, Submission submission) {
if (UserDetailsServiceImpl.isAdminLoginned(request)) {
return true;
}
// TODO cast to Authentication
if (UserDetailsServiceImpl.isUser((Authentication) request.getUserPrincipal(), submission.getUser())) {
return true;
}
boolean sourceBrowser = UserDetailsServiceImpl.isSourceBrowser(request);
if (sourceBrowser) {
Long contestId = submission.getContest();
if (contestId == null) {
return true;
}
Contest contest = contestMapper.findOne(contestId);
return contest == null || contest.isEnded();
}
return false;
}
use of cn.edu.zjnu.acm.judge.domain.Contest in project judge by zjnu-acm.
the class SubmissionService method contestSubmit.
public CompletableFuture<?> contestSubmit(int languageId, String source, String userId, String ip, long contestId, long problemNum) {
check(languageId, source, userId);
Contest contest = contestService.findOneByIdAndNotDisabled(contestId);
// contest not started yet, can't submit the problem.
if (!contest.isStarted()) {
throw new BusinessException(BusinessCode.CONTEST_PROBLEM_NOT_FOUND, contestId, problemNum);
}
Problem problem = contestService.getProblem(contestId, problemNum, null);
return submit0(Submission.builder().contest(contest.isEnded() ? null : contestId).problem(problem.getOrigin()).ip(ip), source, userId, languageId);
}
Aggregations