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

Development: Reactivate auxiliary repository integration tests for LocalVC #9763

Merged

Conversation

SimonEntholzer
Copy link
Contributor

@SimonEntholzer SimonEntholzer commented Nov 12, 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 documented the Java code using JavaDoc style.

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).
  • I tested all changes and their related features with all corresponding user types on a test server configured with Gitlab and Jenkins.

Motivation and Context

Description

Steps for Testing

  1. Make sure the server tests pass.

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

Test Coverage

Screenshots

Summary by CodeRabbit

  • New Features

    • Introduced a new integration test suite for programming exercises with local version control and continuous integration.
    • Added methods to enhance testing capabilities for programming exercises, including participant identifier handling and online code editor validation.
  • Bug Fixes

    • Improved error handling for auxiliary repository validation and updated expected response statuses.
  • Documentation

    • Enhanced test coverage documentation for programming exercise functionalities and user role simulations.

…ks auxiliary repo tests. Added mock to the _1_ test which actually needs it
@SimonEntholzer SimonEntholzer requested a review from a team as a code owner November 12, 2024 14:19
@github-actions github-actions bot added tests programming Pull requests that affect the corresponding module labels Nov 12, 2024
Copy link

coderabbitai bot commented Nov 12, 2024

Walkthrough

The changes in this pull request introduce enhancements to integration testing for programming exercises. A new field is added to the AbstractProgrammingIntegrationLocalCILocalVCTest class, and multiple test methods are added to the ProgrammingExerciseIntegrationJenkinsGitlabTest class to improve coverage of participant identifiers and online code editor scenarios. Additionally, the ProgrammingExerciseIntegrationTestService class is modified to refine repository handling and validation processes. A new integration test class, ProgrammingExerciseLocalVCIntegrationTest, is also introduced to cover various scenarios related to local version control.

Changes

File Change Summary
src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationLocalCILocalVCTest.java Added field protected ProgrammingExerciseIntegrationTestService programmingExerciseIntegrationTestService; annotated with @Autowired.
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java Added three test methods: testExportSubmissionsByParticipationIds_addParticipantIdentifierToProjectNameError, testExportSubmissionsByParticipationIds_addParticipantIdentifierToProjectName, and createProgrammingExercise_onlineCodeEditorNotExpected_badRequest.
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationTestService.java Modified multiple methods for repository handling and validation, added method testReEvaluateAndUpdateProgrammingExercise_instructorNotInCourse_forbidden, and updated method signatures for better clarity and RESTful practices.
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseLocalVCIntegrationTest.java Added new class ProgrammingExerciseLocalVCIntegrationTest with a suite of integration tests for ProgrammingExerciseIntegrationTestService, covering various scenarios related to auxiliary repositories and user roles.

Possibly related PRs

Suggested labels

server

Suggested reviewers

  • JohannesStoehr
  • MaximilianAnzinger
  • BBesrour
  • coolchock
  • krusche

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 pmd
src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationLocalCILocalVCTest.java

The following rules are missing or misspelled in your ruleset file category/vm/bestpractices.xml: BooleanInstantiation, DontImportJavaLang, DuplicateImports, EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptyStatementNotInLoop, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveMethodLength, ImportFromSamePackage, MissingBreakInSwitch, SimplifyBooleanAssertion. Please check your ruleset configuration.

src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java

The following rules are missing or misspelled in your ruleset file category/vm/bestpractices.xml: BooleanInstantiation, DontImportJavaLang, DuplicateImports, EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptyStatementNotInLoop, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveMethodLength, ImportFromSamePackage, MissingBreakInSwitch, SimplifyBooleanAssertion. Please check your ruleset configuration.

src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationTestService.java

The following rules are missing or misspelled in your ruleset file category/vm/bestpractices.xml: BooleanInstantiation, DontImportJavaLang, DuplicateImports, EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptyStatementNotInLoop, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveMethodLength, ImportFromSamePackage, MissingBreakInSwitch, SimplifyBooleanAssertion. Please check your ruleset configuration.

  • 1 others

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: 6

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

112-159: Improve test organization with JUnit 5 nested classes.

Consider grouping related tests using @Nested classes for better organization and readability.

Example refactoring:

+    @Nested
+    @DisplayName("Auxiliary Repository Retrieval Tests")
+    class AuxiliaryRepositoryRetrievalTests {
         @Test
         @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
         void testGetAuxiliaryRepositoriesMissingExercise() throws Exception {
             programmingExerciseIntegrationTestService.testGetAuxiliaryRepositoriesMissingExercise();
         }
         // ... other retrieval tests
+    }

+    @Nested
+    @DisplayName("Auxiliary Repository Export Tests")
+    class AuxiliaryRepositoryExportTests {
         // ... export related tests
+    }
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationTestService.java (1)

1928-1928: Consider returning HttpStatus.BAD_REQUEST instead of HttpStatus.INTERNAL_SERVER_ERROR.

When a client provides an invalid request, such as setting an ID on a new auxiliary repository, it's more appropriate to return HttpStatus.BAD_REQUEST (400) rather than HttpStatus.INTERNAL_SERVER_ERROR (500). This change will accurately reflect that the error was due to a bad request from the client side.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7876792 and 7702926.

📒 Files selected for processing (4)
  • src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationLocalCILocalVCTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationTestService.java (9 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseLocalVCIntegrationTest.java (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationLocalCILocalVCTest.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/ProgrammingExerciseIntegrationJenkinsGitlabTest.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/ProgrammingExerciseIntegrationTestService.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/ProgrammingExerciseLocalVCIntegrationTest.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/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationTestService.java (2)
Learnt from: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-11-12T12:51:51.200Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.
Learnt from: Hialus
PR: ls1intum/Artemis#7451
File: src/test/java/de/tum/in/www1/artemis/exercise/programmingexercise/ProgrammingExerciseTestService.java:9-9
Timestamp: 2024-11-12T12:51:58.050Z
Learning: The use of wildcard imports is acceptable in this project as specified in the `.editorconfig` file.
🔇 Additional comments (4)
src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationLocalCILocalVCTest.java (1)

55-57: LGTM! Verify service usage in test implementations.

The addition of programmingExerciseIntegrationTestService follows the established patterns and is properly placed in the services section.

Let's verify that this service is actually used in the test implementations:

✅ Verification successful

Service usage correctly implemented in all relevant test classes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of programmingExerciseIntegrationTestService in test classes
# Expected: Find references in concrete test classes that extend this abstract class

# Search for classes extending AbstractProgrammingIntegrationLocalCILocalVCTest
ast-grep --pattern 'class $_ extends AbstractProgrammingIntegrationLocalCILocalVCTest'

# Search for usage of programmingExerciseIntegrationTestService in test files
rg "programmingExerciseIntegrationTestService\." "src/test/java"

Length of output: 37684

src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java (3)

77-81: LGTM! Well-structured test method.

The test follows best practices with:

  • Clear, descriptive name indicating the test scenario and expected outcome
  • Proper security configuration with @WithMockUser
  • Focused scope testing error handling

83-87: LGTM! Well-structured test method.

The test follows best practices with:

  • Clear, descriptive name indicating the test scenario
  • Proper security configuration with @WithMockUser
  • Complements the error case test with success case coverage

577-581: LGTM! Well-structured test method.

The test follows best practices with:

  • Clear, descriptive name indicating the test scenario and expected outcome
  • Proper security configuration with @WithMockUser
  • Focused scope testing invalid input handling

Comment on lines +178 to +203
// @Test
// @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
// void test_redirectGetSolutionRepositoryFilesWithoutContent() throws Exception {
// programmingExerciseIntegrationTestService.test_redirectGetSolutionRepositoryFilesWithoutContent();
// }
//
// @Test
// @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
// void test_redirectGetTemplateRepositoryFilesWithContent() throws Exception {
// programmingExerciseIntegrationTestService.test_redirectGetTemplateRepositoryFilesWithContent();
// }
//
// @Test
// @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
// void testRedirectGetParticipationRepositoryFilesWithContentAtCommit() throws Exception {
// programmingExerciseIntegrationTestService.testRedirectGetParticipationRepositoryFilesWithContentAtCommit();
// }
//
// @Test
// @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
// void testRedirectGetParticipationRepositoryFilesWithContentAtCommitForbidden() throws Exception {
// programmingExerciseIntegrationTestService.testRedirectGetParticipationRepositoryFilesWithContentAtCommitForbidden();
// }

// TODO add all other tests
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Clean up commented code and clarify TODO.

  1. Either implement the commented-out tests or remove them
  2. Replace the vague TODO with specific test cases that need to be added

Would you like help implementing the commented-out tests or creating a detailed list of remaining test cases to be added?

Comment on lines +160 to +177
@Test
@WithMockUser(username = TEST_PREFIX + "instructoralt1", roles = "INSTRUCTOR")
void testReEvaluateAndUpdateProgrammingExercise_instructorNotInCourse_forbidden() throws Exception {
programmingExerciseIntegrationTestService.testReEvaluateAndUpdateProgrammingExercise_instructorNotInCourse_forbidden(TEST_PREFIX);
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testReEvaluateAndUpdateProgrammingExercise_notFound() throws Exception {
programmingExerciseIntegrationTestService.testReEvaluateAndUpdateProgrammingExercise_notFound();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testReEvaluateAndUpdateProgrammingExercise_isNotSameGivenExerciseIdInRequestBody_conflict() throws Exception {
programmingExerciseIntegrationTestService.testReEvaluateAndUpdateProgrammingExercise_isNotSameGivenExerciseIdInRequestBody_conflict();
}
//
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve test method naming and add missing success scenario.

  1. Rename test methods to follow camelCase convention instead of using underscores
  2. Add test for successful re-evaluation scenario

Example refactoring:

-    void testReEvaluateAndUpdateProgrammingExercise_instructorNotInCourse_forbidden() throws Exception {
+    void testReEvaluateAndUpdateProgrammingExerciseWhenInstructorNotInCourseThenForbidden() throws Exception {
         programmingExerciseIntegrationTestService.testReEvaluateAndUpdateProgrammingExercise_instructorNotInCourse_forbidden(TEST_PREFIX);
     }

+    @Test
+    @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
+    void testReEvaluateAndUpdateProgrammingExerciseSuccessful() throws Exception {
+        programmingExerciseIntegrationTestService.testReEvaluateAndUpdateProgrammingExerciseSuccessful();
+    }

Committable suggestion skipped: line range outside the PR's diff.

import org.junit.jupiter.api.Test;
import org.springframework.security.test.context.support.WithMockUser;

class ProgrammingExerciseLocalVCIntegrationTest extends AbstractProgrammingIntegrationLocalCILocalVCTest {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add class-level JavaDoc and integration test annotation.

The class is missing required documentation and integration test setup:

  1. Add comprehensive JavaDoc describing the test class purpose and scope
  2. Add @SpringBootTest annotation for proper Spring context initialization

Apply this diff:

+/**
+ * Integration tests for validating the LocalVC functionality with auxiliary repositories.
+ * These tests verify the behavior of repository operations, validations, and access controls
+ * in the context of programming exercises.
+ */
+@SpringBootTest
 class ProgrammingExerciseLocalVCIntegrationTest extends AbstractProgrammingIntegrationLocalCILocalVCTest {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class ProgrammingExerciseLocalVCIntegrationTest extends AbstractProgrammingIntegrationLocalCILocalVCTest {
/**
* Integration tests for validating the LocalVC functionality with auxiliary repositories.
* These tests verify the behavior of repository operations, validations, and access controls
* in the context of programming exercises.
*/
@SpringBootTest
class ProgrammingExerciseLocalVCIntegrationTest extends AbstractProgrammingIntegrationLocalCILocalVCTest {

Comment on lines +28 to +111
@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateValidAuxiliaryRepository() throws Exception {
programmingExerciseIntegrationTestService.testValidateValidAuxiliaryRepository();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryIdSetOnRequest() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryIdSetOnRequest();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithoutName() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithoutName();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithTooLongName() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithTooLongName();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithDuplicatedName() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithDuplicatedName();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithRestrictedName() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithRestrictedName();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithInvalidCheckoutDirectory() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithInvalidCheckoutDirectory();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithoutCheckoutDirectory() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithoutCheckoutDirectory();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithBlankCheckoutDirectory() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithBlankCheckoutDirectory();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithTooLongCheckoutDirectory() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithTooLongCheckoutDirectory();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithDuplicatedCheckoutDirectory() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithDuplicatedCheckoutDirectory();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithNullCheckoutDirectory() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithNullCheckoutDirectory();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithTooLongDescription() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithTooLongDescription();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testValidateAuxiliaryRepositoryWithoutDescription() throws Exception {
programmingExerciseIntegrationTestService.testValidateAuxiliaryRepositoryWithoutDescription();
}

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add database query count tracking for performance monitoring.

As per coding guidelines, integration tests should track database query performance. Add @Transactional and @SqlMeasure annotations to monitor database interactions.

Example for one test method:

     @Test
+    @Transactional
+    @SqlMeasure
     @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
     void testValidateValidAuxiliaryRepository() throws Exception {
         programmingExerciseIntegrationTestService.testValidateValidAuxiliaryRepository();
     }

Committable suggestion skipped: line range outside the PR's diff.

@@ -2158,7 +2159,7 @@ public void addAuxiliaryRepositoryToExercise(ProgrammingExercise exercise) {
}

private String defaultAuxiliaryRepositoryEndpoint() {
return "/api/programming-exercises/setup";
return "/api/programming-exercises";
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the endpoint returned by defaultAuxiliaryRepositoryEndpoint().

The method defaultAuxiliaryRepositoryEndpoint() currently returns "/api/programming-exercises", which does not point to the auxiliary repository endpoint. It should return the correct path, such as "/api/programming-exercises/" + exerciseId + "/auxiliary-repository", to accurately reflect its purpose.

@@ -2275,8 +2266,8 @@
}
}

void testReEvaluateAndUpdateProgrammingExercise_instructorNotInCourse_forbidden() throws Exception {
userUtilService.addInstructor("other-instructors", userPrefix + "instructoralt");
void testReEvaluateAndUpdateProgrammingExercise_instructorNotInCourse_forbidden(String testPrefix) throws Exception {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove or utilize the unused parameter testPrefix.

The parameter String testPrefix in testReEvaluateAndUpdateProgrammingExercise_instructorNotInCourse_forbidden is not effectively used except for constructing a username. If it's unnecessary, consider removing it to simplify the method signature. If needed, ensure it's properly provided when the method is called.

@krusche krusche added this to the 7.7.1 milestone Nov 16, 2024
@krusche krusche changed the title Develop: Re-add auxiliary repository integration tests for LocalVC Development: Reactivate auxiliary repository integration tests for LocalVC Nov 16, 2024
@krusche krusche merged commit 7bf4a93 into develop Nov 16, 2024
20 of 25 checks passed
@krusche krusche deleted the chore/refactor/programming-exercise-integration-tests branch November 16, 2024 09:19
@coderabbitai coderabbitai bot mentioned this pull request Nov 26, 2024
31 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
programming Pull requests that affect the corresponding module ready for review tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants