Search in sources :

Example 81 with ModelingSubmission

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);
}
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 82 with ModelingSubmission

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);
}
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 83 with ModelingSubmission

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

Example 84 with ModelingSubmission

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);
}
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 85 with ModelingSubmission

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);
}
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)

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