Skip to content
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

Fix: Adjusted BPN validations on different operators #1456

Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: created specific validation for isAllOf operator
  • Loading branch information
danielkenji01 committed Jul 23, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
codesome Ganesh Vernekar
commit 4c6e6113b848bdaa21b7ca6c6019cf3995080dd3
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ public BusinessPartnerGroupFunction(BusinessPartnerStore store) {
OPERATOR_EVALUATOR_MAP.put(EQ, this::evaluateEquals);
OPERATOR_EVALUATOR_MAP.put(NEQ, this::evaluateNotEquals);
OPERATOR_EVALUATOR_MAP.put(IN, this::evaluateIn);
OPERATOR_EVALUATOR_MAP.put(IS_ALL_OF, this::evaluateEquals);
OPERATOR_EVALUATOR_MAP.put(IS_ALL_OF, this::evaluateIsAllOf);
OPERATOR_EVALUATOR_MAP.put(IS_ANY_OF, this::evaluateIn);
OPERATOR_EVALUATOR_MAP.put(IS_NONE_OF, this::evaluateNotEquals);
}
@@ -177,6 +177,14 @@ private Boolean evaluateEquals(BpnGroupHolder bpnGroupHolder) {
return bpnGroupHolder.allowedGroups.equals(bpnGroupHolder.assignedGroups);
}

private boolean evaluateIsAllOf(BpnGroupHolder bpnGroupHolder) {
var assigned = bpnGroupHolder.assignedGroups;
return bpnGroupHolder.allowedGroups
.stream()
.distinct()
.allMatch(assigned::contains);
}

/**
* Internal utility class to hold the list of assigned groups for a BPN, and the list of groups specified in the policy ("allowed groups").
*/
Original file line number Diff line number Diff line change
@@ -183,7 +183,9 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext extensionCo

Arguments.of("Disjoint groups", IS_ALL_OF, List.of("different-group", "another-different-group"), false),
Arguments.of("Matching groups", IS_ALL_OF, List.of(TEST_GROUP_1, TEST_GROUP_2), true),
Arguments.of("Overlapping groups", IS_ALL_OF, List.of(TEST_GROUP_1, TEST_GROUP_2, "different-group", "another-different-group"), false),
Arguments.of("Overlapping groups", IS_ALL_OF, List.of(TEST_GROUP_1, TEST_GROUP_2, "different-group", "another-different-group"), true),
Arguments.of("Overlapping groups (1 overlap)", IS_ALL_OF, List.of(TEST_GROUP_1, "different-group"), false),
Arguments.of("Overlapping groups (1 overlap)", IS_ALL_OF, List.of(TEST_GROUP_1), false),


Arguments.of("Disjoint groups", IS_ANY_OF, List.of("different-group", "another-different-group"), false),