+ @Test
+ public void testGetAllPolicyStatusPfDao() throws PfModelException {
+ assertThatThrownBy(() -> {
+ new PdpProvider().getAllPolicyStatus(null);
+ }).hasMessageMatching(DAO_IS_NULL);
+
+ assertThat(new PdpProvider().getAllPolicyStatus(pfDao)).isEmpty();
+
+ PdpProvider provider = loadDeployments();
+ assertThat(provider.getAllPolicyStatus(pfDao)).hasSize(5);
+ }
+
+ private PdpProvider loadDeployments() {
+ PdpProvider provider = new PdpProvider();
+
+ // same name, different version
+ final ToscaConceptIdentifier policy3 = new ToscaConceptIdentifier(MY_POLICY.getName(), "10.20.30");
+
+ PdpPolicyStatus id1 = statusBuilder.pdpGroup(GROUP_A).pdpId("pdp1").policy(MY_POLICY).build();
+ PdpPolicyStatus id2 = statusBuilder.pdpGroup(GROUP_A).pdpId("pdp2").policy(MY_POLICY2).build();
+ PdpPolicyStatus id3 = statusBuilder.pdpGroup(GROUP_A).pdpId("pdp3").policy(policy3).build();
+ PdpPolicyStatus id4 = statusBuilder.pdpGroup(GROUP_B).pdpId("pdp4").policy(MY_POLICY).build();
+ PdpPolicyStatus id5 = statusBuilder.pdpGroup(GROUP_B).pdpId("pdp5").policy(MY_POLICY2).build();
+ provider.cudPolicyStatus(pfDao, List.of(id1, id2, id3, id4, id5), null, null);
+
+ return provider;
+ }
+
+ @Test
+ public void testGetAllPolicyStatusPfDaoToscaConceptIdentifierOptVersion() throws PfModelException {
+ assertThatThrownBy(() -> {
+ new PdpProvider().getAllPolicyStatus(null, new ToscaConceptIdentifierOptVersion("somePdp", null));
+ }).hasMessageMatching(DAO_IS_NULL);
+
+ assertThatThrownBy(() -> {
+ new PdpProvider().getAllPolicyStatus(pfDao, null);
+ }).hasMessageContaining("policy").hasMessageContaining("null");
+
+ assertThat(new PdpProvider().getAllPolicyStatus(pfDao, new ToscaConceptIdentifierOptVersion("somePdp", null)))
+ .isEmpty();
+
+ PdpProvider provider = loadDeployments();
+ assertThat(provider.getAllPolicyStatus(pfDao, new ToscaConceptIdentifierOptVersion(MY_POLICY))).hasSize(2);
+ assertThat(provider.getAllPolicyStatus(pfDao, new ToscaConceptIdentifierOptVersion(MY_POLICY.getName(), null)))
+ .hasSize(3);
+ }
+