-
Notifications
You must be signed in to change notification settings - Fork 301
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
: Improve metrics integration test coverage
#9306
Development
: Improve metrics integration test coverage
#9306
Conversation
+reduced jacoco missed classes threshold by one
+shouldReturnCompetencyInformation() test (WIP)
…lytics/improve-metrics-integration-tests
+ shouldReturnCompleted() test + shouldReturnScore() test + shouldReturnLectureUnitInformation() test (WIP) + use of lectureMetricsService (WIP)
…lytics/improve-metrics-integration-tests # Conflicts: # src/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/CompetencyInformationDTO.java # src/test/java/de/tum/cit/aet/artemis/AbstractArtemisIntegrationTest.java # src/test/java/de/tum/cit/aet/artemis/MetricsIntegrationTest.java
some minor fixes
Removed ShouldReturnTeamId test
src/main/java/de/tum/cit/aet/artemis/exercise/repository/ExerciseRepository.java
Outdated
Show resolved
Hide resolved
…integration-tests
Fixed LectureInformation test
…integration-tests
WalkthroughThis pull request introduces several changes, including a modification to the Changes
Possibly related issues
Possibly related PRs
Suggested labels
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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: ASSERTIVE
Files selected for processing (6)
- build.gradle (1 hunks)
- src/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/CompetencyInformationDTO.java (2 hunks)
- src/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/LectureUnitInformationDTO.java (1 hunks)
- src/test/java/de/tum/cit/aet/artemis/MetricsIntegrationTest.java (5 hunks)
- src/test/java/de/tum/cit/aet/artemis/StudentScoreUtilService.java (1 hunks)
- src/test/java/de/tum/cit/aet/artemis/exercise/repository/ExerciseTestRepository.java (1 hunks)
Additional context used
Path-based instructions (5)
src/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/LectureUnitInformationDTO.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_importssrc/test/java/de/tum/cit/aet/artemis/exercise/repository/ExerciseTestRepository.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: truesrc/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/CompetencyInformationDTO.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_importssrc/test/java/de/tum/cit/aet/artemis/StudentScoreUtilService.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: truesrc/test/java/de/tum/cit/aet/artemis/MetricsIntegrationTest.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
Additional comments not posted (16)
src/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/LectureUnitInformationDTO.java (1)
21-31
: LGTM!The new static factory method
of
in theLectureUnitInformationDTO
record is a great addition. It provides a clear and concise way to create DTOs fromLectureUnit
instances, promoting code reuse and reducing boilerplate. The method follows the single responsibility principle, uses constructor injection, and adheres to the KISS principle. It also aligns with the guidelines for DTOs by including minimal data and using theZonedDateTime
type for thereleaseDate
field. The method follows the Java naming convention as well. Overall, this is a well-designed and useful addition to the codebase.src/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/CompetencyInformationDTO.java (1)
23-33
: LGTM! The new static factory method enhances the functionality and promotes code reuse.The new static factory method
of
in theCompetencyInformationDTO
class is a great addition that provides several benefits:
- It follows the single responsibility principle by focusing solely on creating a DTO from a domain object.
- It promotes code reuse by providing a centralized way to convert a
Competency
to its DTO representation.- It uses constructor injection to create the DTO, aligning with the provided instructions.
- It keeps the code simple and easy to understand, adhering to the KISS principle.
- The method name
of
follows the Java naming convention for static factory methods.- The method parameters are effectively final, aligning with the least access principle.
Overall, this method enhances the functionality of the
CompetencyInformationDTO
class, promotes better encapsulation, and reduces boilerplate code in client classes that need to perform this conversion. Great job!src/test/java/de/tum/cit/aet/artemis/StudentScoreUtilService.java (1)
37-52
: LGTM!The
createStudentScoreIsRated
method is well-implemented and follows the coding guidelines. It enhances the functionality of theStudentScoreUtilService
by allowing the creation of scores that explicitly denote rated scores, providing a clearer distinction in score handling for exercises.The method is small, focused, and follows a clear logical flow. It calculates the
lastPoints
based on the exercise's maximum points and the provided score percentage, ensuring consistency. The method also uses thestudentScoreRepository
to save the score, avoiding direct database access and promoting separation of concerns.Great job!
src/test/java/de/tum/cit/aet/artemis/MetricsIntegrationTest.java (12)
52-52
: LGTM!The addition of
CompetencyRepository
is necessary for testing competency-related functionality.
55-55
: LGTM!The addition of
ExerciseTestRepository
is necessary for testing exercise-related functionality.
58-58
: LGTM!The addition of
LectureUnitRepository
is necessary for testing lecture unit-related functionality.
61-61
: LGTM!The addition of
StudentScoreRepository
is necessary for testing student score-related functionality.
79-79
: LGTM!The addition of
userID
is necessary for testing user-specific functionality.
Line range hint
84-97
: LGTM!The changes to the
setupTestScenario
method are necessary for setting up the test data for the new test methods. The addition of the user with IDuserID
is required for testing user-specific functionality.
135-145
: LGTM!The
shouldReturnCategories
test method is well-structured and follows the AAA pattern. The assertions are correct and verify that the/api/metrics/course/{courseId}/student
endpoint returns the correct categories for the exercises in the course.
147-163
: LGTM!The
shouldReturnAverageScores
test method is well-structured and follows the AAA pattern. The assertions are correct and verify that the/api/metrics/course/{courseId}/student
endpoint returns the correct average scores for the exercises in the course.
165-182
: LGTM!The
shouldReturnScore
test method is well-structured and follows the AAA pattern. The assertions are correct and verify that the/api/metrics/course/{courseId}/student
endpoint returns the correct scores for the exercises in the course.
266-282
: LGTM!The
shouldReturnCompleted
test method is well-structured and follows the AAA pattern. The assertions are correct and verify that the/api/metrics/course/{courseId}/student
endpoint returns the correct completed exercises for the course.
288-304
: LGTM!The
shouldReturnCompetencyInformation
test method is well-structured and follows the AAA pattern. The assertions are correct and verify that the/api/metrics/course/{courseId}/student
endpoint returns the correct competency information for the course.
310-331
: LGTM!The
shouldReturnLectureUnitInformation
test method is well-structured and follows the AAA pattern. The assertions are correct and verify that the/api/metrics/course/{courseId}/student
endpoint returns the correct lecture unit information for the course.build.gradle (1)
189-189
: Looks good! This change aligns with the goal of improving test coverage.Reducing the
maximum
threshold forMISSEDCOUNT
is a positive step towards enhancing the codebase quality by enforcing stricter coverage requirements. Keep up the good work!
src/test/java/de/tum/cit/aet/artemis/exercise/repository/ExerciseTestRepository.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall Looks Good to me
src/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/CompetencyInformationDTO.java
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/atlas/dto/metrics/LectureUnitInformationDTO.java
Show resolved
Hide resolved
src/test/java/de/tum/cit/aet/artemis/MetricsIntegrationTest.java
Outdated
Show resolved
Hide resolved
…integration-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please fix the server style issue, rest looks good to me 👍
…integration-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing the server style, Code LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reapprove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in Code LGTM
…integration-tests
Development
: Improve metrics integration test coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maintainer approved
Checklist
General
Server
Motivation and Context
The MetricsIntegrationTests only had a very low coverage, and one of the existing tests was not working and deactivated. This PR should extend the test coverage to all metrics besides teamID.
Description
Fixed the test for AverageScore and reactivated it
Added tests for the following metrics parameters:
Added tests for CompetencyInformation and LectureUnitInformation
The tests mainly focus on comparing the result from the "/api/metrics/course/courseID/student" request with test data pulled directly from the specific repositories. This also covers parts of the learningMetricsService, which is used by the endpoint to fetch the data.
Steps for Testing
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
Code Review
Test Coverage
Summary by CodeRabbit
Summary by CodeRabbit
New Features
CompetencyInformationDTO
andLectureUnitInformationDTO
for streamlined object creation from existing entities.StudentScoreUtilService
to create student scores that include rated scores.Bug Fixes
Tests
MetricsIntegrationTest
suite with new methods to validate various student metrics and competencies.ExerciseTestRepository
for enhanced data retrieval capabilities in testing scenarios.