From 98f08cdd382d637bc7e681f32148ea9fef6ccaab Mon Sep 17 00:00:00 2001 From: Jayesh Kharode Date: Thu, 19 Sep 2024 17:04:51 +0530 Subject: [PATCH] MOSIP-35896 Signed-off-by: Jayesh Kharode --- .../residentui/fw/util/AdminTestUtil.java | 40 +++++++++++++++++++ .../residentui/testcase/UpdateMyData.java | 8 +++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/uitest-resident/src/main/java/io/mosip/testrig/residentui/fw/util/AdminTestUtil.java b/uitest-resident/src/main/java/io/mosip/testrig/residentui/fw/util/AdminTestUtil.java index 95845a16..2c4b5c63 100644 --- a/uitest-resident/src/main/java/io/mosip/testrig/residentui/fw/util/AdminTestUtil.java +++ b/uitest-resident/src/main/java/io/mosip/testrig/residentui/fw/util/AdminTestUtil.java @@ -9,6 +9,7 @@ import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.Map; import java.util.TimeZone; import javax.ws.rs.core.MediaType; @@ -41,6 +42,9 @@ public class AdminTestUtil extends BaseTestCase { public static String propsHealthCheckURL = TestRunner.getResourcePath() + "/" + "config/healthCheckEndpoint.properties"; private static String serverComponentsCommitDetails; + private static final Map actuatorValueCache = new HashMap<>(); + public static JSONArray authActuatorResponseArray = null; + public static String getUnUsedUIN(String role){ return JsonPrecondtion @@ -379,4 +383,40 @@ public static void closeFileReader(FileReader fileReader) { } } } + + public static String getValueFromAuthActuator(String section, String key) { + String url = ApplnURI + propsKernel.getProperty("actuatorIDAEndpoint"); + String actuatorCacheKey = url + section + key; + String value = actuatorValueCache.get(actuatorCacheKey); + if (value != null && !value.isEmpty()) + return value; + try { + if (authActuatorResponseArray == null) { + Response response = null; + JSONObject responseJson = null; + response = RestClient.getRequest(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON); + + responseJson = new JSONObject(response.getBody().asString()); + authActuatorResponseArray = responseJson.getJSONArray("propertySources"); + } + + for (int i = 0, size = authActuatorResponseArray.length(); i < size; i++) { + JSONObject eachJson = authActuatorResponseArray.getJSONObject(i); + if (eachJson.get("name").toString().contains(section)) { + value = eachJson.getJSONObject(GlobalConstants.PROPERTIES).getJSONObject(key) + .get(GlobalConstants.VALUE).toString(); + if (ConfigManager.IsDebugEnabled()) + logger.info("Actuator: " + url + " key: " + key + " value: " + value); + break; + } + } + actuatorValueCache.put(actuatorCacheKey, value); + + return value; + } catch (Exception e) { + logger.error(GlobalConstants.EXCEPTION_STRING_2 + e); + return value; + } + + } } \ No newline at end of file diff --git a/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/UpdateMyData.java b/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/UpdateMyData.java index b0bd1029..1c990eee 100644 --- a/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/UpdateMyData.java +++ b/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/UpdateMyData.java @@ -4,6 +4,7 @@ import org.openqa.selenium.By; import org.testng.annotations.Test; +import io.mosip.testrig.residentui.fw.util.AdminTestUtil; import io.mosip.testrig.residentui.kernel.util.ConfigManager; import io.mosip.testrig.residentui.utility.BaseClass; import io.mosip.testrig.residentui.utility.Commons; @@ -18,7 +19,12 @@ public void updateMyDataName() throws Exception { Commons.wait(ConfigManager.packetUpdateWait()*60000); LoginTest.loginTest(); Commons.clickWebelement( driver, By.id("uinservices/updatedemographic")); - Commons.enter( driver, By.id("fullName"+BaseClass.envsupportlang()), Commons.generateRandomAlphabetString()); + String name = AdminTestUtil.getValueFromAuthActuator("json-property", "name"); + name = name.replace("[", "").replace("]", "").replace("\"", ""); + String[] names=name.split(","); + for(String Name:names) { + Commons.enter( driver, By.id(Name+BaseClass.envsupportlang()), Commons.generateRandomAlphabetString()); + } Commons.dropdown( driver, By.id("gender")); Commons.enter( driver, By.id("proofOfIdentityvalue"), data); Commons.dropdown( driver, By.id("proofOfIdentity"));