Skip to content

Commit

Permalink
fix(policy-validation):[eclipse-tractusx#649] trial to fix
Browse files Browse the repository at this point in the history
- but results in failures in PolicyCheckerServiceTest
  • Loading branch information
dsmf committed Jul 10, 2024
1 parent da3bc67 commit be349ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public boolean hasAllConstraint(final Policy acceptedPolicy, final List<Constrai

private boolean isValidOnList(final Constraint constraint, final List<Constraints> acceptedConstraintsList) {
return acceptedConstraintsList.stream()
.anyMatch(acceptedConstraints -> isSameAs(constraint, acceptedConstraints));
.allMatch(acceptedConstraints -> isSameAs(constraint, acceptedConstraints));
}

private boolean isSameAs(final Constraint constraint, final Constraints acceptedConstraints) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ void shouldNotAcceptAndConstraintWithOneLessElement() {
assertThat(result).isFalse();
}

@Test
void shouldNotAcceptSubsetOfAndConstraints() {

final AndConstraint andConstraint = createAndConstraint(
List.of(createAtomicConstraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY,
TestConstants.STATUS_ACTIVE),
createAtomicConstraint(TestConstants.MEMBERSHIP, TestConstants.STATUS_ACTIVE),
createAtomicConstraint(TestConstants.PURPOSE, TestConstants.ID_3_1_TRACE)));

final Policy acceptedPolicy = createPolicyWithAndConstraint(
List.of(new Operand(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY, TestConstants.STATUS_ACTIVE),
// new Operand(TestConstants.MEMBERSHIP, TestConstants.STATUS_ACTIVE),
new Operand(TestConstants.PURPOSE, TestConstants.ID_3_1_TRACE)));

boolean result = cut.hasAllConstraint(acceptedPolicy, List.of(andConstraint));

assertThat(result).isFalse();
}

@Test
void shouldRejectAndConstraintWhenOneIsDifferent() {
final AndConstraint andConstraint = createAndConstraint(
Expand Down

0 comments on commit be349ac

Please sign in to comment.