Skip to content

Use business rules for status transition.#1119

Merged
Carl Sixsmith (carlsixsmith-moj) merged 1 commit into
developfrom
feature/arch-cleanup
Jun 18, 2026
Merged

Use business rules for status transition.#1119
Carl Sixsmith (carlsixsmith-moj) merged 1 commit into
developfrom
feature/arch-cleanup

Conversation

@carlsixsmith-moj

Copy link
Copy Markdown
Contributor

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:

  • Replaced the custom exceptions InvalidActivityTransition and InvalidEnrolmentTransition with business rule classes ActivityStatusTransitionMustBeValid and EnrolmentStatusTransitionMustBeValid, removing the old exception files. (src/Domain/Common/Exceptions/InvalidActivityTransition.cs [1] src/Domain/Common/Exceptions/InvalidEnrolmentTransition.cs [2]
  • Updated the Activity and Participant entities to use the new business rules for status transitions, enforcing validation via CheckRule() instead of conditional logic and exceptions. (src/Domain/Entities/Activities/Activity.cs [1] [2]; src/Domain/Entities/Participants/Participant.cs [3] [4]
  • Added business rule classes ActivityStatusTransitionMustBeValid and EnrolmentStatusTransitionMustBeValid to encapsulate transition logic and error messages. (src/Domain/Entities/Activities/Rules/ActivityStatusTransitionMustBeValid.cs [1] src/Domain/Entities/Participants/Rules/EnrolmentStatusTransitionMustBeValid.cs [2]

Testing Enhancements:

  • Added unit tests for both business rule classes to verify correct detection of valid and invalid transitions, including error messages. (test/Application.UnitTests/Activities/BusinessRules/ActivityStatusTransitionMustBeValidTests.cs [1] test/Application.UnitTests/Participants/BusinessRules/EnrolmentStatusTransitionMustBeValidTests.cs [2]
  • Added participant transition tests to ensure the TransitionTo method 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.cs test/Application.UnitTests/Participants/ParticipantTransitionTests.csR1-R60)

@carlsixsmith-moj Carl Sixsmith (carlsixsmith-moj) added Needs Review This pull request is awaiting review Feature This is a new feature (or extending an existing one) labels Jun 3, 2026
@samgibsonmoj Sam Gibson (samgibsonmoj) added Approved Changes have been approved and removed Needs Review This pull request is awaiting review labels Jun 17, 2026
Introduces business rules for Enrolment Status and Activity Status
that explicitly enforce domain constraints.

This results in better language.
@carlsixsmith-moj Carl Sixsmith (carlsixsmith-moj) merged commit d17a290 into develop Jun 18, 2026
1 check passed
@carlsixsmith-moj Carl Sixsmith (carlsixsmith-moj) deleted the feature/arch-cleanup branch June 18, 2026 09:32
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Changes have been approved Feature This is a new feature (or extending an existing one)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants