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);
}
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());
}
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());
}
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());
}
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");
}
Aggregations