aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java2
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java3
2 files changed, 4 insertions, 1 deletions
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
index a855d5d24..7fa21b021 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
@@ -86,6 +86,8 @@ public class PolicyPersistenceTest {
*/
@Before
public void setupParameters() throws PfModelException, CoderException {
+ // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
+
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
index 81a41aa05..761a47c9a 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
@@ -195,7 +195,6 @@ public class SimpleToscaProvider {
for (JpaToscaPolicy policy : serviceTemplate.getTopologyTemplate().getPolicies().getAll(null)) {
verifyPolicyTypeForPolicy(dao, policy);
-
dao.create(policy);
}
@@ -226,6 +225,7 @@ public class SimpleToscaProvider {
ToscaUtils.assertPoliciesExist(serviceTemplate);
for (JpaToscaPolicy policy : serviceTemplate.getTopologyTemplate().getPolicies().getAll(null)) {
+ verifyPolicyTypeForPolicy(dao, policy);
dao.update(policy);
}
@@ -288,6 +288,7 @@ public class SimpleToscaProvider {
if (PfKey.NULL_KEY_VERSION.equals(policyTypeKey.getVersion())) {
policyType = getLatestPolicyTypeVersion(dao, policyTypeKey.getName());
+ policy.getType().setVersion(policyType.getKey().getVersion());
} else {
policyType = dao.get(JpaToscaPolicyType.class, policyTypeKey);
}