summaryrefslogtreecommitdiffstats
path: root/models-provider/src/test
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/test
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/test')
-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
3 files changed, 98 insertions, 56 deletions
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();
}