Skip to content

Commit

Permalink
fix(impl): [#199] add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmf committed Apr 9, 2024
1 parent fe4edeb commit b04026d
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class PolicyHelperTest {

@Test
void shouldFilterMapByPolicyId() {
void findBpnsByPolicyId_shouldFilterMapByPolicyId() {

// ARRANGE
final HashMap<String, List<Policy>> policyMap = new HashMap<>();
Expand All @@ -50,4 +50,23 @@ void shouldFilterMapByPolicyId() {
assertThat(result).containsExactlyInAnyOrder("BPN1", "BPN2", "BPN4");
}

@Test
void havingPolicyId_whenAppliedAsFilterToAListOfPolicies_shouldFilterByPolicyId() {

// ARRANGE
final String policyIdToFind = "policyToFind";
List<Policy> 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<Policy> result = policies.stream().filter(PolicyHelper.havingPolicyId(policyIdToFind)).toList();

// ASSERT
assertThat(result.stream().map(Policy::getPolicyId).toList()).hasSize(2).containsOnly(policyIdToFind);
}

}

0 comments on commit b04026d

Please sign in to comment.