Skip to content

Commit

Permalink
MOSIP-35390
Browse files Browse the repository at this point in the history
Signed-off-by: Sohan Kumar Dey <[email protected]>
  • Loading branch information
Sohandey committed Sep 6, 2024
1 parent 16282fb commit 4f0400d
Showing 1 changed file with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7831,7 +7831,7 @@ else if (testCaseName.contains("_withinvaliddemofield_inupdate")) {
}
}
//50
if (testCaseName.contains("_withonedemofield")) {
else if (testCaseName.contains("_withonedemofield")) {
if (identity.has("selectedHandles")) {
String firstHandle = selectedHandles.getString(0);
for (int j = 1; j < selectedHandles.length(); j++) {
Expand All @@ -7847,6 +7847,15 @@ else if (testCaseName.contains("_withinvaliddemofield_inupdate")) {
identity.put("selectedHandles", newSelectedHandles);
}
}

//82

else if (testCaseName.contains("_withcasesensitivehandles")) {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject obj = handleArray.getJSONObject(j);
obj.put("value", "HANDLES");
}
}



Expand All @@ -7873,6 +7882,10 @@ public String replaceArrayHandleValuesForUpdateIdentity(String inputJson, String
JSONObject request = jsonObj.getJSONObject("request");
JSONObject identity = request.getJSONObject("identity");
JSONArray selectedHandles = identity.getJSONArray("selectedHandles");
String phone = getValueFromAuthActuator("json-property", "phone_number");
String result = phone.replaceAll("\\[\"|\"\\]", "");



// Iterate over each handle in the selectedHandles array
for (int i = 0; i < selectedHandles.length(); i++) {
Expand Down Expand Up @@ -7924,8 +7937,7 @@ public String replaceArrayHandleValuesForUpdateIdentity(String inputJson, String
}
} else if (testCaseName.contains("_withmultipledemohandles")) {
// Handle specific demo handles by checking and adding them to the selectedHandles
String phone = getValueFromAuthActuator("json-property", "phone_number");
String result = phone.replaceAll("\\[\"|\"\\]", "");

boolean containsPhone = false;
for (int j = 0; j < selectedHandles.length(); j++) {
if (result.equalsIgnoreCase(selectedHandles.getString(j))) {
Expand Down Expand Up @@ -8086,16 +8098,13 @@ else if (testCaseName.contains("_withemptyselectedhandle")) {
identity.put("selectedHandles", new JSONArray());
}
}






else if (testCaseName.contains("_witharandomnonhandleattr")) {
if (identity.has("selectedHandles")) {
List<String> existingHandles = new ArrayList<>();
for (int j = 0; i < selectedHandles.length(); i++) {
existingHandles.add(selectedHandles.getString(i));
for (int j = 0; j < selectedHandles.length(); j++) {
existingHandles.add(selectedHandles.getString(j));
}
Iterator<String> keys = identity.keys();
while (keys.hasNext()) {
Expand All @@ -8116,6 +8125,39 @@ else if (testCaseName.contains("_updateselectedhandleswithinvalid")) {
updatedHandlesArray.put("invalidscehema123");
identity.put("selectedHandles", updatedHandlesArray);
}

else if (testCaseName.contains("_withinvaliddhandle")) {
selectedHandles.put("newFieldHandle");
}

else if (testCaseName.contains("_updateselectedhandleswithscehmaattrwhichisnothandle")) {
Iterator<String> keys = identity.keys();
while (keys.hasNext()) {
String key = keys.next();
if (!selectedHandles.toList().contains(key) && identity.optString(key) != null && identity.get(key) instanceof String) {
selectedHandles.put(key);
break;
}
}
}

else if (testCaseName.contains("_removeselectedhandle_updatephone")) {
if (identity.has("selectedHandles")) {
identity.remove("selectedHandles");
}

if (identity.has(result)) {
identity.put(result, generateRandomNumberString(10));
}
}

else if (testCaseName.contains("_withupdatedhandlewhichisnotinschema")) {
JSONArray newSelectedHandles = new JSONArray();
newSelectedHandles.put("invalid12@@");
identity.put("selectedHandles", newSelectedHandles);
}





Expand Down

0 comments on commit 4f0400d

Please sign in to comment.