use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method saveAndSubmitModelingSubmission_isTeamMode.
@Test
@WithMockUser(username = "student1")
public void saveAndSubmitModelingSubmission_isTeamMode() throws Exception {
useCaseExercise.setMode(ExerciseMode.TEAM);
exerciseRepo.save(useCaseExercise);
Team team = new Team();
team.setName("Team");
team.setShortName("team");
team.setExercise(useCaseExercise);
team.addStudents(userRepo.findOneByLogin("student1").orElseThrow());
team.addStudents(userRepo.findOneByLogin("student2").orElseThrow());
teamRepository.save(useCaseExercise, team);
database.addTeamParticipationForExercise(useCaseExercise, team.getId());
String emptyUseCaseModel = FileUtils.loadFileFromResources("test-data/model-submission/empty-use-case-diagram.json");
ModelingSubmission submission = ModelFactory.generateModelingSubmission(emptyUseCaseModel, false);
submission.setExplanationText("This is a use case diagram.");
ModelingSubmission returnedSubmission = performInitialModelSubmission(useCaseExercise.getId(), submission);
database.checkModelingSubmissionCorrectlyStored(returnedSubmission.getId(), emptyUseCaseModel);
database.changeUser("student1");
Optional<SubmissionVersion> version = submissionVersionRepository.findLatestVersion(returnedSubmission.getId());
assertThat(version).as("submission version was created").isNotEmpty();
assertThat(version.get().getAuthor().getLogin()).as("submission version has correct author").isEqualTo("student1");
assertThat(version.get().getContent()).as("submission version has correct content").isEqualTo("Model: " + returnedSubmission.getModel() + "; Explanation: " + returnedSubmission.getExplanationText());
assertThat(version.get().getCreatedDate()).isNotNull();
assertThat(version.get().getLastModifiedDate()).isNotNull();
database.changeUser("student2");
String validUseCaseModel = FileUtils.loadFileFromResources("test-data/model-submission/use-case-model.json");
returnedSubmission.setModel(validUseCaseModel);
returnedSubmission.setSubmitted(true);
returnedSubmission = performUpdateOnModelSubmission(useCaseExercise.getId(), returnedSubmission);
database.checkModelingSubmissionCorrectlyStored(returnedSubmission.getId(), validUseCaseModel);
checkDetailsHidden(returnedSubmission, true);
database.changeUser("student2");
version = submissionVersionRepository.findLatestVersion(returnedSubmission.getId());
assertThat(version).as("submission version was created").isNotEmpty();
assertThat(version.get().getAuthor().getLogin()).as("submission version has correct author").isEqualTo("student2");
assertThat(version.get().getContent()).as("submission version has correct content").isEqualTo("Model: " + returnedSubmission.getModel() + "; Explanation: " + returnedSubmission.getExplanationText());
returnedSubmission = performUpdateOnModelSubmission(useCaseExercise.getId(), returnedSubmission);
database.changeUser("student2");
Optional<SubmissionVersion> newVersion = submissionVersionRepository.findLatestVersion(returnedSubmission.getId());
assertThat(newVersion.orElseThrow().getId()).as("submission version was not created").isEqualTo(version.get().getId());
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getModelSubmission_lockLimitReached_badRequest.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void getModelSubmission_lockLimitReached_badRequest() throws Exception {
createTenLockedSubmissionsForDifferentExercisesAndUsers("tutor1");
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmission(useCaseExercise, submission, "student2");
request.get("/api/modeling-submissions/" + submission.getId(), HttpStatus.BAD_REQUEST, ModelingSubmission.class);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getModelSubmissionWithoutAssessment_noSubmissionWithoutAssessment_notFound.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void getModelSubmissionWithoutAssessment_noSubmissionWithoutAssessment_notFound() throws Exception {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(classExercise, submission, "student1", "tutor1");
database.updateExerciseDueDate(classExercise.getId(), ZonedDateTime.now().minusHours(1));
request.get("/api/exercises/" + classExercise.getId() + "/modeling-submission-without-assessment", HttpStatus.NOT_FOUND, ModelingSubmission.class);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method saveExercise_beforeDueDate.
@Test
@WithMockUser(username = "student3", roles = "USER")
public void saveExercise_beforeDueDate() throws Exception {
ModelingSubmission storedSubmission = request.postWithResponseBody("/api/exercises/" + classExercise.getId() + "/modeling-submissions", unsubmittedSubmission, ModelingSubmission.class, HttpStatus.OK);
assertThat(storedSubmission.isSubmitted()).isTrue();
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getSubmissionForModelingEditor_unfinishedAssessment.
@Test
@WithMockUser(username = "student1")
public void getSubmissionForModelingEditor_unfinishedAssessment() throws Exception {
StudentParticipation studentParticipation = database.createAndSaveParticipationForExercise(classExercise, "student1");
database.addModelingSubmissionWithEmptyResult(classExercise, "", "student1");
ModelingSubmission returnedSubmission = request.get("/api/participations/" + studentParticipation.getId() + "/latest-modeling-submission", HttpStatus.OK, ModelingSubmission.class);
assertThat(returnedSubmission.getLatestResult()).as("the result is not sent to the client if the assessment is not finished").isNull();
}
Aggregations