Skip to content

Commit

Permalink
MOSIP-31084
Browse files Browse the repository at this point in the history
Signed-off-by: Jayesh Kharode <[email protected]>
  • Loading branch information
Jayesh Kharode committed Jan 10, 2024
1 parent 10eaaea commit 411197a
Show file tree
Hide file tree
Showing 15 changed files with 314 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,37 @@ public class ConfigManager {
private static String IAM_REALM_ID = "keycloak-realm-id";
private static String IAM_USERS_TO_CREATE = "iam-users-to-create";
private static String IAM_USERS_PASSWORD = "iam-users-password";

private static String HolidayDateCenter = "holidayDateCenter";
private static String HolidayDate = "holidayDate";
private static String Preappend = "preappend";
private static String Splitdigit = "splitdigit";
private static String JsonObjName = "jsonObjName";
private static String Bulkwait = "bulkwait";
private static String ValidityDate = "validityDate";
private static String PublicKey = "publicKey";
private static String SignPublicKey = "signPublicKey";
private static String Headless = "headless";
private static String Docker = "docker";
private static String Langcode = "langcode";
private static String DummyData = "dummyData";//loginlang
private static String Loginlang = "loginlang";


private static String loginlang;
private static String langcode;
private static String docker;
private static String headless;
private static String signPublicKey;
private static String publicKey;
private static String validityDate;
private static String bulkwait;
private static String dummyData;
private static String jsonObjName;
private static String splitdigit;
private static String preappend;
private static String holidayDate;
private static String holidayDateCenter;
//
// private static String AUTH_DEMO_SERVICE_PORT = "authDemoServicePort";
// private static String AUTH_DEMO_SERVICE_BASE_URL = "authDemoServiceBaseURL";
Expand Down Expand Up @@ -278,11 +309,94 @@ public static void init() {

push_reports_to_s3 =System.getenv(PUSH_TO_S3) == null ? propsKernel.getProperty(PUSH_TO_S3) : System.getenv(PUSH_TO_S3);
propsKernel.setProperty(PUSH_TO_S3, push_reports_to_s3);
holidayDateCenter =System.getenv(HolidayDateCenter) == null ? propsKernel.getProperty(HolidayDateCenter) : System.getenv(HolidayDateCenter);
propsKernel.setProperty(HolidayDateCenter, holidayDateCenter);

holidayDate =System.getenv(HolidayDate) == null ? propsKernel.getProperty(HolidayDate) : System.getenv(HolidayDate);
propsKernel.setProperty(HolidayDate, holidayDate);

preappend =System.getenv(Preappend) == null ? propsKernel.getProperty(Preappend) : System.getenv(Preappend);
propsKernel.setProperty(Preappend, preappend);

splitdigit =System.getenv(Splitdigit) == null ? propsKernel.getProperty(Splitdigit) : System.getenv(Splitdigit);
propsKernel.setProperty(Splitdigit, splitdigit);

jsonObjName =System.getenv(JsonObjName) == null ? propsKernel.getProperty(JsonObjName) : System.getenv(JsonObjName);
propsKernel.setProperty(JsonObjName, jsonObjName);

bulkwait =System.getenv(Bulkwait) == null ? propsKernel.getProperty(Bulkwait) : System.getenv(Bulkwait);
propsKernel.setProperty(Bulkwait, bulkwait);



dummyData =System.getenv(DummyData) == null ? propsKernel.getProperty(DummyData) : System.getenv(DummyData);
propsKernel.setProperty(DummyData, dummyData);

validityDate =System.getenv(ValidityDate) == null ? propsKernel.getProperty(ValidityDate) : System.getenv(ValidityDate);
propsKernel.setProperty(ValidityDate, validityDate);

publicKey =System.getenv(PublicKey) == null ? propsKernel.getProperty(PublicKey) : System.getenv(PublicKey);
propsKernel.setProperty(PublicKey, publicKey);

signPublicKey =System.getenv(SignPublicKey) == null ? propsKernel.getProperty(SignPublicKey) : System.getenv(SignPublicKey);
propsKernel.setProperty(SignPublicKey, signPublicKey);

headless =System.getenv(Headless) == null ? propsKernel.getProperty(Headless) : System.getenv(Headless);
propsKernel.setProperty(Headless, headless);

docker =System.getenv(Docker) == null ? propsKernel.getProperty(Docker) : System.getenv(Docker);
propsKernel.setProperty(Docker, docker);

langcode =System.getenv(Langcode) == null ? propsKernel.getProperty(Langcode) : System.getenv(Langcode);
propsKernel.setProperty(Langcode, langcode);

loginlang =System.getenv(Loginlang) == null ? propsKernel.getProperty(Loginlang) : System.getenv(Loginlang);
propsKernel.setProperty(Loginlang, loginlang);

admin_userName =System.getenv(ADMIN_USERNAME) == null ? propsKernel.getProperty(ADMIN_USERNAME) : System.getenv(ADMIN_USERNAME);
propsKernel.setProperty(ADMIN_USERNAME, admin_userName);
}

public static String getloginlang() {
return loginlang;
}
public static String getlangcode() {
return langcode;
}
public static String getdocker() {
return docker;
}
public static String getheadless() {
return headless;
}
public static String getsignPublicKey() {
return signPublicKey;
}
public static String getpublicKey() {
return publicKey;
}
public static String getvalidityDate() {
return validityDate;
}
public static String getdummyData() {
return dummyData;
}

public static String getbulkwait() {
return bulkwait;
}
public static String getjsonObjName() {
return jsonObjName;
}
public static String getsplitdigit() {
return splitdigit;
}
public static String getpreappend() {
return preappend;
}
public static String getholidayDate() {
return holidayDate;
}
public static String getholidayDateCenter() {
return holidayDateCenter;
}
public static String getAdminUserName() {
return admin_userName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.aventstack.extentreports.Status;

import io.mosip.testrig.adminui.kernel.util.ConfigManager;
import io.mosip.testrig.adminui.utility.BaseClass;
import io.mosip.testrig.adminui.utility.Commons;
import io.mosip.testrig.adminui.utility.JsonUtil;
Expand All @@ -36,7 +37,7 @@ public class BlockListTest extends BaseClass {
public void blocklistedwordsCRUD() {

try {
String blocklistedWord=JsonUtil.JsonObjParsing(Commons.getTestData(),"dummyData");
String blocklistedWord=ConfigManager.getdummyData();

test=extent.createTest("BlockListTest", "verify Login");
String idBlocklisted="admin/masterdata/blocklisted-words/view";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import com.aventstack.extentreports.Status;

import io.mosip.testrig.adminui.kernel.util.ConfigManager;
import io.mosip.testrig.adminui.utility.BaseClass;
import io.mosip.testrig.adminui.utility.Commons;
import io.mosip.testrig.adminui.utility.JsonUtil;
Expand Down Expand Up @@ -91,7 +92,7 @@ public void bulkUploadCRUD(String table) throws Exception {
// Commons.click(test,driver,By.id("fileInput"));


String filePath = TestRunner.getResourcePath()+ "//BulkUploadFiles//"+ JsonUtil.JsonObjParsing(Commons.getTestData(),"loginlang")+"//"+table+".csv";
String filePath = TestRunner.getResourcePath()+ "//BulkUploadFiles//"+ ConfigManager.getloginlang()+"//"+table+".csv";
Commons.enter(test, driver, By.id("fileInput"), filePath);


Expand All @@ -105,7 +106,7 @@ public void bulkUploadCRUD(String table) throws Exception {
logger.info(divTextArr[1].trim());

Commons.click(test,driver,By.id("confirmmessagepopup")); //DONE
Thread.sleep(Long.parseLong(JsonUtil.JsonObjParsing(Commons.getTestData(),"bulkwait")));
Thread.sleep(Long.parseLong(ConfigManager.getbulkwait()));

String transId=driver.findElement(By.xpath("//table[@class='mat-table']//tr[2]//td[1]")).getText();
String status=driver.findElement(By.xpath("//table[@class='mat-table']//tr[2]//td[5]")).getText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.aventstack.extentreports.Status;

import io.mosip.testrig.adminui.kernel.util.ConfigManager;
import io.mosip.testrig.adminui.utility.BaseClass;
import io.mosip.testrig.adminui.utility.Commons;
import io.mosip.testrig.adminui.utility.JsonUtil;
Expand All @@ -34,7 +35,7 @@ public void centerCRUD() throws Exception {

Reporter.log("centerCRUD",true);
test=extent.createTest("CenterTest", "verify Login");
String holidayDate=JsonUtil.JsonObjParsing(Commons.getTestData(),"holidayDateCenter");
String holidayDate=ConfigManager.getholidayDateCenter();
Commons.click(test,driver,By.id("admin/resources"));

Commons.click(test,driver,By.id("/admin/resources/centers"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.aventstack.extentreports.Status;
import com.paulhammant.ngwebdriver.NgWebDriver;

import io.mosip.testrig.adminui.kernel.util.ConfigManager;
import io.mosip.testrig.adminui.utility.BaseClass;
import io.mosip.testrig.adminui.utility.Commons;
import io.mosip.testrig.adminui.utility.JsonUtil;
Expand All @@ -33,7 +34,7 @@ public class DeviceTest extends BaseClass{
public void deviceCRUD() throws InterruptedException {
String validityDate;
try {
validityDate = JsonUtil.JsonObjParsing(Commons.getTestData(),"validityDate");
validityDate = ConfigManager.getvalidityDate();
test=extent.createTest("DeviceTest", "verify Login");
Commons.click(test,driver,By.id("admin/resources"));
Commons.click(test,driver,By.id("/admin/resources/devices"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.aventstack.extentreports.Status;

import io.mosip.testrig.adminui.kernel.util.ConfigManager;
import io.mosip.testrig.adminui.utility.BaseClass;
import io.mosip.testrig.adminui.utility.Commons;
import io.mosip.testrig.adminui.utility.JsonUtil;
Expand All @@ -39,7 +40,7 @@ public void holidaysCRUD() throws Exception {
test=extent.createTest("HolidaysTest", "verify Login");
String listofholidays="admin/masterdata/holiday/view";
test=extent.createTest("HolidaysTest", "verify Login");
String holidayDate=JsonUtil.JsonObjParsing(Commons.getTestData(),"holidayDate");
String holidayDate=ConfigManager.getholidayDate();
Commons.click(test,driver,By.xpath("//a[@href='#/admin/masterdata']"));

Commons.click(test,driver,By.id(listofholidays));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import io.mosip.testrig.adminui.kernel.util.ConfigManager;
import io.mosip.testrig.adminui.utility.BaseClass;
import io.mosip.testrig.adminui.utility.Commons;
import io.mosip.testrig.adminui.utility.JsonUtil;
import io.mosip.testrig.adminui.utility.TestRunner;

public class LoginTest extends BaseClass{
Expand All @@ -44,7 +46,7 @@ public void loginTest() throws Exception {
driver.findElement(By.linkText("Admin")).click();

try {
language=Commons.getFieldData("langcode");
language=JsonUtil.JsonObjArrayListParsing2(ConfigManager.getlangcode());

logger.info(language);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@

import com.aventstack.extentreports.Status;

import io.mosip.testrig.adminui.kernel.util.ConfigManager;
import io.mosip.testrig.adminui.utility.BaseClass;
import io.mosip.testrig.adminui.utility.Commons;
import io.mosip.testrig.adminui.utility.JsonUtil;
public class MachineTest extends BaseClass{
@Test(groups = "M")
public void machineCRUD() throws Exception {
test=extent.createTest("MachineTest", "verify Login");
String holidayDateCenter=JsonUtil.JsonObjParsing(Commons.getTestData(),"holidayDateCenter");
String publicKey=JsonUtil.JsonObjParsing(Commons.getTestData(),"publicKey");
String holidayDateCenter=ConfigManager.getholidayDateCenter();
String publicKey=ConfigManager.getpublicKey();

String signPublicKey=JsonUtil.JsonObjParsing(Commons.getTestData(),"signPublicKey");
String signPublicKey=ConfigManager.getsignPublicKey();

Commons.click(test,driver,By.id("admin/resources"));
Commons.click(test,driver,By.xpath("//a[@href='#/admin/resources/machines']"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public class BaseClass {
public static ExtentTest test;


public void setLangcode(String langcode) throws Exception {
this.langcode = Commons.getFieldData("langcode");
}


@BeforeSuite

Expand All @@ -94,7 +92,7 @@ public void setUp() throws Exception {
logger.info("Start set up");
if(System.getProperty("os.name").equalsIgnoreCase("Linux")) {

if(JsonUtil.JsonObjParsing(Commons.getTestData(),"Docker").equals("yes")) {
if(ConfigManager.getdocker().equals("yes")) {
logger.info("Docker start");
String configFilePath ="/usr/bin/chromedriver";
System.setProperty("webdriver.chrome.driver", configFilePath);
Expand All @@ -106,7 +104,7 @@ public void setUp() throws Exception {
logger.info("window chrome driver start");
}
ChromeOptions options = new ChromeOptions();
String headless=JsonUtil.JsonObjParsing(Commons.getTestData(),"headless");
String headless=ConfigManager.getheadless();
if(headless.equalsIgnoreCase("yes")) {
logger.info("Running is headless mode");
options.addArguments("--headless", "--disable-gpu","--no-sandbox", "--window-size=1920x1080","--disable-dev-shm-usage");
Expand All @@ -125,12 +123,14 @@ public void setUp() throws Exception {

String language1 = null;
try {
language1 = Commons.getFieldData("langcode");

logger.info(language1);

language1 = ConfigManager.getloginlang();
String loginlang = null;
System.out.println(language1);
if(!language1.equals("sin"))
loginlang = JsonUtil.JsonObjArrayListParsing2(ConfigManager.getlangcode());
{Commons.click(test,driver, By.xpath("//*[@id='kc-locale-dropdown']"));
String var = "//li/a[contains(text(),'" + language1 + "')]";
String var = "//li/a[contains(text(),'" + loginlang + "')]";
Commons.click(test,driver, By.xpath(var));
}

Expand Down Expand Up @@ -248,7 +248,7 @@ public Object[] dpMethod() {
public static String[] readFolderJsonList() {
String contents[] = null;
try {
String langcode = JsonUtil.JsonObjParsing(Commons.getTestData(),"loginlang");
String langcode = ConfigManager.getloginlang();

File directoryPath = new File(TestRunner.getResourcePath()+ "//BulkUploadFiles//" + langcode + "//");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.MediaEntityBuilder;

import io.mosip.testrig.adminui.kernel.util.ConfigManager;

public class Commons extends BaseClass{
private static final Logger logger = Logger.getLogger(Commons.class);

Expand Down Expand Up @@ -284,19 +286,9 @@ public static String getTestData()
{
return JsonUtil.readJsonFileText("TestData.json");
}
public static String getFieldData(String idfield) throws Exception
{
return JsonUtil.JsonObjSimpleParsing(getTestData(), idfield);

}

public static void clickSpan(ExtentTest test,WebDriver driver,String key) throws Exception {

String val=Commons.getFieldData(key);
String var="//span[contains(text(),'"+ val+ "')]";
Commons.click(test,driver,By.xpath(var));
logger.info("clickSpan" + var );
}


public static void deactivate(ExtentTest test,WebDriver driver) {
Commons.click(test,driver,By.id("ellipsis-button0"));
Expand Down Expand Up @@ -444,7 +436,7 @@ public static String getPreAppend()
{
String preappend = null;
try {
preappend = JsonUtil.JsonObjParsing(getTestData(),"preappend");
preappend =ConfigManager.getpreappend();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
Loading

0 comments on commit 411197a

Please sign in to comment.