Skip to content

Commit

Permalink
MOSIP-36077 - Restructured the config manager (#902)
Browse files Browse the repository at this point in the history
* MOSIP-35671 -Merging java21 with develop

Signed-off-by: Mohanachandran S <[email protected]>

* MOSIP-35911 - Added DB queries

Signed-off-by: Mohanachandran S <[email protected]>

* MOSIP-35916 - Renamed the apitest folder to api-test

Signed-off-by: Mohanachandran S <[email protected]>

* MOSIP-36077 - Restructured the config manager

Signed-off-by: Mohanachandran S <[email protected]>

* MOSIP-36077 - Restructured the config manager

Signed-off-by: Mohanachandran S <[email protected]>

* MOSIP-36077 - Restructured the config manager

Signed-off-by: Mohanachandran S <[email protected]>

---------

Signed-off-by: Mohanachandran S <[email protected]>
  • Loading branch information
mohanachandran-s authored Oct 3, 2024
1 parent 0d30411 commit 352fc81
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 345 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@

import io.mosip.testrig.apirig.dbaccess.DBManager;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.CertificateGenerationUtil;
import io.mosip.testrig.apirig.utils.CertsUtil;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.EncryptionDecrptionUtil;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.JWKKeyUtil;
import io.mosip.testrig.apirig.utils.KeyCloakUserAndAPIKeyGeneration;
import io.mosip.testrig.apirig.utils.KeycloakUserManager;
import io.mosip.testrig.apirig.utils.MispPartnerAndLicenseKeyGeneration;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PartnerRegistration;
import io.mosip.testrig.apirig.utils.SkipTestCaseHandler;

Expand Down Expand Up @@ -63,14 +61,15 @@ public static void main(String[] arg) {
for (String envName : envMap.keySet()) {
LOGGER.info(String.format("ENV %s = %s%n", envName, envMap.get(envName)));
}
BaseTestCase.setRunContext(getRunType(), jarUrl);
ExtractResource.removeOldMosipTestTestResource();
if (checkRunType().equalsIgnoreCase("JAR")) {
if (getRunType().equalsIgnoreCase("JAR")) {
ExtractResource.extractCommonResourceFromJar();
} else {
ExtractResource.copyCommonResources();
}
ConfigManager.init();
BaseTestCase.suiteSetup();
PMSConfigManger.init();
BaseTestCase.suiteSetup(getRunType());
SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt");
setLogLevels();

Expand All @@ -91,7 +90,7 @@ public static void main(String[] arg) {
LOGGER.error("Exception " + e.getMessage());
}

MockSMTPListener.bTerminate = true;
OTPListener.bTerminate = true;

if (BaseTestCase.isTargetEnvLTS())
HealthChecker.bTerminate = true;
Expand Down Expand Up @@ -128,7 +127,7 @@ public static void startTestRunner() {
List<String> modulesToRun = BaseTestCase.listOfModules;
String os = System.getProperty("os.name");
LOGGER.info(os);
if (checkRunType().contains("IDE") || os.toLowerCase().contains("windows")) {
if (getRunType().contains("IDE") || os.toLowerCase().contains("windows")) {
homeDir = new File(System.getProperty("user.dir") + "/testNgXmlFiles");
LOGGER.info("IDE :" + homeDir);
} else {
Expand Down Expand Up @@ -157,28 +156,16 @@ public static void startTestRunner() {
* @return String
* @throws IOException
*/
/*
* public static String getGlobalResourcePath() { if
* (checkRunType().equalsIgnoreCase("JAR")) { return new
* File(jarUrl).getParentFile().getAbsolutePath() +
* "/MosipTestResource/MosipTemporaryTestResource"; } else if
* (checkRunType().equalsIgnoreCase("IDE")) { String path = new
* File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).
* getAbsolutePath() + "/MosipTestResource/MosipTemporaryTestResource"; if
* (path.contains(GlobalConstants.TESTCLASSES)) path =
* path.replace(GlobalConstants.TESTCLASSES, "classes"); return path; } return
* "Global Resource File Path Not Found"; }
*/

public static String getGlobalResourcePath() {
if (cachedPath != null) {
return cachedPath;
}

String path = null;
if (checkRunType().equalsIgnoreCase("JAR")) {
if (getRunType().equalsIgnoreCase("JAR")) {
path = new File(jarUrl).getParentFile().getAbsolutePath() + "/MosipTestResource/MosipTemporaryTestResource";
} else if (checkRunType().equalsIgnoreCase("IDE")) {
} else if (getRunType().equalsIgnoreCase("IDE")) {
path = new File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath()
+ "/MosipTestResource/MosipTemporaryTestResource";
if (path.contains(GlobalConstants.TESTCLASSES))
Expand All @@ -195,15 +182,6 @@ public static String getGlobalResourcePath() {

public static String getResourcePath() {
return getGlobalResourcePath();
// if (checkRunType().equalsIgnoreCase("JAR")) {
// return new File(jarUrl).getParentFile().getAbsolutePath();
// } else if (checkRunType().equalsIgnoreCase("IDE")) {
// String path = new File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath();
// if (path.contains(GlobalConstants.TESTCLASSES))
// path = path.replace(GlobalConstants.TESTCLASSES, "classes");
// return path;
// }
// return "Global Resource File Path Not Found";
}

public static String generatePulicKey() {
Expand Down Expand Up @@ -297,7 +275,7 @@ public static Properties getproperty(String path) {
*
* @return
*/
public static String checkRunType() {
public static String getRunType() {
if (MosipTestRunner.class.getResource("MosipTestRunner.class").getPath().contains(".jar"))
return "JAR";
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.restassured.response.Response;

Expand All @@ -50,7 +50,7 @@ public String getTestName() {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -79,7 +79,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
String[] templateFields = testCaseDTO.getTemplateFields();
List<String> queryProp = Arrays.asList(templateFields);
logger.info(queryProp);
String query = "select * from audit.app_audit_log where cr_by = '"+BaseTestCase.currentModule +"-"+propsKernel.getProperty("partner_userName")+"'";
String query = "select * from audit.app_audit_log where cr_by = '"+BaseTestCase.currentModule +"-"+PMSConfigManger.getproperty("partner_userName")+"'";


logger.info(query);
Expand Down Expand Up @@ -113,7 +113,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
@AfterMethod(alwaysRun = true)
public void setResultTestName(ITestResult result) {

String deleteQuery = "delete from audit.app_audit_log where cr_by = '"+propsKernel.getProperty("partner_userName")+"'";
String deleteQuery = "delete from audit.app_audit_log where cr_by = '"+PMSConfigManger.getproperty("partner_userName")+"'";
logger.info(deleteQuery);
AuditDBManager.executeQueryAndDeleteRecord("audit", deleteQuery);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.restassured.response.Response;

Expand All @@ -44,7 +44,7 @@ public class DBValidator extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -41,7 +41,7 @@ public class GetWithParam extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -40,7 +40,7 @@ public class GetWithQueryParam extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -83,7 +83,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
if (ConfigManager.isInServiceNotDeployedList(GlobalConstants.ADMIN) && testCaseName.contains("BulkUpload_")) {
if (PMSConfigManger.isInServiceNotDeployedList(GlobalConstants.ADMIN) && testCaseName.contains("BulkUpload_")) {
throw new SkipException(GlobalConstants.SERVICE_NOT_DEPLOYED_MESSAGE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -40,7 +40,7 @@ public class PatchWithPathParamsAndBody extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -43,7 +42,7 @@ public class PostWithBodyAndPathParams extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -40,7 +40,7 @@ public class PostWithOnlyPathParam extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -42,7 +41,7 @@ public class PutWithPathParamsAndBody extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -41,7 +41,7 @@ public class SimplePatchForAutoGenId extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -41,7 +41,7 @@ public class SimplePost extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -44,7 +43,7 @@ public class SimplePostForAutoGenId extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PMSConfigManger;
import io.mosip.testrig.apirig.utils.PMSUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;
Expand All @@ -41,7 +41,7 @@ public class SimplePut extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (PMSConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Loading

0 comments on commit 352fc81

Please sign in to comment.