Prevent duplicate associations for the same workflow, event, and condition#7354
Prevent duplicate associations for the same workflow, event, and condition#7354PasinduYeshan merged 6 commits intowso2:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the workflow association logic to prevent duplicate associations for the same workflow, event, and condition. The main changes include adding duplicate checks in both association creation and update methods, along with a new helper method to encapsulate this logic.
- Added duplicate detection in
addAssociationandupdateAssociationmethods to prevent creating/updating associations with the same workflow, event, and condition - Introduced a private helper method
isDuplicateAssociationfor reusable duplicate detection logic - Added comprehensive test coverage for the new duplicate detection functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| WorkflowManagementServiceImpl.java | Added duplicate detection logic in addAssociation and updateAssociation methods, plus a new helper method isDuplicateAssociation |
| WorkflowManagementServiceImplTest.java | Added extensive test cases for duplicate detection scenarios, edge cases, and validation |
...w.mgt/src/main/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImpl.java
Outdated
Show resolved
Hide resolved
...w.mgt/src/main/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImpl.java
Show resolved
Hide resolved
...w.mgt/src/main/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImpl.java
Outdated
Show resolved
Hide resolved
...w.mgt/src/main/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImpl.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
...t/src/test/java/org/wso2/carbon/identity/workflow/mgt/WorkflowManagementServiceImplTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7354 +/- ##
============================================
- Coverage 50.90% 50.77% -0.14%
- Complexity 18707 18771 +64
============================================
Files 2067 2073 +6
Lines 119498 120277 +779
Branches 24682 24866 +184
============================================
+ Hits 60835 61073 +238
- Misses 50801 51298 +497
- Partials 7862 7906 +44
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
PR builder started |
|
PR builder completed |
|
PR builder started |
|
PR builder completed |
|
|
PR builder started |
|
PR builder completed |
jenkins-is-staging
left a comment
There was a problem hiding this comment.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/17604010217
[Sync][master -> next][#7354]: Prevent duplicate associations for the same workflow, event, and condition






Proposed changes in this pull request
This pull request enhances the workflow association logic to prevent duplicate associations for the same workflow, event, and condition. The main update is the introduction of duplicate checks in both the association creation and update methods, alongside a new helper method to encapsulate this logic.
Duplicate association prevention:
addAssociationto prevent creating a new association if one with the same workflow, event, and condition already exists. AWorkflowClientExceptionis thrown if a duplicate is found.updateAssociationto prevent updating an association to a state that would duplicate an existing one.isDuplicateAssociationto encapsulate the logic for detecting duplicates, usingCollectionUtilsandObjectsfor null safety and comparison.Related Issues
Merge Order
When should this PR be merged
[Please describe any preconditions that need to be addressed before we
can merge this pull request.]
Follow up actions
[List any possible follow-up actions here; for instance, testing data
migrations, software that we need to install on staging and production
environments.]
Developer Checklist (Mandatory)
product-isissue to track any behavioral change or migration impact.Checklist (for reviewing)
General
Functionality
Code
Tests
Security
Documentation