use of cn.edu.zjnu.acm.judge.domain.Submission in project judge by zjnu-acm.
the class JudgeServiceTest method check.
private void check(Checker c) throws IOException {
String userId = initializer.userId;
CompletableFuture<?> future;
long id;
try {
String extension = getExtension(path);
int language = findFirstLanguageByExtension(EXTENSION_MAP.get(extension));
String source = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
submissionService.remove(userId);
future = submissionService.submit(language, source, userId, IP, initializer.problem);
id = findOneByUserId(userId).getId();
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
initializer.submissions.add(id);
Submission submission;
try {
submission = future.thenApply(__ -> submissionMapper.findOne(id)).get();
} catch (InterruptedException | ExecutionException ex) {
throw new AssertionError(ex);
}
assertNotNull(submission);
int expectScore = c.getScore();
String key = path.getParent().getFileName() + "/" + path.getFileName();
if (specialKey.equals(key)) {
expectScore = specialScore;
}
assertEquals(id + " " + path, expectScore, submission.getScore());
String detail = submissionMapper.getSubmissionDetail(id);
String[] details = detail.split(",");
ArrayList<String> list = Lists.newArrayList();
for (int i = 0; i < details.length; i += 4) {
list.add(details[i]);
}
assertTrue(id + " " + path + " " + Arrays.toString(details), list.contains(Integer.toString(c.getStatus())));
}
use of cn.edu.zjnu.acm.judge.domain.Submission in project judge by zjnu-acm.
the class ShowSourceControllerTest method testShowSource.
/**
* Test of showSource method, of class ShowSourceController.
*
* @see ShowSourceController#showSource(HttpServletRequest, long, Integer,
* Authentication)
*/
@Test
public void testShowSource() throws Exception {
log.info("showSource");
Submission submission = mockDataService.submission();
long solutionId = submission.getId();
Integer style = null;
MvcResult result = mvc.perform(get("/showsource").with(user(submission.getUser())).param("solution_id", Long.toString(solutionId)).param("style", Objects.toString(style, ""))).andExpect(status().isOk()).andExpect(view().name("submissions/source")).andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)).andReturn();
}
use of cn.edu.zjnu.acm.judge.domain.Submission in project judge by zjnu-acm.
the class ShowSubmissionDetailsControllerTest method testShowSolutionDetails.
/**
* Test of showSolutionDetails method, of class
* ShowSubmissionDetailsController.
*
* @see
* ShowSubmissionDetailsController#showSolutionDetails(HttpServletRequest,
* long, Authentication)
*/
@Test
public void testShowSolutionDetails() throws Exception {
log.info("showSolutionDetails");
Submission submission = mockDataService.submission();
long solutionId = submission.getId();
MvcResult result = mvc.perform(get("/showsolutiondetails").with(user(submission.getUser())).param("solution_id", Long.toString(solutionId))).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)).andExpect(view().name("submissions/detail")).andReturn();
}
Aggregations