aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp
diff options
context:
space:
mode:
Diffstat (limited to 'models-pdp')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java17
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java7
2 files changed, 13 insertions, 11 deletions
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 3a81c0b30..7d018860e 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
@@ -50,6 +50,7 @@ import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfKey;
import org.onap.policy.models.base.PfKeyUse;
import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfSearchableKey;
import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.base.PfValidationMessage;
import org.onap.policy.models.base.PfValidationResult;
@@ -76,7 +77,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
private PfReferenceKey key;
@ElementCollection
- private List<PfConceptKey> supportedPolicyTypes;
+ private List<PfSearchableKey> supportedPolicyTypes;
@ElementCollection
private List<PfConceptKey> policies;
@@ -127,7 +128,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
* @param policies policies deployed on this PDP subgroups
* @param pdpInstances the PDP instances on this PDP subgroups
*/
- public JpaPdpSubGroup(@NonNull final PfReferenceKey key, @NonNull final List<PfConceptKey> supportedPolicyTypes,
+ public JpaPdpSubGroup(@NonNull final PfReferenceKey key, @NonNull final List<PfSearchableKey> supportedPolicyTypes,
@NonNull List<PfConceptKey> policies, @NonNull final List<JpaPdp> pdpInstances) {
this.key = key;
this.supportedPolicyTypes = supportedPolicyTypes;
@@ -144,7 +145,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
super(copyConcept);
this.key = new PfReferenceKey(copyConcept.key);
this.supportedPolicyTypes = PfUtils.mapList(copyConcept.supportedPolicyTypes,
- PfConceptKey::new, new ArrayList<>(0));
+ PfSearchableKey::new, new ArrayList<>(0));
this.policies = PfUtils.mapList(copyConcept.policies, PfConceptKey::new, new ArrayList<>(0));
this.currentInstanceCount = copyConcept.currentInstanceCount;
this.desiredInstanceCount = copyConcept.desiredInstanceCount;
@@ -168,7 +169,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
pdpSubgroup.setPdpType(getKey().getLocalName());
pdpSubgroup.setSupportedPolicyTypes(new ArrayList<>());
- for (PfConceptKey supportedPolicyTypeKey : supportedPolicyTypes) {
+ for (PfSearchableKey supportedPolicyTypeKey : supportedPolicyTypes) {
ToscaPolicyTypeIdentifier supportedPolicyTypeIdent = new ToscaPolicyTypeIdentifier(
supportedPolicyTypeKey.getName(), supportedPolicyTypeKey.getVersion());
pdpSubgroup.getSupportedPolicyTypes().add(supportedPolicyTypeIdent);
@@ -205,7 +206,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
if (pdpSubgroup.getSupportedPolicyTypes() != null) {
for (ToscaPolicyTypeIdentifier supportedPolicyType : pdpSubgroup.getSupportedPolicyTypes()) {
this.supportedPolicyTypes
- .add(new PfConceptKey(supportedPolicyType.getName(), supportedPolicyType.getVersion()));
+ .add(new PfSearchableKey(supportedPolicyType.getName(), supportedPolicyType.getVersion()));
}
}
@@ -236,7 +237,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
public List<PfKey> getKeys() {
List<PfKey> keyList = getKey().getKeys();
- for (PfConceptKey ptkey : supportedPolicyTypes) {
+ for (PfSearchableKey ptkey : supportedPolicyTypes) {
keyList.add(new PfKeyUse(ptkey));
}
@@ -256,7 +257,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
public void clean() {
key.clean();
- for (PfConceptKey ptkey : supportedPolicyTypes) {
+ for (PfSearchableKey ptkey : supportedPolicyTypes) {
ptkey.clean();
}
@@ -330,7 +331,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
"a PDP subgroup must support at least one policy type"));
} else {
- for (PfConceptKey supportedPolicyType : supportedPolicyTypes) {
+ for (PfSearchableKey supportedPolicyType : supportedPolicyTypes) {
result = supportedPolicyType.validate(result);
}
}
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java
index ad0164ad4..2d2306978 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java
@@ -36,6 +36,7 @@ import java.util.List;
import org.junit.Test;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfSearchableKey;
import org.onap.policy.models.base.PfValidationResult;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpSubgroupChild;
@@ -152,7 +153,7 @@ public class JpaPdpSubGroupTest {
.contains("INVALID:a PDP subgroup must support at least one policy type"));
testJpaPdpSubGroup.setSupportedPolicyTypes(new ArrayList<>());
- testJpaPdpSubGroup.getSupportedPolicyTypes().add(new PfConceptKey("APolicyType:1.0.0"));
+ testJpaPdpSubGroup.getSupportedPolicyTypes().add(new PfSearchableKey("APolicyType:1.0.0"));
assertTrue(testJpaPdpSubGroup.validate(new PfValidationResult()).isOk());
assertFalse(testJpaPdpSubGroup.validate(new PfValidationResult()).toString()
.contains("INVALID:a PDP subgroup must support at least one policy type"));
@@ -188,7 +189,7 @@ public class JpaPdpSubGroupTest {
testJpaPdpSubGroup.setProperties(null);
assertTrue(testJpaPdpSubGroup.validate(new PfValidationResult()).isOk());
- List<PfConceptKey> supportedPolicyTypes = testJpaPdpSubGroup.getSupportedPolicyTypes();
+ List<PfSearchableKey> supportedPolicyTypes = testJpaPdpSubGroup.getSupportedPolicyTypes();
assertNotNull(supportedPolicyTypes);
testJpaPdpSubGroup.setSupportedPolicyTypes(null);
assertFalse(testJpaPdpSubGroup.validate(new PfValidationResult()).isOk());
@@ -236,7 +237,7 @@ public class JpaPdpSubGroupTest {
testJpaPdpSubGroup.setDesiredInstanceCount(0);
assertEquals(0, testJpaPdpSubGroup.compareTo(otherJpaPdpSubGroup));
- PfConceptKey anotherPolicyType = new PfConceptKey("AnotherPolicyType", "1.0.0");
+ PfSearchableKey anotherPolicyType = new PfSearchableKey("AnotherPolicyType.*", "1.0.0");
testJpaPdpSubGroup.getSupportedPolicyTypes().add(anotherPolicyType);
assertNotEquals(0, testJpaPdpSubGroup.compareTo(otherJpaPdpSubGroup));
testJpaPdpSubGroup.getSupportedPolicyTypes().remove(anotherPolicyType);