-
Notifications
You must be signed in to change notification settings - Fork 305
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
: Add mobile app version compatibility
#10339
Conversation
WalkthroughThis change introduces a new configuration class for managing compatible version information for Android and iOS platforms. It defines an inner class to encapsulate version details and binds these properties from the Spring environment. Additionally, an actuator info contributor class is added to expose these version settings via the application’s info endpoints. A corresponding test class verifies that the contributor correctly adds the configuration details to the info response. Changes
Suggested labels
Suggested reviewers
✨ Finishing Touches
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: 0
🧹 Nitpick comments (2)
src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java (1)
34-58
: Consider using Java Record and adding version validation.The
Platform
class could be simplified using a Java Record. Additionally, consider adding version format validation to ensure semantic versioning compliance.- public static class Platform { - private String min; - private String recommended; - - public Platform() { - } - - public String getMin() { - return min; - } - - public void setMin(String min) { - this.min = min; - } - - public String getRecommended() { - return recommended; - } - - public void setRecommended(String recommended) { - this.recommended = recommended; - } - } + public static record Platform( + @Pattern(regexp = "^\\d+\\.\\d+\\.\\d+$", message = "Version must follow semantic versioning") + String min, + @Pattern(regexp = "^\\d+\\.\\d+\\.\\d+$", message = "Version must follow semantic versioning") + String recommended + ) {}src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java (1)
10-42
: Add test cases for edge cases and invalid inputs.While the happy path is tested, consider adding test cases for:
- Empty version strings
- Invalid version formats
- Null values
- Different version formats between min and recommended
Example test case:
@Test void shouldValidateVersionFormat() { ArtemisCompatibleVersionsConfiguration config = new ArtemisCompatibleVersionsConfiguration(); ArtemisCompatibleVersionsConfiguration.Platform android = new ArtemisCompatibleVersionsConfiguration.Platform(); // Test invalid version format android.setMin("invalid"); android.setRecommended("1.0"); config.setAndroid(android); assertThatThrownBy(() -> { Info.Builder builder = new Info.Builder(); new CompatibleVersionsInfoContributor(config).contribute(builder); }).isInstanceOf(IllegalArgumentException.class); }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
src/main/resources/config/application.yml
is excluded by!**/*.yml
📒 Files selected for processing (3)
src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsInfoContributor.java
(1 hunks)src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...
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/core/config/CompatibleVersionsInfoContributor.java
src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java
`src/test/java/**/*.java`: test_naming: descriptive; test_si...
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/core/config/CompatibleVersionsConfigurationTest.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsInfoContributor.java (1)
1-24
: LGTM! Clean implementation following best practices.The class follows Spring Boot best practices with:
- Constructor injection
- Single responsibility
- Clean integration with Spring Boot Actuator
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.
src/main/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsInfoContributor.java
Outdated
Show resolved
Hide resolved
128a687
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.
Works as expected, tested it in conjunction with ls1intum/artemis-ios#291 and ls1intum/artemis-ios-core-modules#120
(I think you also need to update the name in the test though)
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.
Code
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.
Code
General
: Add mobile app version compatibilityDevelopment
: Add mobile app version compatibility
src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.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.
Tested on TS3, works 👌🏼
eca8c71
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: 0
🧹 Nitpick comments (4)
src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java (3)
1-8
: Test class name should be more descriptive.The test class name should reflect that it's testing the info contributor functionality, not just the configuration.
Rename the class to better reflect its purpose:
-class CompatibleVersionsInfoConfigurationTest { +class CompatibleVersionsInfoContributorTest {
10-28
: Test method should follow BDD naming pattern.The test method name should describe the behavior being tested, following the "given/when/then" pattern for better readability.
Rename the test method and extract the setup into descriptive variables:
- void testContribute() { + void shouldContributeVersionsToInfoEndpoint() { + // given + var androidVersion = "1.2.0"; + var iosVersion = "1.6.1"; ArtemisCompatibleVersionsConfiguration config = new ArtemisCompatibleVersionsConfiguration(); ArtemisCompatibleVersionsConfiguration.Platform android = new ArtemisCompatibleVersionsConfiguration.Platform(); - android.setMin("1.2.0"); - android.setRecommended("1.2.0"); + android.setMin(androidVersion); + android.setRecommended(androidVersion); config.setAndroid(android); ArtemisCompatibleVersionsConfiguration.Platform ios = new ArtemisCompatibleVersionsConfiguration.Platform(); - ios.setMin("1.6.1"); - ios.setRecommended("1.6.1"); + ios.setMin(iosVersion); + ios.setRecommended(iosVersion); config.setIos(ios); CompatibleVersionsInfoContributor contributor = new CompatibleVersionsInfoContributor(config); + // when Info.Builder builder = new Info.Builder(); contributor.contribute(builder); Info info = builder.build();
30-41
: Group assertions by platform for better readability.The assertions should be grouped logically by platform and use descriptive error messages.
Refactor the assertions:
+ // then assertThat(info.getDetails()).containsKey("compatibleVersions"); Object value = info.getDetails().get("compatibleVersions"); - assertThat(value).isInstanceOf(ArtemisCompatibleVersionsConfiguration.class); + assertThat(value) + .as("Info details should contain compatible versions configuration") + .isInstanceOf(ArtemisCompatibleVersionsConfiguration.class); ArtemisCompatibleVersionsConfiguration resultConfig = (ArtemisCompatibleVersionsConfiguration) value; - assertThat(resultConfig.getAndroid().getMin()).isEqualTo("1.2.0"); - assertThat(resultConfig.getAndroid().getRecommended()).isEqualTo("1.2.0"); + // verify Android versions + assertThat(resultConfig.getAndroid()) + .as("Android platform configuration") + .satisfies(platform -> { + assertThat(platform.getMin()).isEqualTo(androidVersion); + assertThat(platform.getRecommended()).isEqualTo(androidVersion); + }); - assertThat(resultConfig.getIos().getMin()).isEqualTo("1.6.1"); - assertThat(resultConfig.getIos().getRecommended()).isEqualTo("1.6.1"); + // verify iOS versions + assertThat(resultConfig.getIos()) + .as("iOS platform configuration") + .satisfies(platform -> { + assertThat(platform.getMin()).isEqualTo(iosVersion); + assertThat(platform.getRecommended()).isEqualTo(iosVersion); + });src/main/java/de/tum/cit/aet/artemis/ArtemisApp.java (1)
29-30
: Improve readability of configuration properties list.The list of configuration properties is becoming long and harder to read. Consider extracting them into a constant or breaking them into logical groups.
Refactor the configuration properties:
+ private static final Class<?>[] CONFIGURATION_PROPERTIES = { + LiquibaseProperties.class, + ProgrammingLanguageConfiguration.class, + TheiaConfiguration.class, + LicenseConfiguration.class, + ArtemisCompatibleVersionsConfiguration.class + }; + @SpringBootApplication -@EnableConfigurationProperties({ LiquibaseProperties.class, ProgrammingLanguageConfiguration.class, TheiaConfiguration.class, LicenseConfiguration.class, - ArtemisCompatibleVersionsConfiguration.class }) +@EnableConfigurationProperties(CONFIGURATION_PROPERTIES)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
src/main/resources/config/application.yml
is excluded by!**/*.yml
📒 Files selected for processing (3)
src/main/java/de/tum/cit/aet/artemis/ArtemisApp.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java
(1 hunks)src/test/java/de/tum/cit/aet/artemis/core/config/CompatibleVersionsConfigurationTest.java
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisCompatibleVersionsConfiguration.java
🧰 Additional context used
📓 Path-based instructions (2)
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...
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/ArtemisApp.java
`src/test/java/**/*.java`: test_naming: descriptive; test_si...
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/core/config/CompatibleVersionsConfigurationTest.java
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: Call Build Workflow / Build .war artifact
- GitHub Check: Call Build Workflow / Build and Push Docker Image
- GitHub Check: client-style
- GitHub Check: server-style
- GitHub Check: client-tests
- GitHub Check: server-tests
- GitHub Check: Analyse
🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/ArtemisApp.java (1)
21-21
: LGTM!The import statement follows the coding guidelines.
Checklist
General
Server
Motivation and Context
Android and iOS apps need to fetch the minimum-recommended versions from the Artemis server. This information can be used to notify users if their app version is outdated, with an update prompt to be added later.
Description
The
/management/info
endpoint now includes the minimum-required Artemis versions for Android and iOS apps.Steps for Testing
Prerequisites:
/management/info
in your browser and search for "compatible-versions" to check the version numbers (e.g., https://artemis-test4.artemis.cit.tum.de/management/info).Testserver States
You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.
Review Progress
Code Review
Manual Tests
Test Coverage
Summary by CodeRabbit