Fix write failure on PDP statistics
[policy/models.git] / models-pdp / src / test / java / org / onap / policy / models / pdp / persistence / provider / PdpProviderTest.java
index aadaf35..63f4681 100644 (file)
@@ -98,9 +98,13 @@ public class PdpProviderTest {
         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
 
-        // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
-        jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
-        jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
+        if (System.getProperty("USE-MARIADB") != null) {
+            jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
+            jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+        } else {
+            jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+            jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
+        }
 
         daoParameters.setJdbcProperties(jdbcProperties);
 
@@ -519,7 +523,7 @@ public class PdpProviderTest {
     }
 
     @Test
-    public void testUpdatePdpStatistics() throws PfModelException {
+    public void testUpdatePdpStatisticsDao() throws PfModelException {
         assertThatThrownBy(() -> {
             new PdpProvider().updatePdpStatistics(null, null, null, null, null);
         }).hasMessageMatching(DAO_IS_NULL);
@@ -583,7 +587,10 @@ public class PdpProviderTest {
         assertThatThrownBy(() -> {
             new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", new PdpStatistics());
         }).hasMessageMatching(DAO_IS_NULL);
+    }
 
+    @Test
+    public void testUpdatePdpStatisticsGroup() throws PfModelException {
         assertThatThrownBy(() -> {
             new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null);
         }).hasMessageMatching(GROUP_IS_NULL);