Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated code lifecycle: Add editing of auxiliary repositories for instructors #9585

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

SimonEntholzer
Copy link
Contributor

@SimonEntholzer SimonEntholzer commented Oct 24, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).

Motivation and Context

Instructors can edit Template, Assignment, Solution and Test repositories in Artemis, by using the "edit in editor" view.
This is not yet possible for auxiliary repositories.

Description

This PR adds support for auxiliary repositories in the edit in editor view.
Also fixes a small UI bug, where the text on the drop-down button was not readable, when not hovering.

Steps for Testing

  1. Create a programming exercise with one or more auxiliary repositories
  2. In the exercise details page, open the "edit in editor" view
  3. In the drop-down, select the previously created auxiliary repositories.
  4. Add/Delete/Change files and folders, and submit.
  5. Go back to the details view, clone the auxiliary repositories and check that the created content is there.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Screenshots

image
image

small Bugfix:
image
vs.
image

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced repository selection in the code editor to include auxiliary repositories.
    • New route for accessing auxiliary repositories with appropriate access control.
  • Bug Fixes

    • Improved data retrieval for programming exercises, ensuring auxiliary repositories are included.
  • Style

    • Updated button styles for better visibility of selected auxiliary repositories.
  • Chores

    • Refined component structure to better manage auxiliary repository selections.
    • Updated tests to validate new functionality related to auxiliary repositories.

@SimonEntholzer SimonEntholzer requested a review from a team as a code owner October 24, 2024 19:23
@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) programming Pull requests that affect the corresponding module labels Oct 24, 2024
Copy link

coderabbitai bot commented Oct 24, 2024

Walkthrough

The pull request introduces enhancements to the ProgrammingExerciseRepository and related components to support auxiliary repositories in a programming exercise context. The method findByIdWithTemplateAndSolutionParticipationLatestResultFeedbackTestCasesElseThrow is updated to include auxiliary repositories in its data retrieval. The HTML and TypeScript files for the code editor component are modified to allow selection of auxiliary repositories, including new properties and methods for managing these repositories. A new route is added to facilitate navigation to auxiliary repositories, ensuring comprehensive integration within the existing framework.

Changes

File Change Summary
src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java Updated findByIdWithTemplateAndSolutionParticipationLatestResultFeedbackTestCasesElseThrow to findByIdWithTemplateAndSolutionParticipationAndAuxiliaryReposAndLatestResultFeedbackTestCasesElseThrow, enhancing data retrieval to include auxiliary repositories.
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.html Enhanced repository selection dropdown to include auxiliary repositories with dynamic button generation.
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.ts Added styleUrl property to component decorator; no other logic changes.
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.scss Added CSS rule for .btn-outline-primary elements in a dropdown state.
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-base-container.component.ts Added AUXILIARY enum value, properties for selected auxiliary repository, and methods for managing repository selection.
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-management-routing.module.ts Added new route for auxiliary repositories with appropriate access control.
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java Updated getProgrammingExerciseWithSetupParticipations to use the new method for fetching exercises, including auxiliary repositories.
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitIntegrationTest.java Updated test assertions to reflect changes in repository method signatures related to auxiliary repositories.
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGradingServiceTest.java Updated method signatures in tests to include auxiliary repositories in the repository fetch process.

Possibly related PRs

Suggested labels

exercise, documentation

Suggested reviewers

  • JohannesStoehr
  • Hialus
  • BBesrour

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (3)
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.html (1)

84-97: Consider adding translations and improving disabled state feedback.

The implementation is solid and follows the new Angular syntax guidelines correctly. However, there are two potential improvements:

  1. Add translation support for consistency with other repository buttons
  2. Enhance the disabled state feedback

Apply these changes to improve the implementation:

 @for (auxiliaryRepository of exercise.auxiliaryRepositories; track exercise.auxiliaryRepositories; let i = $index) {
     @if (auxiliaryRepository.id) {
         <button
-            [disabled]="!exercise"
+            [disabled]="!exercise || !auxiliaryRepository.repositoryUrl"
             (click)="selectAuxiliaryRepository(auxiliaryRepository.id)"
             ngbDropdownItem
             [style.background-color]="
                 selectedRepository === REPOSITORY.AUXILIARY && selectedRepositoryId === auxiliaryRepository.id ? '#3e8acc' : 'transparent'
             "
         >
-            {{ auxiliaryRepository.name }}
+            <span [jhiTranslate]="'artemisApp.editor.repoSelect.auxiliaryRepo'" [translateValues]="{ name: auxiliaryRepository.name }"></span>
         </button>
     }
 }

Add this translation key to your i18n files:

{
  "artemisApp.editor.repoSelect.auxiliaryRepo": "Auxiliary Repository: {{name}}"
}
src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (1)

779-782: LGTM, but consider refactoring the "dark hack".

The changes correctly integrate auxiliary repositories into the data retrieval. However, as noted in the TODO comment, this method uses a hack to load participations separately.

Consider refactoring this into a service layer that properly handles the data loading in a more maintainable way:

-        ProgrammingExercise programmingExerciseWithAuxiliaryRepositories = findByIdWithAuxiliaryRepositoriesElseThrow(programmingExerciseId);
-
-        programmingExerciseWithTemplate.setAuxiliaryRepositories(programmingExerciseWithAuxiliaryRepositories.getAuxiliaryRepositories());
+        // Move to ProgrammingExerciseService
+        @Transactional(readOnly = true)
+        public ProgrammingExercise getProgrammingExerciseWithAllParticipations(Long exerciseId) {
+            ProgrammingExercise exercise = programmingExerciseRepository
+                .findWithTemplateParticipationLatestResultFeedbackTestCasesById(exerciseId)
+                .orElseThrow(() -> new EntityNotFoundException("Programming exercise not found"));
+            
+            // Load solution participation and auxiliary repositories in a single query
+            ProgrammingExercise exerciseWithSolutionAndAuxRepos = programmingExerciseRepository
+                .findWithSolutionParticipationAndAuxiliaryRepositoriesById(exerciseId)
+                .orElseThrow(() -> new EntityNotFoundException("Programming exercise not found"));
+            
+            exercise.setSolutionParticipation(exerciseWithSolutionAndAuxRepos.getSolutionParticipation());
+            exercise.setAuxiliaryRepositories(exerciseWithSolutionAndAuxRepos.getAuxiliaryRepositories());
+            
+            return exercise;
+        }
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-base-container.component.ts (1)

31-31: Consider using PascalCase for enum members

The REPOSITORY enum uses uppercase naming for its members. According to the coding guidelines, enums should use PascalCase. Renaming the enum members to PascalCase will improve consistency.

Apply this diff to update the enum member names:

 export enum REPOSITORY {
-    ASSIGNMENT = 'ASSIGNMENT',
-    TEMPLATE = 'TEMPLATE',
-    SOLUTION = 'SOLUTION',
-    TEST = 'TEST',
-    AUXILIARY = 'AUXILIARY',
+    Assignment = 'ASSIGNMENT',
+    Template = 'TEMPLATE',
+    Solution = 'SOLUTION',
+    Test = 'TEST',
+    Auxiliary = 'AUXILIARY',
 }

Ensure to update all references to these enum members throughout the codebase to reflect the changes.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between caea966 and a18bae2.

📒 Files selected for processing (6)
  • src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.html (2 hunks)
  • src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.ts (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.scss (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-base-container.component.ts (6 hunks)
  • src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-management-routing.module.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.scss
🧰 Additional context used
📓 Path-based instructions (5)
src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-base-container.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-management-routing.module.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

🔇 Additional comments (5)
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.ts (2)

20-20: LGTM! The styleUrl addition follows Angular best practices.

The addition of the styleUrl property follows Angular's component styling best practices and adheres to the coding guidelines.


Line range hint 1-50: Verify auxiliary repository handling implementation.

Given that this PR's main objective is to add support for auxiliary repositories editing, we should verify that this functionality is properly implemented, either in this component or its parent class.

Let's verify the implementation:

✅ Verification successful

Let me gather more information about the auxiliary repository implementation by checking the base component and related files:


Based on the comprehensive evidence from the shell script outputs, I can now provide the final response:

Auxiliary repository support is properly implemented in this component and its parent class

The implementation includes:

  • Proper routing setup for auxiliary repositories via auxiliary/:repositoryId path
  • Complete UI integration in the repository dropdown menu
  • Full handling in the base component including:
    • Repository selection logic
    • Domain change management
    • Navigation methods
    • State management for auxiliary repositories
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for auxiliary repository handling in the base component and related files

# Check base component implementation
echo "Checking base component for auxiliary repository handling..."
rg -A 5 "auxiliary.*repository" "src/main/webapp/app/exercises/programming/manage/code-editor/"

# Check for route configuration
echo "Checking route configuration for auxiliary repository..."
rg -A 5 "auxiliary/:repositoryId" "src/main/webapp/app/exercises/programming/"

# Check for related service methods
echo "Checking service implementations..."
ast-grep --pattern 'class $_ {
  $$$
  auxiliary$_($$$) {
    $$$
  }
  $$$
}'

Length of output: 5135


Script:

#!/bin/bash
# Check the base component implementation
echo "Checking CodeEditorInstructorBaseContainerComponent..."
cat src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-base-container.component.ts

# Check for auxiliary repository related models and interfaces
echo -e "\nChecking for auxiliary repository models..."
rg -l "auxiliaryRepositories?" src/main/webapp/app/exercises/programming/

# Check for auxiliary repository related template
echo -e "\nChecking template for auxiliary repository UI..."
cat src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.html

Length of output: 28924

src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-management-routing.module.ts (1)

57-68: LGTM! Route configuration follows established patterns.

The new route for auxiliary repositories maintains consistency with existing routes in terms of:

  • Authorization controls
  • Cache configuration
  • Component reuse
  • Data structure
src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.html (1)

40-42: LGTM: Repository selection button implementation is clean and functional.

The button text dynamically updates to show either the auxiliary repository name or the selected repository type, providing clear visual feedback to users.

src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-base-container.component.ts (1)

68-69: Properties are correctly named using camelCase

The new properties selectedRepositoryId and selectedAuxiliaryRepositoryName follow the camelCase naming convention, adhering to the coding guidelines.

…ode-editor-instructor-base-container.component.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 24, 2024
sachmii
sachmii previously approved these changes Oct 24, 2024
Copy link

@sachmii sachmii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS4, after adding files and folders to the auxiliary repository and cloning it, they also appeared locally. Worked just fine.

Bildschirmfoto 2024-10-24 um 22 41 35 Bildschirmfoto 2024-10-24 um 22 41 41

Copy link

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test3.artemis.cit.tum.de" is already in use by PR #9565.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Oct 25, 2024
@github-actions github-actions bot added the tests label Oct 25, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitIntegrationTest.java (1)

Line range hint 73-119: Consider splitting testRepositoryMethods into separate test methods.

The current test method contains multiple assertions testing different repository methods. To improve test specificity and maintainability, consider splitting it into separate test methods, each focusing on a specific repository method. This aligns with the test size and specificity guidelines.

Here's a suggested refactor:

-    @Test
-    @WithMockUser(username = TEST_PREFIX + "student3")
-    void testRepositoryMethods() {
-        assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> programmingExerciseRepository.findByIdElseThrow(Long.MAX_VALUE));
-
-        assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> programmingExerciseRepository.findByIdWithAuxiliaryRepositoriesElseThrow(Long.MAX_VALUE));
-
-        assertThatExceptionOfType(EntityNotFoundException.class)
-                .isThrownBy(() -> programmingExerciseRepository.findByIdWithStudentParticipationsAndLegalSubmissionsElseThrow(Long.MAX_VALUE));
-
-        assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> programmingExerciseRepository.findByIdWithSubmissionPolicyElseThrow(Long.MAX_VALUE));
-
-        assertThatExceptionOfType(EntityNotFoundException.class)
-                .isThrownBy(() -> programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationElseThrow(Long.MAX_VALUE));
-
-        assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(
-                () -> programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationAndAuxiliaryReposAndLatestResultFeedbackTestCasesElseThrow(Long.MAX_VALUE));
-
-        assertThatExceptionOfType(EntityNotFoundException.class)
-                .isThrownBy(() -> programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationTeamAssignmentConfigCategoriesElseThrow(Long.MAX_VALUE));
-    }
+    @Test
+    @WithMockUser(username = TEST_PREFIX + "student3")
+    void shouldThrowEntityNotFoundExceptionWhenFindingNonExistentExerciseById() {
+        assertThatExceptionOfType(EntityNotFoundException.class)
+            .isThrownBy(() -> programmingExerciseRepository.findByIdElseThrow(Long.MAX_VALUE));
+    }
+
+    @Test
+    @WithMockUser(username = TEST_PREFIX + "student3")
+    void shouldThrowEntityNotFoundExceptionWhenFindingNonExistentExerciseWithAuxiliaryRepositories() {
+        assertThatExceptionOfType(EntityNotFoundException.class)
+            .isThrownBy(() -> programmingExerciseRepository.findByIdWithAuxiliaryRepositoriesElseThrow(Long.MAX_VALUE));
+    }
+
+    @Test
+    @WithMockUser(username = TEST_PREFIX + "student3")
+    void shouldThrowEntityNotFoundExceptionWhenFindingNonExistentExerciseWithStudentParticipations() {
+        assertThatExceptionOfType(EntityNotFoundException.class)
+            .isThrownBy(() -> programmingExerciseRepository.findByIdWithStudentParticipationsAndLegalSubmissionsElseThrow(Long.MAX_VALUE));
+    }
+
+    @Test
+    @WithMockUser(username = TEST_PREFIX + "student3")
+    void shouldThrowEntityNotFoundExceptionWhenFindingNonExistentExerciseWithSubmissionPolicy() {
+        assertThatExceptionOfType(EntityNotFoundException.class)
+            .isThrownBy(() -> programmingExerciseRepository.findByIdWithSubmissionPolicyElseThrow(Long.MAX_VALUE));
+    }
+
+    @Test
+    @WithMockUser(username = TEST_PREFIX + "student3")
+    void shouldThrowEntityNotFoundExceptionWhenFindingNonExistentExerciseWithTemplateAndSolutionParticipation() {
+        assertThatExceptionOfType(EntityNotFoundException.class)
+            .isThrownBy(() -> programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationElseThrow(Long.MAX_VALUE));
+    }
+
+    @Test
+    @WithMockUser(username = TEST_PREFIX + "student3")
+    void shouldThrowEntityNotFoundExceptionWhenFindingNonExistentExerciseWithTemplateAndSolutionParticipationAndAuxiliaryRepos() {
+        assertThatExceptionOfType(EntityNotFoundException.class)
+            .isThrownBy(() -> programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationAndAuxiliaryReposAndLatestResultFeedbackTestCasesElseThrow(Long.MAX_VALUE));
+    }
+
+    @Test
+    @WithMockUser(username = TEST_PREFIX + "student3")
+    void shouldThrowEntityNotFoundExceptionWhenFindingNonExistentExerciseWithTemplateAndSolutionParticipationTeamAssignment() {
+        assertThatExceptionOfType(EntityNotFoundException.class)
+            .isThrownBy(() -> programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationTeamAssignmentConfigCategoriesElseThrow(Long.MAX_VALUE));
+    }

Benefits of this refactor:

  1. Each test method has a clear, specific purpose
  2. Test failures are easier to diagnose
  3. Test names clearly describe the expected behavior
  4. Follows the test size and specificity guidelines
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 42ad8a3 and 365fe3f.

📒 Files selected for processing (5)
  • src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1 hunks)
  • src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.html (4 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGradingServiceTest.java (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/app/exercises/programming/manage/code-editor/code-editor-instructor-and-editor-container.component.html
🧰 Additional context used
📓 Path-based instructions (4)
src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGradingServiceTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

📓 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (3)
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-06-15T20:04:18.637Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-10-08T15:35:42.972Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
Learnt from: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-10-08T15:35:48.767Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
🔇 Additional comments (4)
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitIntegrationTest.java (1)

116-117: LGTM! The assertion correctly tests the new repository method.

The updated assertion properly verifies that the new repository method findByIdWithTemplateAndSolutionParticipationAndAuxiliaryReposAndLatestResultFeedbackTestCasesElseThrow throws an EntityNotFoundException when the entity is not found.

src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (2)

773-774: LGTM: Method name accurately reflects the new functionality.

The method name has been updated to include "AndAuxiliaryRepos" which clearly indicates its enhanced capability to fetch auxiliary repositories.


780-783: Consider optimizing the database queries.

The current implementation makes multiple separate database calls which could impact performance:

  1. One for template participation
  2. One for solution participation
  3. One for auxiliary repositories

Consider refactoring this to use a single optimized query that fetches all required data at once.

Let's analyze the query patterns:

src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1)

509-509: LGTM! Method name updated to include auxiliary repositories.

The change correctly updates the repository method call to include auxiliary repositories in the response, which aligns with the PR's objective to support auxiliary repository editing in the "edit in editor" view.

Let's verify that this is the only occurrence of the old method name that needed to be updated:

✅ Verification successful

Method name correctly updated to include auxiliary repositories

The change is correct and consistent with the codebase. The repository interface shows that this is a new method name that aligns with the PR's objective to support auxiliary repositories in the "edit in editor" view. The old method name does not exist anywhere in the codebase, indicating this is a clean update.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining occurrences of the old method name
# Test: Expect no matches as all occurrences should have been updated

rg "findByIdWithTemplateAndSolutionParticipationLatestResultFeedbackTestCasesElseThrow"

Length of output: 87


Script:

#!/bin/bash
# Let's verify both the interface definition and implementation
# 1. Search for the repository interface
fd "ProgrammingExerciseRepository" --type f

# 2. After finding the repository, let's check its content
ast-grep --pattern 'interface ProgrammingExerciseRepository {
  $$$
  findByIdWithTemplate$$$ElseThrow($$$) {
    $$$
  }
  $$$
}'

# 3. Let's also check for any test files that might use this method
fd "ProgrammingExerciseResource.*Test" --type f

# 4. Let's verify the implementation class if it exists
fd "ProgrammingExerciseRepositoryImpl" --type f

Length of output: 687


Script:

#!/bin/bash
# Let's check the repository interface content directly using cat
cat src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java

# Also check the service class that might use this method
cat src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseRepositoryService.java

# And the test file
cat src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseRepositoryServiceTest.java

Length of output: 117312

Copy link

@HawKhiem HawKhiem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS3. Works as described!

Screenshot 2024-10-25 184722
Screenshot 2024-10-25 184744
Screenshot 2024-10-25 184801
Screenshot 2024-10-25 184810

Copy link

@Feras797 Feras797 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS3, the auxiliary repositories work as described.
image

Copy link

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test2.artemis.cit.tum.de" is already in use by PR #9265.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Oct 25, 2024
@sachmii sachmii added deploy:artemis-test3 and removed deployment-error Added by deployment workflows if an error occured labels Oct 25, 2024
@sachmii sachmii temporarily deployed to artemis-test3.artemis.cit.tum.de October 25, 2024 22:16 — with GitHub Actions Inactive
Copy link

@sachmii sachmii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS4, still works fine. Re-approve

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 365fe3f and d9124e1.

📒 Files selected for processing (2)
  • src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseResource.java
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (1)

791-792: Method name change looks good.

The method name now accurately reflects that it includes auxiliary repositories in the fetched data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) programming Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

5 participants