aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-01-04 13:35:29 +0000
committerliamfallon <liam.fallon@est.tech>2021-01-05 12:12:21 +0000
commit6cf781f89ada83ec5e317745b8b92086b96d27ac (patch)
treee2488460d749e044d8379273002dccfc978d45d9 /main/src
parenta65c190d43d9ee5c21321b4bfa3cdda032342a78 (diff)
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: I22bb3fdbaf2e237221a5c89afbf7898410603835 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java5
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java9
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PolicyUndeployer.java5
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/msgdata/Request.java5
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java5
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java9
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/notification/PolicyCommonTracker.java25
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java25
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationData.java10
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/notification/PolicyTrackerData.java7
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java14
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java7
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java18
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java43
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java5
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java17
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java16
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java42
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/MultiPdpStatusListenerTest.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java66
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java10
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonSupport.java26
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java14
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java15
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationDataTest.java12
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/notification/PolicyTrackerDataTest.java5
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java6
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java18
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java8
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java42
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java24
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java31
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java31
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java6
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java10
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupQueryTest.java12
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupStateChangeTest.java10
37 files changed, 321 insertions, 294 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java
index e5246eb1..79a5e990 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -30,8 +31,8 @@ import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
@@ -106,7 +107,7 @@ public class PdpMessageGenerator {
throws PfModelException {
final List<ToscaPolicy> policies = new LinkedList<>();
- for (final ToscaPolicyIdentifier policyIdentifier : subGroup.getPolicies()) {
+ for (final ToscaConceptIdentifier policyIdentifier : subGroup.getPolicies()) {
policies.addAll(databaseProvider.getPolicyList(policyIdentifier.getName(), policyIdentifier.getVersion()));
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java
index cb9d51b8..85038dee 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -38,7 +39,7 @@ import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
import org.onap.policy.pap.main.comm.msgdata.Request;
import org.onap.policy.pap.main.comm.msgdata.RequestListener;
@@ -350,7 +351,7 @@ public class PdpModifyRequestMap {
@Override
public void failure(String responsePdpName, String reason) {
- Collection<ToscaPolicyIdentifier> undeployPolicies = requestCompleted(responsePdpName);
+ Collection<ToscaConceptIdentifier> undeployPolicies = requestCompleted(responsePdpName);
if (undeployPolicies.isEmpty()) {
// nothing to undeploy
return;
@@ -391,7 +392,7 @@ public class PdpModifyRequestMap {
* @param responsePdpName name of the PDP provided in the response
* @return a list of policies to be undeployed
*/
- private Collection<ToscaPolicyIdentifier> requestCompleted(String responsePdpName) {
+ private Collection<ToscaConceptIdentifier> requestCompleted(String responsePdpName) {
if (!pdpName.equals(responsePdpName)) {
return Collections.emptyList();
}
@@ -407,7 +408,7 @@ public class PdpModifyRequestMap {
return Collections.emptyList();
}
- Collection<ToscaPolicyIdentifier> undeployPolicies = request.getUndeployPolicies();
+ Collection<ToscaConceptIdentifier> undeployPolicies = request.getUndeployPolicies();
if (undeployPolicies.isEmpty()) {
// nothing to undeploy - just start the next request
startNextRequest(request);
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PolicyUndeployer.java b/main/src/main/java/org/onap/policy/pap/main/comm/PolicyUndeployer.java
index ecf34893..b5ea2354 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PolicyUndeployer.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PolicyUndeployer.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -22,7 +23,7 @@ package org.onap.policy.pap.main.comm;
import java.util.Collection;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@FunctionalInterface
public interface PolicyUndeployer {
@@ -34,6 +35,6 @@ public interface PolicyUndeployer {
* @param policies policies to be undeployed
* @throws PfModelException if an error occurs
*/
- public void undeploy(String group, String subgroup, Collection<ToscaPolicyIdentifier> policies)
+ public void undeploy(String group, String subgroup, Collection<ToscaConceptIdentifier> policies)
throws PfModelException;
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/Request.java b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/Request.java
index 7edb9041..d8f8895d 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/Request.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/Request.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -23,7 +24,7 @@ package org.onap.policy.pap.main.comm.msgdata;
import java.util.Collection;
import org.onap.policy.models.pdp.concepts.PdpMessage;
import org.onap.policy.models.pdp.concepts.PdpStatus;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pap.main.notification.PolicyNotifier;
/**
@@ -102,5 +103,5 @@ public interface Request {
*
* @return a list of policies to be undeployed
*/
- public Collection<ToscaPolicyIdentifier> getUndeployPolicies();
+ public Collection<ToscaConceptIdentifier> getUndeployPolicies();
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java
index 7e0397a5..9a1184b8 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. 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.
@@ -31,7 +32,7 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.utils.services.ServiceManager;
import org.onap.policy.models.pdp.concepts.PdpMessage;
import org.onap.policy.models.pdp.concepts.PdpStatus;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pap.main.comm.QueueToken;
import org.onap.policy.pap.main.comm.TimerManager;
import org.onap.policy.pap.main.notification.PolicyNotifier;
@@ -327,7 +328,7 @@ public abstract class RequestImpl implements Request {
* Just returns an empty list.
*/
@Override
- public Collection<ToscaPolicyIdentifier> getUndeployPolicies() {
+ public Collection<ToscaConceptIdentifier> getUndeployPolicies() {
return Collections.emptyList();
}
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java
index 753735d4..ada9d193 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -31,8 +32,8 @@ import org.apache.commons.lang3.StringUtils;
import org.onap.policy.models.pdp.concepts.PdpMessage;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
import org.onap.policy.pap.main.parameters.RequestParams;
@@ -45,7 +46,7 @@ public class UpdateReq extends RequestImpl {
* Policies to be undeployed if the request fails.
*/
@Getter
- private Collection<ToscaPolicyIdentifier> undeployPolicies = Collections.emptyList();
+ private Collection<ToscaConceptIdentifier> undeployPolicies = Collections.emptyList();
/**
* Constructs the object, and validates the parameters.
@@ -76,7 +77,7 @@ public class UpdateReq extends RequestImpl {
return reason;
}
- Set<ToscaPolicyIdentifier> actualSet = new HashSet<>(alwaysList(response.getPolicies()));
+ Set<ToscaConceptIdentifier> actualSet = new HashSet<>(alwaysList(response.getPolicies()));
getNotifier().processResponse(response.getName(), actualSet);
PdpUpdate message = getMessage();
@@ -95,7 +96,7 @@ public class UpdateReq extends RequestImpl {
// see if the policies match
- Set<ToscaPolicyIdentifier> expectedSet = new HashSet<>(alwaysList(message.getPolicies()).stream()
+ Set<ToscaConceptIdentifier> expectedSet = new HashSet<>(alwaysList(message.getPolicies()).stream()
.map(ToscaPolicy::getIdentifier).collect(Collectors.toSet()));
if (!actualSet.equals(expectedSet)) {
diff --git a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyCommonTracker.java b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyCommonTracker.java
index bd14ffb9..3529ccb7 100644
--- a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyCommonTracker.java
+++ b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyCommonTracker.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. 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.
@@ -33,7 +34,7 @@ import java.util.Set;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
import org.onap.policy.models.pap.concepts.PolicyStatus;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Common super class for deploy and undeploy trackers.
@@ -48,7 +49,7 @@ public abstract class PolicyCommonTracker {
* Use a LinkedHashMap, because we'll be doing lots of iteration over the map, and
* iteration over a LinkedHashMap is faster than over a plain HashMap.
*/
- private final Map<ToscaPolicyIdentifier, PolicyTrackerData> policy2data = new LinkedHashMap<>();
+ private final Map<ToscaConceptIdentifier, PolicyTrackerData> policy2data = new LinkedHashMap<>();
/**
@@ -85,8 +86,8 @@ public abstract class PolicyCommonTracker {
* @param ident identifier of the policy of interest
* @return the status of the given policy, or empty if the policy is not found
*/
- public Optional<PolicyStatus> getStatus(ToscaPolicyIdentifier ident) {
- ToscaPolicyIdentifier ident2 = new ToscaPolicyIdentifier(ident.getName(), ident.getVersion());
+ public Optional<PolicyStatus> getStatus(ToscaConceptIdentifier ident) {
+ ToscaConceptIdentifier ident2 = new ToscaConceptIdentifier(ident.getName(), ident.getVersion());
PolicyTrackerData data = policy2data.get(ident2);
return Optional.ofNullable(data == null ? null : makeStatus(ident2, data));
}
@@ -140,7 +141,7 @@ public abstract class PolicyCommonTracker {
* @param statusList status messages are added here if policies become complete as a
* result of this operation
*/
- public void processResponse(String pdp, Collection<ToscaPolicyIdentifier> activePolicies,
+ public void processResponse(String pdp, Collection<ToscaConceptIdentifier> activePolicies,
List<PolicyStatus> statusList) {
processResponse(pdp, new HashSet<>(activePolicies), statusList);
}
@@ -154,7 +155,7 @@ public abstract class PolicyCommonTracker {
* @param statusList status messages are added here if policies become complete as a
* result of this operation
*/
- public void processResponse(String pdp, Set<ToscaPolicyIdentifier> activePolicies, List<PolicyStatus> statusList) {
+ public void processResponse(String pdp, Set<ToscaConceptIdentifier> activePolicies, List<PolicyStatus> statusList) {
updateMap(statusList, (policyId, data) -> updateData(pdp, data, activePolicies.contains(policyId)));
}
@@ -173,13 +174,13 @@ public abstract class PolicyCommonTracker {
* policy is complete (i.e., no longer awaiting any responses)
*/
private void updateMap(List<PolicyStatus> statusList,
- BiPredicate<ToscaPolicyIdentifier, PolicyTrackerData> updater) {
+ BiPredicate<ToscaConceptIdentifier, PolicyTrackerData> updater) {
- Iterator<Entry<ToscaPolicyIdentifier, PolicyTrackerData>> iter = policy2data.entrySet().iterator();
+ Iterator<Entry<ToscaConceptIdentifier, PolicyTrackerData>> iter = policy2data.entrySet().iterator();
while (iter.hasNext()) {
- Entry<ToscaPolicyIdentifier, PolicyTrackerData> ent = iter.next();
+ Entry<ToscaConceptIdentifier, PolicyTrackerData> ent = iter.next();
- ToscaPolicyIdentifier policyId = ent.getKey();
+ ToscaConceptIdentifier policyId = ent.getKey();
PolicyTrackerData data = ent.getValue();
if (!updater.test(policyId, data)) {
@@ -224,7 +225,7 @@ public abstract class PolicyCommonTracker {
* @param entry policy entry
* @return a new status notification
*/
- private PolicyStatus makeStatus(Map.Entry<ToscaPolicyIdentifier, PolicyTrackerData> entry) {
+ private PolicyStatus makeStatus(Map.Entry<ToscaConceptIdentifier, PolicyTrackerData> entry) {
return makeStatus(entry.getKey(), entry.getValue());
}
@@ -235,7 +236,7 @@ public abstract class PolicyCommonTracker {
* @param data data to be used to set the status fields
* @return a new status notification
*/
- private PolicyStatus makeStatus(ToscaPolicyIdentifier policyId, PolicyTrackerData data) {
+ private PolicyStatus makeStatus(ToscaConceptIdentifier policyId, PolicyTrackerData data) {
PolicyStatus status = new PolicyStatus(data.getPolicyType(), policyId);
data.putValuesInto(status);
diff --git a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java
index 12630af2..c13e9b78 100644
--- a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java
+++ b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -36,10 +36,9 @@ import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
import org.onap.policy.pap.main.comm.Publisher;
import org.onap.policy.pap.main.comm.QueueToken;
@@ -81,7 +80,7 @@ public class PolicyNotifier {
this.publisher = publisher;
try (PolicyModelsProvider dao = daoFactory.create()) {
- Map<ToscaPolicyIdentifier, ToscaPolicyTypeIdentifier> id2type = loadPolicyTypes(dao);
+ Map<ToscaConceptIdentifier, ToscaConceptIdentifier> id2type = loadPolicyTypes(dao);
loadPolicies(dao, id2type);
}
}
@@ -93,10 +92,10 @@ public class PolicyNotifier {
* @return a mapping from policy id to policy type
* @throws PfModelException if a DB error occurs
*/
- private Map<ToscaPolicyIdentifier, ToscaPolicyTypeIdentifier> loadPolicyTypes(PolicyModelsProvider dao)
+ private Map<ToscaConceptIdentifier, ToscaConceptIdentifier> loadPolicyTypes(PolicyModelsProvider dao)
throws PfModelException {
- Map<ToscaPolicyIdentifier, ToscaPolicyTypeIdentifier> id2type = new HashMap<>();
+ Map<ToscaConceptIdentifier, ToscaConceptIdentifier> id2type = new HashMap<>();
for (ToscaPolicy policy : dao.getFilteredPolicyList(ToscaPolicyFilter.builder().build())) {
id2type.put(policy.getIdentifier(), policy.getTypeIdentifier());
@@ -112,7 +111,7 @@ public class PolicyNotifier {
* @param dao provider used to retrieve policies from the DB
* @throws PfModelException if a DB error occurs
*/
- private void loadPolicies(PolicyModelsProvider dao, Map<ToscaPolicyIdentifier, ToscaPolicyTypeIdentifier> id2type)
+ private void loadPolicies(PolicyModelsProvider dao, Map<ToscaConceptIdentifier, ToscaConceptIdentifier> id2type)
throws PfModelException {
for (PdpGroup group : dao.getPdpGroups(null)) {
for (PdpSubGroup subgrp : group.getPdpSubgroups()) {
@@ -128,12 +127,12 @@ public class PolicyNotifier {
* @param group group containing the subgroup
* @param subgrp subgroup whose policies are to be loaded
*/
- private void loadPolicies(Map<ToscaPolicyIdentifier, ToscaPolicyTypeIdentifier> id2type, PdpGroup group,
+ private void loadPolicies(Map<ToscaConceptIdentifier, ToscaConceptIdentifier> id2type, PdpGroup group,
PdpSubGroup subgrp) {
- for (ToscaPolicyIdentifier policyId : subgrp.getPolicies()) {
+ for (ToscaConceptIdentifier policyId : subgrp.getPolicies()) {
- ToscaPolicyTypeIdentifier type = id2type.get(policyId);
+ ToscaConceptIdentifier type = id2type.get(policyId);
if (type == null) {
logger.error("group {}:{} refers to non-existent policy {}", group.getName(), subgrp.getPdpType(),
policyId);
@@ -171,7 +170,7 @@ public class PolicyNotifier {
* @param ident identifier of the policy of interest
* @return the status of the given policy, or empty if the policy is not found
*/
- public synchronized Optional<PolicyStatus> getStatus(ToscaPolicyIdentifier ident) {
+ public synchronized Optional<PolicyStatus> getStatus(ToscaConceptIdentifier ident) {
return deployTracker.getStatus(ident);
}
@@ -204,7 +203,7 @@ public class PolicyNotifier {
* @param activePolicies policies that are still active on the PDP, as specified in
* the response
*/
- public synchronized void processResponse(String pdp, Collection<ToscaPolicyIdentifier> activePolicies) {
+ public synchronized void processResponse(String pdp, Collection<ToscaConceptIdentifier> activePolicies) {
processResponse(pdp, new HashSet<>(activePolicies));
}
@@ -215,7 +214,7 @@ public class PolicyNotifier {
* @param activePolicies policies that are still active on the PDP, as specified in
* the response
*/
- public synchronized void processResponse(String pdp, Set<ToscaPolicyIdentifier> activePolicies) {
+ public synchronized void processResponse(String pdp, Set<ToscaConceptIdentifier> activePolicies) {
PolicyNotification notification = new PolicyNotification();
undeployTracker.processResponse(pdp, activePolicies, notification.getDeleted());
diff --git a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationData.java b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationData.java
index a65e46f2..b93f8930 100644
--- a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationData.java
+++ b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationData.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -24,16 +25,15 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import lombok.Getter;
-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;
/**
* Data used to track deploy/undeploy of a policy to PDPs.
*/
@Getter
public class PolicyPdpNotificationData {
- private final ToscaPolicyIdentifier policyId;
- private final ToscaPolicyTypeIdentifier policyType;
+ private final ToscaConceptIdentifier policyId;
+ private final ToscaConceptIdentifier policyType;
private final Set<String> pdps = new HashSet<>();
@@ -43,7 +43,7 @@ public class PolicyPdpNotificationData {
* @param policyId ID of the policy being deployed/undeployed
* @param policyType type of the associated policy
*/
- public PolicyPdpNotificationData(ToscaPolicyIdentifier policyId, ToscaPolicyTypeIdentifier policyType) {
+ public PolicyPdpNotificationData(ToscaConceptIdentifier policyId, ToscaConceptIdentifier policyType) {
this.policyId = policyId;
this.policyType = policyType;
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyTrackerData.java b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyTrackerData.java
index 29e7b147..7dfb378f 100644
--- a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyTrackerData.java
+++ b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyTrackerData.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -25,7 +26,7 @@ import java.util.HashSet;
import java.util.Set;
import lombok.Getter;
import org.onap.policy.models.pap.concepts.PolicyStatus;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Data associated with a policy, used by PolicyTracker. PDPs start in
@@ -38,7 +39,7 @@ public class PolicyTrackerData {
* The policy type associated with the policy.
*/
@Getter
- private final ToscaPolicyTypeIdentifier policyType;
+ private final ToscaConceptIdentifier policyType;
/**
* PDPs that have successfully completed an update of the policy.
@@ -61,7 +62,7 @@ public class PolicyTrackerData {
*
* @param policyType policy type
*/
- public PolicyTrackerData(ToscaPolicyTypeIdentifier policyType) {
+ public PolicyTrackerData(ToscaConceptIdentifier policyType) {
this.policyType = policyType;
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
index 4e61621b..00db7cc0 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * 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");
@@ -44,10 +44,9 @@ import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -344,7 +343,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
private void trackPdpsDelSubGroup(SessionData data, PdpSubGroup subgrp) throws PfModelException {
Set<String> pdps = subgrp.getPdpInstances().stream().map(Pdp::getInstanceId).collect(Collectors.toSet());
- for (ToscaPolicyIdentifier policyId : subgrp.getPolicies()) {
+ for (ToscaConceptIdentifier policyId : subgrp.getPolicies()) {
data.trackUndeploy(policyId, pdps);
}
}
@@ -432,7 +431,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
*/
private ValidationResult validateSupportedTypes(SessionData data, PdpSubGroup subgrp) throws PfModelException {
BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
- for (ToscaPolicyTypeIdentifier type : subgrp.getSupportedPolicyTypes()) {
+ for (ToscaConceptIdentifier type : subgrp.getSupportedPolicyTypes()) {
if (!type.getName().endsWith(".*") && data.getPolicyType(type) == null) {
result.addResult(
new ObjectValidationResult("policy type", type, ValidationStatus.INVALID, "unknown policy type"));
@@ -443,7 +442,8 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
}
@Override
- protected Updater makeUpdater(SessionData data, ToscaPolicy policy, ToscaPolicyIdentifierOptVersion desiredPolicy) {
+ protected Updater makeUpdater(SessionData data, ToscaPolicy policy,
+ ToscaConceptIdentifierOptVersion desiredPolicy) {
throw new UnsupportedOperationException("makeUpdater should not be invoked");
}
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
index 80dcda35..658a13cc 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -38,7 +39,7 @@ import javax.ws.rs.core.Response.Status;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.pap.concepts.PdpGroupDeleteResponse;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -124,7 +125,7 @@ public class PdpGroupDeleteControllerV1 extends PapRestControllerV1 {
@ApiParam(value = "PDP Policy Name", required = true) @PathParam("name") String policyName) {
return doOperation(requestId, "undeploy policy failed",
- () -> provider.undeploy(new ToscaPolicyIdentifierOptVersion(policyName, null)));
+ () -> provider.undeploy(new ToscaConceptIdentifierOptVersion(policyName, null)));
}
/**
@@ -166,7 +167,7 @@ public class PdpGroupDeleteControllerV1 extends PapRestControllerV1 {
@ApiParam(value = "PDP Policy Version", required = true) @PathParam("version") String version) {
return doOperation(requestId, "undeploy policy failed",
- () -> provider.undeploy(new ToscaPolicyIdentifierOptVersion(policyName, version)));
+ () -> provider.undeploy(new ToscaConceptIdentifierOptVersion(policyName, version)));
}
/**
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java
index 44450389..38851cd3 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* 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,9 +30,9 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -93,7 +93,7 @@ public class PdpGroupDeleteProvider extends ProviderBase {
* @param policyIdent identifier of the policy to be undeployed
* @throws PfModelException if an error occurred
*/
- public void undeploy(ToscaPolicyIdentifierOptVersion policyIdent) throws PfModelException {
+ public void undeploy(ToscaConceptIdentifierOptVersion policyIdent) throws PfModelException {
process(policyIdent, this::undeployPolicy);
}
@@ -104,7 +104,7 @@ public class PdpGroupDeleteProvider extends ProviderBase {
* @param ident identifier of the policy to be deleted
* @throws PfModelException if an error occurred
*/
- private void undeployPolicy(SessionData data, ToscaPolicyIdentifierOptVersion ident) throws PfModelException {
+ private void undeployPolicy(SessionData data, ToscaConceptIdentifierOptVersion ident) throws PfModelException {
try {
processPolicy(data, ident);
@@ -125,10 +125,10 @@ public class PdpGroupDeleteProvider extends ProviderBase {
*/
@Override
protected Updater makeUpdater(SessionData data, ToscaPolicy policy,
- ToscaPolicyIdentifierOptVersion desiredIdent) {
+ ToscaConceptIdentifierOptVersion desiredIdent) {
// construct a matcher based on whether or not the version was specified
- Predicate<ToscaPolicyIdentifier> matcher;
+ Predicate<ToscaConceptIdentifier> matcher;
if (desiredIdent.getVersion() != null) {
// version was specified - match the whole identifier
@@ -148,9 +148,9 @@ public class PdpGroupDeleteProvider extends ProviderBase {
boolean result = false;
- Iterator<ToscaPolicyIdentifier> iter = subgroup.getPolicies().iterator();
+ Iterator<ToscaConceptIdentifier> iter = subgroup.getPolicies().iterator();
while (iter.hasNext()) {
- ToscaPolicyIdentifier ident = iter.next();
+ ToscaConceptIdentifier ident = iter.next();
if (matcher.test(ident)) {
result = true;
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
index d09e2ea7..c30ee8f9 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -44,10 +44,9 @@ import org.onap.policy.models.pdp.concepts.DeploymentSubGroup;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -226,7 +225,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
private boolean addPolicies(SessionData data, PdpSubGroup dbsub, DeploymentSubGroup subgrp)
throws PfModelException {
- Set<ToscaPolicyIdentifier> policies = new LinkedHashSet<>(dbsub.getPolicies());
+ Set<ToscaConceptIdentifier> policies = new LinkedHashSet<>(dbsub.getPolicies());
policies.addAll(subgrp.getPolicies());
DeploymentSubGroup subgrp2 = new DeploymentSubGroup(subgrp);
@@ -239,7 +238,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
private boolean deletePolicies(SessionData data, PdpSubGroup dbsub, DeploymentSubGroup subgrp)
throws PfModelException {
- Set<ToscaPolicyIdentifier> policies = new LinkedHashSet<>(dbsub.getPolicies());
+ Set<ToscaConceptIdentifier> policies = new LinkedHashSet<>(dbsub.getPolicies());
policies.removeAll(subgrp.getPolicies());
DeploymentSubGroup subgrp2 = new DeploymentSubGroup(subgrp);
@@ -252,10 +251,10 @@ public class PdpGroupDeployProvider extends ProviderBase {
private boolean updatePolicies(SessionData data, PdpSubGroup dbsub, DeploymentSubGroup subgrp)
throws PfModelException {
- Set<ToscaPolicyIdentifier> undeployed = new HashSet<>(dbsub.getPolicies());
+ Set<ToscaConceptIdentifier> undeployed = new HashSet<>(dbsub.getPolicies());
undeployed.removeAll(subgrp.getPolicies());
- Set<ToscaPolicyIdentifier> deployed = new HashSet<>(subgrp.getPolicies());
+ Set<ToscaConceptIdentifier> deployed = new HashSet<>(subgrp.getPolicies());
deployed.removeAll(dbsub.getPolicies());
if (deployed.isEmpty() && undeployed.isEmpty()) {
@@ -266,11 +265,11 @@ public class PdpGroupDeployProvider extends ProviderBase {
Set<String> pdps = dbsub.getPdpInstances().stream().map(Pdp::getInstanceId).collect(Collectors.toSet());
- for (ToscaPolicyIdentifier policyId : deployed) {
+ for (ToscaConceptIdentifier policyId : deployed) {
data.trackDeploy(policyId, pdps);
}
- for (ToscaPolicyIdentifier policyId : undeployed) {
+ for (ToscaConceptIdentifier policyId : undeployed) {
data.trackUndeploy(policyId, pdps);
}
@@ -320,7 +319,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
- for (ToscaPolicyIdentifier ident : subgrp.getPolicies()) {
+ for (ToscaConceptIdentifier ident : subgrp.getPolicies()) {
// note: "ident" may not have a fully qualified version
String expectedVersion = dbname2vers.get(ident.getName());
@@ -333,7 +332,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
// policy doesn't appear in the DB's policy list - look it up
- ToscaPolicy policy = data.getPolicy(new ToscaPolicyIdentifierOptVersion(ident));
+ ToscaPolicy policy = data.getPolicy(new ToscaConceptIdentifierOptVersion(ident));
if (policy == null) {
result.addResult(new ObjectValidationResult(POLICY_RESULT_NAME, ident, ValidationStatus.INVALID,
"unknown policy"));
@@ -359,7 +358,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
* fully qualified
* @param result the validation result
*/
- private void validateVersion(String dbvers, ToscaPolicyIdentifier ident, BeanValidationResult result) {
+ private void validateVersion(String dbvers, ToscaConceptIdentifier ident, BeanValidationResult result) {
String idvers = ident.getVersion();
if (dbvers.equals(idvers)) {
return;
@@ -397,7 +396,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
*/
private void deploySimplePolicies(SessionData data, PdpDeployPolicies policies) throws PfModelException {
- for (ToscaPolicyIdentifierOptVersion desiredPolicy : policies.getPolicies()) {
+ for (ToscaConceptIdentifierOptVersion desiredPolicy : policies.getPolicies()) {
try {
processPolicy(data, desiredPolicy);
@@ -415,10 +414,10 @@ public class PdpGroupDeployProvider extends ProviderBase {
*/
@Override
protected Updater makeUpdater(SessionData data, ToscaPolicy policy,
- ToscaPolicyIdentifierOptVersion requestedIdent) {
+ ToscaConceptIdentifierOptVersion requestedIdent) {
- ToscaPolicyIdentifier desiredIdent = policy.getIdentifier();
- ToscaPolicyTypeIdentifier desiredType = policy.getTypeIdentifier();
+ ToscaConceptIdentifier desiredIdent = policy.getIdentifier();
+ ToscaConceptIdentifier desiredType = policy.getTypeIdentifier();
return (group, subgroup) -> {
@@ -457,15 +456,15 @@ public class PdpGroupDeployProvider extends ProviderBase {
* @param desiredType policy type of interest
* @return {@code true} if the policy type is supported, {@code false} otherwise
*/
- private boolean isPolicySupported(List<ToscaPolicyTypeIdentifier> supportedTypes,
- ToscaPolicyTypeIdentifier desiredType) {
+ private boolean isPolicySupported(List<ToscaConceptIdentifier> supportedTypes,
+ ToscaConceptIdentifier desiredType) {
if (supportedTypes.contains(desiredType)) {
return true;
}
String desiredTypeName = desiredType.getName();
- for (ToscaPolicyTypeIdentifier type : supportedTypes) {
+ for (ToscaConceptIdentifier type : supportedTypes) {
String supType = type.getName();
if (supType.endsWith(".*") && desiredTypeName.startsWith(supType.substring(0, supType.length() - 1))) {
// matches everything up to, AND INCLUDING, the "."
@@ -487,11 +486,11 @@ public class PdpGroupDeployProvider extends ProviderBase {
* @throws PfModelRuntimeException if the subgroup contains a different version of the
* desired policy
*/
- private boolean containsPolicy(PdpGroup group, PdpSubGroup subgroup, ToscaPolicyIdentifier desiredIdent) {
+ private boolean containsPolicy(PdpGroup group, PdpSubGroup subgroup, ToscaConceptIdentifier desiredIdent) {
String desnm = desiredIdent.getName();
String desvers = desiredIdent.getVersion();
- for (ToscaPolicyIdentifier actualIdent : subgroup.getPolicies()) {
+ for (ToscaConceptIdentifier actualIdent : subgroup.getPolicies()) {
if (!actualIdent.getName().equals(desnm)) {
continue;
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java
index cbacd5bf..bc838621 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -38,7 +39,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.pap.concepts.PolicyStatus;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.notification.PolicyNotifier;
@@ -173,7 +174,7 @@ public class PolicyStatusControllerV1 extends PapRestControllerV1 {
@ApiParam(value = "Policy Version", required = true) @PathParam("version") String version,
@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) final UUID requestId) {
- ToscaPolicyIdentifier ident = new ToscaPolicyIdentifier(name, version);
+ ToscaConceptIdentifier ident = new ToscaConceptIdentifier(name, version);
Optional<PolicyStatus> result = notifier.getStatus(ident);
if (result.isPresent()) {
return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java
index 85ad1280..1e7c788b 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -29,9 +29,9 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
import org.onap.policy.pap.main.comm.PolicyUndeployer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +51,7 @@ public class PolicyUndeployerImpl extends ProviderBase implements PolicyUndeploy
}
@Override
- public void undeploy(String group, String subgroup, Collection<ToscaPolicyIdentifier> policies)
+ public void undeploy(String group, String subgroup, Collection<ToscaConceptIdentifier> policies)
throws PfModelException {
process(new Info(group, subgroup, policies), this::undeployPolicies);
@@ -84,7 +84,7 @@ public class PolicyUndeployerImpl extends ProviderBase implements PolicyUndeploy
boolean updated = false;
Set<String> pdps = subgroup.getPdpInstances().stream().map(Pdp::getInstanceId).collect(Collectors.toSet());
- for (ToscaPolicyIdentifier ident : policyInfo.policies) {
+ for (ToscaConceptIdentifier ident : policyInfo.policies) {
if (!subgroup.getPolicies().remove(ident)) {
continue;
}
@@ -104,16 +104,17 @@ public class PolicyUndeployerImpl extends ProviderBase implements PolicyUndeploy
}
@Override
- protected Updater makeUpdater(SessionData data, ToscaPolicy policy, ToscaPolicyIdentifierOptVersion desiredPolicy) {
+ protected Updater makeUpdater(SessionData data, ToscaPolicy policy,
+ ToscaConceptIdentifierOptVersion desiredPolicy) {
throw new UnsupportedOperationException("makeUpdater should not be invoked");
}
private static class Info {
private String group;
private String subgroup;
- private Collection<ToscaPolicyIdentifier> policies;
+ private Collection<ToscaConceptIdentifier> policies;
- public Info(String group, String subgroup, Collection<ToscaPolicyIdentifier> policies) {
+ public Info(String group, String subgroup, Collection<ToscaConceptIdentifier> policies) {
this.group = group;
this.subgroup = subgroup;
this.policies = policies;
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java b/main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java
index 0b8da90b..0de7a6c4 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,9 +33,9 @@ import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
import org.onap.policy.pap.main.comm.PdpModifyRequestMap;
@@ -127,7 +127,7 @@ public abstract class ProviderBase {
* @param desiredPolicy request policy
* @throws PfModelException if an error occurred
*/
- protected void processPolicy(SessionData data, ToscaPolicyIdentifierOptVersion desiredPolicy)
+ protected void processPolicy(SessionData data, ToscaConceptIdentifierOptVersion desiredPolicy)
throws PfModelException {
ToscaPolicy policy = getPolicy(data, desiredPolicy);
@@ -156,7 +156,7 @@ public abstract class ProviderBase {
* @return a function to update a subgroup
*/
protected abstract Updater makeUpdater(SessionData data, ToscaPolicy policy,
- ToscaPolicyIdentifierOptVersion desiredPolicy);
+ ToscaConceptIdentifierOptVersion desiredPolicy);
/**
* Finds the active PDP group(s) that supports the given policy type.
@@ -167,7 +167,7 @@ public abstract class ProviderBase {
* given PDP types
* @throws PfModelException if an error occurred
*/
- private Collection<PdpGroup> getGroups(SessionData data, ToscaPolicyTypeIdentifier policyType)
+ private Collection<PdpGroup> getGroups(SessionData data, ToscaConceptIdentifier policyType)
throws PfModelException {
return data.getActivePdpGroupsByPolicyType(policyType);
@@ -233,7 +233,7 @@ public abstract class ProviderBase {
update.setDescription(group.getDescription());
update.setPdpGroup(group.getName());
update.setPdpSubgroup(subgroup.getPdpType());
- update.setPolicies(subgroup.getPolicies().stream().map(ToscaPolicyIdentifierOptVersion::new)
+ update.setPolicies(subgroup.getPolicies().stream().map(ToscaConceptIdentifierOptVersion::new)
.map(ident -> getPolicy(data, ident)).collect(Collectors.toList()));
return update;
@@ -247,7 +247,7 @@ public abstract class ProviderBase {
* @return the policy of interest
* @throws PfModelRuntimeException if an error occurred or the policy was not found
*/
- private ToscaPolicy getPolicy(SessionData data, ToscaPolicyIdentifierOptVersion ident) {
+ private ToscaPolicy getPolicy(SessionData data, ToscaConceptIdentifierOptVersion ident) {
try {
ToscaPolicy policy = data.getPolicy(ident);
if (policy == null) {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java b/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java
index 0d8f7033..cdcc51c6 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -37,13 +38,12 @@ import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter.ToscaPolicyFilterBuilder;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pap.main.notification.PolicyPdpNotificationData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,7 +75,7 @@ public class SessionData {
* Maps a policy type to the list of matching groups. Every group appearing within
* this map has a corresponding entry in {@link #groupCache}.
*/
- private final Map<ToscaPolicyTypeIdentifier, List<GroupData>> type2groups = new HashMap<>();
+ private final Map<ToscaConceptIdentifier, List<GroupData>> type2groups = new HashMap<>();
/**
* Maps a PDP name to its most recently generated update and state-change requests.
@@ -85,24 +85,24 @@ public class SessionData {
/**
* Maps a policy's identifier to the policy.
*/
- private final Map<ToscaPolicyIdentifierOptVersion, ToscaPolicy> policyCache = new HashMap<>();
+ private final Map<ToscaConceptIdentifierOptVersion, ToscaPolicy> policyCache = new HashMap<>();
/**
* Maps a policy type's identifier to the policy.
*/
- private final Map<ToscaPolicyTypeIdentifier, ToscaPolicyType> typeCache = new HashMap<>();
+ private final Map<ToscaConceptIdentifier, ToscaPolicyType> typeCache = new HashMap<>();
/**
* Policies to be deployed. This is just used to build up the data, which is then
* passed to the notifier once the update is "committed".
*/
- private final Map<ToscaPolicyIdentifier, PolicyPdpNotificationData> deploy = new HashMap<>();
+ private final Map<ToscaConceptIdentifier, PolicyPdpNotificationData> deploy = new HashMap<>();
/**
* Policies to be undeployed. This is just used to build up the data, which is then
* passed to the notifier once the update is "committed".
*/
- private final Map<ToscaPolicyIdentifier, PolicyPdpNotificationData> undeploy = new HashMap<>();
+ private final Map<ToscaConceptIdentifier, PolicyPdpNotificationData> undeploy = new HashMap<>();
/**
@@ -122,7 +122,7 @@ public class SessionData {
* @return the specified policy type
* @throws PfModelException if an error occurred
*/
- public ToscaPolicyType getPolicyType(ToscaPolicyTypeIdentifier desiredType) throws PfModelException {
+ public ToscaPolicyType getPolicyType(ToscaConceptIdentifier desiredType) throws PfModelException {
ToscaPolicyType type = typeCache.get(desiredType);
if (type == null) {
@@ -147,7 +147,7 @@ public class SessionData {
* @return the specified policy
* @throws PfModelException if an error occurred
*/
- public ToscaPolicy getPolicy(ToscaPolicyIdentifierOptVersion desiredPolicy) throws PfModelException {
+ public ToscaPolicy getPolicy(ToscaConceptIdentifierOptVersion desiredPolicy) throws PfModelException {
ToscaPolicy policy = policyCache.get(desiredPolicy);
if (policy == null) {
@@ -164,7 +164,7 @@ public class SessionData {
}
// desired version may have only been a prefix - cache with full identifier, too
- policyCache.putIfAbsent(new ToscaPolicyIdentifierOptVersion(policy.getIdentifier()), policy);
+ policyCache.putIfAbsent(new ToscaConceptIdentifierOptVersion(policy.getIdentifier()), policy);
return policy;
}
@@ -346,7 +346,7 @@ public class SessionData {
* @return the active groups supporting the given policy
* @throws PfModelException if an error occurred
*/
- public List<PdpGroup> getActivePdpGroupsByPolicyType(ToscaPolicyTypeIdentifier type) throws PfModelException {
+ public List<PdpGroup> getActivePdpGroupsByPolicyType(ToscaConceptIdentifier type) throws PfModelException {
/*
* Cannot use computeIfAbsent() because the enclosed code throws an unchecked
* exception and handling that would obfuscate the code too much, thus disabling
@@ -431,7 +431,7 @@ public class SessionData {
* @param pdps PDPs to which the policy is being deployed
* @throws PfModelException if an error occurred
*/
- protected void trackDeploy(ToscaPolicyIdentifier policyId, Collection<String> pdps) throws PfModelException {
+ protected void trackDeploy(ToscaConceptIdentifier policyId, Collection<String> pdps) throws PfModelException {
trackDeploy(policyId, new HashSet<>(pdps));
}
@@ -442,7 +442,7 @@ public class SessionData {
* @param pdps PDPs to which the policy is being deployed
* @throws PfModelException if an error occurred
*/
- protected void trackDeploy(ToscaPolicyIdentifier policyId, Set<String> pdps) throws PfModelException {
+ protected void trackDeploy(ToscaConceptIdentifier policyId, Set<String> pdps) throws PfModelException {
addData(policyId, pdps, deploy, undeploy);
}
@@ -453,7 +453,7 @@ public class SessionData {
* @param pdps PDPs to which the policy is being undeployed
* @throws PfModelException if an error occurred
*/
- protected void trackUndeploy(ToscaPolicyIdentifier policyId, Collection<String> pdps) throws PfModelException {
+ protected void trackUndeploy(ToscaConceptIdentifier policyId, Collection<String> pdps) throws PfModelException {
trackUndeploy(policyId, new HashSet<>(pdps));
}
@@ -464,7 +464,7 @@ public class SessionData {
* @param pdps PDPs to which the policy is being undeployed
* @throws PfModelException if an error occurred
*/
- protected void trackUndeploy(ToscaPolicyIdentifier policyId, Set<String> pdps) throws PfModelException {
+ protected void trackUndeploy(ToscaConceptIdentifier policyId, Set<String> pdps) throws PfModelException {
addData(policyId, pdps, undeploy, deploy);
}
@@ -477,17 +477,17 @@ public class SessionData {
* @param removeMap map from which it should be removed
* @throws PfModelException if an error occurred
*/
- private void addData(ToscaPolicyIdentifier policyId, Set<String> pdps,
- Map<ToscaPolicyIdentifier, PolicyPdpNotificationData> addMap,
- Map<ToscaPolicyIdentifier, PolicyPdpNotificationData> removeMap) throws PfModelException {
+ private void addData(ToscaConceptIdentifier policyId, Set<String> pdps,
+ Map<ToscaConceptIdentifier, PolicyPdpNotificationData> addMap,
+ Map<ToscaConceptIdentifier, PolicyPdpNotificationData> removeMap) throws PfModelException {
PolicyPdpNotificationData removeData = removeMap.get(policyId);
if (removeData != null) {
removeData.removeAll(pdps);
}
- ToscaPolicyIdentifierOptVersion optid = new ToscaPolicyIdentifierOptVersion(policyId);
- ToscaPolicyTypeIdentifier policyType = getPolicy(optid).getTypeIdentifier();
+ ToscaConceptIdentifierOptVersion optid = new ToscaConceptIdentifierOptVersion(policyId);
+ ToscaConceptIdentifier policyType = getPolicy(optid).getTypeIdentifier();
addMap.computeIfAbsent(policyId, key -> new PolicyPdpNotificationData(policyId, policyType)).addAll(pdps);
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/MultiPdpStatusListenerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/MultiPdpStatusListenerTest.java
index 9cef0c95..4f276a90 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/MultiPdpStatusListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/MultiPdpStatusListenerTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -33,7 +34,6 @@ import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
import org.onap.policy.models.pdp.concepts.PdpStatus;
-import org.onap.policy.pap.main.comm.MultiPdpStatusListener;
public class MultiPdpStatusListenerTest {
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
index a8c47043..1fdbfe65 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,7 +38,7 @@ import org.onap.policy.models.pdp.concepts.PdpStatus;
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.ToscaConceptIdentifier;
import org.onap.policy.pap.main.parameters.PdpParameters;
import org.onap.policy.pap.main.rest.e2e.End2EndBase;
@@ -72,8 +72,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status1.setPdpGroup(DEFAULT_GROUP);
status1.setPdpType(APEX_TYPE);
status1.setHealthy(PdpHealthStatus.HEALTHY);
- final List<ToscaPolicyIdentifier> idents1 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents1 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status1.setPolicies(idents1);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status1);
verifyPdpGroup(DEFAULT_GROUP, 1);
@@ -86,8 +86,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status2.setPdpType(APEX_TYPE);
status2.setHealthy(PdpHealthStatus.HEALTHY);
status2.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents2 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents2 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status2.setPolicies(idents2);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status2);
verifyPdpGroup(DEFAULT_GROUP, 1);
@@ -100,8 +100,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status3.setPdpType(APEX_TYPE);
status3.setHealthy(PdpHealthStatus.HEALTHY);
status3.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents3 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents3 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status3.setPolicies(idents3);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status3);
verifyPdpGroup(DEFAULT_GROUP, 2);
@@ -113,8 +113,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status4.setPdpGroup("wrongGroup");
status4.setPdpType(APEX_TYPE);
status4.setHealthy(PdpHealthStatus.HEALTHY);
- final List<ToscaPolicyIdentifier> idents4 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents4 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status4.setPolicies(idents4);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status4);
verifyPdpGroup(DEFAULT_GROUP, 2);
@@ -127,8 +127,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status5.setPdpType(APEX_TYPE);
status5.setHealthy(PdpHealthStatus.HEALTHY);
status5.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents5 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents5 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status5.setPolicies(idents5);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status5);
verifyPdpGroup(DEFAULT_GROUP, 2);
@@ -141,9 +141,9 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status6.setPdpType(APEX_TYPE);
status6.setHealthy(PdpHealthStatus.HEALTHY);
status6.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents6 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION),
- new ToscaPolicyIdentifier("onap.restart.tca", POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents6 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION),
+ new ToscaConceptIdentifier("onap.restart.tca", POLICY_VERSION));
status6.setPolicies(idents6);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status6);
verifyPdpGroup(DEFAULT_GROUP, 2);
@@ -168,8 +168,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status7b.setPdpType(APEX_TYPE);
status7b.setPdpSubgroup(APEX_TYPE);
status7b.setHealthy(PdpHealthStatus.HEALTHY);
- final List<ToscaPolicyIdentifier> idents7b =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents7b =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status7b.setPolicies(idents7b);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status7b);
verifyPdpGroup(DEFAULT_GROUP, 2);
@@ -182,8 +182,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status8.setPdpType(APEX_TYPE);
status8.setPdpSubgroup(APEX_TYPE);
status8.setHealthy(PdpHealthStatus.HEALTHY);
- final List<ToscaPolicyIdentifier> idents8 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents8 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status8.setPolicies(idents8);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status8);
verifyPdpGroup(DEFAULT_GROUP, 1);
@@ -196,8 +196,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status9.setPdpType(APEX_TYPE);
status9.setPdpSubgroup(APEX_TYPE);
status9.setHealthy(PdpHealthStatus.HEALTHY);
- final List<ToscaPolicyIdentifier> idents9 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents9 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status9.setPolicies(idents9);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status9);
verifyPdpGroup(DEFAULT_GROUP, 0);
@@ -216,8 +216,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status1.setPdpGroup(DEFAULT_GROUP);
status1.setPdpType(APEX_TYPE);
status1.setHealthy(PdpHealthStatus.HEALTHY);
- final List<ToscaPolicyIdentifier> idents1 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents1 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status1.setPolicies(idents1);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status1);
verifyPdpGroup(DEFAULT_GROUP, 1);
@@ -230,8 +230,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status2.setPdpType(APEX_TYPE);
status2.setHealthy(PdpHealthStatus.HEALTHY);
status2.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents2 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents2 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status2.setPolicies(idents2);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status2);
@@ -243,8 +243,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status3.setPdpType(APEX_TYPE);
status3.setHealthy(PdpHealthStatus.HEALTHY);
status3.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents3 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents3 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status3.setPolicies(idents3);
PdpStatistics pdpStatistics03 = new PdpStatistics();
@@ -264,8 +264,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status4.setPdpType(APEX_TYPE);
status4.setHealthy(PdpHealthStatus.HEALTHY);
status4.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents4 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents4 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status4.setPolicies(idents4);
status4.setStatistics(null);
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status4);
@@ -279,8 +279,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status5.setPdpType(APEX_TYPE);
status5.setHealthy(PdpHealthStatus.HEALTHY);
status5.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents5 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents5 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status5.setPolicies(idents5);
PdpStatistics pdpStatistics05 = new PdpStatistics();
@@ -301,8 +301,8 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
status6.setPdpType(APEX_TYPE);
status6.setHealthy(PdpHealthStatus.HEALTHY);
status6.setPdpSubgroup(APEX_TYPE);
- final List<ToscaPolicyIdentifier> idents6 =
- Arrays.asList(new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION));
+ final List<ToscaConceptIdentifier> idents6 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
status5.setPolicies(idents6);
PdpStatistics pdpStatistics06 = new PdpStatistics();
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
index 3a35370b..114d50e6 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -59,8 +59,8 @@ import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
import org.onap.policy.pap.main.comm.msgdata.Request;
import org.onap.policy.pap.main.comm.msgdata.RequestListener;
import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams;
@@ -86,7 +86,7 @@ public class PdpModifyRequestMapTest extends CommonRequestBase {
* Used to capture input to undeployer.undeploy().
*/
@Captor
- private ArgumentCaptor<Collection<ToscaPolicyIdentifier>> undeployCaptor;
+ private ArgumentCaptor<Collection<ToscaConceptIdentifier>> undeployCaptor;
@Mock
private PdpRequests requests;
@@ -547,7 +547,7 @@ public class PdpModifyRequestMapTest extends CommonRequestBase {
@Test
public void testSingletonListenerFailureUndeploy() throws Exception {
- ToscaPolicyIdentifier ident = new ToscaPolicyIdentifier("undeployed", "2.3.4");
+ ToscaConceptIdentifier ident = new ToscaConceptIdentifier("undeployed", "2.3.4");
ToscaPolicy policy = mock(ToscaPolicy.class);
when(policy.getIdentifier()).thenReturn(ident);
@@ -592,7 +592,7 @@ public class PdpModifyRequestMapTest extends CommonRequestBase {
@Test
public void testSingletonListenerFailureUndeployMessageUnchanged() throws Exception {
- ToscaPolicyIdentifier ident = new ToscaPolicyIdentifier("msg-unchanged", "8.7.6");
+ ToscaConceptIdentifier ident = new ToscaConceptIdentifier("msg-unchanged", "8.7.6");
ToscaPolicy policy = mock(ToscaPolicy.class);
when(policy.getIdentifier()).thenReturn(ident);
diff --git a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonSupport.java b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonSupport.java
index 14f3055c..de1848d4 100644
--- a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonSupport.java
+++ b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonSupport.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -24,8 +25,7 @@ import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.onap.policy.models.pap.concepts.PolicyStatus;
-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;
/**
* Super class for policy notification test classes.
@@ -37,22 +37,22 @@ public class PolicyCommonSupport {
protected static final String PDP3 = "pdp-3";
protected static final String PDP4 = "pdp-4";
- protected ToscaPolicyTypeIdentifier type;
- protected ToscaPolicyIdentifier policy1;
- protected ToscaPolicyIdentifier policy2;
- protected ToscaPolicyIdentifier policy3;
- protected ToscaPolicyIdentifier policy4;
+ protected ToscaConceptIdentifier type;
+ protected ToscaConceptIdentifier policy1;
+ protected ToscaConceptIdentifier policy2;
+ protected ToscaConceptIdentifier policy3;
+ protected ToscaConceptIdentifier policy4;
/**
* Creates various objects.
*/
@Before
public void setUp() {
- type = new ToscaPolicyTypeIdentifier("my-type", "3.2.1");
- policy1 = new ToscaPolicyIdentifier("my-id-a", "1.2.0");
- policy2 = new ToscaPolicyIdentifier("my-id-b", "1.2.1");
- policy3 = new ToscaPolicyIdentifier("my-id-c", "1.2.2");
- policy4 = new ToscaPolicyIdentifier("my-id-d", "1.2.3");
+ type = new ToscaConceptIdentifier("my-type", "3.2.1");
+ policy1 = new ToscaConceptIdentifier("my-id-a", "1.2.0");
+ policy2 = new ToscaConceptIdentifier("my-id-b", "1.2.1");
+ policy3 = new ToscaConceptIdentifier("my-id-c", "1.2.2");
+ policy4 = new ToscaConceptIdentifier("my-id-d", "1.2.3");
}
/**
@@ -62,7 +62,7 @@ public class PolicyCommonSupport {
* @param pdps PDPs to be included within the data
* @return a new notification data structure
*/
- protected PolicyPdpNotificationData makeData(ToscaPolicyIdentifier policyId, String... pdps) {
+ protected PolicyPdpNotificationData makeData(ToscaConceptIdentifier policyId, String... pdps) {
PolicyPdpNotificationData data = new PolicyPdpNotificationData(policyId, type);
data.addAll(Arrays.asList(pdps));
return data;
diff --git a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java
index 34d4db60..b80b80d7 100644
--- a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -37,17 +38,18 @@ import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.models.pap.concepts.PolicyStatus;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.powermock.reflect.Whitebox;
public class PolicyCommonTrackerTest extends PolicyCommonSupport {
private MyTracker tracker;
- private Map<ToscaPolicyIdentifier, PolicyTrackerData> map;
+ private Map<ToscaConceptIdentifier, PolicyTrackerData> map;
/**
* Creates various objects, including {@link #tracker}.
*/
+ @Override
@Before
public void setUp() {
super.setUp();
@@ -73,24 +75,24 @@ public class PolicyCommonTrackerTest extends PolicyCommonSupport {
tracker.addData(makeData(policy1, PDP1, PDP2));
tracker.addData(makeData(policy2, PDP2));
- policy3 = new ToscaPolicyIdentifier(policy1.getName(), policy1.getVersion() + "0");
+ policy3 = new ToscaConceptIdentifier(policy1.getName(), policy1.getVersion() + "0");
tracker.addData(makeData(policy3, PDP3));
List<PolicyStatus> statusList = tracker.getStatus(policy1.getName());
assertEquals(2, statusList.size());
- Set<ToscaPolicyIdentifier> idents =
+ Set<ToscaConceptIdentifier> idents =
statusList.stream().map(PolicyStatus::getPolicy).collect(Collectors.toSet());
assertTrue(idents.contains(policy1));
assertTrue(idents.contains(policy3));
}
@Test
- public void testGetStatusToscaPolicyIdentifier() {
+ public void testGetStatusToscaConceptIdentifier() {
tracker.addData(makeData(policy1, PDP1, PDP2));
tracker.addData(makeData(policy2, PDP2));
- policy3 = new ToscaPolicyIdentifier(policy1.getName(), policy1.getVersion() + "0");
+ policy3 = new ToscaConceptIdentifier(policy1.getName(), policy1.getVersion() + "0");
tracker.addData(makeData(policy3, PDP3));
Optional<PolicyStatus> status = tracker.getStatus(policy1);
diff --git a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
index 1305f27e..5e64c939 100644
--- a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -50,9 +51,8 @@ import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
import org.onap.policy.pap.main.PolicyPapRuntimeException;
import org.onap.policy.pap.main.comm.Publisher;
@@ -95,6 +95,7 @@ public class PolicyNotifierTest extends PolicyCommonSupport {
/**
* Creates various objects, including {@link #notifier}.
*/
+ @Override
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -122,7 +123,7 @@ public class PolicyNotifierTest extends PolicyCommonSupport {
when(dao.getPdpGroups(null)).thenReturn(Arrays.asList(group1, group2));
- ToscaPolicyTypeIdentifier type2 = new ToscaPolicyTypeIdentifier("my other type", "8.8.8");
+ ToscaConceptIdentifier type2 = new ToscaConceptIdentifier("my other type", "8.8.8");
// note: no mapping for policy4
when(dao.getFilteredPolicyList(any())).thenReturn(Arrays.asList(makePolicy(policy1, type),
@@ -159,7 +160,7 @@ public class PolicyNotifierTest extends PolicyCommonSupport {
assertEquals("[sub #2 A 0]", data.getPdps().toString());
}
- private ToscaPolicy makePolicy(ToscaPolicyIdentifier policyId, ToscaPolicyTypeIdentifier type) {
+ private ToscaPolicy makePolicy(ToscaConceptIdentifier policyId, ToscaConceptIdentifier type) {
ToscaPolicy policy = new ToscaPolicy();
policy.setName(policyId.getName());
@@ -179,7 +180,7 @@ public class PolicyNotifierTest extends PolicyCommonSupport {
return group;
}
- private PdpSubGroup makeSubGroup(String name, int numPdps, ToscaPolicyIdentifier... policies) {
+ private PdpSubGroup makeSubGroup(String name, int numPdps, ToscaConceptIdentifier... policies) {
final PdpSubGroup subgrp = new PdpSubGroup();
subgrp.setPdpType(name);
subgrp.setPdpInstances(new ArrayList<>(numPdps));
@@ -213,7 +214,7 @@ public class PolicyNotifierTest extends PolicyCommonSupport {
}
@Test
- public void testGetStatusToscaPolicyIdentifier() {
+ public void testGetStatusToscaConceptIdentifier() {
Optional<PolicyStatus> status = Optional.of(status1);
when(deploy.getStatus(policy1)).thenReturn(status);
@@ -243,7 +244,7 @@ public class PolicyNotifierTest extends PolicyCommonSupport {
doAnswer(addStatus(2, status1, status2)).when(deploy).processResponse(eq(PDP1), any(), any());
doAnswer(addStatus(2, status3, status4)).when(undeploy).processResponse(eq(PDP1), any(), any());
- List<ToscaPolicyIdentifier> activePolicies = Arrays.asList(policy1, policy2);
+ List<ToscaConceptIdentifier> activePolicies = Arrays.asList(policy1, policy2);
notifier.processResponse(PDP1, activePolicies);
PolicyNotification notification = getNotification();
diff --git a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationDataTest.java b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationDataTest.java
index cd8b4d32..67a3cb1f 100644
--- a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationDataTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyPdpNotificationDataTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -30,8 +31,7 @@ import java.util.Collections;
import java.util.TreeSet;
import org.junit.Before;
import org.junit.Test;
-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;
/**
* Note: this wraps the PDPs in a TreeSet so that the content can be verified without
@@ -43,8 +43,8 @@ public class PolicyPdpNotificationDataTest {
private static final String PDP3 = "pdp-3";
private static final String PDP4 = "pdp-4";
- private ToscaPolicyIdentifier policyId;
- private ToscaPolicyTypeIdentifier policyType;
+ private ToscaConceptIdentifier policyId;
+ private ToscaConceptIdentifier policyType;
private PolicyPdpNotificationData data;
/**
@@ -52,8 +52,8 @@ public class PolicyPdpNotificationDataTest {
*/
@Before
public void setUp() {
- policyId = new ToscaPolicyIdentifier("my-id", "1.2.3");
- policyType = new ToscaPolicyTypeIdentifier("my-type", "3.2.1");
+ policyId = new ToscaConceptIdentifier("my-id", "1.2.3");
+ policyType = new ToscaConceptIdentifier("my-type", "3.2.1");
data = new PolicyPdpNotificationData(policyId, policyType);
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyTrackerDataTest.java b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyTrackerDataTest.java
index ff797809..2d27b75e 100644
--- a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyTrackerDataTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyTrackerDataTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -31,11 +32,11 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.models.pap.concepts.PolicyStatus;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class PolicyTrackerDataTest {
- private static final ToscaPolicyTypeIdentifier TYPE = new ToscaPolicyTypeIdentifier("my-type", "1.2.3");
+ private static final ToscaConceptIdentifier TYPE = new ToscaConceptIdentifier("my-type", "1.2.3");
private static final String PDP1 = "pdp-1";
private static final String PDP2 = "pdp-2";
private static final String PDP3 = "pdp-3";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
index fc3bc626..a753db1e 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * 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.
@@ -48,7 +48,7 @@ import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
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;
public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -478,7 +478,7 @@ public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
when(dao.getPdpGroups(group.getName())).thenReturn(Arrays.asList(group));
newgrp.getPdpSubgroups().get(0).getSupportedPolicyTypes()
- .add(new ToscaPolicyTypeIdentifier("typeX.*", "9.8.7"));
+ .add(new ToscaConceptIdentifier("typeX.*", "9.8.7"));
// the group is updated with a new supported policy type in subgroup
assertEquals(2, newgrp.getPdpSubgroups().get(0).getSupportedPolicyTypes().size());
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
index 250b9678..99aa3542 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -51,8 +51,8 @@ import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
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.ToscaPolicyIdentifierOptVersion;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.pap.main.rest.ProviderBase.Updater;
public class TestPdpGroupDeleteProvider extends ProviderSuper {
@@ -66,9 +66,9 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper {
private ArgumentCaptor<Set<String>> pdpCaptor;
private MyProvider prov;
- private ToscaPolicyIdentifierOptVersion optIdent;
- private ToscaPolicyIdentifierOptVersion fullIdent;
- private ToscaPolicyIdentifier ident;
+ private ToscaConceptIdentifierOptVersion optIdent;
+ private ToscaConceptIdentifierOptVersion fullIdent;
+ private ToscaConceptIdentifier ident;
private Updater updater;
@@ -89,8 +89,8 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper {
super.setUp();
ident = policy1.getIdentifier();
- optIdent = new ToscaPolicyIdentifierOptVersion(ident.getName(), null);
- fullIdent = new ToscaPolicyIdentifierOptVersion(ident.getName(), ident.getVersion());
+ optIdent = new ToscaConceptIdentifierOptVersion(ident.getName(), null);
+ fullIdent = new ToscaConceptIdentifierOptVersion(ident.getName(), ident.getVersion());
prov = new MyProvider();
@@ -292,7 +292,7 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper {
}
@Override
- protected void processPolicy(SessionData data, ToscaPolicyIdentifierOptVersion desiredPolicy)
+ protected void processPolicy(SessionData data, ToscaConceptIdentifierOptVersion desiredPolicy)
throws PfModelException {
// do nothing
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java
index 739a5f38..f2d33374 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,7 +35,7 @@ import org.onap.policy.models.pap.concepts.PdpGroupDeployResponse;
import org.onap.policy.models.pdp.concepts.DeploymentGroup;
import org.onap.policy.models.pdp.concepts.DeploymentGroups;
import org.onap.policy.models.pdp.concepts.DeploymentSubGroup;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
/**
* Note: this tests failure cases; success cases are tested by tests in the "e2e" package.
@@ -104,8 +104,8 @@ public class TestPdpGroupDeployControllerV1 extends CommonPapRestServer {
}
private Entity<PdpDeployPolicies> makePdpPoliciesEntity() {
- ToscaPolicyIdentifierOptVersion pol1 = new ToscaPolicyIdentifierOptVersion("policy-a", "1");
- ToscaPolicyIdentifierOptVersion pol2 = new ToscaPolicyIdentifierOptVersion("policy-b", null);
+ ToscaConceptIdentifierOptVersion pol1 = new ToscaConceptIdentifierOptVersion("policy-a", "1");
+ ToscaConceptIdentifierOptVersion pol2 = new ToscaConceptIdentifierOptVersion("policy-b", null);
PdpDeployPolicies policies = new PdpDeployPolicies();
policies.setPolicies(Arrays.asList(pol1, pol2));
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
index db320b5c..b6763008 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -24,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -53,8 +54,8 @@ import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
import org.onap.policy.pap.main.notification.PolicyPdpNotificationData;
public class TestPdpGroupDeployProvider extends ProviderSuper {
@@ -85,6 +86,7 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
*
* @throws Exception if an error occurs
*/
+ @Override
@Before
public void setUp() throws Exception {
@@ -107,9 +109,9 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
when(dao.getPdpGroups(dbgroup.getName())).thenReturn(Arrays.asList(dbgroup));
// add new policies
- List<ToscaPolicyIdentifier> policies = newgrp.getPdpSubgroups().get(0).getPolicies();
- policies.add(new ToscaPolicyIdentifier(POLICY2_NAME, POLICY2_VERSION));
- policies.add(new ToscaPolicyIdentifier(POLICY3_NAME, POLICY3_VERSION));
+ List<ToscaConceptIdentifier> policies = newgrp.getPdpSubgroups().get(0).getPolicies();
+ policies.add(new ToscaConceptIdentifier(POLICY2_NAME, POLICY2_VERSION));
+ policies.add(new ToscaConceptIdentifier(POLICY3_NAME, POLICY3_VERSION));
when(dao.getFilteredPolicyList(any())).thenReturn(loadPolicies("createGroupNewPolicy.json"))
.thenReturn(loadPolicies("createGroupNewPolicy2.json"))
@@ -134,15 +136,15 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
PdpGroup newgrp = groups.getGroups().get(0);
// additional policies in the DB that will be removed
- List<ToscaPolicyIdentifier> policies = newgrp.getPdpSubgroups().get(0).getPolicies();
- policies.add(new ToscaPolicyIdentifier(POLICY2_NAME, POLICY2_VERSION));
- policies.add(new ToscaPolicyIdentifier(POLICY3_NAME, POLICY3_VERSION));
+ List<ToscaConceptIdentifier> policies = newgrp.getPdpSubgroups().get(0).getPolicies();
+ policies.add(new ToscaConceptIdentifier(POLICY2_NAME, POLICY2_VERSION));
+ policies.add(new ToscaConceptIdentifier(POLICY3_NAME, POLICY3_VERSION));
PdpGroup dbgroup = new PdpGroup(newgrp);
when(dao.getPdpGroups(dbgroup.getName())).thenReturn(Arrays.asList(dbgroup));
// policy that should be left
- final ToscaPolicyIdentifier policyId1 = policies.remove(0);
+ final ToscaConceptIdentifier policyId1 = policies.remove(0);
when(dao.getFilteredPolicyList(any())).thenReturn(loadPolicies("createGroupNewPolicy.json"))
.thenReturn(loadPolicies("createGroupNewPolicy2.json"))
@@ -171,24 +173,24 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
PdpSubGroup subgrp = newgrp.getPdpSubgroups().get(0);
// put policy3 into db subgroup
- subgrp.getPolicies().add(new ToscaPolicyIdentifier(POLICY3_NAME, POLICY3_VERSION));
+ subgrp.getPolicies().add(new ToscaConceptIdentifier(POLICY3_NAME, POLICY3_VERSION));
PdpGroup dbgroup = new PdpGroup(newgrp);
when(dao.getPdpGroups(dbgroup.getName())).thenReturn(Arrays.asList(dbgroup));
// now make the subgrp reflect our final expectation
subgrp.getPolicies().remove(1);
- subgrp.getPolicies().add(new ToscaPolicyIdentifier(POLICY2_NAME, POLICY2_VERSION));
+ subgrp.getPolicies().add(new ToscaConceptIdentifier(POLICY2_NAME, POLICY2_VERSION));
// indicate policy2 being added and policy3 being deleted
DeploymentSubGroup depsub1 = new DeploymentSubGroup();
depsub1.setAction(Action.POST);
depsub1.setPdpType(subgrp.getPdpType());
- depsub1.setPolicies(Arrays.asList(new ToscaPolicyIdentifier(POLICY2_NAME, POLICY2_VERSION)));
+ depsub1.setPolicies(Arrays.asList(new ToscaConceptIdentifier(POLICY2_NAME, POLICY2_VERSION)));
DeploymentSubGroup depsub2 = new DeploymentSubGroup();
depsub2.setAction(Action.DELETE);
depsub2.setPdpType(subgrp.getPdpType());
- depsub2.setPolicies(Arrays.asList(new ToscaPolicyIdentifier(POLICY3_NAME, POLICY3_VERSION)));
+ depsub2.setPolicies(Arrays.asList(new ToscaConceptIdentifier(POLICY3_NAME, POLICY3_VERSION)));
DeploymentGroup depgroup = new DeploymentGroup();
depgroup.setName(newgrp.getName());
@@ -215,7 +217,7 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
when(dao.getPdpGroups(group.getName())).thenReturn(Arrays.asList(group));
// something different in this subgroup
- group.getPdpSubgroups().get(0).getPolicies().add(new ToscaPolicyIdentifier(POLICY2_NAME, POLICY2_VERSION));
+ group.getPdpSubgroups().get(0).getPolicies().add(new ToscaConceptIdentifier(POLICY2_NAME, POLICY2_VERSION));
prov.updateGroupPolicies(toDeploymentGroups(groups));
@@ -290,7 +292,7 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
when(dao.getPdpGroups(group.getName())).thenReturn(Arrays.asList(group));
// something different in this subgroup
- group.getPdpSubgroups().get(0).getPolicies().add(new ToscaPolicyIdentifier(POLICY2_NAME, POLICY2_VERSION));
+ group.getPdpSubgroups().get(0).getPolicies().add(new ToscaConceptIdentifier(POLICY2_NAME, POLICY2_VERSION));
prov.updateGroupPolicies(toDeploymentGroups(groups));
@@ -334,10 +336,10 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
when(dao.getPdpGroups(group.getName())).thenReturn(Arrays.asList(group));
// add two new policies
- ToscaPolicyIdentifier policyId2 = new ToscaPolicyIdentifier(POLICY2_NAME, POLICY2_VERSION);
+ ToscaConceptIdentifier policyId2 = new ToscaConceptIdentifier(POLICY2_NAME, POLICY2_VERSION);
subgrp.getPolicies().add(policyId2);
- ToscaPolicyIdentifier policyId3 = new ToscaPolicyIdentifier(POLICY3_NAME, POLICY3_VERSION);
+ ToscaConceptIdentifier policyId3 = new ToscaConceptIdentifier(POLICY3_NAME, POLICY3_VERSION);
subgrp.getPolicies().add(policyId3);
when(dao.getFilteredPolicyList(any())).thenReturn(loadPolicies("createGroupNewPolicy.json"))
@@ -374,7 +376,7 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
// use version prefix
PdpSubGroup subgrp = newgrp.getPdpSubgroups().get(0);
- ToscaPolicyIdentifier ident = subgrp.getPolicies().get(0);
+ ToscaConceptIdentifier ident = subgrp.getPolicies().get(0);
String version = ident.getVersion();
ident.setVersion("1");
@@ -649,7 +651,7 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
assertEquals(subgrp.getPdpType(), pdpUpdate.getPdpSubgroup());
- List<ToscaPolicyIdentifier> pdpPolicies =
+ List<ToscaConceptIdentifier> pdpPolicies =
pdpUpdate.getPolicies().stream().map(ToscaPolicy::getIdentifier).collect(Collectors.toList());
Collections.sort(pdpPolicies);
@@ -659,7 +661,7 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
assertEquals(Arrays.asList(group), updates);
}
- private void assertDeploymentData(PolicyPdpNotificationData data, ToscaPolicyIdentifier policyId,
+ private void assertDeploymentData(PolicyPdpNotificationData data, ToscaConceptIdentifier policyId,
String expectedPdps) {
assertEquals(policyId, data.getPolicyId());
assertEquals(policy1.getTypeIdentifier(), data.getPolicyType());
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java
index 1a54fe5f..9ae64452 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -21,7 +22,7 @@
package org.onap.policy.pap.main.rest;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -42,7 +43,7 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
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.ToscaConceptIdentifier;
public class TestPolicyUndeployerImpl extends ProviderSuper {
private static final String MY_GROUP = "my-group";
@@ -56,10 +57,10 @@ public class TestPolicyUndeployerImpl extends ProviderSuper {
@Captor
private ArgumentCaptor<Set<String>> pdpCaptor;
- private ToscaPolicyIdentifier ident1;
- private ToscaPolicyIdentifier ident2;
- private ToscaPolicyIdentifier ident3;
- private ToscaPolicyIdentifier ident4;
+ private ToscaConceptIdentifier ident1;
+ private ToscaConceptIdentifier ident2;
+ private ToscaConceptIdentifier ident3;
+ private ToscaConceptIdentifier ident4;
private PdpGroup group;
private PdpSubGroup subgroup;
private MyProvider prov;
@@ -75,15 +76,16 @@ public class TestPolicyUndeployerImpl extends ProviderSuper {
*
* @throws Exception if an error occurs
*/
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
- ident1 = new ToscaPolicyIdentifier("ident-a", "2.3.1");
- ident2 = new ToscaPolicyIdentifier("ident-b", "2.3.2");
- ident3 = new ToscaPolicyIdentifier("ident-c", "2.3.3");
- ident4 = new ToscaPolicyIdentifier("ident-d", "2.3.4");
+ ident1 = new ToscaConceptIdentifier("ident-a", "2.3.1");
+ ident2 = new ToscaConceptIdentifier("ident-b", "2.3.2");
+ ident3 = new ToscaConceptIdentifier("ident-c", "2.3.3");
+ ident4 = new ToscaConceptIdentifier("ident-d", "2.3.4");
group = new PdpGroup();
group.setName(MY_GROUP);
@@ -131,7 +133,7 @@ public class TestPolicyUndeployerImpl extends ProviderSuper {
*/
@Test
public void testUndeployPoliciesUnchanged() throws PfModelException {
- List<ToscaPolicyIdentifier> origlist = Arrays.asList(ident3, ident4);
+ List<ToscaConceptIdentifier> origlist = Arrays.asList(ident3, ident4);
subgroup.setPolicies(new LinkedList<>(origlist));
prov.undeploy(MY_GROUP, MY_SUBGROUP, Arrays.asList(ident1, ident2));
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java
index 818237d5..060173bb 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -24,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -44,12 +45,13 @@ import org.mockito.ArgumentCaptor;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.pap.concepts.PapPolicyIdentifier;
import org.onap.policy.models.pap.concepts.PdpDeployPolicies;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
import org.onap.policy.pap.main.notification.PolicyPdpNotificationData;
import org.powermock.reflect.Whitebox;
@@ -82,6 +84,7 @@ public class TestProviderBase extends ProviderSuper {
*
* @throws Exception if an error occurs
*/
+ @Override
@Before
public void setUp() throws Exception {
@@ -156,7 +159,7 @@ public class TestProviderBase extends ProviderSuper {
when(dao.getFilteredPdpGroups(any())).thenReturn(Collections.emptyList());
SessionData session = new SessionData(dao);
- ToscaPolicyIdentifierOptVersion ident = new ToscaPolicyIdentifierOptVersion(POLICY1_NAME, POLICY1_VERSION);
+ ToscaConceptIdentifierOptVersion ident = new ToscaConceptIdentifierOptVersion(POLICY1_NAME, POLICY1_VERSION);
assertThatThrownBy(() -> prov.processPolicy(session, ident)).isInstanceOf(PfModelException.class)
.hasMessage("policy not supported by any PDP group: policyA 1.2.3");
@@ -167,7 +170,7 @@ public class TestProviderBase extends ProviderSuper {
PfModelException exc = new PfModelException(Status.CONFLICT, EXPECTED_EXCEPTION);
when(dao.getFilteredPolicyList(any())).thenThrow(exc);
- ToscaPolicyIdentifierOptVersion req = loadRequest();
+ ToscaConceptIdentifierOptVersion req = loadRequest();
assertThatThrownBy(() -> prov.process(req, this::handle)).isInstanceOf(PfModelRuntimeException.class)
.hasCause(exc);
}
@@ -176,7 +179,7 @@ public class TestProviderBase extends ProviderSuper {
public void testGetPolicy_NotFound() throws Exception {
when(dao.getFilteredPolicyList(any())).thenReturn(Collections.emptyList());
- ToscaPolicyIdentifierOptVersion req = loadRequest();
+ ToscaConceptIdentifierOptVersion req = loadRequest();
assertThatThrownBy(() -> prov.process(req, this::handle)).isInstanceOf(PfModelRuntimeException.class)
.hasMessage("cannot find policy: policyA 1.2.3")
.extracting(ex -> ((PfModelRuntimeException) ex).getErrorResponse().getResponseCode())
@@ -263,7 +266,7 @@ public class TestProviderBase extends ProviderSuper {
PdpDeployPolicies request = loadFile("updateGroupReqMultiple.json", PdpDeployPolicies.class);
prov.process(request, (data, deploy) -> {
- for (ToscaPolicyIdentifierOptVersion policy : deploy.getPolicies()) {
+ for (ToscaConceptIdentifierOptVersion policy : deploy.getPolicies()) {
handle(data, policy);
}
});
@@ -307,7 +310,7 @@ public class TestProviderBase extends ProviderSuper {
*
* @return a standard request
*/
- protected ToscaPolicyIdentifierOptVersion loadRequest() {
+ protected ToscaConceptIdentifierOptVersion loadRequest() {
return loadRequest("requestBase.json");
}
@@ -317,8 +320,8 @@ public class TestProviderBase extends ProviderSuper {
* @param fileName name of the file from which to load
* @return the request that was loaded
*/
- protected ToscaPolicyIdentifierOptVersion loadRequest(String fileName) {
- return loadFile(fileName, ToscaPolicyIdentifierOptVersion.class);
+ protected ToscaConceptIdentifierOptVersion loadRequest(String fileName) {
+ return loadFile(fileName, PapPolicyIdentifier.class).getGenericIdentifier();
}
/**
@@ -326,7 +329,7 @@ public class TestProviderBase extends ProviderSuper {
*
* @return an empty request
*/
- protected ToscaPolicyIdentifierOptVersion loadEmptyRequest() {
+ protected ToscaConceptIdentifierOptVersion loadEmptyRequest() {
return loadRequest("emptyRequestBase.json");
}
@@ -337,7 +340,7 @@ public class TestProviderBase extends ProviderSuper {
* @param request request to be handled
* @throws PfModelException if an error occurred
*/
- private void handle(SessionData data, ToscaPolicyIdentifierOptVersion request) throws PfModelException {
+ private void handle(SessionData data, ToscaConceptIdentifierOptVersion request) throws PfModelException {
prov.processPolicy(data, request);
}
@@ -369,7 +372,7 @@ public class TestProviderBase extends ProviderSuper {
@Override
protected Updater makeUpdater(SessionData data, ToscaPolicy policy,
- ToscaPolicyIdentifierOptVersion desiredPolicy) {
+ ToscaConceptIdentifierOptVersion desiredPolicy) {
return (group, subgroup) -> {
if (shouldUpdate.remove()) {
@@ -379,7 +382,7 @@ public class TestProviderBase extends ProviderSuper {
data.trackDeploy(policy.getIdentifier(), Collections.singleton(PDP1));
data.trackUndeploy(policy.getIdentifier(), Collections.singleton(PDP2));
- ToscaPolicyIdentifier ident2 = new ToscaPolicyIdentifier(POLICY1_NAME, "9.9.9");
+ ToscaConceptIdentifier ident2 = new ToscaConceptIdentifier(POLICY1_NAME, "9.9.9");
data.trackDeploy(ident2, Collections.singleton(PDP3));
data.trackUndeploy(ident2, Collections.singleton(PDP4));
return true;
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java
index 34b7c61f..a2914cfa 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -28,7 +29,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -52,12 +53,11 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pap.main.notification.PolicyPdpNotificationData;
public class TestSessionData extends ProviderSuper {
@@ -73,9 +73,9 @@ public class TestSessionData extends ProviderSuper {
private static final String EXPECTED_EXCEPTION = "expected exception";
private SessionData session;
- private ToscaPolicyIdentifierOptVersion ident;
- private ToscaPolicyTypeIdentifier type;
- private ToscaPolicyTypeIdentifier type2;
+ private ToscaConceptIdentifierOptVersion ident;
+ private ToscaConceptIdentifier type;
+ private ToscaConceptIdentifier type2;
private PdpGroup group1;
private PdpGroup group2;
@@ -84,13 +84,14 @@ public class TestSessionData extends ProviderSuper {
*
* @throws Exception if an error occurs
*/
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
- ident = new ToscaPolicyIdentifierOptVersion(POLICY_NAME, POLICY_VERSION);
- type = new ToscaPolicyTypeIdentifier(POLICY_TYPE, POLICY_TYPE_VERSION);
- type2 = new ToscaPolicyTypeIdentifier(POLICY_TYPE, POLICY_TYPE_VERSION + "0");
+ ident = new ToscaConceptIdentifierOptVersion(POLICY_NAME, POLICY_VERSION);
+ type = new ToscaConceptIdentifier(POLICY_TYPE, POLICY_TYPE_VERSION);
+ type2 = new ToscaConceptIdentifier(POLICY_TYPE, POLICY_TYPE_VERSION + "0");
group1 = loadGroup("group1.json");
group2 = loadGroup("group2.json");
@@ -137,7 +138,7 @@ public class TestSessionData extends ProviderSuper {
assertEquals(null, filter.getVersionPrefix());
// retrieve a second time using full version - should use cache
- assertSame(policy1, session.getPolicy(new ToscaPolicyIdentifierOptVersion(policy1.getIdentifier())));
+ assertSame(policy1, session.getPolicy(new ToscaConceptIdentifierOptVersion(policy1.getIdentifier())));
verify(dao).getFilteredPolicyList(any());
}
@@ -155,7 +156,7 @@ public class TestSessionData extends ProviderSuper {
assertEquals("1.", filter.getVersionPrefix());
// retrieve a second time using full version - should use cache
- assertSame(policy1, session.getPolicy(new ToscaPolicyIdentifierOptVersion(policy1.getIdentifier())));
+ assertSame(policy1, session.getPolicy(new ToscaConceptIdentifierOptVersion(policy1.getIdentifier())));
verify(dao).getFilteredPolicyList(any());
}
@@ -173,7 +174,7 @@ public class TestSessionData extends ProviderSuper {
assertEquals(null, filter.getVersionPrefix());
// retrieve a second time using full version - should use cache
- assertSame(policy1, session.getPolicy(new ToscaPolicyIdentifierOptVersion(policy1.getIdentifier())));
+ assertSame(policy1, session.getPolicy(new ToscaConceptIdentifierOptVersion(policy1.getIdentifier())));
verify(dao).getFilteredPolicyList(any());
}
@@ -577,7 +578,7 @@ public class TestSessionData extends ProviderSuper {
when(dao.getFilteredPolicyList(any())).thenReturn(Arrays.asList(policy));
- ToscaPolicyIdentifier policyId = new ToscaPolicyIdentifier(POLICY_NAME, POLICY_VERSION);
+ ToscaConceptIdentifier policyId = new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION);
List<String> pdps = Arrays.asList(PDP1, PDP2);
for (TrackEx trackFunc : trackFuncs) {
@@ -657,6 +658,6 @@ public class TestSessionData extends ProviderSuper {
@FunctionalInterface
private static interface TrackEx {
- public void accept(ToscaPolicyIdentifier policyId, Collection<String> pdps) throws PfModelException;
+ public void accept(ToscaConceptIdentifier policyId, Collection<String> pdps) throws PfModelException;
}
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java
index d9fc66ad..55cf2f4c 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -40,7 +41,7 @@ import org.onap.policy.models.pap.concepts.PdpGroupDeleteResponse;
import org.onap.policy.models.pap.concepts.PolicyNotification;
import org.onap.policy.models.pap.concepts.PolicyStatus;
import org.onap.policy.models.pdp.concepts.PdpStatus;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pap.main.PapConstants;
public class PdpGroupDeleteTest extends End2EndBase {
@@ -63,6 +64,7 @@ public class PdpGroupDeleteTest extends End2EndBase {
/**
* Sets up.
*/
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -152,7 +154,7 @@ public class PdpGroupDeleteTest extends End2EndBase {
assertEquals(2, deleted.getSuccessCount());
assertEquals(0, deleted.getFailureCount());
assertEquals(0, deleted.getIncompleteCount());
- assertEquals(new ToscaPolicyIdentifier("onap.restart.tcaB", "1.0.0"), deleted.getPolicy());
+ assertEquals(new ToscaConceptIdentifier("onap.restart.tcaB", "1.0.0"), deleted.getPolicy());
rawresp = invocationBuilder.delete();
resp = rawresp.readEntity(PdpGroupDeleteResponse.class);
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java
index 549ae206..3c5bed87 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2020 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.
@@ -47,7 +48,7 @@ import org.onap.policy.models.pdp.concepts.DeploymentGroup;
import org.onap.policy.models.pdp.concepts.DeploymentGroups;
import org.onap.policy.models.pdp.concepts.PdpStatus;
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;
import org.onap.policy.pap.main.PapConstants;
public class PdpGroupDeployTest extends End2EndBase {
@@ -71,6 +72,7 @@ public class PdpGroupDeployTest extends End2EndBase {
/**
* Sets up.
*/
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -90,7 +92,7 @@ public class PdpGroupDeployTest extends End2EndBase {
status11.setPdpType(DEPLOY_SUBGROUP);
status11.setPdpSubgroup(DEPLOY_SUBGROUP);
- List<ToscaPolicyIdentifier> idents = Arrays.asList(new ToscaPolicyIdentifier("onap.restart.tca", "1.0.0"));
+ List<ToscaConceptIdentifier> idents = Arrays.asList(new ToscaConceptIdentifier("onap.restart.tca", "1.0.0"));
status11.setPolicies(idents);
PdpStatus status12 = new PdpStatus();
@@ -147,9 +149,9 @@ public class PdpGroupDeployTest extends End2EndBase {
status11.setPdpType(DEPLOY_SUBGROUP);
status11.setPdpSubgroup(DEPLOY_SUBGROUP);
- final ToscaPolicyIdentifier ident = new ToscaPolicyIdentifier("onap.restart.tcaB", "1.0.0");
+ final ToscaConceptIdentifier ident = new ToscaConceptIdentifier("onap.restart.tcaB", "1.0.0");
- List<ToscaPolicyIdentifier> idents = Arrays.asList(ident);
+ List<ToscaConceptIdentifier> idents = Arrays.asList(ident);
status11.setPolicies(idents);
PdpStatus status12 = new PdpStatus();
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupQueryTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupQueryTest.java
index 5f16751c..a0a40ce5 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupQueryTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupQueryTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.
@@ -39,8 +40,7 @@ import org.onap.policy.models.pdp.concepts.PdpGroups;
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;
public class PdpGroupQueryTest extends End2EndBase {
private static final String GROUP_ENDPOINT = "pdps";
@@ -94,17 +94,17 @@ public class PdpGroupQueryTest extends End2EndBase {
assertEquals(2, filterList(subgrp.getPdpInstances(), pdp -> pdp.getHealthy() == PdpHealthStatus.HEALTHY)
.size());
assertEquals("pdpTypeA", subgrp.getPdpType());
- assertEquals("[onap.restart.tca]", mapList(subgrp.getPolicies(), ToscaPolicyIdentifier::getName).toString());
- assertEquals("[1.0.0]", mapList(subgrp.getPolicies(), ToscaPolicyIdentifier::getVersion).toString());
+ assertEquals("[onap.restart.tca]", mapList(subgrp.getPolicies(), ToscaConceptIdentifier::getName).toString());
+ assertEquals("[1.0.0]", mapList(subgrp.getPolicies(), ToscaConceptIdentifier::getVersion).toString());
Map<String, Object> props = new LinkedHashMap<>();
props.put("ten", 10);
assertEquals(props.toString(), subgrp.getProperties().toString());
assertEquals("[onap.policies.monitoring.cdap.tca.hi.lo.app]",
- mapList(subgrp.getSupportedPolicyTypes(), ToscaPolicyTypeIdentifier::getName).toString());
+ mapList(subgrp.getSupportedPolicyTypes(), ToscaConceptIdentifier::getName).toString());
assertEquals("[1.0.0]",
- mapList(subgrp.getSupportedPolicyTypes(), ToscaPolicyTypeIdentifier::getVersion).toString());
+ mapList(subgrp.getSupportedPolicyTypes(), ToscaConceptIdentifier::getVersion).toString());
}
private void checkGroup2(PdpGroup group) {
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupStateChangeTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupStateChangeTest.java
index 8cfc800c..df7fcc01 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupStateChangeTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupStateChangeTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* 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.junit.Test;
import org.onap.policy.models.pap.concepts.PdpGroupStateChangeResponse;
import org.onap.policy.models.pdp.concepts.PdpStatus;
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 PdpGroupStateChangeTest extends End2EndBase {
private static final String PDP1 = "pdpAA_1";
@@ -61,6 +62,7 @@ public class PdpGroupStateChangeTest extends End2EndBase {
/**
* Sets up.
*/
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -72,9 +74,9 @@ public class PdpGroupStateChangeTest extends End2EndBase {
public void testMakePassive() throws Exception {
addGroups("stateChangeGroupDeactivate.json");
- ToscaPolicyIdentifier policy =
- new ToscaPolicyIdentifier("onap.restart.tca", "1.0.0");
- List<ToscaPolicyIdentifier> policies = Collections.singletonList(policy);
+ ToscaConceptIdentifier policy =
+ new ToscaConceptIdentifier("onap.restart.tca", "1.0.0");
+ List<ToscaConceptIdentifier> policies = Collections.singletonList(policy);
PdpStatus status11 = new PdpStatus();
status11.setName(PDP1);