From b04026d5ae90ba3eec5e1a6233a176d2c4966260 Mon Sep 17 00:00:00 2001 From: Matthias Fischer Date: Tue, 9 Apr 2024 12:31:03 +0200 Subject: [PATCH] fix(impl): [#199] add test --- .../services/PolicyHelperTest.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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); + } + }