Search in sources :

Example 36 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project ArTEMiS by ls1intum.

the class ModelingSubmissionIntegrationTest method saveAndSubmitModelingSubmission_objectDiagram.

@Test
@WithMockUser(username = "student1")
public void saveAndSubmitModelingSubmission_objectDiagram() throws Exception {
    database.createAndSaveParticipationForExercise(objectExercise, "student1");
    String emptyObjectModel = FileUtils.loadFileFromResources("test-data/model-submission/empty-object-diagram.json");
    ModelingSubmission submission = ModelFactory.generateModelingSubmission(emptyObjectModel, false);
    ModelingSubmission returnedSubmission = performInitialModelSubmission(objectExercise.getId(), submission);
    database.checkModelingSubmissionCorrectlyStored(returnedSubmission.getId(), emptyObjectModel);
    checkDetailsHidden(returnedSubmission, true);
    String validObjectModel = FileUtils.loadFileFromResources("test-data/model-submission/object-model.json");
    returnedSubmission.setModel(validObjectModel);
    returnedSubmission.setSubmitted(true);
    returnedSubmission = performUpdateOnModelSubmission(objectExercise.getId(), returnedSubmission);
    database.checkModelingSubmissionCorrectlyStored(returnedSubmission.getId(), validObjectModel);
    checkDetailsHidden(returnedSubmission, true);
}
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 37 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 38 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 39 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project ArTEMiS by ls1intum.

the class ModelingSubmissionIntegrationTest method getModelSubmissionWithoutAssessment.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void getModelSubmissionWithoutAssessment() throws Exception {
    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", 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")));
    storedSubmission.setSubmissionDate(ZonedDateTime.ofInstant(storedSubmission.getSubmissionDate().truncatedTo(ChronoUnit.MILLIS).toInstant(), ZoneId.of("UTC")));
    assertThat(storedSubmission).as("submission was found").isEqualToIgnoringGivenFields(submission, "results");
    assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull();
    checkDetailsHidden(storedSubmission, false);
}
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 40 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project ArTEMiS by ls1intum.

the class ModelingSubmissionIntegrationTest method getModelSubmissionWithResult_involved_allowed.

@Test
@WithMockUser(username = "student1", roles = "USER")
public void getModelSubmissionWithResult_involved_allowed() throws Exception {
    ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
    submission = database.addModelingSubmission(classExercise, submission, "student1");
    PlagiarismComparison<ModelingSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
    PlagiarismSubmission<ModelingSubmissionElement> submissionA = new PlagiarismSubmission<>();
    submissionA.setStudentLogin("student1");
    submissionA.setSubmissionId(submission.getId());
    plagiarismComparison.setSubmissionA(submissionA);
    PlagiarismCase plagiarismCase = new PlagiarismCase();
    plagiarismCase = plagiarismCaseRepository.save(plagiarismCase);
    Post post = new Post();
    post.setAuthor(userRepo.getUserByLoginElseThrow("instructor1"));
    post.setTitle("Title Plagiarism Case Post");
    post.setContent("Content Plagiarism Case Post");
    post.setVisibleForStudents(true);
    post.setPlagiarismCase(plagiarismCase);
    postRepository.save(post);
    submissionA.setPlagiarismCase(plagiarismCase);
    plagiarismComparisonRepository.save(plagiarismComparison);
    var submissionResult = request.get("/api/modeling-submissions/" + submission.getId(), HttpStatus.OK, ModelingSubmission.class);
    assertThat(submissionResult.getParticipation()).as("Should anonymize participation").isNull();
    assertThat(submissionResult.getResults()).as("Should anonymize results").isEmpty();
    assertThat(submissionResult.getSubmissionDate()).as("Should anonymize submission date").isNull();
}
Also used : PlagiarismComparison(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison) PlagiarismCase(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismCase) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingSubmissionElement(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingSubmissionElement) PlagiarismSubmission(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission) Post(de.tum.in.www1.artemis.domain.metis.Post) 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