diff options
author | Jim Hahn <jrh3@att.com> | 2021-01-06 18:06:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-01-06 18:06:30 +0000 |
commit | 5de03dca5b7c5d327311acab4a845e0db0d2eb10 (patch) | |
tree | 1925a47b6aa83329ec6d7fcd1e0d895f5cff8338 | |
parent | 0c6eda4f7abc4fd9ae73c7c6cd208775009ddac0 (diff) | |
parent | 20379d580cd91dfb5d7d945dc46a627445c87aa6 (diff) |
Merge "Changed identifiers to concept identifiers"
-rw-r--r-- | main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java | 21 | ||||
-rw-r--r-- | main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java | 9 |
2 files changed, 14 insertions, 16 deletions
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java index 03f46b9e..cb20c04c 100644 --- a/main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java +++ b/main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java @@ -3,7 +3,7 @@ * ONAP Policy API
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,8 +41,7 @@ import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-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 providers that use a model provider.
@@ -131,8 +130,8 @@ public class CommonModelProvider implements AutoCloseable { */
private List<PdpGroup> getPolicyTypeFilteredPdpGroups(PfConceptKey policyType) throws PfModelException {
- List<ToscaPolicyTypeIdentifier> policyTypes = new ArrayList<>();
- policyTypes.add(new ToscaPolicyTypeIdentifier(policyType.getName(), policyType.getVersion()));
+ List<ToscaConceptIdentifier> policyTypes = new ArrayList<>();
+ policyTypes.add(new ToscaConceptIdentifier(policyType.getName(), policyType.getVersion()));
PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder().policyTypeList(policyTypes).groupState(PdpState.ACTIVE)
.pdpState(PdpState.ACTIVE).build();
return modelsProvider.getFilteredPdpGroups(pdpGroupFilter);
@@ -158,7 +157,7 @@ public class CommonModelProvider implements AutoCloseable { Map<Pair<String, String>, T> deployedPolicyMap = new HashMap<>();
for (PdpGroup pdpGroup : pdpGroups) {
- List<ToscaPolicyIdentifier> policyIdentifiers = extractPolicyIdentifiers(policyId, pdpGroup, policyType);
+ List<ToscaConceptIdentifier> policyIdentifiers = extractPolicyIdentifiers(policyId, pdpGroup, policyType);
T deployedPolicies = getDeployedPolicies(policyIdentifiers, policyType, getter, consumer, data);
deployedPolicyMap.put(Pair.of(pdpGroup.getName(), pdpGroup.getVersion()), deployedPolicies);
}
@@ -176,12 +175,12 @@ public class CommonModelProvider implements AutoCloseable { *
* @throws PfModelException the PfModel parsing exception
*/
- private List<ToscaPolicyIdentifier> extractPolicyIdentifiers(String policyId, PdpGroup pdpGroup,
+ private List<ToscaConceptIdentifier> extractPolicyIdentifiers(String policyId, PdpGroup pdpGroup,
PfConceptKey policyType) throws PfModelException {
- List<ToscaPolicyIdentifier> policyIdentifiers = new ArrayList<>();
+ List<ToscaConceptIdentifier> policyIdentifiers = new ArrayList<>();
for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) {
- for (ToscaPolicyIdentifier policyIdentifier : pdpSubGroup.getPolicies()) {
+ for (ToscaConceptIdentifier policyIdentifier : pdpSubGroup.getPolicies()) {
if (policyId.equalsIgnoreCase(policyIdentifier.getName())) {
policyIdentifiers.add(policyIdentifier);
}
@@ -207,10 +206,10 @@ public class CommonModelProvider implements AutoCloseable { *
* @throws PfModelException the PfModel parsing exception
*/
- private <T, R> T getDeployedPolicies(List<ToscaPolicyIdentifier> policyIdentifiers, PfConceptKey policyType,
+ private <T, R> T getDeployedPolicies(List<ToscaConceptIdentifier> policyIdentifiers, PfConceptKey policyType,
BiFunctionWithEx<String, String, R> getter, BiConsumer<T, R> consumer, T data) throws PfModelException {
- for (ToscaPolicyIdentifier policyIdentifier : policyIdentifiers) {
+ for (ToscaConceptIdentifier policyIdentifier : policyIdentifiers) {
R result = getter.apply(policyIdentifier.getName(),
getTrimedVersionForLegacyType(policyIdentifier.getVersion(), policyType));
consumer.accept(data, result);
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java index e71cfc54..e0f3375f 100644 --- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java +++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java @@ -3,7 +3,7 @@ * ONAP Policy API * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2020 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,8 +54,7 @@ import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.provider.PolicyModelsProviderFactory; import org.onap.policy.models.provider.PolicyModelsProviderParameters; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** @@ -180,7 +179,7 @@ public class TestPolicyProvider { pdpSubGroup.setPdpType("type"); pdpSubGroup.setDesiredInstanceCount(123); pdpSubGroup.setSupportedPolicyTypes(new ArrayList<>()); - pdpSubGroup.getSupportedPolicyTypes().add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion)); + pdpSubGroup.getSupportedPolicyTypes().add(new ToscaConceptIdentifier(policyTypeId, policyTypeVersion)); pdpGroup.getPdpSubgroups().add(pdpSubGroup); Pdp pdp = new Pdp(); @@ -215,7 +214,7 @@ public class TestPolicyProvider { // Update pdpSubGroup pdpSubGroup.setPolicies(new ArrayList<>()); - pdpSubGroup.getPolicies().add(new ToscaPolicyIdentifier(policyId, policyVersion)); + pdpSubGroup.getPolicies().add(new ToscaConceptIdentifier(policyId, policyVersion)); assertEquals(1, databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getPolicies().size()); |