summaryrefslogtreecommitdiffstats
path: root/models-provider/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-01 21:03:34 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-01 21:03:34 +0000
commit0664ecd9f945ffa27126707db144e91156313ba1 (patch)
treed1503017e7aed6d4172f527cb78cf20745b382d4 /models-provider/src
parent0ac03692ecd0fbe69660b1246ca0c1fbac53e623 (diff)
Add extra methods to Provider interface
This review provides the full specification of the Provider interfce and stups the new implemented methods into the relevant delegated providers. Issue-ID: POLICY-1095 Change-Id: I5f297f8dbbe4131ce910fce95459425ac8b7c3f9 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-provider/src')
-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
6 files changed, 445 insertions, 106 deletions
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();
}