From f2b0318f53abf9f2345a5cdca74f3dd635aa9b60 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 4 Jan 2021 12:15:18 +0000 Subject: Changed identifiers to concept identifiers The policy models tosca classes ToscaPolicyIdentifier and ToscaPolicyIdentifierOptVersion can be used to identify any TOSCA concept, not just TOSCA policies so they are renamed to ToscaConceptIdentifier and ToscaCinceptIdentifierOptVersion respectively. The class ToscaPolicyTypeIdentifier is redundant and is replaced by ToscaConceptIdentifier. Issue-ID: POLICY-2900 Change-Id: Id0a37c42ea4e74f07b47e1694c4f8291c35879c9 Signed-off-by: liamfallon --- .../models/pdp/concepts/DeploymentSubGroup.java | 9 ++- .../policy/models/pdp/concepts/PdpGroupFilter.java | 19 +++-- .../onap/policy/models/pdp/concepts/PdpStatus.java | 8 +- .../policy/models/pdp/concepts/PdpSubGroup.java | 17 ++-- .../pdp/persistence/concepts/JpaPdpSubGroup.java | 13 ++-- .../pdp/concepts/DeploymentSubGroupTest.java | 11 +-- .../models/pdp/concepts/PdpGroupFilterTest.java | 91 +++++++++++----------- .../policy/models/pdp/concepts/PdpGroupTest.java | 8 +- .../policy/models/pdp/concepts/PdpGroupsTest.java | 5 +- .../policy/models/pdp/concepts/PdpStatusTest.java | 6 +- .../models/pdp/concepts/PdpSubGroupTest.java | 25 +++--- .../pdp/persistence/provider/PdpProviderTest.java | 13 ++-- 12 files changed, 111 insertions(+), 114 deletions(-) (limited to 'models-pdp') diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java index 1a1fe228d..35443a291 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +28,7 @@ import lombok.NonNull; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * A deployment (i.e., set of policies) for all PDPs of the same pdp type running within a @@ -44,7 +45,7 @@ public class DeploymentSubGroup { private String pdpType; private Action action; - private List policies; + private List policies; /** * Constructs the object. @@ -61,7 +62,7 @@ public class DeploymentSubGroup { public DeploymentSubGroup(@NonNull final DeploymentSubGroup source) { this.pdpType = source.pdpType; this.action = source.action; - this.policies = PfUtils.mapList(source.policies, ToscaPolicyIdentifier::new, new ArrayList<>(0)); + this.policies = PfUtils.mapList(source.policies, ToscaConceptIdentifier::new, new ArrayList<>(0)); } /** @@ -75,7 +76,7 @@ public class DeploymentSubGroup { result.validateNotNull("pdpType", pdpType); result.validateNotNull("action", action); - result.validateNotNullList("policies", policies, ToscaPolicyIdentifier::validatePapRest); + result.validateNotNullList("policies", policies, ToscaConceptIdentifier::validatePapRest); return result; } 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 313482d2e..a7ceaa9a5 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 @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,8 +29,7 @@ import lombok.NonNull; import org.apache.commons.lang3.ObjectUtils; import org.onap.policy.models.base.PfObjectFilter; 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; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Filter class for searches for {@link PdpGroup} instances. If any fields are null, they are ignored. @@ -50,14 +49,14 @@ public class PdpGroupFilter implements PfObjectFilter { private String pdpType; // Set regular expressions on fields to match policy type names and versions - private List policyTypeList; + 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 List policyList; + private List policyList; // If set, only PDP groups where policies are matched exactly are returned @Builder.Default @@ -110,7 +109,7 @@ public class PdpGroupFilter implements PfObjectFilter { * @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 filterOnPolicyTypeList(final PdpGroup pdpGroup, final List typeFilter, + private boolean filterOnPolicyTypeList(final PdpGroup pdpGroup, final List typeFilter, final boolean matchPolicyTypesExactly) { if (typeFilter == null) { return true; @@ -139,9 +138,9 @@ public class PdpGroupFilter implements PfObjectFilter { * @return true if one element of the elements to find is supported by an element on * the list we searched */ - private boolean findSupportedPolicyType(List supportedPolicyTypes, - List typeFilter) { - for (ToscaPolicyTypeIdentifier supportedPolicyType : supportedPolicyTypes) { + private boolean findSupportedPolicyType(List supportedPolicyTypes, + List typeFilter) { + for (ToscaConceptIdentifier supportedPolicyType : supportedPolicyTypes) { String supName = supportedPolicyType.getName(); if (supName.endsWith(".*")) { String substr = supName.substring(0, supName.length() - 1); @@ -164,7 +163,7 @@ public class PdpGroupFilter implements PfObjectFilter { * @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 filterOnPolicyList(final PdpGroup pdpGroup, final List policyFilter, + private boolean filterOnPolicyList(final PdpGroup pdpGroup, final List policyFilter, final boolean matchPoliciesExactly) { if (policyFilter == null) { return true; diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java index 6207bbe0c..e90a4d10e 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +30,7 @@ import org.onap.policy.models.base.PfUtils; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpMessageType; 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.ToscaConceptIdentifier; /** * Class to represent the PDP_STATUS message that all the PDP's will send to PAP. @@ -51,7 +51,7 @@ public class PdpStatus extends PdpMessage { */ private String description; - private List policies; + private List policies; private String deploymentInstanceInfo; private String properties; private PdpStatistics statistics; @@ -77,7 +77,7 @@ public class PdpStatus extends PdpMessage { this.state = source.state; this.healthy = source.healthy; this.description = source.description; - this.policies = PfUtils.mapList(source.policies, ToscaPolicyIdentifier::new, new ArrayList<>(0)); + this.policies = PfUtils.mapList(source.policies, ToscaConceptIdentifier::new, new ArrayList<>(0)); this.deploymentInstanceInfo = source.deploymentInstanceInfo; this.properties = source.properties; this.statistics = (source.statistics == null ? null : new PdpStatistics(source.statistics)); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java index e3e33b454..bfd9dac95 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,8 +32,7 @@ import org.onap.policy.common.parameters.ObjectValidationResult; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent a group of all PDP's of the same pdp type running for a particular @@ -44,8 +43,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi @Data public class PdpSubGroup { private String pdpType; - private List supportedPolicyTypes; - private List policies; + private List supportedPolicyTypes; + private List policies; private int currentInstanceCount; private int desiredInstanceCount; private Map properties; @@ -65,9 +64,9 @@ public class PdpSubGroup { */ public PdpSubGroup(@NonNull final PdpSubGroup source) { this.pdpType = source.pdpType; - this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, ToscaPolicyTypeIdentifier::new, + this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, ToscaConceptIdentifier::new, new ArrayList<>(0)); - this.policies = PfUtils.mapList(source.policies, ToscaPolicyIdentifier::new, new ArrayList<>(0)); + this.policies = PfUtils.mapList(source.policies, ToscaConceptIdentifier::new, new ArrayList<>(0)); this.currentInstanceCount = source.currentInstanceCount; this.desiredInstanceCount = source.desiredInstanceCount; this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties)); @@ -87,9 +86,9 @@ public class PdpSubGroup { result.validateNotNull("pdpType", pdpType); // When doing PdpGroup Update operation, supported policy types and policies doesn't have to be validated. if (!updateGroupFlow) { - result.validateNotNullList("policies", policies, ToscaPolicyIdentifier::validatePapRest); + result.validateNotNullList("policies", policies, ToscaConceptIdentifier::validatePapRest); result.validateNotNullList("supportedPolicyTypes", supportedPolicyTypes, - ToscaPolicyTypeIdentifier::validatePapRest); + ToscaConceptIdentifier::validatePapRest); if (supportedPolicyTypes != null && supportedPolicyTypes.isEmpty()) { result.addResult(new ObjectValidationResult("supportedPolicyTypes", supportedPolicyTypes, diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java index 3474fccc1..27ad34e4a 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,8 +61,7 @@ import org.onap.policy.models.base.PfUtils; import org.onap.policy.models.base.validation.annotations.VerifyKey; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpSubGroup; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent a PDP subgroup in the database. @@ -186,14 +185,14 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative()); for (PfSearchableKey supportedPolicyTypeKey : supportedPolicyTypes) { - ToscaPolicyTypeIdentifier supportedPolicyTypeIdent = new ToscaPolicyTypeIdentifier( + ToscaConceptIdentifier supportedPolicyTypeIdent = new ToscaConceptIdentifier( supportedPolicyTypeKey.getName(), supportedPolicyTypeKey.getVersion()); pdpSubgroup.getSupportedPolicyTypes().add(supportedPolicyTypeIdent); } pdpSubgroup.setPolicies(new ArrayList<>()); for (PfConceptKey policyKey : policies) { - ToscaPolicyIdentifier toscaPolicyIdentifier = new ToscaPolicyIdentifier(); + ToscaConceptIdentifier toscaPolicyIdentifier = new ToscaConceptIdentifier(); toscaPolicyIdentifier.setName(policyKey.getName()); toscaPolicyIdentifier.setVersion(policyKey.getVersion()); pdpSubgroup.getPolicies().add(toscaPolicyIdentifier); @@ -220,7 +219,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative(); if (pdpSubgroup.getSupportedPolicyTypes() != null) { - for (ToscaPolicyTypeIdentifier supportedPolicyType : pdpSubgroup.getSupportedPolicyTypes()) { + for (ToscaConceptIdentifier supportedPolicyType : pdpSubgroup.getSupportedPolicyTypes()) { this.supportedPolicyTypes .add(new PfSearchableKey(supportedPolicyType.getName(), supportedPolicyType.getVersion())); } @@ -228,7 +227,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative(); if (pdpSubgroup.getPolicies() != null) { - for (ToscaPolicyIdentifier toscaPolicyIdentifier : pdpSubgroup.getPolicies()) { + for (ToscaConceptIdentifier toscaPolicyIdentifier : pdpSubgroup.getPolicies()) { this.policies .add(new PfConceptKey(toscaPolicyIdentifier.getName(), toscaPolicyIdentifier.getVersion())); } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroupTest.java index 511d88f27..744c2e892 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroupTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +35,7 @@ import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.pdp.concepts.DeploymentSubGroup.Action; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Test methods not tested by {@link ModelsTest}. @@ -56,10 +57,10 @@ public class DeploymentSubGroupTest { orig.setPdpType("my-type"); orig.setAction(Action.POST); - final ToscaPolicyIdentifier pol1 = new ToscaPolicyIdentifier(); + final ToscaConceptIdentifier pol1 = new ToscaConceptIdentifier(); pol1.setName("policy-A"); pol1.setVersion("1.0.0"); - final ToscaPolicyIdentifier pol2 = new ToscaPolicyIdentifier(); + final ToscaConceptIdentifier pol2 = new ToscaConceptIdentifier(); pol2.setName("policy-B"); pol1.setVersion("2.0.0"); orig.setPolicies(Arrays.asList(pol1, pol2)); @@ -73,7 +74,7 @@ public class DeploymentSubGroupTest { subgrp.setPdpType("pdp-type"); subgrp.setAction(Action.PATCH); - subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaPolicyIdentifier.class))); + subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaConceptIdentifier.class))); // valid ValidationResult result = subgrp.validatePapRest(); @@ -103,7 +104,7 @@ public class DeploymentSubGroupTest { // invalid policy item sub2 = new DeploymentSubGroup(subgrp); - sub2.getPolicies().set(0, makeIdent(null, VERSION_300, ToscaPolicyIdentifier.class)); + sub2.getPolicies().set(0, makeIdent(null, VERSION_300, ToscaConceptIdentifier.class)); assertInvalid(sub2); } 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 6a0ae6b4e..89a1333ef 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 @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,8 +34,7 @@ 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; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Test of the {@link PdpGroupFilter} class. @@ -174,9 +173,9 @@ public class PdpGroupFilterTest { @Test public void testFilterPolicyType() { - List identifierList = new ArrayList<>(); + List identifierList = new ArrayList<>(); - identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1)); PdpGroupFilter filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); List filteredList = filter.filter(pdpGroupList); @@ -184,7 +183,7 @@ public class PdpGroupFilterTest { identifierList.clear(); // don't match wild cards - identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); final List wildCards = pdpGroupList.stream().map(this::makeWildCardPolicyTypes).collect(Collectors.toList()); @@ -193,42 +192,42 @@ public class PdpGroupFilterTest { identifierList.clear(); // match wild cards - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); filteredList = filter.filter(wildCards); assertEquals(4, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(4, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(4, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE2, VERSION7)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(2, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE3, VERSION0)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(2, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION9)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0)); + identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION9)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE2, VERSION7)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE3, VERSION0)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(5, filteredList.size()); @@ -238,30 +237,30 @@ public class PdpGroupFilterTest { assertEquals(0, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); filteredList = filter.filter(pdpGroupList); assertEquals(2, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE2, VERSION7)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE3, VERSION0)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4)); - identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE3, VERSION0)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build(); filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); @@ -278,7 +277,7 @@ public class PdpGroupFilterTest { PdpGroup newGroup = new PdpGroup(group); for (PdpSubGroup subgroup : newGroup.getPdpSubgroups()) { - for (ToscaPolicyTypeIdentifier subType : subgroup.getSupportedPolicyTypes()) { + for (ToscaConceptIdentifier subType : subgroup.getSupportedPolicyTypes()) { if (POLICY_TYPE0.equals(subType.getName())) { subType.setName("policy.type.*"); } @@ -290,51 +289,51 @@ public class PdpGroupFilterTest { @Test public void testFilterPolicy() { - List identifierList = new ArrayList<>(); + List identifierList = new ArrayList<>(); - identifierList.add(new ToscaPolicyIdentifier(NON_EXISTANT, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1)); PdpGroupFilter filter = PdpGroupFilter.builder().policyList(identifierList).build(); List filteredList = filter.filter(pdpGroupList); assertEquals(0, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION9)); + identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION9)); filter = PdpGroupFilter.builder().policyList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(0, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION4)); filter = PdpGroupFilter.builder().policyList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(4, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY1, VERSION4)); filter = PdpGroupFilter.builder().policyList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY2, VERSION4)); filter = PdpGroupFilter.builder().policyList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(2, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY3, VERSION1)); filter = PdpGroupFilter.builder().policyList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(NON_EXISTANT, VERSION1)); - identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION9)); - identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4)); - identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4)); - identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4)); - identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION9)); + identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY1, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY2, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY3, VERSION1)); filter = PdpGroupFilter.builder().policyList(identifierList).build(); filteredList = filter.filter(pdpGroupList); assertEquals(5, filteredList.size()); @@ -344,27 +343,27 @@ public class PdpGroupFilterTest { assertEquals(0, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION4)); filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build(); filteredList = filter.filter(pdpGroupList); assertEquals(3, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4)); - identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY1, VERSION4)); filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build(); filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY2, VERSION4)); filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build(); filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); identifierList.clear(); - identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4)); - identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1)); + identifierList.add(new ToscaConceptIdentifier(POLICY2, VERSION4)); + identifierList.add(new ToscaConceptIdentifier(POLICY3, VERSION1)); 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 index 0ede98064..ae88f50f9 100644 --- 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 @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import java.util.TreeMap; import org.junit.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.models.pdp.enums.PdpState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Test methods not tested by {@link ModelsTest}. @@ -129,7 +129,7 @@ public class PdpGroupTest { PdpSubGroup subgroup1 = new PdpSubGroup(); subgroup1.setDesiredInstanceCount(1); subgroup1.setPdpType(PDP_TYPE1); - subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaPolicyTypeIdentifier("a-type-name", "3.2.1"))); + subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaConceptIdentifier("a-type-name", "3.2.1"))); subgroup1.setPolicies(Collections.emptyList()); group.setPdpSubgroups(Arrays.asList(subgroup1)); @@ -165,7 +165,7 @@ public class PdpGroupTest { PdpSubGroup subgroup1 = new PdpSubGroup(); subgroup1.setDesiredInstanceCount(1); subgroup1.setPdpType(PDP_TYPE1); - subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaPolicyTypeIdentifier("a-type-name", "3.2.1"))); + subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaConceptIdentifier("a-type-name", "3.2.1"))); subgroup1.setPolicies(Collections.emptyList()); PdpSubGroup subgroup2 = new PdpSubGroup(subgroup1); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java index bd98f18c3..5cf7c1340 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +35,7 @@ import java.util.List; import java.util.Map; import org.junit.Test; import org.onap.policy.common.parameters.ValidationResult; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; public class PdpGroupsTest { @@ -46,7 +47,7 @@ public class PdpGroupsTest { PdpSubGroup subgrp = new PdpSubGroup(); subgrp.setDesiredInstanceCount(1); subgrp.setPdpType("pdp-type"); - subgrp.setSupportedPolicyTypes(Arrays.asList(new ToscaPolicyTypeIdentifier("policy-type", "9.8.7"))); + subgrp.setSupportedPolicyTypes(Arrays.asList(new ToscaConceptIdentifier("policy-type", "9.8.7"))); subgrp.setPolicies(Collections.emptyList()); group1.setPdpSubgroups(Arrays.asList(subgrp)); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStatusTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStatusTest.java index 79f15b980..90b8d43c7 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStatusTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStatusTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import java.util.Collections; import org.junit.Test; import org.onap.policy.models.pdp.enums.PdpHealthStatus; 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.ToscaConceptIdentifier; public class PdpStatusTest { @@ -52,7 +52,7 @@ public class PdpStatusTest { orig.setPdpGroup("my-group"); orig.setPdpSubgroup("my-subgroup"); orig.setPdpType("my-type"); - orig.setPolicies(Arrays.asList(new ToscaPolicyIdentifier("policy-A", "1.0.0"))); + orig.setPolicies(Arrays.asList(new ToscaConceptIdentifier("policy-A", "1.0.0"))); orig.setProperties("my-properties"); final PdpResponseDetails resp = new PdpResponseDetails(); 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 index ba55426c7..7d3d4ab92 100644 --- 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 @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,7 @@ import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Test methods not tested by {@link ModelsTest}. @@ -70,10 +69,10 @@ public class PdpSubGroupTest { orig.setPdpType("my-type"); - final ToscaPolicyIdentifier pol1 = new ToscaPolicyIdentifier(); + final ToscaConceptIdentifier pol1 = new ToscaConceptIdentifier(); pol1.setName("policy-A"); pol1.setVersion("1.0.0"); - final ToscaPolicyIdentifier pol2 = new ToscaPolicyIdentifier(); + final ToscaConceptIdentifier pol2 = new ToscaConceptIdentifier(); pol2.setName("policy-B"); pol1.setVersion("2.0.0"); orig.setPolicies(Arrays.asList(pol1, pol2)); @@ -83,8 +82,8 @@ public class PdpSubGroupTest { 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"); + final ToscaConceptIdentifier supp1 = new ToscaConceptIdentifier("supp-A", "1.2"); + final ToscaConceptIdentifier supp2 = new ToscaConceptIdentifier("supp-B", "3.4"); orig.setSupportedPolicyTypes(Arrays.asList(supp1, supp2)); assertEquals(orig.toString(), new PdpSubGroup(orig).toString()); @@ -97,8 +96,8 @@ public class PdpSubGroupTest { subgrp.setDesiredInstanceCount(1); subgrp.setPdpType("pdp-type"); subgrp.setSupportedPolicyTypes( - Arrays.asList(makeIdent("type-X", VERSION_300, ToscaPolicyTypeIdentifier.class))); - subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaPolicyIdentifier.class))); + Arrays.asList(makeIdent("type-X", VERSION_300, ToscaConceptIdentifier.class))); + subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaConceptIdentifier.class))); ValidationResult result = subgrp.validatePapRest(false); assertNotNull(result); @@ -130,8 +129,8 @@ public class PdpSubGroupTest { subgrp.setDesiredInstanceCount(1); subgrp.setPdpType("pdp-type"); subgrp.setSupportedPolicyTypes( - Arrays.asList(makeIdent("type-X", VERSION_300, ToscaPolicyTypeIdentifier.class))); - subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaPolicyIdentifier.class))); + Arrays.asList(makeIdent("type-X", VERSION_300, ToscaConceptIdentifier.class))); + subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaConceptIdentifier.class))); // valid ValidationResult result = subgrp.validatePapRest(false); @@ -171,7 +170,7 @@ public class PdpSubGroupTest { // invalid policy type item sub2 = new PdpSubGroup(subgrp); - sub2.getSupportedPolicyTypes().set(0, makeIdent(null, VERSION_300, ToscaPolicyTypeIdentifier.class)); + sub2.getSupportedPolicyTypes().set(0, makeIdent(null, VERSION_300, ToscaConceptIdentifier.class)); assertInvalid(sub2); // null policies @@ -186,7 +185,7 @@ public class PdpSubGroupTest { // invalid policy item sub2 = new PdpSubGroup(subgrp); - sub2.getPolicies().set(0, makeIdent(null, VERSION_300, ToscaPolicyIdentifier.class)); + sub2.getPolicies().set(0, makeIdent(null, VERSION_300, ToscaConceptIdentifier.class)); assertInvalid(sub2); } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java index cad1357b9..d57204adf 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,8 +49,7 @@ import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.pdp.enums.PdpHealthStatus; 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; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider; /** @@ -153,11 +152,11 @@ public class PdpProviderTest { assertEquals(5, new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()).size()); - List policyTypeList = new ArrayList<>(); - policyTypeList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3")); + List policyTypeList = new ArrayList<>(); + policyTypeList.add(new ToscaConceptIdentifier("policy.type.0", "1.2.3")); - List policyList = new ArrayList<>(); - policyList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6")); + List policyList = new ArrayList<>(); + policyList.add(new ToscaConceptIdentifier("Policy0", "4.5.6")); // @formatter:off final PdpGroupFilter filter = PdpGroupFilter.builder() -- cgit 1.2.3-korg