Search in sources :

Example 71 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class ProgrammingSubmissionIntegrationTest method triggerBuildStudent.

@Test
@WithMockUser(username = "student1", roles = "USER")
void triggerBuildStudent() throws Exception {
    bambooRequestMockProvider.enableMockingOfRequests();
    doReturn(COMMIT_HASH_OBJECT_ID).when(gitService).getLastCommitHash(any());
    String login = "student1";
    StudentParticipation participation = database.addStudentParticipationForProgrammingExercise(exercise, login);
    bambooRequestMockProvider.mockTriggerBuild((ProgrammingExerciseParticipation) participation);
    String url = "/api/programming-submissions/" + participation.getId() + "/trigger-build";
    request.postWithoutLocation(url, null, HttpStatus.OK, new HttpHeaders());
    List<ProgrammingSubmission> submissions = submissionRepository.findAll();
    assertThat(submissions).hasSize(1);
    ProgrammingSubmission submission = submissions.get(0);
    var optionalSubmission = submissionRepository.findWithEagerResultsById(submission.getId());
    assertThat(optionalSubmission).isPresent();
    assertThat(optionalSubmission.get().getLatestResult()).isNull();
    assertThat(submission.isSubmitted()).isTrue();
    assertThat(submission.getType()).isEqualTo(SubmissionType.MANUAL);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ProgrammingExerciseStudentParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 72 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class ProgrammingSubmissionIntegrationTest method triggerBuildInstructor.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
void triggerBuildInstructor() throws Exception {
    bambooRequestMockProvider.enableMockingOfRequests();
    doReturn(COMMIT_HASH_OBJECT_ID).when(gitService).getLastCommitHash(any());
    String login = "student1";
    StudentParticipation participation = database.addStudentParticipationForProgrammingExercise(exercise, login);
    bambooRequestMockProvider.mockTriggerBuild((ProgrammingExerciseParticipation) participation);
    bambooRequestMockProvider.mockTriggerBuild((ProgrammingExerciseParticipation) participation);
    request.postWithoutLocation("/api/programming-submissions/" + participation.getId() + "/trigger-build?submissionType=INSTRUCTOR", null, HttpStatus.OK, new HttpHeaders());
    List<ProgrammingSubmission> submissions = submissionRepository.findAll();
    assertThat(submissions).hasSize(1);
    ProgrammingSubmission submission = submissions.get(0);
    var optionalSubmission = submissionRepository.findWithEagerResultsById(submission.getId());
    assertThat(optionalSubmission).isPresent();
    assertThat(optionalSubmission.get().getLatestResult()).isNull();
    assertThat(submission.isSubmitted()).isTrue();
    assertThat(submission.getType()).isEqualTo(SubmissionType.INSTRUCTOR);
    // Trigger the call again and make sure that the submission shouldn't be recreated
    request.postWithoutLocation("/api/programming-submissions/" + participation.getId() + "/trigger-build?submissionType=INSTRUCTOR", null, HttpStatus.OK, new HttpHeaders());
    var updatedSubmissions = submissionRepository.findAll();
    assertThat(updatedSubmissions).hasSize(1);
    assertThat(updatedSubmissions.get(0).getId()).isEqualTo(submission.getId());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ProgrammingExerciseStudentParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 73 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class ProgrammingSubmissionIntegrationTest method triggerBuildInstructorTutorForbidden.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
void triggerBuildInstructorTutorForbidden() throws Exception {
    String login = "student1";
    StudentParticipation participation = database.addStudentParticipationForProgrammingExercise(exercise, login);
    String url = "/api/programming-submissions/" + participation.getId() + "/trigger-build?submissionType=INSTRUCTOR";
    request.postWithoutLocation(url, null, HttpStatus.FORBIDDEN, new HttpHeaders());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ProgrammingExerciseStudentParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 74 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class ProgrammingSubmissionIntegrationTest method triggerBuildInstructor_cannotGetLastCommitHash.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
void triggerBuildInstructor_cannotGetLastCommitHash() throws Exception {
    bambooRequestMockProvider.enableMockingOfRequests();
    doThrow(EntityNotFoundException.class).when(gitService).getLastCommitHash(any());
    String login = "student1";
    StudentParticipation participation = database.addStudentParticipationForProgrammingExercise(exercise, login);
    bambooRequestMockProvider.mockTriggerBuild((ProgrammingExerciseParticipation) participation);
    bambooRequestMockProvider.mockTriggerBuild((ProgrammingExerciseParticipation) participation);
    request.postWithoutLocation("/api/programming-submissions/" + participation.getId() + "/trigger-build?submissionType=INSTRUCTOR", null, HttpStatus.NOT_FOUND, new HttpHeaders());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ProgrammingExerciseStudentParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 75 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class AssessmentServiceTest method createFileUploadSubmissionAndCalculateScore.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createFileUploadSubmissionAndCalculateScore() {
    FileUploadExercise exercise = createFileuploadExerciseWithSGI(course1);
    Submission submissionWithoutResult = new FileUploadSubmission();
    submissionWithoutResult.setSubmissionDate(pastTimestamp.plusMinutes(3L));
    submissionWithoutResult = database.addSubmission(exercise, submissionWithoutResult, "student1");
    database.addSubmission((StudentParticipation) submissionWithoutResult.getParticipation(), submissionWithoutResult);
    List<Feedback> feedbacks = createFeedback(exercise);
    var result = new Result();
    result.setSubmission(submissionWithoutResult);
    result.setFeedbacks(feedbacks);
    result.setParticipation(submissionWithoutResult.getParticipation());
    submissionWithoutResult.addResult(result);
    resultRepository.submitResult(result, exercise, exerciseDateService.getDueDate(result.getParticipation()));
    resultRepository.save(result);
    assertThat(result.getResultString()).isEqualTo("6 of 7 points");
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)219 Test (org.junit.jupiter.api.Test)118 WithMockUser (org.springframework.security.test.context.support.WithMockUser)112 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)60 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)50 ProgrammingExerciseStudentParticipation (de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation)48 ZonedDateTime (java.time.ZonedDateTime)44 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)42 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)40 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)36 Exam (de.tum.in.www1.artemis.domain.exam.Exam)30 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)30 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)28 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)28 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)26 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)24 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)24 Participation (de.tum.in.www1.artemis.domain.participation.Participation)24 Collectors (java.util.stream.Collectors)24