Remove references to MariaDB from resource files
[policy/pap.git] / main / src / test / java / org / onap / policy / pap / main / parameters / CommonTestData.java
index 34d7220..130f1ef 100644 (file)
@@ -3,6 +3,7 @@
  *  Copyright (C) 2019 Nordix Foundation.
  *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modification Copyright 2022. Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.Paths;
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
@@ -85,6 +87,28 @@ public class CommonTestData {
         }
     }
 
+    /**
+     * Gets the postgres PAP parameters, as a String.
+     *
+     * @param port port to be inserted into the parameters
+     * @return the postgres PAP parameters
+     */
+    public String getPapPostgresParameterGroupAsString(int port) {
+
+        try {
+            String json = new String(Files.readAllBytes(Paths.get(
+                    "src/test/resources/parameters/PapConfigParameters_Postgres.json")));
+
+            json = json.replace("${port}", String.valueOf(port));
+            json = json.replace("${dbName}", "jdbc:h2:mem:testdb" + dbNum);
+
+            return json;
+
+        } catch (IOException e) {
+            throw new PolicyPapRuntimeException("cannot read PAP parameters", e);
+        }
+    }
+
     /**
      * Gets the full path to the parameter file, which may vary depending on whether or
      * not this is an end-to-end test.