diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/e2e/methods/ResetContextData.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/e2e/methods/ResetContextData.java new file mode 100644 index 000000000..555376fe0 --- /dev/null +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/e2e/methods/ResetContextData.java @@ -0,0 +1,38 @@ + package io.mosip.testrig.dslrig.ivv.e2e.methods; + + import org.apache.log4j.Level; + import org.apache.log4j.Logger; + import org.json.JSONObject; + + import io.mosip.testrig.apirig.kernel.util.ConfigManager; + import io.mosip.testrig.dslrig.ivv.core.base.StepInterface; + import io.mosip.testrig.dslrig.ivv.core.exceptions.RigInternalError; + import io.mosip.testrig.dslrig.ivv.orchestrator.BaseTestCaseUtil; + import io.restassured.response.Response; + +public class ResetContextData extends BaseTestCaseUtil implements StepInterface{ + public static Logger logger = Logger.getLogger(ResetContextData.class); + + static { + if (ConfigManager.IsDebugEnabled()) + logger.setLevel(Level.ALL); + else + logger.setLevel(Level.ERROR); + } + + @Override + public void run() throws RigInternalError { + Response response = null; + + String clearBaseUrlNamespaceData = baseUrl + props.getProperty("resetContextData"); + response = getRequest(clearBaseUrlNamespaceData, "Clear baseUrl namespace data", step); + if (response != null && response.getStatusCode() == 200) { + String responseString = response.getBody().asString(); + if (!responseString.contains("true")) { + logger.info(responseString); + this.hasError = true; + throw new RigInternalError("Clearing baseUrl namespace data from variable manager failed"); + } + } + } + } \ No newline at end of file diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/config/scenarios.json b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/config/scenarios.json index 1b298f609..1a6ca9baf 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/config/scenarios.json +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/config/scenarios.json @@ -262,6 +262,12 @@ "Input Parameters": "NA", "Return Value": "NA", "Action": "e2e_GenerateAuthCertifcates()" + }, + "Step-43": { + "Description": "Resets the context data", + "Input Parameters": "NA", + "Return Value": "NA", + "Action": "e2e_ResetContextData()" } }, { @@ -2396,7 +2402,7 @@ "Tag": "Postive_Test", "Persona": "ResidentMaleAdult", "Group": "NA", - "Description": "A blind Resident walk-ins to registration center completes the process and gets UIN card. Later performs biometric authentication using left little finger", + "Description": "A differently abled resident walk-ins to registration center completes the process and gets UIN card. Later performs biometric authentication using left little finger", "Step-0": { "Description": "Performs health check of given component", "Input Parameters": "Keyword to check, only packetcreator is supported", @@ -16301,7 +16307,7 @@ "Tag": "Postive_Test", "Persona": "ResidentMaleAdult", "Group": "Adult_New_Exception", - "Description": "A blind Resident walk-ins to registration center completes the process and gets UIN card .Later updates all biometrics and using uin check for the absence of exception marked modality", + "Description": "A differently abled resident walk-ins to registration center completes the process and gets UIN card .Later updates all biometrics and using uin check for the absence of exception marked modality", "Step-0": { "Description": "Performs health check of given component", "Input Parameters": "Keyword to check, only packetcreator is supported", diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/config/test-orchestrator_mz.properties b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/config/test-orchestrator_mz.properties index f8cafa0e5..75f04e8f8 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/config/test-orchestrator_mz.properties +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/config/test-orchestrator_mz.properties @@ -61,4 +61,5 @@ updatePersonabioexceptions=/persona/bioexceptions blocklistedWord=/v1/masterdata/blocklistedwords/ holidayCreation=/v1/masterdata/holidays getPacketTagsInfo=/commons/v1/packetmanager/info -clearDeviceCertCache=/clearDeviceCertCache \ No newline at end of file +clearDeviceCertCache=/clearDeviceCertCache +resetContextData=/resetContextData \ No newline at end of file diff --git a/mosip-packet-creator/src/main/java/io/mosip/testrig/dslrig/packetcreator/controller/ContextController.java b/mosip-packet-creator/src/main/java/io/mosip/testrig/dslrig/packetcreator/controller/ContextController.java index e079c588c..07493ba85 100644 --- a/mosip-packet-creator/src/main/java/io/mosip/testrig/dslrig/packetcreator/controller/ContextController.java +++ b/mosip-packet-creator/src/main/java/io/mosip/testrig/dslrig/packetcreator/controller/ContextController.java @@ -1,5 +1,8 @@ package io.mosip.testrig.dslrig.packetcreator.controller; +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Properties; import org.slf4j.Logger; @@ -13,6 +16,9 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; +import io.mosip.mock.sbi.devicehelper.SBIDeviceHelper; +import io.mosip.testrig.dslrig.dataprovider.BiometricDataProvider; +import io.mosip.testrig.dslrig.dataprovider.preparation.MosipMasterData; import io.mosip.testrig.dslrig.dataprovider.util.DataProviderConstants; import io.mosip.testrig.dslrig.dataprovider.variables.VariableManager; import io.mosip.testrig.dslrig.packetcreator.service.ContextUtils; @@ -61,4 +67,15 @@ public class ContextController { } return bRet; } + + @GetMapping(value = "/resetContextData/{contextKey}") + public @ResponseBody String resetContextData(@PathVariable("contextKey") String contextKey) { + try { + return VariableManager.deleteNameSpace( + VariableManager.getVariableValue(contextKey, "urlBase").toString() + "run_context"); + } catch (Exception ex) { + logger.error("resetNameSpaceData", ex); + return "{\"" + ex.getMessage() + "\"}"; + } + } } diff --git a/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/preparation/MosipDataSetup.java b/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/preparation/MosipDataSetup.java index f8e02859e..ab2339244 100644 --- a/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/preparation/MosipDataSetup.java +++ b/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/preparation/MosipDataSetup.java @@ -30,6 +30,7 @@ public class MosipDataSetup { private static final Logger logger = LoggerFactory.getLogger(MosipDataSetup.class); + private static String RUN_CONTEXT = "run_context"; public static Properties getConfig(String contextKey) { Properties props = new Properties(); @@ -96,8 +97,8 @@ public static List getMachineDetail(String machineId, String + "v1/masterdata/machines/"; url = url + machineId + "/ "; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -109,7 +110,7 @@ public static List getMachineDetail(String machineId, String machines = objectMapper.readValue(typeArray.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, MosipMachineModel.class)); - setCache(url, machines,contextKey); + setCache(url, machines,run_context); } @@ -126,9 +127,9 @@ public static List searchMachineDetail(String machineId, Stri String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + "v1/masterdata/machines/search"; + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; - - Object o =getCache(url,contextKey); + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -170,7 +171,7 @@ public static List searchMachineDetail(String machineId, Stri machines = objectMapper.readValue(typeArray.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, MosipMachineModel.class)); - setCache(url, machines,contextKey); + setCache(url, machines,run_context); } @@ -249,8 +250,8 @@ public static List getMachineTypes(String contextKey) { String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"machinetype").toString(); url = url + "all"; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -263,7 +264,7 @@ public static List getMachineTypes(String contextKey) { machineTypes = objectMapper.readValue(typeArray.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, MosipMachineTypeModel.class)); - setCache(url, machineTypes,contextKey); + setCache(url, machineTypes,run_context); } } catch (Exception e) { logger.error(e.getMessage()); @@ -276,8 +277,8 @@ public static List getRegCenterTypes(String co String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"regcentertype").toString(); url = url + "all"; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -290,7 +291,7 @@ public static List getRegCenterTypes(String co machineTypes = objectMapper.readValue(typeArray.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, MosipRegistrationCenterTypeModel.class)); - setCache(url, machineTypes,contextKey); + setCache(url, machineTypes,run_context); } } catch (Exception e) { logger.error(e.getMessage()); @@ -453,8 +454,8 @@ public static List getDevices(String centerId,String contextKe VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"mappeddevices").toString(); url = url +centerId; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -467,7 +468,7 @@ public static List getDevices(String centerId,String contextKe devices = objectMapper.readValue(typeArray.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, MosipDeviceModel.class)); - setCache(url, devices,contextKey); + setCache(url, devices,run_context); } } catch (Exception e) { logger.error(e.getMessage()); diff --git a/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/preparation/MosipMasterData.java b/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/preparation/MosipMasterData.java index 9f0962722..6fcf51e21 100644 --- a/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/preparation/MosipMasterData.java +++ b/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/preparation/MosipMasterData.java @@ -54,6 +54,7 @@ public class MosipMasterData { private static final Logger logger = LoggerFactory.getLogger(MosipMasterData.class); + private static String RUN_CONTEXT = "run_context"; /* static { @@ -80,7 +81,7 @@ public static List getBiometricAttrByTypes(String String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"biometricAttributes").toString(); url = url + lang + "/" + bioType; - +// String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; Object o =getCache(url,contextKey); if(o != null) return( (List) o); @@ -110,6 +111,7 @@ public static List getBiometricTypes(String contextKey) String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"biometricTypes").toString(); +// String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; Object o =getCache(url,contextKey); if(o != null) return( (List) o); @@ -135,8 +137,8 @@ public static List getConfiguredLanguages(String contextKey) { List langs =null; String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() +VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"languages").toString(); - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -149,7 +151,7 @@ public static List getConfiguredLanguages(String contextKey) { langs = objectMapper.readValue(langArray.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, MosipLanguage.class)); - setCache(url, langs,contextKey); + setCache(url, langs,run_context); } } catch (Exception e) { logger.error(e.getMessage()); @@ -166,8 +168,8 @@ public static Hashtable> getAllDynamicFields(Stri String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"dynamicFields").toString(); - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (Hashtable>) o); @@ -204,7 +206,7 @@ public static Hashtable> getAllDynamicFields(Stri lst.add(m); } - setCache(url, tblDynaFieldsLang,contextKey); + setCache(url, tblDynaFieldsLang,run_context); pageno++; } @@ -244,7 +246,8 @@ public static LocationHierarchyModel[] getLocationHierarchy(String langCode,Stri String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"locationhierarchy").toString(); - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (LocationHierarchyModel[]) o); @@ -269,7 +272,7 @@ public static LocationHierarchyModel[] getLocationHierarchy(String langCode,Stri } } - setCache(url, locationHierarchy,contextKey); + setCache(url, locationHierarchy,run_context); } } catch (Exception e) { @@ -285,8 +288,8 @@ public static List getImmedeateChildren(String locCode, Stri String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + "v1/masterdata/locations/immediatechildren/"; url = url+ locCode + "/" + langCode ; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -305,7 +308,7 @@ public static List getImmedeateChildren(String locCode, Stri newLocList.add(lm); } locList = newLocList; - setCache(url, locList,contextKey); + setCache(url, locList,run_context); } } catch (Exception e) { if(RestClient.isDebugEnabled(contextKey)) @@ -319,7 +322,8 @@ public static MosipPreRegLoginConfig getPreregLoginConfig(String contextKey) { MosipPreRegLoginConfig config = new MosipPreRegLoginConfig(); String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"loginconfig").toString(); - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (MosipPreRegLoginConfig) o); @@ -367,7 +371,7 @@ public static MosipPreRegLoginConfig getPreregLoginConfig(String contextKey) { } - setCache(url, config, contextKey); + setCache(url, config, run_context); } } catch (Exception e) { logger.error(e.getMessage()); @@ -380,7 +384,8 @@ public static ApplicationConfigIdSchema getAppConfigIdSchema(String contextKey) String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(contextKey,"applicaionconfig").toString(); - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (ApplicationConfigIdSchema) o); @@ -394,7 +399,7 @@ public static ApplicationConfigIdSchema getAppConfigIdSchema(String contextKey) if(idSchemaObject != null) { ObjectMapper objectMapper = new ObjectMapper(); config = objectMapper.readValue(idSchemaObject.toString(), ApplicationConfigIdSchema.class); - setCache(url, config,contextKey); + setCache(url, config,run_context); } } @@ -410,8 +415,8 @@ public static List getLocationsByLevel(String level,String String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"locationbylevel").toString(); url = url+ level ; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -430,7 +435,7 @@ public static List getLocationsByLevel(String level,String newLocList.add(lm); } locList = newLocList; - setCache(url, locList,contextKey); + setCache(url, locList,run_context); } } catch (Exception e) { logger.error(e.getMessage()); @@ -448,79 +453,6 @@ static JSONObject genQueryParams() throws JSONException { return queryParams; } - /* - public static Hashtable> getIDSchemaLatestVersion_defunct() { - - Hashtable> tbl = new Hashtable> (); - String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + - VariableManager.getVariableValue( - VariableManager.NS_DEFAULT, - //"individualtypes" - "idschemaapi" - ).toString(); - - Object o =getCache(url,contextKey); - if(o != null) - return( (Hashtable>) o); - - try { - JSONObject resp = RestClient.get(url, genQueryParams(), new JSONObject(),contextKey); - - //int nSchema = resp.getInt("totalItems"); - JSONArray idSchema = null; - double schemaVersion = 0.0; - String schemaTitle = ""; - idSchema = resp.getJSONArray("schema"); - - String schemaJson = resp.getString("schemaJson"); - System.out.println(idSchema.toString()); - schemaVersion= resp.getDouble( "idVersion"); - schemaTitle = resp.getString("title"); - List listSchema = new ArrayList(); - - if(schemaJson != null && !schemaJson.equals("")) { - JSONObject schemaObj = new JSONObject(schemaJson); - JSONObject identityObj = schemaObj.getJSONObject("properties").getJSONObject("identity"); - JSONObject identityProps = identityObj.getJSONObject("properties"); - JSONArray jsonArray = identityObj.getJSONArray("required"); - - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(Include.NON_NULL); - - for(int i = 0; i < jsonArray.length(); i++){ - String reqdField = jsonArray.getString(i); - JSONObject prop = identityProps.getJSONObject(reqdField); - MosipIDSchema schema = objectMapper.readValue(prop.toString(), MosipIDSchema.class); - schema.setRequired(true); - schema.setInputRequired(true); - - schema.setId(reqdField); - if(schema.getTypeRef() != null) { - if(schema.getTypeRef().contains("simpleType")) - schema.setType("simpleType"); - else - if(schema.getTypeRef().contains("documentType")) - schema.setType("documentType"); - else - if(schema.getTypeRef().contains("biometricsType")) - schema.setType("biometricsType"); - } - listSchema.add(schema); - - } - - tbl.put(schemaVersion, listSchema); - - setCache(url, tbl); - } - - - } catch (Exception e) { - logger.error(e.getMessage()); - } - return tbl; - } -*/ private static JSONArray getRequiredFileds(JSONObject resp) { String schemaJson = resp.getString("schemaJson"); @@ -593,14 +525,14 @@ public static Hashtable getIDSchemaLatestVersion(String cont //"individualtypes" "idschemaapi" ).toString(); - + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; String process=VariableManager.getVariableValue(contextKey,"process").toString(); if(process == null) { process="NEW"; } process = process.toLowerCase().trim() + "Process"; - Object o =getCache(url,contextKey); + Object o =getCache(url,run_context); if(o != null) return( (Hashtable) o); @@ -705,7 +637,7 @@ public static Hashtable getIDSchemaLatestVersion(String cont prop.put("requiredAttributes",requiredAttributes); tbl.put(schemaVersion, prop); - setCache(url, tbl,contextKey); + setCache(url, tbl,run_context); } } @@ -727,8 +659,9 @@ public static Hashtable getPreregIDSchemaLatestVersion(Strin "uiSpec" ).toString(); //url="https://qa-double.mosip.net/preregistration/v1/uispec/latest?identitySchemaVersion=0&version=0"; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + + Object o =getCache(url,run_context); if(o != null) return( (Hashtable) o); @@ -767,7 +700,7 @@ public static Hashtable getPreregIDSchemaLatestVersion(Strin //tbl.put(0.2, prop); tbl.put(resp.getDouble("idSchemaVersion"), prop); - setCache(url, tbl,contextKey); + setCache(url, tbl,run_context); } } catch (Exception e) { @@ -780,8 +713,8 @@ public static List getDocumentCategories(String contextKe String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"documentCategories").toString(); - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -799,7 +732,7 @@ public static List getDocumentCategories(String contextKe if(m.getIsActive() ) newDocTypeList.add(m); } - setCache(url, newDocTypeList,contextKey); + setCache(url, newDocTypeList,run_context); return newDocTypeList; } @@ -816,8 +749,8 @@ public static List getDocumentTypes(String categoryCode,Strin String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"documentTypes").toString(); url = url + categoryCode +"/"+ langCode; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -835,7 +768,7 @@ public static List getDocumentTypes(String categoryCode,Strin if(m.getIsActive() ) newDocTypeList.add(m); } - setCache(url, newDocTypeList,contextKey); + setCache(url, newDocTypeList,run_context); return newDocTypeList; } } catch (Exception e) { @@ -850,8 +783,8 @@ public static List getMappedDocumentTypes(String categoryCode String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"documentTypes").toString(); url = url + categoryCode +"/"+ langCode; - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -868,7 +801,7 @@ public static List getMappedDocumentTypes(String categoryCode if(m.getIsActive() ) newDocTypeList.add(m); } - setCache(url, newDocTypeList,contextKey); + setCache(url, newDocTypeList,run_context); return newDocTypeList; } } catch (Exception e) { @@ -928,8 +861,8 @@ public static Hashtable> getIndividualTyp String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"individualtypes").toString(); - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (Hashtable>) o); @@ -954,7 +887,7 @@ public static Hashtable> getIndividualTyp newList.add(m); } } - setCache(url, tbl,contextKey); + setCache(url, tbl,run_context); //return tbl; } @@ -976,8 +909,8 @@ public static List getGenderTypes(String lang,String contextKe }else { String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"gendertypes").toString(); - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (List) o); @@ -990,7 +923,7 @@ public static List getGenderTypes(String lang,String contextKe genderTypeList = objectMapper.readValue(docCatArray.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, MosipGenderModel.class)); - setCache(url, genderTypeList,contextKey); + setCache(url, genderTypeList,run_context); return genderTypeList; } @@ -1009,8 +942,8 @@ private static List getGenderTypesLTS(String lang, String cont String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() + VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"genderTypesByDynamicField").toString(); - - Object o =getCache(url +"_"+lang,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url +"_"+lang,run_context); if(o != null) return( (List) o); @@ -1056,7 +989,7 @@ private static List getGenderTypesLTS(String lang, String cont mgm.setValue(value); genderTypeList.add(mgm); } - setCache(url +"_"+lang, genderTypeList,contextKey); + setCache(url +"_"+lang, genderTypeList,run_context); return genderTypeList; } } catch (Exception e) { @@ -1302,8 +1235,8 @@ public static JSONArray getUiSpecId(String contextKey) { JSONArray array= new JSONArray(); String url = VariableManager.getVariableValue(contextKey,"urlBase").toString().trim() +"preregistration/v1/uispec/latest?identitySchemaVersion=0&version=0"; //String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() +VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"uiSpec").toString(); - - Object o =getCache(url,contextKey); + String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT; + Object o =getCache(url,run_context); if(o != null) return( (JSONArray) o); @@ -1321,7 +1254,7 @@ public static JSONArray getUiSpecId(String contextKey) { System.out.println("printing Array : "+ array); - setCache(url, array, contextKey); + setCache(url, array, run_context); } } catch (Exception e) { logger.error(e.getMessage()); diff --git a/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/variables/VariableManager.java b/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/variables/VariableManager.java index e40199f28..e90a1b549 100644 --- a/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/variables/VariableManager.java +++ b/mosipTestDataProvider/src/io/mosip/testrig/dslrig/dataprovider/variables/VariableManager.java @@ -148,6 +148,36 @@ public static Boolean loadNamespaceFromPropertyFile(String propFile, String cont return bRet; } + + public static String deleteNameSpace(String contextKey) { + try { + printAllContents(); + Cache cache = varNameSpaces.remove(contextKey); + if (cache != null) { + synchronized (cacheManager) { + cacheManager.destroyCache(contextKey); + } + } + } catch (Exception e) { + logger.error(e.getMessage()); + return "false"; + } + return "true"; + } + + public static void printAllContents() { + StringBuffer s = new StringBuffer(); + for (String nameSpace : varNameSpaces.keySet()) { + Cache cache = varNameSpaces.get(nameSpace); + s.append("Contents of Namespace: " + nameSpace + "\\n"); + for (Cache.Entry entry : cache) { + String varName = entry.getKey(); + Object value = entry.getValue(); + s.append(varName + " = " + value + "\\n"); + } + } + logger.info(s.toString()); + } /* * Variables are embedded inside a text in following format {{varname}}