diff options
author | liamfallon <liam.fallon@est.tech> | 2019-04-08 17:30:54 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-04-08 17:30:54 +0000 |
commit | 0b15f3bf60162a62505593186737bca98bd4349c (patch) | |
tree | 0935b5d9321c9a988256741309d9dfdb688f4521 /models-pdp | |
parent | a32b49c3ec54e5f3bf23634a5fb538909905f8e6 (diff) |
Add lists and tests for PDP filters
The policy type and policy filters for PDP groups are added
in this review.
Also filter tests for PDP group filter is completed.
Issue-ID: POLICY-1095
Change-Id: Ia28776c809f2ab879af4007b3480621637a83f69
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-pdp')
-rw-r--r-- | models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java | 98 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java (renamed from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java) | 4 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java | 222 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java (renamed from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpGroup.java) | 4 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java (renamed from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpInstanceDetails.java) | 4 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java (renamed from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpMessage.java) | 2 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java (renamed from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpStateChange.java) | 4 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java (renamed from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java) | 4 | ||||
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java (renamed from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpUpdate.java) | 4 | ||||
-rw-r--r-- | models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json | 287 |
10 files changed, 553 insertions, 80 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java index 3c07a9d0f..0f86c6890 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java @@ -43,23 +43,33 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { public static final String LATEST_VERSION = "LATEST"; - // Regular expression + // Name to find private String name; - // Regular Expression, set to to get the latest version + // Version to find, set to LATEST_VERSION to get the latest version private String version; + // State to find private PdpState groupState; - // Regular expression + // PDP type to find private String pdpType; // Set regular expressions on fields to match policy type names and versions - private ToscaPolicyTypeIdentifier policyType; + private List<ToscaPolicyTypeIdentifier> policyTypeList; + + // If set, only PDP groups where policy types are matched exactly are returned + @Builder.Default + private boolean matchPolicyTypesExactly = false; // Set regular expressions on fields to match policy names and versions - private ToscaPolicyIdentifier policy; + private List<ToscaPolicyIdentifier> policyList; + + // If set, only PDP groups where policies are matched exactly are returned + @Builder.Default + private boolean matchPoliciesExactly = false; + // If set, only PDP groups with PDPs in this state are returned private PdpState pdpState; @Override @@ -68,15 +78,15 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { // @formatter:off List<PdpGroup> returnList = originalList.stream() .filter(p -> filterString(p.getName(), name)) - .filter(p -> (version != null && LATEST_VERSION.equals(version)) + .filter(p -> LATEST_VERSION.equals(version) || filterString(p.getVersion(), version)) .filter(p -> groupState == null || ObjectUtils.compare(p.getPdpGroupState(), groupState) == 0) .filter(p -> filterOnPdpType(p, pdpType)) - .filter(p -> filterOnPolicyType(p, policyType)) - .filter(p -> filterOnPolicy(p, policy)) + .filter(p -> filterOnPolicyTypeList(p, policyTypeList, matchPolicyTypesExactly)) + .filter(p -> filterOnPolicyList(p, policyList, matchPoliciesExactly)) .filter(p -> filterOnPdpState(p, pdpState)) .collect(Collectors.toList()); - // @formatter:off + // @formatter:on if (LATEST_VERSION.equals(version)) { returnList = this.latestVersionFilter(returnList); @@ -97,7 +107,7 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { return true; } - for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) { + for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) { if (pdpSubGroup.getPdpType().equals(pdpType)) { return true; } @@ -110,24 +120,27 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { * Filter PDP groups on policy type. * * @param pdpGroup the PDP group to check - * @param policyTypeFilter the policy type regular expressions to check for + * @param typeFilter the policy type regular expressions to check for + * @param matchPolicyTypesExactly if true, only PDP groups where policy types are matched exactly are returned * @return true if the filter should let this PDP group through */ - private boolean filterOnPolicyType(final PdpGroup pdpGroup, final ToscaPolicyTypeIdentifier policyTypeFiler) { - if (policyTypeFiler == null) { + private boolean filterOnPolicyTypeList(final PdpGroup pdpGroup, final List<ToscaPolicyTypeIdentifier> typeFilter, + final boolean matchPolicyTypesExactly) { + if (typeFilter == null) { return true; } - for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) { - for (ToscaPolicyTypeIdentifier foundPolicyType : pdpSubGroup.getSupportedPolicyTypes()) { - if (foundPolicyType.getName().matches(policyTypeFiler.getName()) - && foundPolicyType.getVersion().matches(policyTypeFiler.getVersion())) { - return true; - } + for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) { + if (matchPolicyTypesExactly && areListsIdentical(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { + return true; + } else if (!matchPolicyTypesExactly + && findSingleElement(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { + return true; } } return false; + } /** @@ -135,19 +148,20 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { * * @param pdpGroup the PDP group to check * @param policyFilter the policy regular expressions to check for + * @param matchPoliciesExactly if true, only PDP groups where ps are matched exactly are returned * @return true if the filter should let this PDP group through */ - private boolean filterOnPolicy(final PdpGroup pdpGroup, final ToscaPolicyIdentifier policyFiler) { - if (policyFiler == null) { + private boolean filterOnPolicyList(final PdpGroup pdpGroup, final List<ToscaPolicyIdentifier> policyFilter, + final boolean matchPoliciesExactly) { + if (policyFilter == null) { return true; } - for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) { - for (ToscaPolicyIdentifier foundPolicy : pdpSubGroup.getPolicies()) { - if (foundPolicy.getName().matches(policyFiler.getName()) - && foundPolicy.getVersion().matches(policyFiler.getVersion())) { - return true; - } + for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) { + if (matchPoliciesExactly && areListsIdentical(pdpSubGroup.getPolicies(), policyFilter)) { + return true; + } else if (!matchPoliciesExactly && findSingleElement(pdpSubGroup.getPolicies(), policyFilter)) { + return true; } } @@ -166,7 +180,7 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { return true; } - for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) { + for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) { for (Pdp pdp : pdpSubGroup.getPdpInstances()) { if (pdpState.equals(pdp.getPdpState())) { return true; @@ -176,4 +190,32 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { return false; } + + /** + * Check if two lists have identical content. + * + * @param leftList the left list + * @param rightList the right list + * @return true if the lists are identical + */ + private <T> boolean areListsIdentical(final List<T> leftList, List<T> rightList) { + return leftList.equals(rightList); + } + + /** + * Find a single element of a list in a list. + * + * @param listToSearch the list in which we are searching for elements + * @param listOfElementsToFind the list of elements, one of which we wish to find on the list we are searching + * @return true if one element of the elements to find is found on the list we searched + */ + private <T> boolean findSingleElement(final List<T> listToSearch, List<T> listOfElementsToFind) { + for (Object elementToFind : listOfElementsToFind) { + if (listToSearch.contains(elementToFind)) { + return true; + } + } + + return false; + } } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java index 1813dde7d..d22642d98 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java @@ -35,12 +35,12 @@ import org.onap.policy.common.utils.validation.ToStringTester; * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ -public class TestModels { +public class ModelsTest { @Test public void testPdpModels() { final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester()) .with(new GetterTester()).build(); - validator.validate(TestModels.class.getPackage().getName(), new FilterPackageInfo()); + validator.validate(ModelsTest.class.getPackage().getName(), new FilterPackageInfo()); } } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java index 61974dc89..75ec4d169 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java @@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; import java.util.List; import org.junit.Before; @@ -31,6 +32,9 @@ import org.junit.Test; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.pdp.enums.PdpState; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; /** * Test of the {@link PdpGroupFilter} class. @@ -105,4 +109,222 @@ public class PdpGroupFilterTest { filteredList = filter.filter(pdpGroupList); assertEquals(0, filteredList.size()); } + + @Test + public void testFilterPdpGroupState() { + PdpGroupFilter filter = PdpGroupFilter.builder().groupState(PdpState.ACTIVE).build(); + List<PdpGroup> filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + + filter = PdpGroupFilter.builder().groupState(PdpState.PASSIVE).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(2, filteredList.size()); + + filter = PdpGroupFilter.builder().groupState(PdpState.TEST).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + + filter = PdpGroupFilter.builder().groupState(PdpState.SAFE).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + + filter = PdpGroupFilter.builder().groupState(PdpState.TERMINATED).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(0, filteredList.size()); + } + + @Test + public void testFilterPdpType() { + PdpGroupFilter filter = PdpGroupFilter.builder().pdpType("APEX").build(); + List<PdpGroup> filteredList = filter.filter(pdpGroupList); + assertEquals(5, filteredList.size()); + + filter = PdpGroupFilter.builder().pdpType("DROOLS").build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(2, filteredList.size()); + + filter = PdpGroupFilter.builder().pdpType("XACML").build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + } + + @Test + public void testFilterPdpState() { + PdpGroupFilter filter = PdpGroupFilter.builder().pdpState(PdpState.ACTIVE).build(); + List<PdpGroup> filteredList = filter.filter(pdpGroupList); + assertEquals(3, filteredList.size()); + + filter = PdpGroupFilter.builder().pdpState(PdpState.PASSIVE).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(3, filteredList.size()); + + filter = PdpGroupFilter.builder().pdpState(PdpState.SAFE).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(2, filteredList.size()); + + filter = PdpGroupFilter.builder().pdpState(PdpState.TEST).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(2, filteredList.size()); + } + + @Test + public void testFilterPolicyType() { + List<ToscaPolicyTypeIdentifier> identifierList = new ArrayList<>(); + + identifierList.add(new ToscaPolicyTypeIdentifier("Nonexistant", "1.2.3")); + PdpGroupFilter filter = + PdpGroupFilter.builder().policyTypeList(identifierList).build(); + List<PdpGroup> filteredList = filter.filter(pdpGroupList); + assertEquals(0, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(4, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(4, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.2", "7.8.9")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(2, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.3", "0.1.2")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(2, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyTypeIdentifier("Nonexistant", "1.2.3")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "9.9.9")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.2", "7.8.9")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.3", "0.1.2")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(5, filteredList.size()); + + filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(0, filteredList.size()); + + identifierList.clear(); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(2, filteredList.size()); + + identifierList.clear(); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.2", "7.8.9")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + + identifierList.clear(); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.3", "0.1.2")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + + identifierList.clear(); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6")); + identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.3", "0.1.2")); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + } + + @Test + public void testFilterPolicy() { + List<ToscaPolicyIdentifier> identifierList = new ArrayList<>(); + + identifierList.add(new ToscaPolicyIdentifier("Nonexistant", "1.2.3")); + PdpGroupFilter filter = + PdpGroupFilter.builder().policyList(identifierList).build(); + List<PdpGroup> filteredList = filter.filter(pdpGroupList); + assertEquals(0, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyIdentifier("Policy0", "9.9.9")); + filter = PdpGroupFilter.builder().policyList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(0, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6")); + filter = PdpGroupFilter.builder().policyList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(4, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyIdentifier("Policy1", "4.5.6")); + filter = PdpGroupFilter.builder().policyList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyIdentifier("Policy2", "4.5.6")); + filter = PdpGroupFilter.builder().policyList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(2, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyIdentifier("Policy3", "1.2.3")); + filter = PdpGroupFilter.builder().policyList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + identifierList.clear(); + + identifierList.add(new ToscaPolicyIdentifier("Nonexistant", "1.2.3")); + identifierList.add(new ToscaPolicyIdentifier("Policy0", "9.9.9")); + identifierList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6")); + identifierList.add(new ToscaPolicyIdentifier("Policy1", "4.5.6")); + identifierList.add(new ToscaPolicyIdentifier("Policy2", "4.5.6")); + identifierList.add(new ToscaPolicyIdentifier("Policy3", "1.2.3")); + filter = PdpGroupFilter.builder().policyList(identifierList).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(5, filteredList.size()); + + filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(0, filteredList.size()); + + identifierList.clear(); + identifierList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6")); + filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(3, filteredList.size()); + + identifierList.clear(); + identifierList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6")); + identifierList.add(new ToscaPolicyIdentifier("Policy1", "4.5.6")); + filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + + identifierList.clear(); + identifierList.add(new ToscaPolicyIdentifier("Policy2", "4.5.6")); + filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + + identifierList.clear(); + identifierList.add(new ToscaPolicyIdentifier("Policy2", "4.5.6")); + identifierList.add(new ToscaPolicyIdentifier("Policy3", "1.2.3")); + filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build(); + filteredList = filter.filter(pdpGroupList); + assertEquals(1, filteredList.size()); + } } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpGroup.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java index 4698ece7b..77666b228 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpGroup.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java @@ -34,9 +34,9 @@ import org.junit.Test; import org.onap.policy.models.pdp.enums.PdpState; /** - * Test the copy constructor, as {@link TestModels} tests the other methods. + * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class TestPdpGroup { +public class PdpGroupTest { @Test public void testCopyConstructor() { diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpInstanceDetails.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java index 79bb52ee8..e1c76671a 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpInstanceDetails.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java @@ -28,9 +28,9 @@ import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpState; /** - * Test the copy constructor, as {@link TestModels} tests the other methods. + * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class TestPdpInstanceDetails { +public class PdpInstanceDetailsTest { @Test public void testCopyConstructor() { diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpMessage.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java index 0d3f591c7..bc90f649b 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpMessage.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java @@ -32,7 +32,7 @@ import org.onap.policy.models.pdp.enums.PdpMessageType; /** * Tests methods not already tested by {@link TestModels}. */ -public class TestPdpMessage { +public class PdpMessageTest { private static final String PDP_NAME = "pdpA"; private static final String PDP_GROUP = "groupA"; private static final String PDP_SUBGROUP = "subgroupA"; diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpStateChange.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java index 55eaedc26..f50d2a7b7 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpStateChange.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java @@ -29,9 +29,9 @@ import org.junit.Test; import org.onap.policy.models.pdp.enums.PdpState; /** - * Test the copy constructor, as {@link TestModels} tests the other methods. + * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class TestPdpStateChange { +public class PdpStateChangeTest { @Test public void testCopyConstructor() { diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java index c80745d76..4284f71c4 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java @@ -33,9 +33,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; /** - * Test the copy constructor, as {@link TestModels} tests the other methods. + * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class TestPdpSubGroup { +public class PdpSubGroupTest { @Test public void testCopyConstructor() { diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpUpdate.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java index b366088d1..8889e483f 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpUpdate.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java @@ -32,9 +32,9 @@ import org.junit.Test; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** - * Test the copy constructor, as {@link TestModels} tests the other methods. + * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class TestPdpUpdate { +public class PdpUpdateTest { @Test public void testCopyConstructor() { diff --git a/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json b/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json index c62e1ea58..623ee4e23 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json +++ b/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json @@ -1,73 +1,133 @@ { - "groups": [ + "groups": + [ { "name": "PdpGroup0", "version": "1.2.3", "description": "group description", "pdpGroupState": "PASSIVE", - "properties": { + "properties": + { "groupProperty0": "Value of Group Property 0" }, - "pdpSubgroups": [ + + "pdpSubgroups": + [ { "pdpType": "APEX", - "supportedPolicyTypes": [ + "supportedPolicyTypes": + [ { "name": "policy.type.0", "version": "1.2.3" + }, + { + "name": "policy.type.1", + "version": "4.5.6" + }, + { + "name": "policy.type.2", + "version": "7.8.9" } ], - "policies": [ + + "policies": + [ { "name": "Policy0", "version": "4.5.6" + }, + { + "name": "Policy1", + "version": "4.5.6" } ], + "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": { + "properties": + { "subgroupProperty0": "Value of sub Group Property 0" }, - "pdpInstances": [ + + "pdpInstances": + [ { "instanceId": "apex-0", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", "message": "message from PDP" + }, + { + "instanceId": "apex-0", + "pdpState": "PASSIVE", + "healthy": "NOT_HEALTHY", + "message": "message from PDP" + }, + { + "instanceId": "apex-0", + "pdpState": "SAFE", + "healthy": "NOT_HEALTHY", + "message": "message from PDP" + }, + { + "instanceId": "apex-0", + "pdpState": "TEST", + "healthy": "NOT_HEALTHY", + "message": "message from PDP" } ] } ] }, + { "name": "PdpGroup0", "version": "1.2.4", "description": "group description", - "pdpGroupState": "PASSIVE", - "properties": { + "pdpGroupState": "ACTIVE", + "properties": + { "groupProperty0": "Value of Group Property 0" }, - "pdpSubgroups": [ + + "pdpSubgroups": + [ { "pdpType": "APEX", - "supportedPolicyTypes": [ + "supportedPolicyTypes": + [ { "name": "policy.type.0", "version": "1.2.3" + }, + { + "name": "policy.type.1", + "version": "4.5.6" + }, + { + "name": "policy.type.3", + "version": "0.1.2" } ], - "policies": [ + + "policies": + [ { - "name": "Policy0", + "name": "Policy2", "version": "4.5.6" } ], + "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": { + "properties": + { "subgroupProperty0": "Value of sub Group Property 0" }, - "pdpInstances": [ + + "pdpInstances": + [ { "instanceId": "apex-0", "pdpState": "ACTIVE", @@ -78,38 +138,92 @@ } ] }, + { "name": "PdpGroup0", "version": "1.2.1", "description": "group description", - "pdpGroupState": "PASSIVE", - "properties": { + "pdpGroupState": "SAFE", + "properties": + { "groupProperty0": "Value of Group Property 0" }, - "pdpSubgroups": [ + + "pdpSubgroups": + [ { "pdpType": "APEX", - "supportedPolicyTypes": [ + "supportedPolicyTypes": + [ + { + "name": "policy.type.1", + "version": "4.5.6" + }, + { + "name": "policy.type.3", + "version": "0.1.2" + } + ], + + "policies": + [ + { + "name": "Policy2", + "version": "4.5.6" + }, + { + "name": "Policy3", + "version": "1.2.3" + } + ], + + "currentInstanceCount": 123, + "desiredInstanceCount": 456, + "properties": + { + "subgroupProperty0": "Value of sub Group Property 0" + }, + + "pdpInstances": + [ + { + "instanceId": "apex-0", + "pdpState": "SAFE", + "healthy": "NOT_HEALTHY", + "message": "message from PDP" + } + ] + }, + { + "pdpType": "DROOLS", + "supportedPolicyTypes": + [ { "name": "policy.type.0", "version": "1.2.3" } ], - "policies": [ + + "policies": + [ { "name": "Policy0", "version": "4.5.6" } ], + "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": { + "properties": + { "subgroupProperty0": "Value of sub Group Property 0" }, - "pdpInstances": [ + + "pdpInstances": + [ { "instanceId": "apex-0", - "pdpState": "ACTIVE", + "pdpState": "SAFE", "healthy": "NOT_HEALTHY", "message": "message from PDP" } @@ -122,33 +236,47 @@ "version": "1.2.1", "description": "group description", "pdpGroupState": "PASSIVE", - "properties": { + "properties": + { "groupProperty0": "Value of Group Property 0" }, - "pdpSubgroups": [ + + "pdpSubgroups": + [ { "pdpType": "APEX", - "supportedPolicyTypes": [ + "supportedPolicyTypes": + [ { - "name": "policy.type.0", - "version": "1.2.3" + "name": "policy.type.1", + "version": "4.5.6" + }, + { + "name": "policy.type.2", + "version": "7.8.9" } ], - "policies": [ + + "policies": + [ { "name": "Policy0", "version": "4.5.6" } ], + "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": { + "properties": + { "subgroupProperty0": "Value of sub Group Property 0" }, - "pdpInstances": [ + + "pdpInstances": + [ { "instanceId": "apex-0", - "pdpState": "ACTIVE", + "pdpState": "PASSIVE", "healthy": "NOT_HEALTHY", "message": "message from PDP" } @@ -156,35 +284,116 @@ } ] }, + { "name": "PdpGroup1", "version": "1.2.3", "description": "group description", - "pdpGroupState": "PASSIVE", - "properties": { + "pdpGroupState": "TEST", + "properties": + { "groupProperty0": "Value of Group Property 0" }, - "pdpSubgroups": [ + + "pdpSubgroups": + [ { "pdpType": "APEX", - "supportedPolicyTypes": [ + "supportedPolicyTypes": + [ + { + "name": "policy.type.0", + "version": "1.2.3" + } + ], + + "policies": + [ + { + "name": "Policy0", + "version": "4.5.6" + } + ], + + "currentInstanceCount": 123, + "desiredInstanceCount": 456, + "properties": + { + "subgroupProperty0": "Value of sub Group Property 0" + }, + + "pdpInstances": + [ + { + "instanceId": "apex-0", + "pdpState": "TEST", + "healthy": "NOT_HEALTHY", + "message": "message from PDP" + } + ] + }, + { + "pdpType": "DROOLS", + "supportedPolicyTypes": + [ + { + "name": "policy.type.0", + "version": "1.2.3" + } + ], + + "policies": + [ + { + "name": "Policy0", + "version": "4.5.6" + } + ], + + "currentInstanceCount": 123, + "desiredInstanceCount": 456, + "properties": + { + "subgroupProperty0": "Value of sub Group Property 0" + }, + + "pdpInstances": + [ + { + "instanceId": "apex-0", + "pdpState": "PASSIVE", + "healthy": "NOT_HEALTHY", + "message": "message from PDP" + } + ] + }, + { + "pdpType": "XACML", + "supportedPolicyTypes": + [ { "name": "policy.type.0", "version": "1.2.3" } ], - "policies": [ + + "policies": + [ { "name": "Policy0", "version": "4.5.6" } ], + "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": { + "properties": + { "subgroupProperty0": "Value of sub Group Property 0" }, - "pdpInstances": [ + + "pdpInstances": + [ { "instanceId": "apex-0", "pdpState": "ACTIVE", |