diff --git a/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/services/PolicyHelperTest.java b/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/services/PolicyHelperTest.java index 1362d7a7bb..8612ae2610 100644 --- a/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/services/PolicyHelperTest.java +++ b/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/services/PolicyHelperTest.java @@ -30,7 +30,7 @@ class PolicyHelperTest { @Test - void shouldFilterMapByPolicyId() { + void findBpnsByPolicyId_shouldFilterMapByPolicyId() { // ARRANGE final HashMap> policyMap = new HashMap<>(); @@ -50,4 +50,23 @@ void shouldFilterMapByPolicyId() { assertThat(result).containsExactlyInAnyOrder("BPN1", "BPN2", "BPN4"); } + @Test + void havingPolicyId_whenAppliedAsFilterToAListOfPolicies_shouldFilterByPolicyId() { + + // ARRANGE + final String policyIdToFind = "policyToFind"; + List policies = List.of( // + Policy.builder().policyId("policy1").build(), // + Policy.builder().policyId(policyIdToFind).build(), // + Policy.builder().policyId("policy3").build(), // + Policy.builder().policyId("policy4").build(), // + Policy.builder().policyId(policyIdToFind).build()); + + // ACT + final List result = policies.stream().filter(PolicyHelper.havingPolicyId(policyIdToFind)).toList(); + + // ASSERT + assertThat(result.stream().map(Policy::getPolicyId).toList()).hasSize(2).containsOnly(policyIdToFind); + } + }