Search in sources :

Example 1 with ResultService

use of de.tum.in.www1.artemis.service.ResultService in project ArTEMiS by ls1intum.

the class ResultServiceTest method reset.

@BeforeEach
public void reset() {
    database.addUsers(2, 1, 1, 1);
    Course course = database.addCourseWithOneProgrammingExercise();
    this.programmingExercise = (ProgrammingExercise) course.getExercises().stream().filter(exercise -> exercise instanceof ProgrammingExercise).findAny().orElseThrow();
    // This is done to avoid proxy issues in the processNewResult method of the ResultService.
    this.programmingExerciseStudentParticipation = database.addStudentParticipationForProgrammingExercise(this.programmingExercise, "student1");
    ProgrammingExercise examProgrammingExercise = database.addCourseExamExerciseGroupWithOneProgrammingExercise();
    this.examStudentParticipation = database.addStudentParticipationForProgrammingExercise(examProgrammingExercise, "student1");
}
Also used : ProgrammingExercise(de.tum.in.www1.artemis.domain.ProgrammingExercise) Course(de.tum.in.www1.artemis.domain.Course) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ResultService

use of de.tum.in.www1.artemis.service.ResultService in project ArTEMiS by ls1intum.

the class ResultServiceIntegrationTest method reset.

@BeforeEach
public void reset() {
    database.addUsers(10, 2, 0, 2);
    course = database.addCourseWithOneProgrammingExercise();
    programmingExercise = (ProgrammingExercise) course.getExercises().stream().filter(exercise -> exercise instanceof ProgrammingExercise).findAny().orElseThrow();
    ProgrammingExercise programmingExerciseWithStaticCodeAnalysis = database.addProgrammingExerciseToCourse(course, true);
    // This is done to avoid proxy issues in the processNewResult method of the ResultService.
    solutionParticipation = solutionProgrammingExerciseRepository.findWithEagerResultsAndSubmissionsByProgrammingExerciseId(programmingExercise.getId()).get();
    programmingExerciseStudentParticipation = database.addStudentParticipationForProgrammingExercise(programmingExercise, "student1");
    database.addStudentParticipationForProgrammingExercise(programmingExerciseWithStaticCodeAnalysis, "student1");
    database.addCourseWithOneModelingExercise();
    modelingExercise = modelingExerciseRepository.findAll().get(0);
    modelingExercise.setDueDate(ZonedDateTime.now().minusHours(1));
    modelingExerciseRepository.save(modelingExercise);
    studentParticipation = database.createAndSaveParticipationForExercise(modelingExercise, "student2");
    Exam exam = database.addExamWithExerciseGroup(this.course, true);
    this.examModelingExercise = new ModelingExercise();
    this.examModelingExercise.setMaxPoints(100D);
    this.examModelingExercise.setExerciseGroup(exam.getExerciseGroups().get(0));
    this.modelingExerciseRepository.save(this.examModelingExercise);
    this.examRepository.save(exam);
    Result result = ModelFactory.generateResult(true, 200D).resultString("Good effort!").participation(programmingExerciseStudentParticipation);
    List<Feedback> feedbacks = ModelFactory.generateFeedback().stream().peek(feedback -> feedback.setText("Good work here")).collect(Collectors.toList());
    result.setFeedbacks(feedbacks);
    result.setAssessmentType(AssessmentType.SEMI_AUTOMATIC);
    String dummyHash = "9b3a9bd71a0d80e5bbc42204c319ed3d1d4f0d6d";
    doReturn(ObjectId.fromString(dummyHash)).when(gitService).getLastCommitHash(ArgumentMatchers.any());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers(org.mockito.ArgumentMatchers) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) EnumSource(org.junit.jupiter.params.provider.EnumSource) VersionControlRepositoryPermission(de.tum.in.www1.artemis.service.connectors.VersionControlRepositoryPermission) ArrayList(java.util.ArrayList) ProgrammingExerciseStudentParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation) JSONObject(org.json.JSONObject) Map(java.util.Map) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelFactory(de.tum.in.www1.artemis.util.ModelFactory) Mockito.doReturn(org.mockito.Mockito.doReturn) Exam(de.tum.in.www1.artemis.domain.exam.Exam) ResultWithPointsPerGradingCriterionDTO(de.tum.in.www1.artemis.web.rest.dto.ResultWithPointsPerGradingCriterionDTO) SolutionProgrammingExerciseParticipation(de.tum.in.www1.artemis.domain.participation.SolutionProgrammingExerciseParticipation) MethodSource(org.junit.jupiter.params.provider.MethodSource) QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) QuizSubmission(de.tum.in.www1.artemis.domain.quiz.QuizSubmission) Set(java.util.Set) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) Constants(de.tum.in.www1.artemis.config.Constants) ObjectId(org.eclipse.jgit.lib.ObjectId) Test(org.junit.jupiter.api.Test) HttpStatus(org.springframework.http.HttpStatus) EntityNotFoundException(de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) WithMockUser(org.springframework.security.test.context.support.WithMockUser) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) de.tum.in.www1.artemis.domain.enumeration(de.tum.in.www1.artemis.domain.enumeration) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) Exam(de.tum.in.www1.artemis.domain.exam.Exam) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ResultService

use of de.tum.in.www1.artemis.service.ResultService in project Artemis by ls1intum.

the class ResultServiceIntegrationTest method reset.

@BeforeEach
public void reset() {
    database.addUsers(10, 2, 0, 2);
    course = database.addCourseWithOneProgrammingExercise();
    programmingExercise = (ProgrammingExercise) course.getExercises().stream().filter(exercise -> exercise instanceof ProgrammingExercise).findAny().orElseThrow();
    ProgrammingExercise programmingExerciseWithStaticCodeAnalysis = database.addProgrammingExerciseToCourse(course, true);
    // This is done to avoid proxy issues in the processNewResult method of the ResultService.
    solutionParticipation = solutionProgrammingExerciseRepository.findWithEagerResultsAndSubmissionsByProgrammingExerciseId(programmingExercise.getId()).get();
    programmingExerciseStudentParticipation = database.addStudentParticipationForProgrammingExercise(programmingExercise, "student1");
    database.addStudentParticipationForProgrammingExercise(programmingExerciseWithStaticCodeAnalysis, "student1");
    database.addCourseWithOneModelingExercise();
    modelingExercise = modelingExerciseRepository.findAll().get(0);
    modelingExercise.setDueDate(ZonedDateTime.now().minusHours(1));
    modelingExerciseRepository.save(modelingExercise);
    studentParticipation = database.createAndSaveParticipationForExercise(modelingExercise, "student2");
    Exam exam = database.addExamWithExerciseGroup(this.course, true);
    this.examModelingExercise = new ModelingExercise();
    this.examModelingExercise.setMaxPoints(100D);
    this.examModelingExercise.setExerciseGroup(exam.getExerciseGroups().get(0));
    this.modelingExerciseRepository.save(this.examModelingExercise);
    this.examRepository.save(exam);
    Result result = ModelFactory.generateResult(true, 200D).resultString("Good effort!").participation(programmingExerciseStudentParticipation);
    List<Feedback> feedbacks = ModelFactory.generateFeedback().stream().peek(feedback -> feedback.setText("Good work here")).collect(Collectors.toList());
    result.setFeedbacks(feedbacks);
    result.setAssessmentType(AssessmentType.SEMI_AUTOMATIC);
    String dummyHash = "9b3a9bd71a0d80e5bbc42204c319ed3d1d4f0d6d";
    doReturn(ObjectId.fromString(dummyHash)).when(gitService).getLastCommitHash(ArgumentMatchers.any());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers(org.mockito.ArgumentMatchers) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) EnumSource(org.junit.jupiter.params.provider.EnumSource) VersionControlRepositoryPermission(de.tum.in.www1.artemis.service.connectors.VersionControlRepositoryPermission) ArrayList(java.util.ArrayList) ProgrammingExerciseStudentParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation) JSONObject(org.json.JSONObject) Map(java.util.Map) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelFactory(de.tum.in.www1.artemis.util.ModelFactory) Mockito.doReturn(org.mockito.Mockito.doReturn) Exam(de.tum.in.www1.artemis.domain.exam.Exam) ResultWithPointsPerGradingCriterionDTO(de.tum.in.www1.artemis.web.rest.dto.ResultWithPointsPerGradingCriterionDTO) SolutionProgrammingExerciseParticipation(de.tum.in.www1.artemis.domain.participation.SolutionProgrammingExerciseParticipation) MethodSource(org.junit.jupiter.params.provider.MethodSource) QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) QuizSubmission(de.tum.in.www1.artemis.domain.quiz.QuizSubmission) Set(java.util.Set) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) Constants(de.tum.in.www1.artemis.config.Constants) ObjectId(org.eclipse.jgit.lib.ObjectId) Test(org.junit.jupiter.api.Test) HttpStatus(org.springframework.http.HttpStatus) EntityNotFoundException(de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) WithMockUser(org.springframework.security.test.context.support.WithMockUser) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) de.tum.in.www1.artemis.domain.enumeration(de.tum.in.www1.artemis.domain.enumeration) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) Exam(de.tum.in.www1.artemis.domain.exam.Exam) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ResultService

use of de.tum.in.www1.artemis.service.ResultService in project Artemis by ls1intum.

the class ResultServiceTest method reset.

@BeforeEach
public void reset() {
    database.addUsers(2, 1, 1, 1);
    Course course = database.addCourseWithOneProgrammingExercise();
    this.programmingExercise = (ProgrammingExercise) course.getExercises().stream().filter(exercise -> exercise instanceof ProgrammingExercise).findAny().orElseThrow();
    // This is done to avoid proxy issues in the processNewResult method of the ResultService.
    this.programmingExerciseStudentParticipation = database.addStudentParticipationForProgrammingExercise(this.programmingExercise, "student1");
    ProgrammingExercise examProgrammingExercise = database.addCourseExamExerciseGroupWithOneProgrammingExercise();
    this.examStudentParticipation = database.addStudentParticipationForProgrammingExercise(examProgrammingExercise, "student1");
}
Also used : ProgrammingExercise(de.tum.in.www1.artemis.domain.ProgrammingExercise) Course(de.tum.in.www1.artemis.domain.Course) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BeforeEach (org.junit.jupiter.api.BeforeEach)4 Constants (de.tum.in.www1.artemis.config.Constants)2 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)2 Course (de.tum.in.www1.artemis.domain.Course)2 ProgrammingExercise (de.tum.in.www1.artemis.domain.ProgrammingExercise)2 de.tum.in.www1.artemis.domain.enumeration (de.tum.in.www1.artemis.domain.enumeration)2 Exam (de.tum.in.www1.artemis.domain.exam.Exam)2 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)2 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)2 ProgrammingExerciseStudentParticipation (de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation)2 SolutionProgrammingExerciseParticipation (de.tum.in.www1.artemis.domain.participation.SolutionProgrammingExerciseParticipation)2 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)2 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)2 QuizSubmission (de.tum.in.www1.artemis.domain.quiz.QuizSubmission)2 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)2 VersionControlRepositoryPermission (de.tum.in.www1.artemis.service.connectors.VersionControlRepositoryPermission)2 ModelFactory (de.tum.in.www1.artemis.util.ModelFactory)2 ResultWithPointsPerGradingCriterionDTO (de.tum.in.www1.artemis.web.rest.dto.ResultWithPointsPerGradingCriterionDTO)2 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)2 ZonedDateTime (java.time.ZonedDateTime)2