Skip to content

Commit

Permalink
MOSIP-30001
Browse files Browse the repository at this point in the history
Signed-off-by: Pankaj Godiyal <[email protected]>
  • Loading branch information
pg-techno123 committed Oct 30, 2023
1 parent cbb2bb2 commit e090728
Show file tree
Hide file tree
Showing 10 changed files with 4,503 additions and 994 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,17 @@ public void run() throws RigInternalError {

try {
checkForBDB.test(test);
} catch (AuthenticationTestException e) {
logger.error(e.getMessage());
} catch (AdminTestException e) {
} catch (AuthenticationTestException | AdminTestException e) {
logger.error(e.getMessage());
this.hasError = true;
throw new RigInternalError(e.getMessage());
}

Response response = checkForBDB.response;
JSONObject responseJson = new JSONObject(response.asString());
JSONObject responseData = responseJson.getJSONObject("response");
JSONArray responseArray = responseData.getJSONArray("documents");

String bioData = responseArray.getJSONObject(0).getString("value");

// String cleanedString = cleanBase64String(bioData);

Base64.Decoder decoder = Base64.getUrlDecoder();

// Decode the base64 encoded string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class GetPacketTemplate extends BaseTestCaseUtil implements StepInterface {
static Logger logger = Logger.getLogger(GetPacketTemplate.class);

static {
if (ConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
Expand All @@ -29,49 +29,54 @@ public void run() throws RigInternalError {
String qualityScore = "80";
boolean genarateValidCbeff = true;
String process = null;
String personaPath=null;
String personaPath = null;
Properties personaIdValue = null;
if (step.getParameters().isEmpty() && !step.getScenario().getGeneratedResidentData().isEmpty()) { // used to child packet processing
JSONArray jsonArray = packetUtility.getTemplate(new HashSet<String>(step.getScenario().getGeneratedResidentData()), "NEW",
step.getScenario().getCurrentStep(),step,qualityScore,genarateValidCbeff);
if (step.getParameters().isEmpty() && !step.getScenario().getGeneratedResidentData().isEmpty()) { // used to
// child
// packet
// processing
JSONArray jsonArray = packetUtility.getTemplate(
new HashSet<String>(step.getScenario().getGeneratedResidentData()), "NEW",
step.getScenario().getCurrentStep(), step, qualityScore, genarateValidCbeff);
JSONObject obj = jsonArray.getJSONObject(0);
step.getScenario().setTemplatPath_updateResident( obj.get("path").toString());
step.getScenario().setTemplatPath_updateResident(obj.get("path").toString());
} else {
process = step.getParameters().get(0);
if (step.getParameters().size() > 1) {
String personaId = step.getParameters().get(1);
if(step.getParameters().size()==3) {
if (step.getParameters().size() == 3) {
qualityScore = step.getParameters().get(2);
}
if(step.getParameters().size()==4) {
if (step.getParameters().size() == 4) {
genarateValidCbeff = Boolean.parseBoolean(step.getParameters().get(3));
}
if(personaId.startsWith("$$")) {
personaPath=step.getScenario().getVariables().get(personaId);
step.getScenario().getResidentTemplatePaths().clear();//step.getScenario().getResidentTemplatePaths().clear();
}else {
if (personaId.startsWith("$$")) {
personaPath = step.getScenario().getVariables().get(personaId);
step.getScenario().getResidentTemplatePaths().clear();// step.getScenario().getResidentTemplatePaths().clear();
} else {
personaIdValue = PacketUtility.getParamsFromArg(personaId, "@@");
for (String id : personaIdValue.stringPropertyNames()) {
String value = personaIdValue.get(id).toString();
if (step.getScenario().getResidentPersonaIdPro().get(value) == null)
{this.hasError=true;throw new RigInternalError("Persona id : [" + value + "] is not present is the system");
}
personaPath = step.getScenario().getResidentPersonaIdPro().get(value).toString();
if (step.getScenario().getResidentPersonaIdPro().get(value) == null) {
this.hasError = true;
throw new RigInternalError("Persona id : [" + value + "] is not present is the system");
}
personaPath = step.getScenario().getResidentPersonaIdPro().get(value).toString();
}

}
step.getScenario().getResidentTemplatePaths().put(personaPath, null);
}

JSONArray resp = packetUtility.getTemplate(step.getScenario().getResidentTemplatePaths().keySet(), process,
step.getScenario().getCurrentStep(), step, qualityScore,genarateValidCbeff);
step.getScenario().getCurrentStep(), step, qualityScore, genarateValidCbeff);

for (int i = 0; i < resp.length(); i++) {
JSONObject obj = resp.getJSONObject(i);
String id = obj.get("id").toString();
String tempFilePath = obj.get("path").toString();
if(step.getOutVarName()!=null)
step.getScenario().getVariables().put(step.getOutVarName(), tempFilePath);
if (step.getOutVarName() != null)
step.getScenario().getVariables().put(step.getOutVarName(), tempFilePath);
for (String residentPath : step.getScenario().getResidentTemplatePaths().keySet()) {
if (residentPath.contains(id)) {
step.getScenario().getResidentTemplatePaths().put(residentPath, tempFilePath);
Expand All @@ -81,10 +86,10 @@ public void run() throws RigInternalError {

}
for (String residentPath : step.getScenario().getResidentTemplatePaths().keySet()) {
if (step.getScenario().getResidentTemplatePaths().get(residentPath) == null)
{
this.hasError=true;throw new RigInternalError("Unable to get packetTemplate from packet utility");
}
if (step.getScenario().getResidentTemplatePaths().get(residentPath) == null) {
this.hasError = true;
throw new RigInternalError("Unable to get packetTemplate from packet utility");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public class Orchestrator {
public static Boolean beforeSuiteFailed = false;
public static Boolean beforeSuiteExeuted = false;
public static final Object lock = new Object();

public static long suiteStartTime = System.currentTimeMillis();
public static long suiteMaxTimeInMillis = 7200000; // 2 hour in milliseconds
static AtomicInteger counterLock = new AtomicInteger(0); // enable fairness policy

private HashMap<String, String> packages = new HashMap<String, String>() {
Expand All @@ -90,6 +91,7 @@ public class Orchestrator {

@BeforeSuite
public void beforeSuite() {

this.properties = Utils.getProperties(TestRunner.getExternalResourcePath() + "/config/config.properties");
Utils.setupLogger(System.getProperty("user.dir") + "/" + System.getProperty("testng.outpur.dir") + "/"
+ this.properties.getProperty("ivv._path.auditlog"));
Expand All @@ -110,7 +112,6 @@ public void beforeSuite() {

htmlReporter = new ExtentHtmlReporter(BaseTestCaseUtil.getExtentReportName());

;
extent = new ExtentReports();

extent.attachReporter(htmlReporter);
Expand Down Expand Up @@ -286,6 +287,12 @@ private void run(int i, Scenario scenario, HashMap<String, String> configs, Hash
// Wait till all scenarios are executed
while (counterLock.get() < totalScenario - 1) // executed excluding after suite
{
long currentTime = System.currentTimeMillis();
if (currentTime - suiteStartTime >= suiteMaxTimeInMillis) {
logger.error("Exhausted the maximum suite execution time.Hence, terminating the execution");
break;
}

logger.info(" Thread ID: " + Thread.currentThread().getId() + " inside scenariosExecuted "
+ counterLock.get() + "- " + scenario.getId());
Thread.sleep(10000); // Sleep for 10 sec
Expand Down
Loading

0 comments on commit e090728

Please sign in to comment.