From 0b15f3bf60162a62505593186737bca98bd4349c Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 8 Apr 2019 17:30:54 +0000 Subject: 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 --- .../policy/models/pdp/concepts/PdpGroupFilter.java | 98 +++++-- .../policy/models/pdp/concepts/ModelsTest.java | 46 ++++ .../models/pdp/concepts/PdpGroupFilterTest.java | 222 ++++++++++++++++ .../policy/models/pdp/concepts/PdpGroupTest.java | 111 ++++++++ .../pdp/concepts/PdpInstanceDetailsTest.java | 52 ++++ .../policy/models/pdp/concepts/PdpMessageTest.java | 160 ++++++++++++ .../models/pdp/concepts/PdpStateChangeTest.java | 53 ++++ .../models/pdp/concepts/PdpSubGroupTest.java | 83 ++++++ .../policy/models/pdp/concepts/PdpUpdateTest.java | 74 ++++++ .../policy/models/pdp/concepts/TestModels.java | 46 ---- .../policy/models/pdp/concepts/TestPdpGroup.java | 111 -------- .../pdp/concepts/TestPdpInstanceDetails.java | 52 ---- .../policy/models/pdp/concepts/TestPdpMessage.java | 160 ------------ .../models/pdp/concepts/TestPdpStateChange.java | 53 ---- .../models/pdp/concepts/TestPdpSubGroup.java | 83 ------ .../policy/models/pdp/concepts/TestPdpUpdate.java | 74 ------ .../resources/testdata/PdpGroupsForFiltering.json | 287 ++++++++++++++++++--- 17 files changed, 1119 insertions(+), 646 deletions(-) create mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java create mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java create mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java create mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java create mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java create mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java create mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java delete mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java delete mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpGroup.java delete mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpInstanceDetails.java delete mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpMessage.java delete mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpStateChange.java delete mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java delete mode 100644 models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpUpdate.java (limited to 'models-pdp') 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 { 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 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 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 { // @formatter:off List 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 { 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 { * 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 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 { * * @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 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 { 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 { 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 boolean areListsIdentical(final List leftList, List 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 boolean findSingleElement(final List listToSearch, List 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/ModelsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java new file mode 100644 index 000000000..d22642d98 --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +import org.junit.Test; +import org.onap.policy.common.utils.validation.ToStringTester; + +/** + * Class to perform unit testing of models. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public class ModelsTest { + + @Test + public void testPdpModels() { + final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester()) + .with(new GetterTester()).build(); + 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 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 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 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 identifierList = new ArrayList<>(); + + identifierList.add(new ToscaPolicyTypeIdentifier("Nonexistant", "1.2.3")); + PdpGroupFilter filter = + PdpGroupFilter.builder().policyTypeList(identifierList).build(); + List 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 identifierList = new ArrayList<>(); + + identifierList.add(new ToscaPolicyIdentifier("Nonexistant", "1.2.3")); + PdpGroupFilter filter = + PdpGroupFilter.builder().policyList(identifierList).build(); + List 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/PdpGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java new file mode 100644 index 000000000..77666b228 --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +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.Arrays; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import org.junit.Test; +import org.onap.policy.models.pdp.enums.PdpState; + +/** + * Test the copy constructor, as {@link ModelsTest} tests the other methods. + */ +public class PdpGroupTest { + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new PdpGroup(null)).isInstanceOf(NullPointerException.class); + + PdpGroup orig = new PdpGroup(); + + // verify with null values + assertEquals("PdpGroup(name=null, version=null, description=null, pdpGroupState=null, " + + "properties=null, pdpSubgroups=[])", new PdpGroup(orig).toString()); + + // verify with all values + orig.setDescription("my-descript"); + orig.setName("my-name"); + orig.setVersion("1.2.3"); + orig.setDescription("my-description"); + orig.setPdpGroupState(PdpState.SAFE); + + PdpSubGroup sub1 = new PdpSubGroup(); + sub1.setCurrentInstanceCount(10); + PdpSubGroup sub2 = new PdpSubGroup(); + sub2.setCurrentInstanceCount(11); + orig.setPdpSubgroups(Arrays.asList(sub1, sub2)); + + Map props = new TreeMap<>(); + props.put("key-A", "value-A"); + props.put("key-B", "value-B"); + orig.setProperties(props); + + assertEquals("PdpGroup(name=my-name, version=1.2.3, description=my-description, " + + "pdpGroupState=SAFE, properties={key-A=value-A, key-B=value-B}, " + + "pdpSubgroups=[PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], " + + "currentInstanceCount=10, desiredInstanceCount=0, properties=null, pdpInstances=[]), " + + "PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], currentInstanceCount=11, " + + "desiredInstanceCount=0, properties=null, pdpInstances=[])])", new PdpGroup(orig).toString()); + } + + @Test + public void testHashCode() { + PdpGroup group = new PdpGroup(); + group.setDescription("A"); + int hash = group.hashCode(); + + assertEquals(hash, group.hashCode()); + + group.setDescription("B"); + assertTrue(hash != group.hashCode()); + } + + @Test + public void testCompareTo() { + PdpGroup pdpGroup0 = new PdpGroup(); + pdpGroup0.setName("Name0"); + pdpGroup0.setVersion("1.2.3"); + + PdpGroup pdpGroup1 = new PdpGroup(); + pdpGroup1.setName("Name0"); + pdpGroup1.setVersion("1.2.3"); + + assertEquals(0, pdpGroup0.compareTo(pdpGroup1)); + + PdpGroups pdpGroups = new PdpGroups(); + pdpGroups.setGroups(new ArrayList<>()); + pdpGroups.getGroups().add(pdpGroup0); + pdpGroups.getGroups().add(pdpGroup1); + + List> mapList = pdpGroups.toMapList(); + + assertEquals(1, mapList.size()); + assertEquals(1, mapList.get(0).size()); + } +} diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java new file mode 100644 index 000000000..e1c76671a --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java @@ -0,0 +1,52 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.policy.models.pdp.enums.PdpHealthStatus; +import org.onap.policy.models.pdp.enums.PdpState; + +/** + * Test the copy constructor, as {@link ModelsTest} tests the other methods. + */ +public class PdpInstanceDetailsTest { + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new Pdp(null)).isInstanceOf(NullPointerException.class); + + Pdp orig = new Pdp(); + + // verify with null values + assertEquals(orig.toString(), new Pdp(orig).toString()); + + // verify with all values + orig.setHealthy(PdpHealthStatus.TEST_IN_PROGRESS); + orig.setInstanceId("my-instance"); + orig.setMessage("my-message"); + orig.setPdpState(PdpState.SAFE); + + assertEquals(orig.toString(), new Pdp(orig).toString()); + } +} diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java new file mode 100644 index 000000000..bc90f649b --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.policy.models.pdp.enums.PdpMessageType; + +/** + * Tests methods not already tested by {@link TestModels}. + */ +public class PdpMessageTest { + private static final String PDP_NAME = "pdpA"; + private static final String PDP_GROUP = "groupA"; + private static final String PDP_SUBGROUP = "subgroupA"; + private static final String DIFFERENT = "differentValue"; + + private PdpMessage message; + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new PdpMessage((PdpMessage) null)).isInstanceOf(NullPointerException.class); + + // verify with null values + message = new PdpMessage(PdpMessageType.PDP_STATE_CHANGE); + PdpMessage newmsg = new PdpMessage(message); + newmsg.setRequestId(message.getRequestId()); + newmsg.setTimestampMs(message.getTimestampMs()); + assertEquals(message.toString(), newmsg.toString()); + + // verify with all values + message = makeMessage(PDP_NAME, PDP_GROUP, PDP_SUBGROUP); + newmsg = new PdpMessage(message); + newmsg.setRequestId(message.getRequestId()); + newmsg.setTimestampMs(message.getTimestampMs()); + assertEquals(message.toString(), newmsg.toString()); + } + + @Test + public void testAppliesTo_NameCombos() { + /* + * Test cases where the name matches. + */ + for (String msgGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { + for (String msgSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { + message = makeMessage(PDP_NAME, msgGroup, msgSubgroup); + + for (String pdpGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { + for (String pdpSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { + assertTrue("name msg " + message + " pdp group " + pdpGroup + "/" + pdpSubgroup, + message.appliesTo(PDP_NAME, pdpGroup, pdpSubgroup)); + } + } + } + } + + /* + * Test cases where the name does not match. + */ + for (String msgGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { + for (String msgSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { + message = makeMessage(PDP_NAME, msgGroup, msgSubgroup); + + for (String pdpGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { + for (String pdpSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { + assertFalse("name msg " + message + " pdp group " + pdpGroup + "/" + pdpSubgroup, + message.appliesTo(DIFFERENT, pdpGroup, pdpSubgroup)); + } + } + } + } + } + + @Test + public void testAppliesTo_BroadcastGroup() { + /* + * Test cases where the group matches. + */ + for (String msgSubgroup : new String[] {null, PDP_SUBGROUP}) { + message = makeMessage(null, PDP_GROUP, msgSubgroup); + + assertTrue("group msg " + message, message.appliesTo(PDP_NAME, PDP_GROUP, PDP_SUBGROUP)); + } + + /* + * Test cases where the group does not match. + */ + for (String msgGroup : new String[] {null, PDP_GROUP}) { + for (String msgSubgroup : new String[] {null, PDP_SUBGROUP}) { + message = makeMessage(null, msgGroup, msgSubgroup); + + for (String pdpGroup : new String[] {null, DIFFERENT}) { + assertFalse("group msg " + message + " pdp group " + pdpGroup, + message.appliesTo(PDP_NAME, pdpGroup, PDP_SUBGROUP)); + } + } + } + } + + @Test + public void testAppliesTo_BroadcastSubGroup() { + /* + * Test cases where the subgroup matches. + */ + message = makeMessage(null, PDP_GROUP, PDP_SUBGROUP); + assertTrue("subgroup msg " + message, message.appliesTo(PDP_NAME, PDP_GROUP, PDP_SUBGROUP)); + + /* + * Test cases where the subgroup does not match. + */ + message = makeMessage(null, PDP_GROUP, PDP_SUBGROUP); + + for (String pdpSubgroup : new String[] {null, DIFFERENT}) { + assertFalse("subgroup msg " + message + " pdp subgroup " + pdpSubgroup, + message.appliesTo(PDP_NAME, PDP_GROUP, pdpSubgroup)); + } + } + + @Test + public void testAppliesTo_NullPdpName() { + message = makeMessage(PDP_NAME, PDP_GROUP, PDP_SUBGROUP); + + assertThatThrownBy(() -> message.appliesTo(null, PDP_GROUP, PDP_SUBGROUP)) + .isInstanceOf(NullPointerException.class); + + } + + private PdpMessage makeMessage(String pdpName, String pdpGroup, String pdpSubgroup) { + PdpMessage msg = new PdpMessage(PdpMessageType.PDP_STATE_CHANGE); + + msg.setName(pdpName); + msg.setPdpGroup(pdpGroup); + msg.setPdpSubgroup(pdpSubgroup); + + return msg; + } +} diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java new file mode 100644 index 000000000..f50d2a7b7 --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; + +import org.junit.Test; +import org.onap.policy.models.pdp.enums.PdpState; + +/** + * Test the copy constructor, as {@link ModelsTest} tests the other methods. + */ +public class PdpStateChangeTest { + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new PdpStateChange(null)).isInstanceOf(NullPointerException.class); + + PdpStateChange orig = new PdpStateChange(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpStateChange(orig).toString())); + + // verify with all values + orig.setName("my-name"); + orig.setPdpGroup("my-group"); + orig.setPdpSubgroup("my-subgroup"); + orig.setState(PdpState.SAFE); + + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpStateChange(orig).toString())); + } +} diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java new file mode 100644 index 000000000..4284f71c4 --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.Map; +import java.util.TreeMap; + +import org.junit.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; + +/** + * Test the copy constructor, as {@link ModelsTest} tests the other methods. + */ +public class PdpSubGroupTest { + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new PdpSubGroup(null)).isInstanceOf(NullPointerException.class); + + final PdpSubGroup orig = new PdpSubGroup(); + + // verify with null values + assertEquals( + "PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], " + + "currentInstanceCount=0, desiredInstanceCount=0, properties=null, pdpInstances=[])", + new PdpSubGroup(orig).toString()); + + // verify with all values + orig.setCurrentInstanceCount(10); + orig.setDesiredInstanceCount(11); + + final Pdp inst1 = new Pdp(); + inst1.setInstanceId("my-id-A"); + final Pdp inst2 = new Pdp(); + inst2.setInstanceId("my-id-B"); + orig.setPdpInstances(Arrays.asList(inst1, inst2)); + + orig.setPdpType("my-type"); + + final ToscaPolicyIdentifier pol1 = new ToscaPolicyIdentifier(); + pol1.setName("policy-A"); + pol1.setVersion("1.0.0"); + final ToscaPolicyIdentifier pol2 = new ToscaPolicyIdentifier(); + pol2.setName("policy-B"); + pol1.setVersion("2.0.0"); + orig.setPolicies(Arrays.asList(pol1, pol2)); + + final Map props = new TreeMap<>(); + props.put("key-A", "value-A"); + props.put("key-B", "value-B"); + orig.setProperties(props); + + final ToscaPolicyTypeIdentifier supp1 = new ToscaPolicyTypeIdentifier("supp-A", "1.2"); + final ToscaPolicyTypeIdentifier supp2 = new ToscaPolicyTypeIdentifier("supp-B", "3.4"); + orig.setSupportedPolicyTypes(Arrays.asList(supp1, supp2)); + + assertEquals(orig.toString(), new PdpSubGroup(orig).toString()); + } +} diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java new file mode 100644 index 000000000..8889e483f --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; + +import java.util.Arrays; +import java.util.List; +import org.junit.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; + +/** + * Test the copy constructor, as {@link ModelsTest} tests the other methods. + */ +public class PdpUpdateTest { + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new PdpUpdate(null)).isInstanceOf(NullPointerException.class); + + PdpUpdate orig = new PdpUpdate(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpUpdate(orig).toString())); + + // verify with all values + orig.setDescription("my-description"); + orig.setName("my-name"); + orig.setPdpGroup("my-group"); + orig.setPdpSubgroup("my-subgroup"); + orig.setPdpHeartbeatIntervalMs(30000L); + + ToscaPolicy policy1 = new ToscaPolicy(); + policy1.setName("policy-a"); + policy1.setVersion("1.2.3"); + + ToscaPolicy policy2 = new ToscaPolicy(); + policy2.setName("policy-b"); + policy2.setVersion("4.5.6"); + + List policies = Arrays.asList(policy1, policy2); + orig.setPolicies(policies); + + PdpUpdate other = new PdpUpdate(orig); + + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); + + // ensure list and items are not the same object + assertTrue(other.getPolicies() != policies); + assertTrue(other.getPolicies().get(0) != policies.get(0)); + } +} 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/TestModels.java deleted file mode 100644 index 1813dde7d..000000000 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -import org.junit.Test; -import org.onap.policy.common.utils.validation.ToStringTester; - -/** - * Class to perform unit testing of models. - * - * @author Ram Krishna Verma (ram.krishna.verma@est.tech) - */ -public class TestModels { - - @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()); - } -} 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/TestPdpGroup.java deleted file mode 100644 index 4698ece7b..000000000 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpGroup.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -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.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import org.junit.Test; -import org.onap.policy.models.pdp.enums.PdpState; - -/** - * Test the copy constructor, as {@link TestModels} tests the other methods. - */ -public class TestPdpGroup { - - @Test - public void testCopyConstructor() { - assertThatThrownBy(() -> new PdpGroup(null)).isInstanceOf(NullPointerException.class); - - PdpGroup orig = new PdpGroup(); - - // verify with null values - assertEquals("PdpGroup(name=null, version=null, description=null, pdpGroupState=null, " - + "properties=null, pdpSubgroups=[])", new PdpGroup(orig).toString()); - - // verify with all values - orig.setDescription("my-descript"); - orig.setName("my-name"); - orig.setVersion("1.2.3"); - orig.setDescription("my-description"); - orig.setPdpGroupState(PdpState.SAFE); - - PdpSubGroup sub1 = new PdpSubGroup(); - sub1.setCurrentInstanceCount(10); - PdpSubGroup sub2 = new PdpSubGroup(); - sub2.setCurrentInstanceCount(11); - orig.setPdpSubgroups(Arrays.asList(sub1, sub2)); - - Map props = new TreeMap<>(); - props.put("key-A", "value-A"); - props.put("key-B", "value-B"); - orig.setProperties(props); - - assertEquals("PdpGroup(name=my-name, version=1.2.3, description=my-description, " - + "pdpGroupState=SAFE, properties={key-A=value-A, key-B=value-B}, " - + "pdpSubgroups=[PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], " - + "currentInstanceCount=10, desiredInstanceCount=0, properties=null, pdpInstances=[]), " - + "PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], currentInstanceCount=11, " - + "desiredInstanceCount=0, properties=null, pdpInstances=[])])", new PdpGroup(orig).toString()); - } - - @Test - public void testHashCode() { - PdpGroup group = new PdpGroup(); - group.setDescription("A"); - int hash = group.hashCode(); - - assertEquals(hash, group.hashCode()); - - group.setDescription("B"); - assertTrue(hash != group.hashCode()); - } - - @Test - public void testCompareTo() { - PdpGroup pdpGroup0 = new PdpGroup(); - pdpGroup0.setName("Name0"); - pdpGroup0.setVersion("1.2.3"); - - PdpGroup pdpGroup1 = new PdpGroup(); - pdpGroup1.setName("Name0"); - pdpGroup1.setVersion("1.2.3"); - - assertEquals(0, pdpGroup0.compareTo(pdpGroup1)); - - PdpGroups pdpGroups = new PdpGroups(); - pdpGroups.setGroups(new ArrayList<>()); - pdpGroups.getGroups().add(pdpGroup0); - pdpGroups.getGroups().add(pdpGroup1); - - List> mapList = pdpGroups.toMapList(); - - assertEquals(1, mapList.size()); - assertEquals(1, mapList.get(0).size()); - } -} 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/TestPdpInstanceDetails.java deleted file mode 100644 index 79bb52ee8..000000000 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpInstanceDetails.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -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. - */ -public class TestPdpInstanceDetails { - - @Test - public void testCopyConstructor() { - assertThatThrownBy(() -> new Pdp(null)).isInstanceOf(NullPointerException.class); - - Pdp orig = new Pdp(); - - // verify with null values - assertEquals(orig.toString(), new Pdp(orig).toString()); - - // verify with all values - orig.setHealthy(PdpHealthStatus.TEST_IN_PROGRESS); - orig.setInstanceId("my-instance"); - orig.setMessage("my-message"); - orig.setPdpState(PdpState.SAFE); - - assertEquals(orig.toString(), new Pdp(orig).toString()); - } -} 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/TestPdpMessage.java deleted file mode 100644 index 0d3f591c7..000000000 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpMessage.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.models.pdp.enums.PdpMessageType; - -/** - * Tests methods not already tested by {@link TestModels}. - */ -public class TestPdpMessage { - private static final String PDP_NAME = "pdpA"; - private static final String PDP_GROUP = "groupA"; - private static final String PDP_SUBGROUP = "subgroupA"; - private static final String DIFFERENT = "differentValue"; - - private PdpMessage message; - - @Test - public void testCopyConstructor() { - assertThatThrownBy(() -> new PdpMessage((PdpMessage) null)).isInstanceOf(NullPointerException.class); - - // verify with null values - message = new PdpMessage(PdpMessageType.PDP_STATE_CHANGE); - PdpMessage newmsg = new PdpMessage(message); - newmsg.setRequestId(message.getRequestId()); - newmsg.setTimestampMs(message.getTimestampMs()); - assertEquals(message.toString(), newmsg.toString()); - - // verify with all values - message = makeMessage(PDP_NAME, PDP_GROUP, PDP_SUBGROUP); - newmsg = new PdpMessage(message); - newmsg.setRequestId(message.getRequestId()); - newmsg.setTimestampMs(message.getTimestampMs()); - assertEquals(message.toString(), newmsg.toString()); - } - - @Test - public void testAppliesTo_NameCombos() { - /* - * Test cases where the name matches. - */ - for (String msgGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { - for (String msgSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { - message = makeMessage(PDP_NAME, msgGroup, msgSubgroup); - - for (String pdpGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { - for (String pdpSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { - assertTrue("name msg " + message + " pdp group " + pdpGroup + "/" + pdpSubgroup, - message.appliesTo(PDP_NAME, pdpGroup, pdpSubgroup)); - } - } - } - } - - /* - * Test cases where the name does not match. - */ - for (String msgGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { - for (String msgSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { - message = makeMessage(PDP_NAME, msgGroup, msgSubgroup); - - for (String pdpGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { - for (String pdpSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { - assertFalse("name msg " + message + " pdp group " + pdpGroup + "/" + pdpSubgroup, - message.appliesTo(DIFFERENT, pdpGroup, pdpSubgroup)); - } - } - } - } - } - - @Test - public void testAppliesTo_BroadcastGroup() { - /* - * Test cases where the group matches. - */ - for (String msgSubgroup : new String[] {null, PDP_SUBGROUP}) { - message = makeMessage(null, PDP_GROUP, msgSubgroup); - - assertTrue("group msg " + message, message.appliesTo(PDP_NAME, PDP_GROUP, PDP_SUBGROUP)); - } - - /* - * Test cases where the group does not match. - */ - for (String msgGroup : new String[] {null, PDP_GROUP}) { - for (String msgSubgroup : new String[] {null, PDP_SUBGROUP}) { - message = makeMessage(null, msgGroup, msgSubgroup); - - for (String pdpGroup : new String[] {null, DIFFERENT}) { - assertFalse("group msg " + message + " pdp group " + pdpGroup, - message.appliesTo(PDP_NAME, pdpGroup, PDP_SUBGROUP)); - } - } - } - } - - @Test - public void testAppliesTo_BroadcastSubGroup() { - /* - * Test cases where the subgroup matches. - */ - message = makeMessage(null, PDP_GROUP, PDP_SUBGROUP); - assertTrue("subgroup msg " + message, message.appliesTo(PDP_NAME, PDP_GROUP, PDP_SUBGROUP)); - - /* - * Test cases where the subgroup does not match. - */ - message = makeMessage(null, PDP_GROUP, PDP_SUBGROUP); - - for (String pdpSubgroup : new String[] {null, DIFFERENT}) { - assertFalse("subgroup msg " + message + " pdp subgroup " + pdpSubgroup, - message.appliesTo(PDP_NAME, PDP_GROUP, pdpSubgroup)); - } - } - - @Test - public void testAppliesTo_NullPdpName() { - message = makeMessage(PDP_NAME, PDP_GROUP, PDP_SUBGROUP); - - assertThatThrownBy(() -> message.appliesTo(null, PDP_GROUP, PDP_SUBGROUP)) - .isInstanceOf(NullPointerException.class); - - } - - private PdpMessage makeMessage(String pdpName, String pdpGroup, String pdpSubgroup) { - PdpMessage msg = new PdpMessage(PdpMessageType.PDP_STATE_CHANGE); - - msg.setName(pdpName); - msg.setPdpGroup(pdpGroup); - msg.setPdpSubgroup(pdpSubgroup); - - return msg; - } -} 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/TestPdpStateChange.java deleted file mode 100644 index 55eaedc26..000000000 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpStateChange.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; - -import org.junit.Test; -import org.onap.policy.models.pdp.enums.PdpState; - -/** - * Test the copy constructor, as {@link TestModels} tests the other methods. - */ -public class TestPdpStateChange { - - @Test - public void testCopyConstructor() { - assertThatThrownBy(() -> new PdpStateChange(null)).isInstanceOf(NullPointerException.class); - - PdpStateChange orig = new PdpStateChange(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpStateChange(orig).toString())); - - // verify with all values - orig.setName("my-name"); - orig.setPdpGroup("my-group"); - orig.setPdpSubgroup("my-subgroup"); - orig.setState(PdpState.SAFE); - - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpStateChange(orig).toString())); - } -} 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/TestPdpSubGroup.java deleted file mode 100644 index c80745d76..000000000 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.Map; -import java.util.TreeMap; - -import org.junit.Test; -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. - */ -public class TestPdpSubGroup { - - @Test - public void testCopyConstructor() { - assertThatThrownBy(() -> new PdpSubGroup(null)).isInstanceOf(NullPointerException.class); - - final PdpSubGroup orig = new PdpSubGroup(); - - // verify with null values - assertEquals( - "PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], " - + "currentInstanceCount=0, desiredInstanceCount=0, properties=null, pdpInstances=[])", - new PdpSubGroup(orig).toString()); - - // verify with all values - orig.setCurrentInstanceCount(10); - orig.setDesiredInstanceCount(11); - - final Pdp inst1 = new Pdp(); - inst1.setInstanceId("my-id-A"); - final Pdp inst2 = new Pdp(); - inst2.setInstanceId("my-id-B"); - orig.setPdpInstances(Arrays.asList(inst1, inst2)); - - orig.setPdpType("my-type"); - - final ToscaPolicyIdentifier pol1 = new ToscaPolicyIdentifier(); - pol1.setName("policy-A"); - pol1.setVersion("1.0.0"); - final ToscaPolicyIdentifier pol2 = new ToscaPolicyIdentifier(); - pol2.setName("policy-B"); - pol1.setVersion("2.0.0"); - orig.setPolicies(Arrays.asList(pol1, pol2)); - - final Map props = new TreeMap<>(); - props.put("key-A", "value-A"); - props.put("key-B", "value-B"); - orig.setProperties(props); - - final ToscaPolicyTypeIdentifier supp1 = new ToscaPolicyTypeIdentifier("supp-A", "1.2"); - final ToscaPolicyTypeIdentifier supp2 = new ToscaPolicyTypeIdentifier("supp-B", "3.4"); - orig.setSupportedPolicyTypes(Arrays.asList(supp1, supp2)); - - assertEquals(orig.toString(), new PdpSubGroup(orig).toString()); - } -} 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/TestPdpUpdate.java deleted file mode 100644 index b366088d1..000000000 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpUpdate.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; - -import java.util.Arrays; -import java.util.List; -import org.junit.Test; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; - -/** - * Test the copy constructor, as {@link TestModels} tests the other methods. - */ -public class TestPdpUpdate { - - @Test - public void testCopyConstructor() { - assertThatThrownBy(() -> new PdpUpdate(null)).isInstanceOf(NullPointerException.class); - - PdpUpdate orig = new PdpUpdate(); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpUpdate(orig).toString())); - - // verify with all values - orig.setDescription("my-description"); - orig.setName("my-name"); - orig.setPdpGroup("my-group"); - orig.setPdpSubgroup("my-subgroup"); - orig.setPdpHeartbeatIntervalMs(30000L); - - ToscaPolicy policy1 = new ToscaPolicy(); - policy1.setName("policy-a"); - policy1.setVersion("1.2.3"); - - ToscaPolicy policy2 = new ToscaPolicy(); - policy2.setName("policy-b"); - policy2.setVersion("4.5.6"); - - List policies = Arrays.asList(policy1, policy2); - orig.setPolicies(policies); - - PdpUpdate other = new PdpUpdate(orig); - - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); - - // ensure list and items are not the same object - assertTrue(other.getPolicies() != policies); - assertTrue(other.getPolicies().get(0) != policies.get(0)); - } -} 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", -- cgit 1.2.3-korg