Repository navigation
Fix/apply functional paradigm and ddd - #6
Merged
Merged
Conversation
# Conflicts: # src/main/java/se/jensen/yuki/springboot/user/usecase/UserService.java
This branch contains ongoing refactoring to DDD structure.
…ord, and Update Profile
…HashedPassword type
…assword use cases to utilize HashedPassword value object
…asses to include validation
There was a problem hiding this comment.
Pull request overview
This PR continues the ongoing DDD refactor by extracting a dedicated user bounded context (domain model + value objects + use cases + web controllers) and migrating the rest of the application from the legacy model.User / repository.UserRepository approach to the new JPA entity + load service.
Changes:
- Introduces a DDD-style
usermodule: domain model/value objects, repository abstraction + JPA adapter, query/command controllers, and use cases. - Migrates multiple services/entities/repositories/tests to reference
UserJpaEntity/UserJpaRepositoryand a temporaryUserLoadService. - Adds new unit/controller tests for user use cases and controllers; removes the legacy
UserServiceIntegrationTest.
Reviewed changes
Copilot reviewed 79 out of 79 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/se/jensen/yuki/springboot/user/web/UserControllerTest.java | Adds MockMvc coverage for new /users command/query endpoints. |
| src/test/java/se/jensen/yuki/springboot/user/usecase/command/UpdateUserProfileUseCaseTest.java | Unit test for profile update use case. |
| src/test/java/se/jensen/yuki/springboot/user/usecase/command/UpdatePasswordUseCaseTest.java | Unit tests for password update use case (happy + error paths). |
| src/test/java/se/jensen/yuki/springboot/user/usecase/command/UpdateEmailUseCaseTest.java | Unit tests for email update use case (happy + error paths). |
| src/test/java/se/jensen/yuki/springboot/user/usecase/command/DeleteUserUseCaseTest.java | Unit tests for delete user use case. |
| src/test/java/se/jensen/yuki/springboot/testutil/TestUsers.java | Test helper for creating SecurityUser principals. |
| src/test/java/se/jensen/yuki/springboot/testutil/TestPasswords.java | Test helper for generating BCrypt hashes. |
| src/test/java/se/jensen/yuki/springboot/service/UserServiceIntegrationTest.java | Removes legacy integration test tied to deleted UserService. |
| src/test/java/se/jensen/yuki/springboot/service/PostServiceIntegrationTest.java | Updates integration test setup to use UserJpaEntity/UserJpaRepository. |
| src/test/java/se/jensen/yuki/springboot/service/MuteServiceIntegrationTest.java | Updates integration test setup to use UserJpaEntity/UserJpaRepository and uses getFirst(). |
| src/test/java/se/jensen/yuki/springboot/service/LikeServiceIntegrationTest.java | Updates integration test setup to use UserJpaEntity/UserJpaRepository and uses getFirst(). |
| src/test/java/se/jensen/yuki/springboot/service/FollowServiceIntegrationTest.java | Updates integration test setup to use UserJpaEntity/UserJpaRepository. |
| src/test/java/se/jensen/yuki/springboot/service/BlockServiceIntegrationTest.java | Updates integration test setup to use UserJpaEntity/UserJpaRepository and uses getFirst(). |
| src/test/java/se/jensen/yuki/springboot/service/AuthServiceIntegrationTest.java | Updates integration test to use UserJpaEntity/UserJpaRepository. |
| src/main/java/se/jensen/yuki/springboot/util/CurrentUserProvider.java | Switches current-user lookup to UserLoadService. |
| src/main/java/se/jensen/yuki/springboot/user/web/mapper/UserResponseMapper.java | Adds MapStruct mapper for mapping domain User to response DTO. |
| src/main/java/se/jensen/yuki/springboot/user/web/dto/UserUpdateProfileRequest.java | Moves DTO into user.web.dto and updates validation rules/messages. |
| src/main/java/se/jensen/yuki/springboot/user/web/dto/UserUpdatePasswordRequest.java | Moves DTO into user.web.dto and adds Javadoc. |
| src/main/java/se/jensen/yuki/springboot/user/web/dto/UserUpdateEmailRequest.java | Moves DTO into user.web.dto and adds Javadoc. |
| src/main/java/se/jensen/yuki/springboot/user/web/dto/UserRequestDTO.java | Moves DTO into user.web.dto and updates validation rules/messages. |
| src/main/java/se/jensen/yuki/springboot/user/web/dto/UserProfileResponse.java | Adds new user profile response DTO under the new module. |
| src/main/java/se/jensen/yuki/springboot/user/web/UserQueryController.java | Adds query-side controller for user endpoints (get all/me/by id). |
| src/main/java/se/jensen/yuki/springboot/user/web/UserCommandController.java | Adds command-side controller for profile/email/password update and delete. |
| src/main/java/se/jensen/yuki/springboot/user/usecase/query/UserQueryServiceImpl.java | Adds query service implementation mapping domain users to DTOs. |
| src/main/java/se/jensen/yuki/springboot/user/usecase/query/UserQueryService.java | Adds query service interface. |
| src/main/java/se/jensen/yuki/springboot/user/usecase/command/UpdateUserProfileUseCase.java | Adds use case for updating user profile (domain-level update + save). |
| src/main/java/se/jensen/yuki/springboot/user/usecase/command/UpdatePasswordUseCase.java | Adds use case for password update with password verification rules. |
| src/main/java/se/jensen/yuki/springboot/user/usecase/command/UpdateEmailUseCase.java | Adds use case for email update with password verification. |
| src/main/java/se/jensen/yuki/springboot/user/usecase/command/DeleteUserUseCase.java | Adds use case for deleting a user. |
| src/main/java/se/jensen/yuki/springboot/user/usecase/UserLoadServiceImpl.java | Adds temporary service for loading users via JPA repository with exceptions. |
| src/main/java/se/jensen/yuki/springboot/user/usecase/UserLoadService.java | Adds interface for temporary JPA-based user loading during migration. |
| src/main/java/se/jensen/yuki/springboot/user/infrastructure/jpa/UserRepositoryImpl.java | Implements domain UserRepository via JPA repository + mapper. |
| src/main/java/se/jensen/yuki/springboot/user/infrastructure/jpa/UserJpaRepository.java | Adds Spring Data JPA repository for UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/user/infrastructure/jpa/UserJpaMapper.java | Adds mapper between UserJpaEntity and domain User. |
| src/main/java/se/jensen/yuki/springboot/user/infrastructure/jpa/UserJpaEntity.java | Moves/renames legacy user JPA entity into new module. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/mapper/UsernameMapper.java | Adds MapStruct mapper for Username VO. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/mapper/UserRoleMapper.java | Adds MapStruct mapper for UserRole VO. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/mapper/UserIdMapper.java | Adds MapStruct mapper for UserId VO. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/mapper/PasswordMapper.java | Adds MapStruct mapper for HashedPassword VO. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/mapper/EmailMapper.java | Adds MapStruct mapper for Email VO. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/mapper/DisplayNameMapper.java | Adds MapStruct mapper for DisplayName VO. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/mapper/BioMapper.java | Adds MapStruct mapper for Bio VO. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/mapper/AvatarUrlMapper.java | Adds MapStruct mapper for AvatarUrl VO. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/Username.java | Adds Username value object with validation. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/UserRole.java | Adds UserRole value object with validation. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/UserId.java | Adds UserId value object with validation. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/HashedPassword.java | Adds HashedPassword value object validating BCrypt hashes. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/Email.java | Adds Email value object with validation. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/DisplayName.java | Adds DisplayName value object with validation. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/Bio.java | Adds Bio value object with validation. |
| src/main/java/se/jensen/yuki/springboot/user/domain/vo/AvatarUrl.java | Adds AvatarUrl value object with validation. |
| src/main/java/se/jensen/yuki/springboot/user/domain/UserRepository.java | Adds domain repository abstraction for users. |
| src/main/java/se/jensen/yuki/springboot/user/domain/User.java | Adds domain aggregate/root for users with mutation methods. |
| src/main/java/se/jensen/yuki/springboot/service/UserService.java | Removes legacy service in favor of use cases/query services. |
| src/main/java/se/jensen/yuki/springboot/service/PostService.java | Migrates author loading to UserLoadService and UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/service/LikeService.java | Migrates user loading to UserLoadService. |
| src/main/java/se/jensen/yuki/springboot/service/CustomUserDetailsService.java | Migrates user loading to UserLoadService and new SecurityUser ctor. |
| src/main/java/se/jensen/yuki/springboot/service/CommentService.java | Migrates author loading to UserLoadService and UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/service/AuthService.java | Migrates persistence to UserJpaRepository/UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/repository/UserRepository.java | Removes legacy Spring Data repository for old model.User. |
| src/main/java/se/jensen/yuki/springboot/repository/FollowRepository.java | Updates JPQL entity reference to UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/model/SecurityUser.java | Refactors SecurityUser construction to no longer depend on entity type. |
| src/main/java/se/jensen/yuki/springboot/model/RefreshToken.java | Changes refresh token relation to reference UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/model/PostLike.java | Changes like relation to reference UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/model/Post.java | Changes post relation to reference UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/model/Mute.java | Changes mute relations to reference UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/model/Follow.java | Changes follow relations to reference UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/model/CommentLike.java | Changes comment-like relation to reference UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/model/Comment.java | Changes comment author relation to reference UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/model/Block.java | Changes block relations to reference UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/mapper/UserMapper.java | Removes legacy user mapper in favor of new module mapper(s). |
| src/main/java/se/jensen/yuki/springboot/mapper/PostMapper.java | Updates mapping signature to accept UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/mapper/CommentMapper.java | Updates mapping signatures to accept UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/mapper/AuthMapper.java | Updates mapping target type to UserJpaEntity. |
| src/main/java/se/jensen/yuki/springboot/dto/user/UserProfileResponse.java | Removes legacy DTO location in favor of new module DTO. |
| src/main/java/se/jensen/yuki/springboot/controller/UserController.java | Removes legacy controller in favor of new command/query controllers. |
| src/main/java/se/jensen/yuki/springboot/config/JwtFilter.java | Migrates user loading to UserLoadService and refactors principal creation. |
| src/main/java/se/jensen/yuki/springboot/Application.java | Broadens entity/repository scanning to cover new package structure. |
| README.md | Notes that the refactor is WIP and DDD-oriented. |
Comments suppressed due to low confidence (2)
src/main/java/se/jensen/yuki/springboot/user/web/dto/UserUpdateProfileRequest.java:13
- The displayName validation constraints are inconsistent: @SiZe(min=3,max=30) conflicts with the regex quantifier
{2,29}(and the message says 3–30). As written, a 30-character name will pass @SiZe but fail the pattern, and a 2-character string will fail @SiZe but match the pattern. Align the regex to enforce the same length range (or remove length from the regex and rely solely on @SiZe).
src/main/java/se/jensen/yuki/springboot/user/web/dto/UserRequestDTO.java:37 - The displayName validation constraints are inconsistent: @SiZe(min=3,max=30) conflicts with the regex quantifier
{2,29}(and the message says 3–30). This can produce confusing validation failures (e.g., length=30 passes @SiZe but fails @pattern). Align the regex with @SiZe, or drop the length quantifier from the regex.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.