Skip to content

Commit

Permalink
fix(policy-check):[eclipse-tractusx#649] add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmf committed Jul 12, 2024
1 parent 82836af commit 45f1977
Showing 1 changed file with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void shouldAcceptAndConstraint() {
}

@Test
void shouldNotAcceptAndConstraintWithOneLessElement() {
void shouldNotAcceptAndConstraintWithOneLessElement() { // TODO remove this duplicate test, see SubsetAndTests
final AndConstraint andConstraint = createAndConstraint(
List.of(createAtomicConstraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY,
TestConstants.STATUS_ACTIVE),
Expand All @@ -118,23 +118,44 @@ void shouldNotAcceptAndConstraintWithOneLessElement() {
assertThat(result).isFalse();
}

@Test
void shouldNotAcceptSubsetOfAndConstraints() {
@Nested
@DisplayName("Tests asserting that for AND all must match in both ways (no subset match allowed)")
class SubsetAndTests {
@Test
void shouldNotAcceptAndConstraintWithOneMoreElement() {

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 AndConstraint andConstraint = createAndConstraint(
List.of(createAtomicConstraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY,
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)));
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)));

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

assertThat(result).isFalse();
assertThat(result).isFalse();
}

@Test
void shouldNotAcceptAndConstraintWithOneLessElement() {

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.PURPOSE, TestConstants.ID_3_1_TRACE)));

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

assertThat(result).isFalse();
}
}

@Test
Expand Down

0 comments on commit 45f1977

Please sign in to comment.