summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-02 12:25:51 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-02 12:25:51 +0000
commit93da21cc7fd920e4c63a6c6800c89e236d602241 (patch)
treee162717f3f3c582bfe2d8821d5e789859962a258
parent2ec461c2c24cdf507d601be02fee3786f5d86f7b (diff)
parent0664ecd9f945ffa27126707db144e91156313ba1 (diff)
Merge "Add extra methods to Provider interface"
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java110
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java178
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java116
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java103
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java28
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java81
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java45
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java116
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java4
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java8
10 files changed, 660 insertions, 129 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
index fe0576dfe..6af2d211b 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
@@ -20,11 +20,21 @@
package org.onap.policy.models.pdp.persistence.provider;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.dao.PfDao;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* This class provides the provision of information on PAP concepts in the database to callers.
@@ -36,16 +46,42 @@ public class PdpProvider {
* Get PDP groups.
*
* @param dao the DAO to use to access the database
- * @param pdpGroupFilter a filter for the get
+ * @param name the name of the policy to get, null to get all PDP groups
+ * @param version the version of the policy to get, null to get all versions of a PDP group
* @return the PDP groups found
* @throws PfModelException on errors getting PDP groups
*/
- public PdpGroups getPdpGroups(@NonNull final PfDao dao, @NonNull final String pdpGroupFilter)
+ public PdpGroups getPdpGroups(@NonNull final PfDao dao, final String name, final String version)
throws PfModelException {
return new PdpGroups();
}
/**
+ * Get latest PDP Groups.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the PDP group to get, null to get all PDP groups
+ * @return the PDP groups found
+ * @throws PfModelException on errors getting policies
+ */
+ public PdpGroups getLatestPdpGroups(@NonNull final PfDao dao, final String name) throws PfModelException {
+ return new PdpGroups();
+ }
+
+ /**
+ * Get a filtered list of PDP groups.
+ *
+ * @param dao the DAO to use to access the database
+ * @param pdpType The PDP type filter for the returned PDP groups
+ * @param supportedPolicyTypes a list of policy type name/version pairs that the PDP groups must support.
+ * @return the PDP groups found
+ */
+ public PdpGroups getFilteredPdpGroups(@NonNull final PfDao dao, @NonNull final String pdpType,
+ @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
+ return new PdpGroups();
+ }
+
+ /**
* Creates PDP groups.
*
* @param dao the DAO to use to access the database
@@ -71,16 +107,76 @@ public class PdpProvider {
return new PdpGroups();
}
+
+ /**
+ * Update a PDP subgroup.
+ *
+ * @param dao the DAO to use to access the database
+ * @param pdpGroupName the name of the PDP group of the PDP subgroup
+ * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
+ * @param pdpSubGroup the PDP subgroup to be updated
+ * @throws PfModelException on errors updating PDP subgroups
+ */
+ public void updatePdpSubGroup(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
+ @NonNull final String pdpGroupVersion, @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
+ // Not implemented yet
+ }
+
/**
- * Delete PDP groups.
+ * Delete a PDP group.
*
* @param dao the DAO to use to access the database
- * @param pdpGroupFilter a filter for the get
- * @return the PDP groups deleted
+ * @param name the name of the policy to get, null to get all PDP groups
+ * @param version the version of the policy to get, null to get all versions of a PDP group
+ * @return the PDP group deleted
* @throws PfModelException on errors deleting PDP groups
*/
- public PdpGroups deletePdpGroups(@NonNull final PfDao dao, @NonNull final String pdpGroupFilter)
+ public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name, @NonNull final String version)
throws PfModelException {
- return new PdpGroups();
+ return new PdpGroup();
+
+ }
+
+ /**
+ * Get PDP statistics.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the PDP group to get statistics for, null to get all PDP groups
+ * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group
+ * @return the statistics found
+ * @throws PfModelException on errors getting statistics
+ */
+ public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Update PDP statistics for a PDP.
+ *
+ * @param dao the DAO to use to access the database
+ * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
+ * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for
+ * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
+ * @param pdpInstanceId the instance ID of the PDP to update statistics for
+ * @throws PfModelException on errors updating statistics
+ */
+ public void updatePdpStatistics(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
+ @NonNull final String pdpGroupVersion, @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final PdpStatistics pdppStatistics) throws PfModelException {
+ // Not implemented yet
+ }
+
+ /**
+ * Get deployed policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies deployed as a map of policy lists keyed by PDP group
+ * @throws PfModelException on errors getting policies
+ */
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(@NonNull final PfDao dao, final String name)
+ throws PfModelException {
+ return new LinkedHashMap<>();
}
}
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
index a8d8483e3..b0494ff60 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
@@ -20,12 +20,19 @@
package org.onap.policy.models.provider;
+import java.util.List;
import java.util.Map;
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
@@ -48,13 +55,40 @@ public interface PolicyModelsProvider extends AutoCloseable {
/**
* Get policy types.
*
- * @param name the name of the policy type to get.
- * @param version the version of the policy type to get.
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @param version the version of the policy type to get, set to null to get all versions
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public ToscaServiceTemplate getPolicyTypes(@NonNull final String name, @NonNull final String version)
- throws PfModelException;
+ public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get policy types.
+ *
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @param version the version of the policy type to get, set to null to get all versions
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get latest policy types.
+ *
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException;
+
+ /**
+ * Get latest policy types.
+ *
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException;
/**
* Create policy types.
@@ -77,26 +111,62 @@ public interface PolicyModelsProvider extends AutoCloseable {
throws PfModelException;
/**
- * Delete policy types.
+ * Delete policy type.
*
* @param name the name of the policy type to delete.
* @param version the version of the policy type to delete.
- * @return the TOSCA service template containing the policy types that were deleted
+ * @return the TOSCA service template containing the policy type that was deleted
* @throws PfModelException on errors deleting policy types
*/
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
throws PfModelException;
/**
* Get policies.
*
- * @param name the name of the policy to get.
- * @param version the version of the policy to get.
+ * @param name the name of the policy to get, null to get all policies
+ * @param version the version of the policy to get, null to get all versions of a policy
* @return the policies found
* @throws PfModelException on errors getting policies
*/
- public ToscaServiceTemplate getPolicies(@NonNull final String name, @NonNull final String version)
- throws PfModelException;
+ public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get policies.
+ *
+ * @param name the name of the policy to get, null to get all policies
+ * @param version the version of the policy to get, null to get all versions of a policy
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get policies for a policy type name.
+ *
+ * @param policyTypeName the name of the policy type for which to get policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName) throws PfModelException;
+
+ /**
+ * Get latest policies.
+ *
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException;
+
+ /**
+ * Get latest policies.
+ *
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException;
/**
* Create policies.
@@ -108,7 +178,6 @@ public interface PolicyModelsProvider extends AutoCloseable {
public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException;
-
/**
* Update policies.
*
@@ -120,14 +189,14 @@ public interface PolicyModelsProvider extends AutoCloseable {
throws PfModelException;
/**
- * Delete policies.
+ * Delete policy.
*
* @param name the name of the policy to delete.
* @param version the version of the policy to delete.
- * @return the TOSCA service template containing the policy types that were deleted
- * @throws PfModelException on errors deleting policies
+ * @return the TOSCA service template containing the policy that was deleted
+ * @throws PfModelException on errors deleting a policy
*/
- public ToscaServiceTemplate deletePolicies(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
throws PfModelException;
/**
@@ -210,11 +279,31 @@ public interface PolicyModelsProvider extends AutoCloseable {
/**
* Get PDP groups.
*
- * @param pdpGroupFilter a filter for the get
+ * @param name the name of the policy to get, null to get all PDP groups
+ * @param version the version of the policy to get, null to get all versions of a PDP group
* @return the PDP groups found
* @throws PfModelException on errors getting PDP groups
*/
- public PdpGroups getPdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
+ public PdpGroups getPdpGroups(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get latest PDP Groups.
+ *
+ * @param name the name of the PDP group to get, null to get all PDP groups
+ * @return the PDP groups found
+ * @throws PfModelException on errors getting policies
+ */
+ public PdpGroups getLatestPdpGroups(final String name) throws PfModelException;
+
+ /**
+ * Get a filtered list of PDP groups.
+ *
+ * @param pdpType The PDP type filter for the returned PDP groups
+ * @param supportedPolicyTypes a list of policy type name/version pairs that the PDP groups must support.
+ * @return the PDP groups found
+ */
+ public PdpGroups getFilteredPdpGroups(@NonNull final String pdpType,
+ @NonNull final List<Pair<String, String>> supportedPolicyTypes);
/**
* Creates PDP groups.
@@ -234,12 +323,57 @@ public interface PolicyModelsProvider extends AutoCloseable {
*/
public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
+
+ /**
+ * Update a PDP subgroup.
+ *
+ * @param pdpGroupName the name of the PDP group of the PDP subgroup
+ * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
+ * @param pdpSubGroup the PDP subgroup to be updated
+ * @throws PfModelException on errors updating PDP subgroups
+ */
+ public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException;
+
/**
- * Delete PDP groups.
+ * Delete a PDP group.
*
- * @param pdpGroupFilter a filter for the get
- * @return the PDP groups deleted
+ * @param name the name of the policy to get, null to get all PDP groups
+ * @param version the version of the policy to get, null to get all versions of a PDP group
+ * @return the PDP group deleted
* @throws PfModelException on errors deleting PDP groups
*/
- public PdpGroups deletePdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
+ public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException;
+
+ /**
+ * Get PDP statistics.
+ *
+ * @param name the name of the PDP group to get statistics for, null to get all PDP groups
+ * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group
+ * @return the statistics found
+ * @throws PfModelException on errors getting statistics
+ */
+ public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException;
+
+ /**
+ * Update PDP statistics for a PDP.
+ *
+ * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
+ * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for
+ * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
+ * @param pdpInstanceId the instance ID of the PDP to update statistics for
+ * @throws PfModelException on errors updating statistics
+ */
+ public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final PdpStatistics pdppStatistics) throws PfModelException;
+
+ /**
+ * Get deployed policies.
+ *
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies deployed as a map of policy lists keyed by PDP group
+ * @throws PfModelException on errors getting policies
+ */
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(final String name) throws PfModelException;
}
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
index 9a32feb65..ee8ed7348 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
@@ -23,22 +23,29 @@ package org.onap.policy.models.provider.impl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Base64;
+import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.dao.DaoParameters;
import org.onap.policy.models.dao.PfDao;
import org.onap.policy.models.dao.PfDaoFactory;
import org.onap.policy.models.dao.impl.DefaultPfDao;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.persistence.provider.PdpProvider;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
@@ -137,13 +144,30 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getPolicyTypes(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
+ public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException {
assertInitilized();
return new AuthorativeToscaProvider().getPolicyTypes(pfDao, name, version);
}
@Override
+ public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getPolicyTypeList(pfDao, name, version);
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getLatestPolicyTypes(pfDao, name);
+ }
+
+ @Override
+ public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getLatestPolicyTypeList(pfDao, name);
+ }
+
+ @Override
public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
assertInitilized();
@@ -158,20 +182,43 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
throws PfModelException {
assertInitilized();
- return new AuthorativeToscaProvider().deletePolicyTypes(pfDao, name, version);
+ return new AuthorativeToscaProvider().deletePolicyType(pfDao, name, version);
}
@Override
- public ToscaServiceTemplate getPolicies(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
+ public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException {
assertInitilized();
return new AuthorativeToscaProvider().getPolicies(pfDao, name, version);
}
@Override
+ public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getPolicyList(pfDao, name, version);
+ }
+
+ @Override
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getPolicyList4PolicyType(pfDao, policyTypeName);
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getLatestPolicies(pfDao, name);
+ }
+
+ @Override
+ public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getLatestPolicyList(pfDao, name);
+ }
+
+ @Override
public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
assertInitilized();
@@ -186,10 +233,10 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate deletePolicies(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
throws PfModelException {
assertInitilized();
- return new AuthorativeToscaProvider().deletePolicies(pfDao, name, version);
+ return new AuthorativeToscaProvider().deletePolicy(pfDao, name, version);
}
@Override
@@ -246,27 +293,68 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public PdpGroups getPdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
+ public PdpGroups getPdpGroups(final String name, final String version) throws PfModelException {
+ assertInitilized();
+ return new PdpProvider().getPdpGroups(pfDao, name, version);
+ }
+
+ @Override
+ public PdpGroups getLatestPdpGroups(final String name) throws PfModelException {
assertInitilized();
- return new PdpProvider().getPdpGroups(pfDao, pdpGroupFilter);
+ return new PdpProvider().getLatestPdpGroups(pfDao, name);
}
@Override
- public PdpGroups createPdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException {
+ public PdpGroups getFilteredPdpGroups(@NonNull final String pdpType,
+ @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
+ assertInitilized();
+ return new PdpProvider().getFilteredPdpGroups(pfDao, pdpType, supportedPolicyTypes);
+ }
+
+ @Override
+ public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException {
assertInitilized();
return new PdpProvider().createPdpGroups(pfDao, pdpGroups);
}
@Override
- public PdpGroups updatePdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException {
+ public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException {
assertInitilized();
return new PdpProvider().updatePdpGroups(pfDao, pdpGroups);
}
@Override
- public PdpGroups deletePdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
+ public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
+ assertInitilized();
+ new PdpProvider().updatePdpSubGroup(pfDao, pdpGroupName, pdpGroupVersion, pdpSubGroup);
+ }
+
+ @Override
+ public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException {
+ assertInitilized();
+ return new PdpProvider().deletePdpGroup(pfDao, name, version);
+ }
+
+ @Override
+ public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException {
+ assertInitilized();
+ return new PdpProvider().getPdpStatistics(pfDao, name, version);
+ }
+
+ @Override
+ public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final PdpStatistics pdppStatistics) throws PfModelException {
+ assertInitilized();
+ new PdpProvider().updatePdpStatistics(pfDao, pdpGroupName, pdpGroupVersion, pdpType, pdpInstanceId,
+ pdppStatistics);
+ }
+
+ @Override
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(final String name) throws PfModelException {
assertInitilized();
- return new PdpProvider().deletePdpGroups(pfDao, pdpGroupFilter);
+ return new PdpProvider().getDeployedPolicyList(pfDao, name);
}
/**
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
index 8881ed08e..3db8e5e35 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
@@ -21,19 +21,27 @@
package org.onap.policy.models.provider.impl;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
@@ -64,12 +72,26 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate getPolicyTypes(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
+ public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyTypeGetResponse.json");
}
@Override
+ public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ @Override
public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
return serviceTemplate;
@@ -82,18 +104,37 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyTypeDeleteResponse.json");
}
@Override
- public ToscaServiceTemplate getPolicies(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
+ public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyGetResponse.json");
}
@Override
+ public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ @Override
public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
return serviceTemplate;
@@ -106,7 +147,7 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate deletePolicies(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyDeleteResponse.json");
}
@@ -158,23 +199,57 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public PdpGroups getPdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
- return new PdpGroups();
+ public PdpGroups getPdpGroups(final String name, final String version) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups getLatestPdpGroups(final String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups getFilteredPdpGroups(@NonNull final String pdpType,
+ @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
+ return null;
+ }
+
+ @Override
+ public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
+ // Not implemented
+ }
+
+ @Override
+ public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException {
+ return null;
}
@Override
- public PdpGroups createPdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException {
- return new PdpGroups();
+ public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException {
+ return new ArrayList<>();
}
@Override
- public PdpGroups updatePdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException {
- return new PdpGroups();
+ public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final PdpStatistics pdppStatistics) throws PfModelException {
+ // Not implemented
}
@Override
- public PdpGroups deletePdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
- return new PdpGroups();
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(final String name) throws PfModelException {
+ return null;
}
/**
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
index 7eb712236..d9253334a 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
@@ -139,15 +139,15 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("serviceTemplate is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicyTypes(null, null);
+ databaseProvider.deletePolicyType(null, null);
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicyTypes("aaa", null);
+ databaseProvider.deletePolicyType("aaa", null);
}).hasMessage("version is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicyTypes(null, "aaa");
+ databaseProvider.deletePolicyType(null, "aaa");
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
@@ -171,15 +171,15 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("serviceTemplate is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicies(null, null);
+ databaseProvider.deletePolicy(null, null);
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicies(null, "aaa");
+ databaseProvider.deletePolicy(null, "aaa");
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicies("aaa", null);
+ databaseProvider.deletePolicy("aaa", null);
}).hasMessage("version is marked @NonNull but is null");
assertThatThrownBy(() -> {
@@ -215,10 +215,6 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("policyId is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.getPdpGroups(null);
- }).hasMessage("pdpGroupFilter is marked @NonNull but is null");
-
- assertThatThrownBy(() -> {
databaseProvider.createPdpGroups(null);
}).hasMessage("pdpGroups is marked @NonNull but is null");
@@ -227,8 +223,8 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("pdpGroups is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePdpGroups(null);
- }).hasMessage("pdpGroupFilter is marked @NonNull but is null");
+ databaseProvider.deletePdpGroup(null, null);
+ }).hasMessage("name is marked @NonNull but is null");
databaseProvider.close();
@@ -263,7 +259,7 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("no policy types specified on service template");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicyTypes("name", "version");
+ databaseProvider.deletePolicyType("name", "version");
}).hasMessage("policy type not found: name:version");
assertThatThrownBy(() -> {
@@ -279,7 +275,7 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("topology template not specified on service template");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicies("name", "version");
+ databaseProvider.deletePolicy("name", "version");
}).hasMessage("policy not found: name:version");
assertThatThrownBy(() -> {
@@ -314,10 +310,10 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.deleteGuardPolicy("policy_id");
}).hasMessage("no policy found for policy ID: policy_id");
- assertNotNull(databaseProvider.getPdpGroups("filter"));
+ assertNotNull(databaseProvider.getPdpGroups("name", "version"));
assertNotNull(databaseProvider.createPdpGroups(new PdpGroups()));
assertNotNull(databaseProvider.updatePdpGroups(new PdpGroups()));
- assertNotNull(databaseProvider.deletePdpGroups("filter"));
+ assertNotNull(databaseProvider.deletePdpGroup("name", "version"));
} catch (Exception exc) {
LOGGER.warn("test should not throw an exception", exc);
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
index a9a0d13e3..9320df57f 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
@@ -20,16 +20,23 @@
package org.onap.policy.models.provider.impl;
+import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
@@ -69,7 +76,7 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate deletePolicyTypes(final String name, final String version) throws PfModelException {
+ public ToscaServiceTemplate deletePolicyType(final String name, final String version) throws PfModelException {
return null;
}
@@ -91,7 +98,7 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate deletePolicies(final String name, final String version) throws PfModelException {
+ public ToscaServiceTemplate deletePolicy(final String name, final String version) throws PfModelException {
return null;
}
@@ -140,7 +147,7 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public PdpGroups getPdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
+ public PdpGroups getPdpGroups(String name, String version) throws PfModelException {
return null;
}
@@ -155,7 +162,73 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public PdpGroups deletePdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
+ public PdpGroup deletePdpGroup(@NonNull String name, @NonNull String verison) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicyType> getPolicyTypeList(String name, String version) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicyTypes(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicyType> getLatestPolicyTypeList(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicy> getPolicyList(String name, String version) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull String policyTypeName) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicies(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicy> getLatestPolicyList(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups getLatestPdpGroups(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups getFilteredPdpGroups(@NonNull String pdpType,
+ @NonNull List<Pair<String, String>> supportedPolicyTypes) {
+ return null;
+ }
+
+ @Override
+ public void updatePdpSubGroup(@NonNull String pdpGroupName, @NonNull String pdpGroupVersion,
+ @NonNull PdpSubGroup pdpSubGroup) throws PfModelException {
+ }
+
+ @Override
+ public List<PdpStatistics> getPdpStatistics(String name, String version) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public void updatePdpStatistics(@NonNull String pdpGroupName, @NonNull String pdpGroupVersion,
+ @NonNull String pdpType, @NonNull String pdpInstanceId, @NonNull PdpStatistics pdppStatistics) {
+ }
+
+ @Override
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(String name) throws PfModelException {
return null;
}
}
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
index 3e13d854c..a0b4857de 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.models.provider.impl;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import org.junit.Test;
@@ -73,12 +74,12 @@ public class DummyPolicyModelsProviderTest {
assertNotNull(dummyProvider.getPolicyTypes("name", "version"));
assertNotNull(dummyProvider.createPolicyTypes(new ToscaServiceTemplate()));
assertNotNull(dummyProvider.updatePolicyTypes(new ToscaServiceTemplate()));
- assertNotNull(dummyProvider.deletePolicyTypes("name", "version"));
+ assertNotNull(dummyProvider.deletePolicyType("name", "version"));
assertNotNull(dummyProvider.getPolicies("name", "version"));
assertNotNull(dummyProvider.createPolicies(new ToscaServiceTemplate()));
assertNotNull(dummyProvider.updatePolicies(new ToscaServiceTemplate()));
- assertNotNull(dummyProvider.deletePolicies("name", "version"));
+ assertNotNull(dummyProvider.deletePolicy("name", "version"));
assertNotNull(dummyProvider.getOperationalPolicy("policy_id"));
assertNotNull(dummyProvider.createOperationalPolicy(new LegacyOperationalPolicy()));
@@ -90,36 +91,11 @@ public class DummyPolicyModelsProviderTest {
assertNotNull(dummyProvider.updateGuardPolicy(new LegacyGuardPolicyInput()));
assertNotNull(dummyProvider.deleteGuardPolicy("policy_id"));
- assertNotNull(dummyProvider.getPdpGroups("filter"));
- assertNotNull(dummyProvider.createPdpGroups(new PdpGroups()));
- assertNotNull(dummyProvider.updatePdpGroups(new PdpGroups()));
- assertNotNull(dummyProvider.deletePdpGroups("filter"));
+ assertNull(dummyProvider.getPdpGroups("name", "version"));
+ assertNull(dummyProvider.createPdpGroups(new PdpGroups()));
+ assertNull(dummyProvider.updatePdpGroups(new PdpGroups()));
+ assertNull(dummyProvider.deletePdpGroup("name", "version"));
- assertThatThrownBy(() -> {
- dummyProvider.getPolicyTypes(null, null);
- }).hasMessage("name is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.createPolicyTypes(null);
- }).hasMessage("serviceTemplate is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.updatePolicyTypes(null);
- }).hasMessage("serviceTemplate is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.deletePolicyTypes(null, null);
- }).hasMessage("name is marked @NonNull but is null");
-
- assertThatThrownBy(() -> {
- dummyProvider.getPolicies(null, null);
- }).hasMessage("name is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.createPolicies(null);
- }).hasMessage("serviceTemplate is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.updatePolicies(null);
- }).hasMessage("serviceTemplate is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.deletePolicies(null, null);
- }).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
dummyProvider.getOperationalPolicy(null);
@@ -148,17 +124,14 @@ public class DummyPolicyModelsProviderTest {
}).hasMessage("policyId is marked @NonNull but is null");
assertThatThrownBy(() -> {
- dummyProvider.getPdpGroups(null);
- }).hasMessage("pdpGroupFilter is marked @NonNull but is null");
- assertThatThrownBy(() -> {
dummyProvider.createPdpGroups(null);
}).hasMessage("pdpGroups is marked @NonNull but is null");
assertThatThrownBy(() -> {
dummyProvider.updatePdpGroups(null);
}).hasMessage("pdpGroups is marked @NonNull but is null");
assertThatThrownBy(() -> {
- dummyProvider.deletePdpGroups(null);
- }).hasMessage("pdpGroupFilter is marked @NonNull but is null");
+ dummyProvider.deletePdpGroup(null, null);
+ }).hasMessage("name is marked @NonNull but is null");
dummyProvider.close();
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
index 0201bbea2..e9e92d361 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
@@ -20,11 +20,16 @@
package org.onap.policy.models.tosca.authorative.provider;
+import java.util.ArrayList;
+import java.util.List;
+
import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.dao.PfDao;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
@@ -44,13 +49,53 @@ public class AuthorativeToscaProvider {
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public ToscaServiceTemplate getPolicyTypes(@NonNull final PfDao dao, @NonNull final String name,
- @NonNull final String version) throws PfModelException {
+ public ToscaServiceTemplate getPolicyTypes(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
return new SimpleToscaProvider().getPolicyTypes(dao, new PfConceptKey(name, version)).toAuthorative();
}
/**
+ * Get policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @param version the version of the policy type to get, set to null to get all versions
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getPolicyTypeList(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get latest policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public ToscaServiceTemplate getLatestPolicyTypes(@NonNull final PfDao dao, final String name)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Get latest policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getLatestPolicyTypeList(@NonNull final PfDao dao, final String name)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
* Create policy types.
*
* @param dao the DAO to use to access the database
@@ -81,18 +126,18 @@ public class AuthorativeToscaProvider {
}
/**
- * Delete policy types.
+ * Delete policy type.
*
* @param dao the DAO to use to access the database
* @param name the name of the policy type to delete.
* @param version the version of the policy type to delete.
- * @return the TOSCA service template containing the policy types that were deleted
+ * @return the TOSCA service template containing the policy type that was deleted
* @throws PfModelException on errors deleting policy types
*/
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfDao dao, @NonNull final String name,
+ public ToscaServiceTemplate deletePolicyType(@NonNull final PfDao dao, @NonNull final String name,
@NonNull final String version) throws PfModelException {
- return new SimpleToscaProvider().deletePolicyTypes(dao, new PfConceptKey(name, version)).toAuthorative();
+ return new SimpleToscaProvider().deletePolicyType(dao, new PfConceptKey(name, version)).toAuthorative();
}
/**
@@ -111,6 +156,57 @@ public class AuthorativeToscaProvider {
}
/**
+ * Get policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @param version the version of the policy to get, null to get all versions of a policy
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get policies for a policy type name.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyTypeName the name of the policy type for which to get policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final PfDao dao, @NonNull final String policyTypeName)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get latest policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public ToscaServiceTemplate getLatestPolicies(@NonNull final PfDao dao, final String name) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Get latest policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getLatestPolicyList(@NonNull final PfDao dao, final String name) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
* Create policies.
*
* @param dao the DAO to use to access the database
@@ -141,17 +237,17 @@ public class AuthorativeToscaProvider {
}
/**
- * Delete policies.
+ * Delete policy.
*
* @param dao the DAO to use to access the database
* @param name the name of the policy to delete.
* @param version the version of the policy to delete.
- * @return the TOSCA service template containing the policies that were deleted
+ * @return the TOSCA service template containing the policy that weas deleted
* @throws PfModelException on errors deleting policies
*/
- public ToscaServiceTemplate deletePolicies(@NonNull final PfDao dao, @NonNull final String name,
+ public ToscaServiceTemplate deletePolicy(@NonNull final PfDao dao, @NonNull final String name,
@NonNull final String version) throws PfModelException {
- return new SimpleToscaProvider().deletePolicies(dao, new PfConceptKey(name, version)).toAuthorative();
+ return new SimpleToscaProvider().deletePolicy(dao, new PfConceptKey(name, version)).toAuthorative();
}
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
index 6e356d0ab..e7e81603a 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
@@ -143,7 +143,7 @@ public class SimpleToscaProvider {
* @return the TOSCA service template containing the policy types that were deleted
* @throws PfModelException on errors deleting policy types
*/
- public JpaToscaServiceTemplate deletePolicyTypes(@NonNull final PfDao dao,
+ public JpaToscaServiceTemplate deletePolicyType(@NonNull final PfDao dao,
@NonNull final PfConceptKey policyTypeKey)
throws PfModelException {
@@ -251,7 +251,7 @@ public class SimpleToscaProvider {
* @return the TOSCA service template containing the policies that were deleted
* @throws PfModelException on errors deleting policies
*/
- public JpaToscaServiceTemplate deletePolicies(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
+ public JpaToscaServiceTemplate deletePolicy(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
throws PfModelException {
JpaToscaServiceTemplate serviceTemplate = getPolicies(dao, policyKey);
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
index ebbebce1c..0d486e3ea 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
@@ -213,21 +213,21 @@ public class SimpleToscaProviderTest {
@Test
public void testPoliciesDelete() throws Exception {
try {
- new SimpleToscaProvider().deletePolicies(null, null);
+ new SimpleToscaProvider().deletePolicy(null, null);
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("dao is marked @NonNull but is null", exc.getMessage());
}
try {
- new SimpleToscaProvider().deletePolicies(null, new PfConceptKey());
+ new SimpleToscaProvider().deletePolicy(null, new PfConceptKey());
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("dao is marked @NonNull but is null", exc.getMessage());
}
try {
- new SimpleToscaProvider().deletePolicies(pfDao, null);
+ new SimpleToscaProvider().deletePolicy(pfDao, null);
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("policyKey is marked @NonNull but is null", exc.getMessage());
@@ -249,7 +249,7 @@ public class SimpleToscaProviderTest {
PfConceptKey policyKey = new PfConceptKey("onap.restart.tca:1.0.0");
JpaToscaServiceTemplate deletedServiceTemplate =
- new SimpleToscaProvider().deletePolicies(pfDao, new PfConceptKey(policyKey));
+ new SimpleToscaProvider().deletePolicy(pfDao, new PfConceptKey(policyKey));
assertEquals(originalServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey),
deletedServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey));