Use business rules for status transition.#1119
Merged
Merged
Conversation
b6ba68b to
d36addc
Compare
51071c8 to
64d0ab2
Compare
Sam Gibson (samgibsonmoj)
previously approved these changes
Jun 11, 2026
64d0ab2 to
0598a77
Compare
The merge-base changed after approval.
344e955 to
8d23861
Compare
0598a77 to
9a65731
Compare
Sam Gibson (samgibsonmoj)
approved these changes
Jun 17, 2026
Introduces business rules for Enrolment Status and Activity Status that explicitly enforce domain constraints. This results in better language.
9a65731 to
ff94caf
Compare
Carl Sixsmith (carlsixsmith-moj)
added a commit
that referenced
this pull request
Jun 19, 2026
Introduces business rules for Enrolment Status and Activity Status that explicitly enforce domain constraints. This results in better language.
Carl Sixsmith (carlsixsmith-moj)
added a commit
that referenced
this pull request
Jun 25, 2026
Introduces business rules for Enrolment Status and Activity Status that explicitly enforce domain constraints. This results in better language.
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.
This pull request refactors how status transitions are validated for both activities and participants by replacing custom exception classes with business rule objects, aligning the codebase with a domain-driven design approach. It introduces new business rule classes to encapsulate transition logic and updates the corresponding domain entities to use these rules. Additionally, comprehensive unit tests are added to ensure correct behavior of the new rules and transitions.
Domain Logic Refactoring:
InvalidActivityTransitionandInvalidEnrolmentTransitionwith business rule classesActivityStatusTransitionMustBeValidandEnrolmentStatusTransitionMustBeValid, removing the old exception files. (src/Domain/Common/Exceptions/InvalidActivityTransition.cs[1]src/Domain/Common/Exceptions/InvalidEnrolmentTransition.cs[2]ActivityandParticipantentities to use the new business rules for status transitions, enforcing validation viaCheckRule()instead of conditional logic and exceptions. (src/Domain/Entities/Activities/Activity.cs[1] [2];src/Domain/Entities/Participants/Participant.cs[3] [4]ActivityStatusTransitionMustBeValidandEnrolmentStatusTransitionMustBeValidto encapsulate transition logic and error messages. (src/Domain/Entities/Activities/Rules/ActivityStatusTransitionMustBeValid.cs[1]src/Domain/Entities/Participants/Rules/EnrolmentStatusTransitionMustBeValid.cs[2]Testing Enhancements:
test/Application.UnitTests/Activities/BusinessRules/ActivityStatusTransitionMustBeValidTests.cs[1]test/Application.UnitTests/Participants/BusinessRules/EnrolmentStatusTransitionMustBeValidTests.cs[2]TransitionTomethod updates status correctly on valid transitions, throws the expected exception on invalid transitions, and does not update status when invalid. (test/Application.UnitTests/Participants/ParticipantTransitionTests.cstest/Application.UnitTests/Participants/ParticipantTransitionTests.csR1-R60)