aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorChenfei Gao <cgao@research.att.com>2019-04-04 21:47:01 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-04-05 13:13:59 -0400
commit74d69a2a262f78d76abfec4dcee19421a5cd6ec9 (patch)
tree0950fcc1bd89775550fc651050a2d04e072790d2 /main/src/test
parente156fb8bf79ee361793af0aef4db5228c4c16f20 (diff)
Incorporate filters in provider functions
Use filters to GET wildcard/latest/deployed policies and policy types. Junit tests for providers are coming in next patch/review. Issue-ID: POLICY-1441 Change-Id: Iccd02f395d612ba95728d1bc5808ad16c6f386fe Signed-off-by: Chenfei Gao <cgao@research.att.com> Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java59
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java59
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java69
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java63
4 files changed, 244 insertions, 6 deletions
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
index 8f4f9aed..08f7fecd 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
@@ -20,7 +20,62 @@
* ============LICENSE_END=========================================================
*/
-
package org.onap.policy.api.main.rest.provider;
-public class TestLegacyGuardPolicyProvider {}
+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.fail;
+
+import java.util.Base64;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.api.main.parameters.ApiParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class performs unit test of {@link LegacyGuardPolicyProvider}
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ */
+public class TestLegacyGuardPolicyProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestPolicyProvider.class);
+
+ private LegacyGuardPolicyProvider guardPolicyProvider;
+
+ /**
+ * Initialize parameters.
+ */
+ @Before
+ public void setupParameters() throws PfModelException {
+
+ PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ parameters.setPersistenceUnit("ToscaConceptTest");
+ ApiParameterGroup paramGroup = new ApiParameterGroup("ApiGroup", null, parameters);
+ ParameterService.register(paramGroup, true);
+ guardPolicyProvider = new LegacyGuardPolicyProvider();
+ }
+
+ @Test
+ public void testFetchGuardPolicy() {
+
+ }
+
+ @Test
+ public void testCreateGuardPolicy() {
+
+ }
+
+ @Test
+ public void testDeleteGuardPolicy() {
+
+ }
+}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
index de12fca0..86124c74 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
@@ -20,7 +20,62 @@
* ============LICENSE_END=========================================================
*/
-
package org.onap.policy.api.main.rest.provider;
-public class TestLegacyOperationalPolicyProvider {}
+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.fail;
+
+import java.util.Base64;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.api.main.parameters.ApiParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class performs unit test of {@link LegacyOperationalPolicyProvider}
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ */
+public class TestLegacyOperationalPolicyProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestPolicyProvider.class);
+
+ private LegacyOperationalPolicyProvider operationalPolicyProvider;
+
+ /**
+ * Initialize parameters.
+ */
+ @Before
+ public void setupParameters() throws PfModelException {
+
+ PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ parameters.setPersistenceUnit("ToscaConceptTest");
+ ApiParameterGroup paramGroup = new ApiParameterGroup("ApiGroup", null, parameters);
+ ParameterService.register(paramGroup, true);
+ operationalPolicyProvider = new LegacyOperationalPolicyProvider();
+ }
+
+ @Test
+ public void testFetchOperationalPolicy() {
+
+ }
+
+ @Test
+ public void testCreateOperationalPolicy() {
+
+ }
+
+ @Test
+ public void testDeleteOperationalPolicy() {
+
+ }
+}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
index 11d7e404..eeb4dbae 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
@@ -22,4 +22,71 @@
package org.onap.policy.api.main.rest.provider;
-public class TestPolicyProvider {}
+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.fail;
+
+import java.util.Base64;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.api.main.parameters.ApiParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class performs unit test of {@link PolicyProvider}
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ */
+public class TestPolicyProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestPolicyProvider.class);
+
+ private PolicyProvider policyProvider;
+
+ /**
+ * Initialize parameters.
+ */
+ @Before
+ public void setupParameters() throws PfModelException {
+
+ PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ parameters.setPersistenceUnit("ToscaConceptTest");
+ ApiParameterGroup paramGroup = new ApiParameterGroup("ApiGroup", null, parameters);
+ ParameterService.register(paramGroup, true);
+ policyProvider = new PolicyProvider();
+ System.out.println("xxxx");
+ }
+
+ @Test
+ public void testFetchPolicies() {
+
+ }
+
+ @Test
+ public void testFetchLatestPolicies() {
+
+ }
+
+ @Test
+ public void testFetchDeployedPolicies() {
+
+ }
+
+ @Test
+ public void testCreatePolicy() {
+
+ }
+
+ @Test
+ public void testDeletePolicy() {
+
+ }
+}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
index d60dc2e5..4c3f23b3 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
@@ -22,4 +22,65 @@
package org.onap.policy.api.main.rest.provider;
-public class TestPolicyTypeProvider {}
+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.fail;
+
+import java.util.Base64;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.api.main.parameters.ApiParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class performs unit test of {@link PolicyTypeProvider}
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ */
+public class TestPolicyTypeProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestPolicyTypeProvider.class);
+
+ private PolicyTypeProvider policyTypeProvider;
+
+ /**
+ * Initialize parameters.
+ */
+ @Before
+ public void setupParameters() throws PfModelException {
+
+ PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ parameters.setPersistenceUnit("ToscaConceptTest");
+ ApiParameterGroup paramGroup = new ApiParameterGroup("ApiGroup", null, parameters);
+ ParameterService.register(paramGroup, true);
+ policyTypeProvider = new PolicyTypeProvider();
+ }
+
+ @Test
+ public void testFetchPolicyTypes() {
+
+ }
+
+ @Test
+ public void testFetchLatestPolicyTypes() {
+
+ }
+
+ @Test
+ public void testCreatePolicyType() {
+
+ }
+
+ @Test
+ public void testDeletePolicyType() {
+
+ }
+}