Search in sources :

Example 76 with ModelingSubmission

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());
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 77 with ModelingSubmission

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);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 78 with ModelingSubmission

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);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 79 with ModelingSubmission

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();
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 80 with ModelingSubmission

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();
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Aggregations

ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)160 Test (org.junit.jupiter.api.Test)108 WithMockUser (org.springframework.security.test.context.support.WithMockUser)106 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)36 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)16 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)16 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)12 JsonParser.parseString (com.google.gson.JsonParser.parseString)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)8 ModelingSubmission (de.tum.in.www1.artemis.domain.ModelingSubmission)6 Result (de.tum.in.www1.artemis.domain.Result)6 ModelElement (de.tum.in.www1.artemis.domain.modeling.ModelElement)6 ModelClusterFactory (de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory)6 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)4 ExerciseHint (de.tum.in.www1.artemis.domain.hestia.ExerciseHint)4 Participation (de.tum.in.www1.artemis.domain.participation.Participation)4 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)4 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)4