Skip to content

Commit

Permalink
Merge pull request #765 from jayesh12234/develop
Browse files Browse the repository at this point in the history
MOSIP-35896
  • Loading branch information
aranaravi authored Sep 19, 2024
2 parents 9620981 + 98f08cd commit b2582a6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String> actuatorValueCache = new HashMap<>();
public static JSONArray authActuatorResponseArray = null;

public static String getUnUsedUIN(String role){

return JsonPrecondtion
Expand Down Expand Up @@ -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;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down

0 comments on commit b2582a6

Please sign in to comment.