Skip to content

Commit

Permalink
Merge pull request #1335 from nandhu-kumar/develop
Browse files Browse the repository at this point in the history
MOSIP-35404 | Move component specific test code from common to component api test rigs
  • Loading branch information
ckm007 authored Oct 3, 2024
2 parents ab982c3 + f2a487f commit a4bfcb8
Show file tree
Hide file tree
Showing 23 changed files with 93 additions and 366 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.mosip.testrig.apirig.utils.MispPartnerAndLicenseKeyGeneration;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PartnerRegistration;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.SkipTestCaseHandler;

/**
Expand Down Expand Up @@ -64,14 +65,16 @@ 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();
ResidentConfigManager.init();
BaseTestCase.suiteSetup(getRunType());
SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt");
setLogLevels();

Expand Down Expand Up @@ -102,7 +105,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 @@ -133,7 +136,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 All @@ -156,34 +159,15 @@ public static void startTestRunner() {
runner.run();
}

/**
* The method to return class loader resource path
*
* @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 @@ -200,15 +184,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 @@ -302,7 +277,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 @@ -31,11 +31,11 @@
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.KernelAuthentication;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.mosip.testrig.apirig.utils.RestClient;
import io.restassured.response.Response;
Expand All @@ -56,7 +56,7 @@ public String getTestName() {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.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,10 +27,10 @@
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.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -42,7 +42,7 @@ public class DeleteWithParam extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
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.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

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

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
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.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -45,7 +45,7 @@ public class GetWithParamForAutoGenId extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.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.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.GlobalMethods;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -43,7 +43,7 @@ public class GetWithParamForDownloadCard extends AdminTestUtil implements ITest

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
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.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -42,7 +42,7 @@ public class GetWithParamWithOtpGenerate extends AdminTestUtil implements ITest

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.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.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.GlobalMethods;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -43,7 +43,7 @@ public class GetWithQueryParamForDownloadCard extends AdminTestUtil implements I

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.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,10 +26,10 @@
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.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -39,7 +39,7 @@ public class PatchWithBodyWithOtpGenerate extends AdminTestUtil implements ITest

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.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,10 +27,10 @@
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.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -43,7 +43,7 @@ public class PostWithAutogenIdWithOtpGenerate extends AdminTestUtil implements I

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -121,10 +121,10 @@ public void test(TestCaseDTO testCaseDTO)
int currLoopCount = 0;
while (currLoopCount < maxLoopCount) {
if (testCaseName.contains(GlobalConstants.ESIGNET_)) {
if (ConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
if (ResidentConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
throw new SkipException("esignet is not deployed hence skipping the testcase");
}
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = ResidentConfigManager.getEsignetBaseUrl();
otpResponse = postRequestWithCookieAuthHeaderAndXsrfToken(tempUrl + sendOtpEndPoint,
getJsonFromTemplate(otpReqJson.toString(), sendOtpReqTemplate), COOKIENAME,
testCaseDTO.getTestCaseName());
Expand Down Expand Up @@ -183,10 +183,10 @@ public void test(TestCaseDTO testCaseDTO)
}

if (testCaseName.contains(GlobalConstants.ESIGNET_)) {
if (ConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
if (ResidentConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
throw new SkipException("esignet is not deployed hence skipping the testcase");
}
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = ResidentConfigManager.getEsignetBaseUrl();
response = postRequestWithCookieAuthHeaderAndXsrfTokenForAutoGenId(tempUrl + testCaseDTO.getEndPoint(),
getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate()), COOKIENAME,
testCaseDTO.getTestCaseName(), idKeyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
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.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -42,7 +42,7 @@ public class PostWithBodyWithOtpGenerate extends AdminTestUtil implements ITest

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -95,7 +95,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad

testCaseName = isTestCaseValidForExecution(testCaseDTO);
auditLogCheck = testCaseDTO.isAuditLogCheck();
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = ResidentConfigManager.getEsignetBaseUrl();
JSONObject req = new JSONObject(testCaseDTO.getInput());
String otpRequest = null;
String sendOtpReqTemplate = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
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.GlobalMethods;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -48,7 +48,7 @@ public class PostWithBodyWithOtpGenerateAndPdfDownload extends AdminTestUtil imp

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (ResidentConfigManager.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.GlobalMethods;
import io.mosip.testrig.apirig.utils.ResidentConfigManager;
import io.mosip.testrig.apirig.utils.ResidentUtil;
import io.restassured.response.Response;

Expand All @@ -43,7 +43,7 @@ public class PostWithBodyWithPdfDownload extends AdminTestUtil implements ITest

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

0 comments on commit a4bfcb8

Please sign in to comment.