Skip to content

Commit

Permalink
fix: architecture tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaancayli committed Nov 17, 2024
1 parent a3b5b2c commit a76ca2c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import jakarta.persistence.PreUpdate;
import jakarta.persistence.Table;

import javax.annotation.Nullable;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

Expand Down Expand Up @@ -67,7 +65,6 @@ public abstract class IrisEventSettings extends DomainObject {
private String selectedEventVariant;

// The session type of the event which type of session the event will be triggered in
@Nullable
@Enumerated(EnumType.STRING)
@Column(name = "session_type", nullable = false)
private IrisEventSessionType sessionType;
Expand Down Expand Up @@ -116,12 +113,11 @@ public void setAllowedEventVariants(SortedSet<String> allowedEventVariants) {
this.allowedEventVariants = allowedEventVariants;
}

@Nullable
public String getSelectedEventVariant() {
return selectedEventVariant;
}

public void setSelectedEventVariant(@Nullable String selectedVariant) {
public void setSelectedEventVariant(String selectedVariant) {
this.selectedEventVariant = selectedVariant;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ default ProgrammingExercise findOneByProjectKeyOrThrow(String projectKey, boolea
@EntityGraph(type = LOAD, attributePaths = { "templateParticipation", "solutionParticipation", "studentParticipations.team.students", "buildConfig" })
Optional<ProgrammingExercise> findWithAllParticipationsAndBuildConfigById(long exerciseId);

@EntityGraph(type = LOAD, attributePaths = { "templateParticipation", "solutionParticipation", "studentParticipations.team.students", "buildConfig" })
Optional<ProgrammingExercise> findWithAllParticipationsById(long exerciseId);

@Query("""
SELECT pe
FROM ProgrammingExercise pe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,14 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.test.context.support.WithMockUser;

import de.tum.cit.aet.artemis.assessment.domain.AssessmentType;
import de.tum.cit.aet.artemis.assessment.domain.Result;
import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService;
import de.tum.cit.aet.artemis.atlas.domain.competency.Competency;
import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyJol;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.exception.AccessForbiddenAlertException;
import de.tum.cit.aet.artemis.core.user.util.UserUtilService;
import de.tum.cit.aet.artemis.exercise.domain.Submission;
import de.tum.cit.aet.artemis.exercise.domain.SubmissionType;
import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory;
import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService;
import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository;
import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository;
import de.tum.cit.aet.artemis.iris.domain.settings.event.IrisJolEventSettings;
import de.tum.cit.aet.artemis.iris.repository.IrisSettingsRepository;
import de.tum.cit.aet.artemis.iris.service.pyris.PyrisEventService;
Expand All @@ -43,7 +38,6 @@
import de.tum.cit.aet.artemis.iris.service.session.IrisExerciseChatSessionService;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission;
import de.tum.cit.aet.artemis.programming.domain.ProjectType;
import de.tum.cit.aet.artemis.programming.domain.SolutionProgrammingExerciseParticipation;
import de.tum.cit.aet.artemis.programming.domain.TemplateProgrammingExerciseParticipation;
Expand All @@ -66,7 +60,7 @@ class PyrisEventSystemTest extends AbstractIrisIntegrationTest {
private ProgrammingExerciseUtilService programmingExerciseUtilService;

@Autowired
private SubmissionRepository submissionRepository;
private SubmissionTestRepository submissionRepository;

@Autowired
private PyrisEventService pyrisEventService;
Expand All @@ -80,12 +74,8 @@ class PyrisEventSystemTest extends AbstractIrisIntegrationTest {
@Autowired
private CompetencyUtilService competencyUtilService;

private ProgrammingExercise exercise;

private Course course;

private ProgrammingExerciseStudentParticipation studentParticipation;

private AtomicBoolean pipelineDone;

private Competency competency;
Expand All @@ -96,7 +86,7 @@ void initTestCase() throws GitAPIException, IOException, URISyntaxException {

course = programmingExerciseUtilService.addCourseWithOneProgrammingExercise();
competency = competencyUtilService.createCompetency(course);
exercise = exerciseUtilService.getFirstExerciseWithType(course, ProgrammingExercise.class);
ProgrammingExercise exercise = exerciseUtilService.getFirstExerciseWithType(course, ProgrammingExercise.class);
String projectKey = exercise.getProjectKey();
exercise.setProjectType(ProjectType.PLAIN_GRADLE);
exercise.setTestRepositoryUri(localVCBaseUrl + "/git/" + projectKey + "/" + projectKey.toLowerCase() + "-tests.git");
Expand All @@ -116,7 +106,7 @@ void initTestCase() throws GitAPIException, IOException, URISyntaxException {
String assignmentRepositorySlug = projectKey.toLowerCase() + "-" + TEST_PREFIX + "student1";

// Add a participation for student1.
studentParticipation = participationUtilService.addStudentParticipationForProgrammingExercise(exercise, TEST_PREFIX + "student1");
ProgrammingExerciseStudentParticipation studentParticipation = participationUtilService.addStudentParticipationForProgrammingExercise(exercise, TEST_PREFIX + "student1");
studentParticipation.setRepositoryUri(String.format(localVCBaseUrl + "/git/%s/%s.git", projectKey, assignmentRepositorySlug));
studentParticipation.setBranch(defaultBranch);

Expand All @@ -138,25 +128,6 @@ void initTestCase() throws GitAPIException, IOException, URISyntaxException {
pipelineDone = new AtomicBoolean(false);
}

private Result createSubmission(ProgrammingExerciseStudentParticipation studentParticipation, boolean successful) {
// Create a failing submission for the student.
Submission submission = new ProgrammingSubmission();

submission.setType(SubmissionType.MANUAL);
submission.setParticipation(studentParticipation);
submission = submissionRepository.saveAndFlush(submission);

Result result = ParticipationFactory.generateResult(true, successful ? 100 : 10);
result.setParticipation(studentParticipation);
result.setSubmission(submission);
result.completionDate(ZonedDateTime.now());
result.setAssessmentType(AssessmentType.AUTOMATIC);
submission.addResult(result);
submissionRepository.saveAndFlush(submission);

return resultRepository.save(result);
}

@Test
@WithMockUser(username = TEST_PREFIX + "student1", roles = "USER")
void testShouldFireJolEvent() {
Expand All @@ -168,7 +139,7 @@ void testShouldFireJolEvent() {
});
competencyJolService.setJudgementOfLearning(competency.getId(), userUtilService.getUserByLogin(TEST_PREFIX + "student1").getId(), (short) jolValue);

await().atMost(2, TimeUnit.SECONDS).until(() -> pipelineDone.get());
await().atMost(3, TimeUnit.SECONDS).until(() -> pipelineDone.get());

verify(irisCourseChatSessionService, times(1)).onJudgementOfLearningSet(any(CompetencyJol.class));
verify(pyrisPipelineService, times(1)).executeCourseChatPipeline(eq("jol"), eq(irisSession), any(CompetencyJol.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,7 @@ default ProgrammingExercise getProgrammingExerciseWithBuildConfigElseThrow(Progr
}
return programmingExercise;
}

@EntityGraph(type = LOAD, attributePaths = { "templateParticipation", "solutionParticipation", "studentParticipations.team.students", "buildConfig" })
Optional<ProgrammingExercise> findWithAllParticipationsById(long exerciseId);
}

0 comments on commit a76ca2c

Please sign in to comment.