summaryrefslogtreecommitdiffstats
path: root/main/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test/java')
-rw-r--r--main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java31
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java23
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java3
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java3
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java3
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java4
6 files changed, 48 insertions, 19 deletions
diff --git a/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java b/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java
index c12847a7..d2209e73 100644
--- a/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java
@@ -27,6 +27,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.util.Collections;
+
import org.junit.Test;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.parameters.GroupValidationResult;
@@ -45,8 +47,8 @@ public class TestApiParameterGroup {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false, PORT);
final PolicyModelsProviderParameters databaseProviderParameters =
commonTestData.getDatabaseProviderParameters(false);
- final ApiParameterGroup apiParameters = new ApiParameterGroup(
- CommonTestData.API_GROUP_NAME, restServerParameters, databaseProviderParameters);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME,
+ restServerParameters, databaseProviderParameters, Collections.emptyList());
final GroupValidationResult validationResult = apiParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(restServerParameters.getHost(), apiParameters.getRestServerParameters().getHost());
@@ -58,6 +60,7 @@ public class TestApiParameterGroup {
assertEquals(restServerParameters.isHttps(), apiParameters.getRestServerParameters().isHttps());
assertEquals(restServerParameters.isAaf(), apiParameters.getRestServerParameters().isAaf());
assertEquals(CommonTestData.API_GROUP_NAME, apiParameters.getName());
+ assertTrue(apiParameters.getPreloadPolicyTypes().isEmpty());
}
@Test
@@ -66,7 +69,7 @@ public class TestApiParameterGroup {
final PolicyModelsProviderParameters databaseProviderParameters =
commonTestData.getDatabaseProviderParameters(false);
final ApiParameterGroup apiParameters = new ApiParameterGroup(null,
- restServerParameters, databaseProviderParameters);
+ restServerParameters, databaseProviderParameters, Collections.emptyList());
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, apiParameters.getName());
@@ -81,7 +84,7 @@ public class TestApiParameterGroup {
final PolicyModelsProviderParameters databaseProviderParameters =
commonTestData.getDatabaseProviderParameters(false);
final ApiParameterGroup apiParameters = new ApiParameterGroup("",
- restServerParameters, databaseProviderParameters);
+ restServerParameters, databaseProviderParameters, Collections.emptyList());
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", apiParameters.getName());
@@ -94,8 +97,8 @@ public class TestApiParameterGroup {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(true, PORT);
final PolicyModelsProviderParameters databaseProviderParameters =
commonTestData.getDatabaseProviderParameters(false);
- final ApiParameterGroup apiParameters = new ApiParameterGroup(
- CommonTestData.API_GROUP_NAME, restServerParameters, databaseProviderParameters);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME,
+ restServerParameters, databaseProviderParameters, Collections.emptyList());
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@@ -108,8 +111,8 @@ public class TestApiParameterGroup {
final RestServerParameters restServerParameters = null;
final PolicyModelsProviderParameters databaseProviderParameters =
commonTestData.getDatabaseProviderParameters(false);
- final ApiParameterGroup apiParameters = new ApiParameterGroup(
- CommonTestData.API_GROUP_NAME, restServerParameters, databaseProviderParameters);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME,
+ restServerParameters, databaseProviderParameters, Collections.emptyList());
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@@ -122,8 +125,8 @@ public class TestApiParameterGroup {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false, PORT);
final PolicyModelsProviderParameters databaseProviderParameters =
commonTestData.getDatabaseProviderParameters(true);
- final ApiParameterGroup apiParameters = new ApiParameterGroup(
- CommonTestData.API_GROUP_NAME, restServerParameters, databaseProviderParameters);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME,
+ restServerParameters, databaseProviderParameters, Collections.emptyList());
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@@ -135,8 +138,8 @@ public class TestApiParameterGroup {
public void testApiParameterGroup_NullDatabaseProviderParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false, PORT);
final PolicyModelsProviderParameters databaseProviderParameters = null;
- final ApiParameterGroup apiParameters = new ApiParameterGroup(
- CommonTestData.API_GROUP_NAME, restServerParameters, databaseProviderParameters);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME,
+ restServerParameters, databaseProviderParameters, Collections.emptyList());
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@@ -145,8 +148,8 @@ public class TestApiParameterGroup {
@Test
public void testApiParameterGroup_SetName() {
- final ApiParameterGroup apiParameters = new ApiParameterGroup(
- CommonTestData.API_GROUP_NAME, null, null);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME,
+ null, null, Collections.emptyList());
assertEquals(CommonTestData.API_GROUP_NAME, apiParameters.getName());
apiParameters.setName("SampleName");
assertEquals("SampleName", apiParameters.getName());
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
index 6e51e369..359533ff 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
@@ -33,6 +33,7 @@ import java.lang.reflect.Modifier;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.Base64;
+import java.util.Collections;
import java.util.Properties;
import javax.net.ssl.SSLContext;
@@ -228,7 +229,7 @@ public class TestApiRestServer {
providerParams.setDatabaseUser("policy");
providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
providerParams.setPersistenceUnit("ToscaConceptTest");
- apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams, Collections.emptyList());
ParameterService.register(apiParamGroup, true);
policyTypeProvider = new PolicyTypeProvider();
policyProvider = new PolicyProvider();
@@ -697,6 +698,26 @@ public class TestApiRestServer {
}
@Test
+ public void testReadPreloadPolicyTypesPersistentJson() throws Exception {
+ setupParameters();
+ main = startApiService(true);
+ Response rawResponse = readResource(POLICYTYPES, true, APP_JSON);
+ assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+ ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
+ assertEquals(21, response.getPolicyTypes().size());
+ }
+
+ @Test
+ public void testReadPreloadPolicyTypesPersistentYaml() throws Exception {
+ setupParameters();
+ main = startApiService(true);
+ Response rawResponse = readResource(POLICYTYPES, true, APP_YAML);
+ assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+ ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
+ assertEquals(21, response.getPolicyTypes().size());
+ }
+
+ @Test
public void testReadPolicyTypesPersistentJson() {
testReadPolicyTypesPersistent(APP_JSON);
}
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 f83acce7..3104a100 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
@@ -33,6 +33,7 @@ import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Base64;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -103,7 +104,7 @@ public class TestLegacyGuardPolicyProvider {
providerParams.setDatabaseUser("policy");
providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
providerParams.setPersistenceUnit("ToscaConceptTest");
- apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams, Collections.emptyList());
ParameterService.register(apiParamGroup, true);
guardPolicyProvider = new LegacyGuardPolicyProvider();
policyTypeProvider = new PolicyTypeProvider();
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 f80b1195..31e22e3f 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
@@ -33,6 +33,7 @@ import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Base64;
+import java.util.Collections;
import java.util.List;
import org.junit.After;
@@ -98,7 +99,7 @@ public class TestLegacyOperationalPolicyProvider {
providerParams.setDatabaseUser("policy");
providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
providerParams.setPersistenceUnit("ToscaConceptTest");
- apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams, Collections.emptyList());
ParameterService.register(apiParamGroup, true);
operationalPolicyProvider = new LegacyOperationalPolicyProvider();
policyTypeProvider = new PolicyTypeProvider();
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 2e431704..5d0b4128 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
@@ -32,6 +32,7 @@ import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Base64;
+import java.util.Collections;
import java.util.List;
import org.junit.After;
@@ -105,7 +106,7 @@ public class TestPolicyProvider {
providerParams.setDatabaseUser("policy");
providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
providerParams.setPersistenceUnit("ToscaConceptTest");
- apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams, Collections.emptyList());
ParameterService.register(apiParamGroup, true);
policyTypeProvider = new PolicyTypeProvider();
policyProvider = new PolicyProvider();
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 582b7d4d..a17a7c9a 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
@@ -28,6 +28,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertFalse;
import java.util.Base64;
+import java.util.Collections;
+
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -70,7 +72,7 @@ public class TestPolicyTypeProvider {
providerParams.setDatabaseUser("policy");
providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
providerParams.setPersistenceUnit("ToscaConceptTest");
- apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams, Collections.emptyList());
ParameterService.register(apiParamGroup, true);
policyTypeProvider = new PolicyTypeProvider();
policyProvider = new PolicyProvider();