use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getModelSubmissionForModelingEditor.
@Test
@WithMockUser(username = "student1")
public void getModelSubmissionForModelingEditor() throws Exception {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
submission = (ModelingSubmission) database.addModelingSubmissionWithFinishedResultAndAssessor(classExercise, submission, "student1", "tutor1");
ModelingSubmission receivedSubmission = request.get("/api/participations/" + submission.getParticipation().getId() + "/latest-modeling-submission", HttpStatus.OK, ModelingSubmission.class);
// set dates to UTC and round to milliseconds for comparison
submission.setSubmissionDate(ZonedDateTime.ofInstant(submission.getSubmissionDate().truncatedTo(ChronoUnit.MILLIS).toInstant(), ZoneId.of("UTC")));
receivedSubmission.setSubmissionDate(ZonedDateTime.ofInstant(receivedSubmission.getSubmissionDate().truncatedTo(ChronoUnit.MILLIS).toInstant(), ZoneId.of("UTC")));
assertThat(receivedSubmission).as("submission was found").isEqualTo(submission);
assertThat(receivedSubmission.getLatestResult()).as("result is set").isNotNull();
assertThat(receivedSubmission.getLatestResult().getAssessor()).as("assessor is hidden").isNull();
// students can only see their own models
submission = ModelFactory.generateModelingSubmission(validModel, true);
submission = database.addModelingSubmission(classExercise, submission, "student2");
request.get("/api/participations/" + submission.getParticipation().getId() + "/latest-modeling-submission", HttpStatus.FORBIDDEN, ModelingSubmission.class);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method createModelingSubmission_badRequest.
@Test
@WithMockUser(username = "student1")
public void createModelingSubmission_badRequest() throws Exception {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
modelingSubmissionRepo.save(submission);
request.postWithResponseBody("/api/exercises/" + classExercise.getId() + "/modeling-submissions", submission, ModelingSubmission.class, HttpStatus.BAD_REQUEST);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getModelSubmissionWithoutAssessment_lockSubmission.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void getModelSubmissionWithoutAssessment_lockSubmission() throws Exception {
User user = database.getUserByLogin("tutor1");
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
submission = database.addModelingSubmission(classExercise, submission, "student1");
database.updateExerciseDueDate(classExercise.getId(), ZonedDateTime.now().minusHours(1));
ModelingSubmission storedSubmission = request.get("/api/exercises/" + classExercise.getId() + "/modeling-submission-without-assessment?lock=true", HttpStatus.OK, ModelingSubmission.class);
// set dates to UTC and round to milliseconds for comparison
submission.setSubmissionDate(ZonedDateTime.ofInstant(submission.getSubmissionDate().truncatedTo(ChronoUnit.SECONDS).toInstant(), ZoneId.of("UTC")));
storedSubmission.setSubmissionDate(ZonedDateTime.ofInstant(storedSubmission.getSubmissionDate().truncatedTo(ChronoUnit.SECONDS).toInstant(), ZoneId.of("UTC")));
assertThat(storedSubmission).as("submission was found").isEqualToIgnoringGivenFields(submission, "results", "similarElementCounts");
assertThat(storedSubmission.getLatestResult()).as("result is set").isNotNull();
assertThat(storedSubmission.getLatestResult().getAssessor()).as("assessor is tutor1").isEqualTo(user);
checkDetailsHidden(storedSubmission, false);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getModelSubmissionWithoutAssessment_dueDateNotOver.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void getModelSubmissionWithoutAssessment_dueDateNotOver() throws Exception {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmission(classExercise, submission, "student1");
request.get("/api/exercises/" + classExercise.getId() + "/modeling-submission-without-assessment", HttpStatus.FORBIDDEN, ModelingSubmission.class);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getModelSubmissionWithoutAssessment_asStudent_forbidden.
@Test
@WithMockUser(username = "student1")
public void getModelSubmissionWithoutAssessment_asStudent_forbidden() throws Exception {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmission(classExercise, submission, "student1");
database.updateExerciseDueDate(classExercise.getId(), ZonedDateTime.now().minusHours(1));
request.get("/api/exercises/" + classExercise.getId() + "/modeling-submission-without-assessment", HttpStatus.FORBIDDEN, ModelingSubmission.class);
}
Aggregations