aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java37
-rw-r--r--main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java71
-rw-r--r--main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java3
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java25
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java (renamed from main/src/test/java/org/onap/policy/api/main/exception/PolicyApiRuntimeExceptionTest.java)27
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java26
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java25
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java25
-rw-r--r--main/src/test/resources/META-INF/persistence.xml74
-rw-r--r--main/src/test/resources/parameters/ApiConfigParameters.json8
-rw-r--r--main/src/test/resources/parameters/ApiConfigParameters_Https.json8
-rw-r--r--main/src/test/resources/parameters/ApiConfigParameters_InvalidRestServerParameters.json8
-rw-r--r--main/src/test/resources/parameters/MinimumParameters.json8
-rw-r--r--main/src/test/resources/parameters/NoParameters.json8
-rw-r--r--main/src/test/resources/policies/vDNS.policy.guard.minmax.input.json1
-rw-r--r--main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.json28
-rw-r--r--main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml31
-rw-r--r--main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json223
-rw-r--r--main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml7
19 files changed, 548 insertions, 95 deletions
diff --git a/main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java
index 8ff2f98e..f0f971d4 100644
--- a/main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java
+++ b/main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP Policy API
- * ================================================================================
+ * ONAP Policy API
+ * ================================================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -23,19 +23,29 @@
package org.onap.policy.api.main.parameters;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
/**
* Class to hold/create all parameters for test cases.
*
*/
public class CommonTestData {
+ public static final String API_GROUP_NAME = "ApiGroup";
+
private static final String REST_SERVER_PASSWORD = "zb!XztG34";
private static final String REST_SERVER_USER = "healthcheck";
private static final int REST_SERVER_PORT = 6969;
private static final String REST_SERVER_HOST = "0.0.0.0";
private static final boolean REST_SERVER_HTTPS = false;
private static final boolean REST_SERVER_AAF = false;
- public static final String API_GROUP_NAME = "ApiGroup";
+
+ private static final String PROVIDER_GROUP_NAME = "PolicyProviderParameterGroup";
+ private static final String PROVIDER_IMPL = "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl";
+ private static final String DATABASE_URL = "jdbc:h2:mem:testdb";
+ private static final String DATABASE_USER = "policy";
+ private static final String DATABASE_PASSWORD = "P01icY";
+ private static final String PERSISTENCE_UNIT = "ToscaConceptTest";
/**
* Returns an instance of RestServerParameters for test cases.
@@ -54,4 +64,25 @@ public class CommonTestData {
return restServerParameters;
}
+ /**
+ * Returns an instance of PolicyModelsProviderParameters for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return the PolicyModelsProviderParameters object
+ */
+ public PolicyModelsProviderParameters getDatabaseProviderParameters(final boolean isEmpty) {
+ final PolicyModelsProviderParameters databaseProviderParameters;
+ if (!isEmpty) {
+ databaseProviderParameters = new PolicyModelsProviderParameters();
+ databaseProviderParameters.setName(PROVIDER_GROUP_NAME);
+ databaseProviderParameters.setImplementation(PROVIDER_IMPL);
+ databaseProviderParameters.setDatabaseUrl(DATABASE_URL);
+ databaseProviderParameters.setDatabaseUser(DATABASE_USER);
+ databaseProviderParameters.setDatabasePassword(DATABASE_PASSWORD);
+ databaseProviderParameters.setPersistenceUnit(PERSISTENCE_UNIT);
+ } else {
+ databaseProviderParameters = new PolicyModelsProviderParameters();
+ }
+ return databaseProviderParameters;
+ }
}
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 184f242b..8be52455 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
@@ -1,16 +1,15 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP Policy API
- * ================================================================================
+ * ONAP Policy API
+ * ================================================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,6 +29,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
/**
* Class to perform unit test of ApiParameterGroup.
@@ -41,14 +41,18 @@ public class TestApiParameterGroup {
@Test
public void testApiParameterGroup() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
- final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME,
- restServerParameters);
+ final PolicyModelsProviderParameters databaseProviderParameters =
+ commonTestData.getDatabaseProviderParameters(false);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(
+ CommonTestData.API_GROUP_NAME, restServerParameters, databaseProviderParameters);
final GroupValidationResult validationResult = apiParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(restServerParameters.getHost(), apiParameters.getRestServerParameters().getHost());
assertEquals(restServerParameters.getPort(), apiParameters.getRestServerParameters().getPort());
- assertEquals(restServerParameters.getUserName(), apiParameters.getRestServerParameters().getUserName());
- assertEquals(restServerParameters.getPassword(), apiParameters.getRestServerParameters().getPassword());
+ assertEquals(restServerParameters.getUserName(),
+ apiParameters.getRestServerParameters().getUserName());
+ assertEquals(restServerParameters.getPassword(),
+ apiParameters.getRestServerParameters().getPassword());
assertEquals(restServerParameters.isHttps(), apiParameters.getRestServerParameters().isHttps());
assertEquals(restServerParameters.isAaf(), apiParameters.getRestServerParameters().isAaf());
assertEquals(CommonTestData.API_GROUP_NAME, apiParameters.getName());
@@ -57,52 +61,57 @@ public class TestApiParameterGroup {
@Test
public void testApiParameterGroup_NullName() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
- final ApiParameterGroup apiParameters = new ApiParameterGroup(null, restServerParameters);
+ final PolicyModelsProviderParameters databaseProviderParameters =
+ commonTestData.getDatabaseProviderParameters(false);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(null,
+ restServerParameters, databaseProviderParameters);
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, apiParameters.getName());
- assertTrue(validationResult.getResult().contains(
- "field \"name\" type \"java.lang.String\" value \"null\" INVALID, " + "must be a non-blank string"));
+ assertTrue(validationResult.getResult()
+ .contains("field \"name\" type \"java.lang.String\" value \"null\" INVALID, "
+ + "must be a non-blank string"));
}
@Test
public void testApiParameterGroup_EmptyName() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
-
- final ApiParameterGroup apiParameters = new ApiParameterGroup("", restServerParameters);
+ final PolicyModelsProviderParameters databaseProviderParameters =
+ commonTestData.getDatabaseProviderParameters(false);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup("",
+ restServerParameters, databaseProviderParameters);
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", apiParameters.getName());
- assertTrue(validationResult.getResult().contains(
- "field \"name\" type \"java.lang.String\" value \"\" INVALID, " + "must be a non-blank string"));
+ assertTrue(validationResult.getResult().contains("field \"name\" type \"java.lang.String\" value \"\" INVALID, "
+ + "must be a non-blank string"));
}
@Test
public void testApiParameterGroup_EmptyRestServerParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(true);
-
- final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME,
- restServerParameters);
+ final PolicyModelsProviderParameters databaseProviderParameters =
+ commonTestData.getDatabaseProviderParameters(false);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(
+ CommonTestData.API_GROUP_NAME, restServerParameters, databaseProviderParameters);
final GroupValidationResult validationResult = apiParameters.validate();
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.api.main.parameters.RestServerParameters\" INVALID, "
- + "parameter group has status INVALID"));
+ .contains("\"org.onap.policy.api.main.parameters.RestServerParameters\" INVALID, "
+ + "parameter group has status INVALID"));
}
@Test
- public void testName() {
+ public void testApiParameterGroup_EmptyDatabaseProviderParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
-
- final ApiParameterGroup apiParameters = new ApiParameterGroup("", restServerParameters);
- apiParameters.setName("name");
- assertEquals("name", apiParameters.getName());
- }
-
- @Test
- public void testVaildateForNullRestServiceParameters() {
- final ApiParameterGroup apiParameters = new ApiParameterGroup(CommonTestData.API_GROUP_NAME, null);
+ final PolicyModelsProviderParameters databaseProviderParameters =
+ commonTestData.getDatabaseProviderParameters(true);
+ final ApiParameterGroup apiParameters = new ApiParameterGroup(
+ CommonTestData.API_GROUP_NAME, restServerParameters, databaseProviderParameters);
final GroupValidationResult validationResult = apiParameters.validate();
- assertTrue(validationResult.getResult().contains("parameter group has status INVALID"));
+ assertFalse(validationResult.isValid());
+ assertTrue(validationResult.getResult()
+ .contains("\"org.onap.policy.models.provider.PolicyModelsProviderParameters\" INVALID, "
+ + "parameter group has status INVALID"));
}
}
diff --git a/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java b/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java
index 71d8c357..480a5d8a 100644
--- a/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java
@@ -28,7 +28,6 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-
import org.junit.Test;
import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.startstop.ApiCommandLineArguments;
@@ -153,7 +152,7 @@ public class TestApiParameterHandler {
@Test
public void testApiParameterGroup_InvalidRestServerParameters()
throws PolicyApiException, IOException {
- final String[] apiConfigParameters =
+ final String[] apiConfigParameters =
{ "-c", "parameters/ApiConfigParameters_InvalidRestServerParameters.json" };
final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
arguments.parse(apiConfigParameters);
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 3c8b251d..4fb588c2 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
@@ -140,11 +140,11 @@ public class TestApiRestServer {
main = startApiService(true);
Invocation.Builder invocationBuilder = sendHttpRequest(STATISTICS_ENDPOINT);
StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 0, 200);
+ validateStatisticsReport(report, 200);
updateApiStatistics();
invocationBuilder = sendHttpRequest(STATISTICS_ENDPOINT);
report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 1, 200);
+ validateStatisticsReport(report, 200);
ApiStatisticsManager.resetAllStatistics();
} catch (final Exception exp) {
LOGGER.error("testApiStatistics_200 failed", exp);
@@ -161,7 +161,7 @@ public class TestApiRestServer {
restServer.start();
final Invocation.Builder invocationBuilder = sendHttpRequest(STATISTICS_ENDPOINT);
final StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 0, 500);
+ validateStatisticsReport(report, 500);
ApiStatisticsManager.resetAllStatistics();
} catch (final Exception exp) {
LOGGER.error("testApiStatistics_500 failed", exp);
@@ -175,7 +175,7 @@ public class TestApiRestServer {
main = startApiService(false);
final Invocation.Builder invocationBuilder = sendHttpsRequest(STATISTICS_ENDPOINT);
final StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 0, 200);
+ validateStatisticsReport(report, 200);
} catch (final Exception exp) {
LOGGER.error("testHttpsApiStatistics failed", exp);
fail("Test should not throw an exception");
@@ -283,23 +283,8 @@ public class TestApiRestServer {
ApiStatisticsManager.updatePolicyTypePostFailureCount();
}
- private void validateStatisticsReport(final StatisticsReport report, final int count, final int code) {
+ private void validateStatisticsReport(final StatisticsReport report, final int code) {
assertEquals(code, report.getCode());
- assertEquals(count, report.getTotalApiCallCount());
- assertEquals(count, report.getApiCallSuccessCount());
- assertEquals(count, report.getApiCallFailureCount());
- assertEquals(count, report.getTotalPolicyGetCount());
- assertEquals(count, report.getTotalPolicyPostCount());
- assertEquals(count, report.getTotalPolicyTypeGetCount());
- assertEquals(count, report.getTotalPolicyTypePostCount());
- assertEquals(count, report.getPolicyGetSuccessCount());
- assertEquals(count, report.getPolicyGetFailureCount());
- assertEquals(count, report.getPolicyPostSuccessCount());
- assertEquals(count, report.getPolicyPostFailureCount());
- assertEquals(count, report.getPolicyTypeGetSuccessCount());
- assertEquals(count, report.getPolicyTypeGetFailureCount());
- assertEquals(count, report.getPolicyTypePostSuccessCount());
- assertEquals(count, report.getPolicyTypePostFailureCount());
}
private void validateHealthCheckReport(final String name, final String url, final boolean healthy, final int code,
diff --git a/main/src/test/java/org/onap/policy/api/main/exception/PolicyApiRuntimeExceptionTest.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
index f6770b1e..8f4f9aed 100644
--- a/main/src/test/java/org/onap/policy/api/main/exception/PolicyApiRuntimeExceptionTest.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 IBM.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,26 +20,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.api.main.exception;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.Test;
-public class PolicyApiRuntimeExceptionTest {
+package org.onap.policy.api.main.rest.provider;
- private PolicyApiRuntimeException policyApiRuntimeException;
- private String message = "test exception message";
-
- @Before
- public void setUp() {
- policyApiRuntimeException = new PolicyApiRuntimeException(message);
- }
-
- @Test
- public void testContructor() {
- policyApiRuntimeException = new PolicyApiRuntimeException(message, new Exception());
- assertEquals(message, policyApiRuntimeException.getMessage());
- }
-}
+public class TestLegacyGuardPolicyProvider {}
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
new file mode 100644
index 00000000..de12fca0
--- /dev/null
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.policy.api.main.rest.provider;
+
+public class TestLegacyOperationalPolicyProvider {}
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
new file mode 100644
index 00000000..11d7e404
--- /dev/null
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest.provider;
+
+public class TestPolicyProvider {}
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
new file mode 100644
index 00000000..d60dc2e5
--- /dev/null
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest.provider;
+
+public class TestPolicyTypeProvider {}
diff --git a/main/src/test/resources/META-INF/persistence.xml b/main/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 00000000..23e8567f
--- /dev/null
+++ b/main/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2019 Nordix Foundation.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
+ <class>org.onap.policy.models.dao.converters.Uuid2String</class>
+ <class>org.onap.policy.models.base.PfConceptKey</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.user" value="policy" />
+ <property name="javax.persistence.jdbc.password" value="P01icY" />
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+ </properties>
+ </persistence-unit>
+
+ <persistence-unit name="ToscaConceptMariaDBTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
+ <class>org.onap.policy.models.dao.converters.Uuid2String</class>
+ <class>org.onap.policy.models.base.PfConceptKey</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" />
+ <property name="javax.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/policy" />
+ <property name="javax.persistence.jdbc.user" value="policy" />
+ <property name="javax.persistence.jdbc.password" value="P01icY" />
+ <property name="javax.persistence.schema-generation.database.action" value="create" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/main/src/test/resources/parameters/ApiConfigParameters.json b/main/src/test/resources/parameters/ApiConfigParameters.json
index 8fae1238..c64271c7 100644
--- a/main/src/test/resources/parameters/ApiConfigParameters.json
+++ b/main/src/test/resources/parameters/ApiConfigParameters.json
@@ -5,5 +5,13 @@
"port":6969,
"userName":"healthcheck",
"password":"zb!XztG34"
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/policy",
+ "databaseUser": "policy",
+ "databasePassword": "UDAxaWNZ",
+ "persistenceUnit": "ToscaConceptMariaDBTest"
}
}
diff --git a/main/src/test/resources/parameters/ApiConfigParameters_Https.json b/main/src/test/resources/parameters/ApiConfigParameters_Https.json
index ec732132..878dc1ff 100644
--- a/main/src/test/resources/parameters/ApiConfigParameters_Https.json
+++ b/main/src/test/resources/parameters/ApiConfigParameters_Https.json
@@ -6,5 +6,13 @@
"userName":"healthcheck",
"password":"zb!XztG34",
"https":true
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "UDAxaWNZ",
+ "persistenceUnit": "ToscaConceptTest"
}
}
diff --git a/main/src/test/resources/parameters/ApiConfigParameters_InvalidRestServerParameters.json b/main/src/test/resources/parameters/ApiConfigParameters_InvalidRestServerParameters.json
index 2d394fbc..67e461e0 100644
--- a/main/src/test/resources/parameters/ApiConfigParameters_InvalidRestServerParameters.json
+++ b/main/src/test/resources/parameters/ApiConfigParameters_InvalidRestServerParameters.json
@@ -5,5 +5,13 @@
"port":-1,
"userName":"",
"password":""
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "UDAxaWNZ",
+ "persistenceUnit": "ToscaConceptTest"
}
}
diff --git a/main/src/test/resources/parameters/MinimumParameters.json b/main/src/test/resources/parameters/MinimumParameters.json
index 61c6c869..2600d20f 100644
--- a/main/src/test/resources/parameters/MinimumParameters.json
+++ b/main/src/test/resources/parameters/MinimumParameters.json
@@ -5,5 +5,13 @@
"port":6969,
"userName":"healthcheck",
"password":"zb!XztG34"
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "UDAxaWNZ",
+ "persistenceUnit": "ToscaConceptTest"
}
}
diff --git a/main/src/test/resources/parameters/NoParameters.json b/main/src/test/resources/parameters/NoParameters.json
index 6b0805d3..ed2fbde2 100644
--- a/main/src/test/resources/parameters/NoParameters.json
+++ b/main/src/test/resources/parameters/NoParameters.json
@@ -4,5 +4,13 @@
"port":6969,
"userName":"healthcheck",
"password":"zb!XztG34"
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "UDAxaWNZ",
+ "persistenceUnit": "ToscaConceptTest"
}
} \ No newline at end of file
diff --git a/main/src/test/resources/policies/vDNS.policy.guard.minmax.input.json b/main/src/test/resources/policies/vDNS.policy.guard.minmax.input.json
index c62a229a..2dbfe8ce 100644
--- a/main/src/test/resources/policies/vDNS.policy.guard.minmax.input.json
+++ b/main/src/test/resources/policies/vDNS.policy.guard.minmax.input.json
@@ -1,5 +1,4 @@
{
-{
"policy-id" : "guard.minmax.scaleout",
"contents" : {
"actor": "SO",
diff --git a/main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.json b/main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.json
new file mode 100644
index 00000000..26f4c021
--- /dev/null
+++ b/main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.json
@@ -0,0 +1,28 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "policy_types": [
+ {
+ "onap.policies.Monitoring": {
+ "derived_from": "tosca.policies.Root",
+ "description": "a base policy type for all policies that govern monitoring provision",
+ "version": "1.0.0"
+ }
+ },
+ {
+ "onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server": {
+ "derived_from": "policy.nodes.Root",
+ "version": "1.0.0",
+ "properties": {
+ "buscontroller_feed_publishing_endpoint": {
+ "type": "string",
+ "description": "DMAAP Bus Controller feed endpoint"
+ },
+ "datafile.policy": {
+ "type": "string",
+ "description": "datafile Policy JSON as string"
+ }
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml b/main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml
index 5a093ddb..63796fa3 100644
--- a/main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml
+++ b/main/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml
@@ -1,17 +1,18 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- version: 1.0.0
- onap.policies.Monitoring:
- derived_from: tosca.policies.Root
- description: a base policy type for all policies that govern monitoring provision
- version: 1.0.0
- onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server:
- derived_from: policy.nodes.Root
- version: 1.0.0
- properties:
- buscontroller_feed_publishing_endpoint:
- type: string
- description: DMAAP Bus Controller feed endpoint
- datafile.policy:
- type: string
- description: datafile Policy JSON as string
+ -
+ onap.policies.Monitoring:
+ derived_from: tosca.policies.Root
+ description: a base policy type for all policies that govern monitoring provision
+ version: 1.0.0
+ -
+ onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server:
+ derived_from: policy.nodes.Root
+ version: 1.0.0
+ properties:
+ buscontroller_feed_publishing_endpoint:
+ type: string
+ description: DMAAP Bus Controller feed endpoint
+ datafile.policy:
+ type: string
+ description: datafile Policy JSON as string \ No newline at end of file
diff --git a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json
new file mode 100644
index 00000000..95d7a53b
--- /dev/null
+++ b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json
@@ -0,0 +1,223 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "policy_types": [
+ {
+ "onap.policies.Monitoring": {
+ "derived_from": "tosca.policies.Root",
+ "description": "a base policy type for all policies that governs monitoring provisioning"
+ }
+ },
+ {
+ "onap.policy.monitoring.cdap.tca.hi.lo.app": {
+ "derived_from": "onap.policies.Monitoring",
+ "version": "1.0.0",
+ "properties": {
+ "tca_policy": {
+ "type": "map",
+ "description": "TCA Policy JSON",
+ "entry_schema": {
+ "type": "onap.datatypes.monitoring.tca_policy"
+ }
+ }
+ }
+ }
+ }
+ ],
+ "data_types": [
+ {
+ "onap.datatypes.monitoring.metricsPerEventName": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "controlLoopSchemaType": {
+ "type": "string",
+ "required": true,
+ "description": "Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
+ "constraints": [
+ {
+ "valid_values": [
+ "VM",
+ "VNF"
+ ]
+ }
+ ]
+ },
+ "eventName": {
+ "type": "string",
+ "required": true,
+ "description": "Event name to which thresholds need to be applied"
+ },
+ "policyName": {
+ "type": "string",
+ "required": true,
+ "description": "TCA Policy Scope Name"
+ },
+ "policyScope": {
+ "type": "string",
+ "required": true,
+ "description": "TCA Policy Scope"
+ },
+ "policyVersion": {
+ "type": "string",
+ "required": true,
+ "description": "TCA Policy Scope Version"
+ },
+ "thresholds": {
+ "type": "list",
+ "required": true,
+ "description": "Thresholds associated with eventName",
+ "entry_schema": {
+ "type": "onap.datatypes.monitoring.thresholds"
+ }
+ }
+ }
+ }
+ },
+ {
+ "onap.datatypes.monitoring.tca_policy": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "domain": {
+ "type": "string",
+ "required": true,
+ "description": "Domain name to which TCA needs to be applied",
+ "default": "measurementsForVfScaling",
+ "constraints": [
+ {
+ "equal": "measurementsForVfScaling"
+ }
+ ]
+ },
+ "metricsPerEventName": {
+ "type": "list",
+ "required": true,
+ "description": "Contains eventName and threshold details that need to be applied to given eventName",
+ "entry_schema": {
+ "type": "onap.datatypes.monitoring.metricsPerEventName"
+ }
+ }
+ }
+ }
+ },
+ {
+ "onap.datatypes.monitoring.thresholds": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "closedLoopControlName": {
+ "type": "string",
+ "required": true,
+ "description": "Closed Loop Control Name associated with the threshold"
+ },
+ "closedLoopEventStatus": {
+ "type": "string",
+ "required": true,
+ "description": "Closed Loop Event Status of the threshold",
+ "constraints": [
+ {
+ "valid_values": [
+ "ONSET",
+ "ABATED"
+ ]
+ }
+ ]
+ },
+ "direction": {
+ "type": "string",
+ "required": true,
+ "description": "Direction of the threshold",
+ "constraints": [
+ {
+ "valid_values": [
+ "LESS",
+ "LESS_OR_EQUAL",
+ "GREATER",
+ "GREATER_OR_EQUAL",
+ "EQUAL"
+ ]
+ }
+ ]
+ },
+ "fieldPath": {
+ "type": "string",
+ "required": true,
+ "description": "Json field Path as per CEF message which needs to be analyzed for TCA",
+ "constraints": [
+ {
+ "valid_values": [
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage",
+ "$.event.measurementsForVfScalingFields.meanRequestLatency",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed",
+ "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value"
+ ]
+ }
+ ]
+ },
+ "severity": {
+ "type": "string",
+ "required": true,
+ "description": "Threshold Event Severity",
+ "constraints": [
+ {
+ "valid_values": [
+ "CRITICAL",
+ "MAJOR",
+ "MINOR",
+ "WARNING",
+ "NORMAL"
+ ]
+ }
+ ]
+ },
+ "thresholdValue": {
+ "type": "integer",
+ "required": true,
+ "description": "Threshold value for the field Path inside CEF message"
+ },
+ "version": {
+ "type": "string",
+ "required": true,
+ "description": "Version number associated with the threshold"
+ }
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml
index 699cffd7..f8e9b752 100644
--- a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml
+++ b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml
@@ -1,8 +1,10 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
+ -
onap.policies.Monitoring:
derived_from: tosca.policies.Root
description: a base policy type for all policies that governs monitoring provisioning
+ -
onap.policy.monitoring.cdap.tca.hi.lo.app:
derived_from: onap.policies.Monitoring
version: 1.0.0
@@ -13,6 +15,7 @@ policy_types:
entry_schema:
type: onap.datatypes.monitoring.tca_policy
data_types:
+ -
onap.datatypes.monitoring.metricsPerEventName:
derived_from: tosca.datatypes.Root
properties:
@@ -46,6 +49,7 @@ data_types:
description: Thresholds associated with eventName
entry_schema:
type: onap.datatypes.monitoring.thresholds
+ -
onap.datatypes.monitoring.tca_policy:
derived_from: tosca.datatypes.Root
properties:
@@ -62,6 +66,7 @@ data_types:
description: Contains eventName and threshold details that need to be applied to given eventName
entry_schema:
type: onap.datatypes.monitoring.metricsPerEventName
+ -
onap.datatypes.monitoring.thresholds:
derived_from: tosca.datatypes.Root
properties:
@@ -155,4 +160,4 @@ data_types:
version:
type: string
required: true
- description: Version number associated with the threshold
+ description: Version number associated with the threshold \ No newline at end of file