aboutsummaryrefslogtreecommitdiffstats
path: root/models-provider
diff options
context:
space:
mode:
Diffstat (limited to 'models-provider')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java17
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java7
2 files changed, 12 insertions, 12 deletions
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
index 475e5769d..cd7b7f38e 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
@@ -29,6 +29,7 @@ import javax.ws.rs.core.Response;
import lombok.NonNull;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.dao.DaoParameters;
@@ -66,14 +67,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPfDao.class);
- // Constants for persistence properties
- // @formatter:off
- private static final String JAVAX_PERSISTENCE_JDBC_DRIVER = "javax.persistence.jdbc.driver";
- private static final String JAVAX_PERSISTENCE_JDBC_URL = "javax.persistence.jdbc.url";
- private static final String JAVAX_PERSISTENCE_JDBC_USER = "javax.persistence.jdbc.user";
- private static final String JAVAX_PERSISTENCE_JDBC_PWORD = "javax.persistence.jdbc.password";
- // @formatter:on
-
private final PolicyModelsProviderParameters parameters;
// Database connection and the DAO for reading and writing Policy Framework concepts
@@ -109,10 +102,10 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
// @formatter:off
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty(JAVAX_PERSISTENCE_JDBC_DRIVER, parameters.getDatabaseDriver());
- jdbcProperties.setProperty(JAVAX_PERSISTENCE_JDBC_URL, parameters.getDatabaseUrl());
- jdbcProperties.setProperty(JAVAX_PERSISTENCE_JDBC_USER, parameters.getDatabaseUser());
- jdbcProperties.setProperty(JAVAX_PERSISTENCE_JDBC_PWORD, decodedPassword);
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, parameters.getDatabaseDriver());
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, parameters.getDatabaseUrl());
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, parameters.getDatabaseUser());
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, decodedPassword);
// @formatter:on
daoParameters.setJdbcProperties(jdbcProperties);
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
index 2f3f89c0a..51771ff9a 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
@@ -63,5 +63,12 @@ public class PolicyModelsProviderParametersTest {
pars.setPersistenceUnit("WileECoyote");
result = pars.validate();
assertTrue(result.isValid());
+
+ pars.setDatabaseDriver(null);
+ result = pars.validate();
+ assertFalse(result.isValid());
+ pars.setDatabaseDriver("MichaelsShumacher");
+ result = pars.validate();
+ assertTrue(result.isValid());
}
}