From 2fd6a200c4cc2da15605941a49a6758db83a6536 Mon Sep 17 00:00:00 2001 From: neeharikatech <76684248+neeharikatech@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:03:09 +0530 Subject: [PATCH 1/3] MOSIP-29882 Signed-off-by: neeharikatech <76684248+neeharikatech@users.noreply.github.com> --- .../ivv-orchestrator/config.properties | 2 +- .../dslrig/ivv/e2e/methods/Center.java | 3 +- .../ivv/orchestrator/BaseTestCaseUtil.java | 9 ++++ .../dslrig/ivv/orchestrator/CenterHelper.java | 45 ++++++++++++++++++- .../ivv/orchestrator/EmailableReport.java | 22 +++++---- .../dslrig/ivv/orchestrator/Orchestrator.java | 14 ++++-- .../ivv/orchestrator/TestResources.java | 7 +-- .../GetPostalCode/GetPostalCode.yml | 2 +- .../GetPostalCodeKey.yml | 12 +++++ .../getPostalCodeKey.hbs | 2 + .../getPostalCodeKeyResult.hbs | 2 + 11 files changed, 96 insertions(+), 24 deletions(-) create mode 100644 mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/GetPostalCodeKey.yml create mode 100644 mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKey.hbs create mode 100644 mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKeyResult.hbs diff --git a/mosip-acceptance-tests/ivv-orchestrator/config.properties b/mosip-acceptance-tests/ivv-orchestrator/config.properties index 251df5582..45e781f80 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/config.properties +++ b/mosip-acceptance-tests/ivv-orchestrator/config.properties @@ -96,7 +96,7 @@ ivv.path.biometrics.sheet=local/BiometricsSheet.csv ivv.path.documents.folder=local/data/documents/ ivv.path.biometrics.folder=local/data/biometrics/ ivv._path.auditlog=/testRun/reports/mosip_auditLogs.log -ivv._path.reports=/mosip_e2e_emailable_report.html +ivv._path.reports=/mosip_e2e_emailable_report ivv.path.mappingfile=local/mapping.json ivv.path.idobject=local/IDObjectSchema.json diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/e2e/methods/Center.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/e2e/methods/Center.java index 40443047a..dc31863f1 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/e2e/methods/Center.java +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/e2e/methods/Center.java @@ -71,7 +71,8 @@ public void run() throws RigInternalError { switch (calltype) { case "CREATE": String holidayLocationCode=centerHelper.getLocationCodeHoliday(); - String postalCode=centerHelper.getPostalCode(); + String thirdlevelpostalcode=centerHelper.getThirdlevelpostalcodekey();//implement + String postalCode=centerHelper.getPostalCode(thirdlevelpostalcode); //String zone=userHelper.getZoneOfUser(map.get("user")); String zone=userHelper.getLeafZones(); String centerId=centerHelper.centerCreate(zone,holidayLocationCode,postalCode); diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/BaseTestCaseUtil.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/BaseTestCaseUtil.java index 5c2c096e8..7b50509e8 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/BaseTestCaseUtil.java +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/BaseTestCaseUtil.java @@ -60,6 +60,15 @@ public class BaseTestCaseUtil extends BaseStep { public static String partnerKeyUrl = null; public static String partnerId = null; public static HashMap> prereqDataSet = new HashMap>(); + public static String extentReportName=""; + + public static String getExtentReportName() { + return extentReportName; + } + + public static void setExtentReportName(String emailableReportName) { + BaseTestCaseUtil.extentReportName = emailableReportName; + } public BaseTestCaseUtil() { } diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/CenterHelper.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/CenterHelper.java index 4afdb118b..11cfc973d 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/CenterHelper.java +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/CenterHelper.java @@ -30,6 +30,8 @@ public class CenterHelper extends BaseTestCaseUtil { private static final String GetLocationCodeHoliday = "ivv_masterdata/GetLocationCodeHoliday/GetLocationCodeHoliday.yml"; private static final String GetPostalCode = "ivv_masterdata/GetPostalCode/GetPostalCode.yml"; + + private static final String GetPostalCodeKey = "ivv_masterdata/GetThirdLevelPostalCodeKey/GetPostalCodeKey.yml"; SimplePost simplepost=new SimplePost() ; PatchWithPathParam patchwithpathparam=new PatchWithPathParam(); @@ -248,14 +250,14 @@ public String getLocationCodeHoliday() throws RigInternalError { - public String getPostalCode() throws RigInternalError { + public String getPostalCode(String pc) throws RigInternalError { try { String lastSyncTime =null; Object[] testObjPost=getWithParam.getYmlTestData(GetPostalCode); TestCaseDTO testPost=(TestCaseDTO)testObjPost[0]; //String langCode=BaseTestCase.languageCode; - //testPost.setEndPoint(testPost.getEndPoint().replace("langcode", langCode)); + testPost.setEndPoint(testPost.getEndPoint().replace("postalcode", pc)); getWithParam.test(testPost); Response response= getWithParam.response; String locationCode=null; @@ -288,6 +290,45 @@ public String getPostalCode() throws RigInternalError { } + public String getThirdlevelpostalcodekey() throws RigInternalError { + + try { String lastSyncTime =null; + Object[] testObjPost=getWithParam.getYmlTestData(GetPostalCodeKey); + + TestCaseDTO testPost=(TestCaseDTO)testObjPost[0]; + //String langCode=BaseTestCase.languageCode; + testPost.setEndPoint(testPost.getEndPoint().replace("langcode", BaseTestCase.languageCode)); + getWithParam.test(testPost); + Response response= getWithParam.response; + String postalCode=null; + if(response!=null) + { + JSONObject jsonObject = new JSONObject(response.getBody().asString()); + JSONObject responseObj = jsonObject.getJSONObject("response"); + JSONArray responseArray = responseObj.getJSONArray("locationHierarchyLevels"); + if (responseArray.length() > 0) { + JSONObject locationObject = responseArray.getJSONObject(responseArray.length()-1); + postalCode = locationObject.getString("hierarchyLevelName"); + + // Traverse on the "code" field + logger.info("Location Code: " + postalCode); + return postalCode; + } else { + logger.error("No location data found in the response."); + } + + + } + return postalCode; + }catch (Exception e) + { + this.hasError=true; + throw new RigInternalError(e.getMessage()); + + } + + } + diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java index 84331bd8b..56bbf342e 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java @@ -108,26 +108,24 @@ public void generateReport(List xmlSuites, List suites, String if (ConfigManager.getPushReportsToS3().equalsIgnoreCase("yes")) { S3Adapter s3Adapter = new S3Adapter(); boolean isStoreSuccess = false; + boolean isStoreSuccess2 = false; try { isStoreSuccess = s3Adapter.putObject(ConfigManager.getS3Account(), BaseTestCase.testLevel, null, null, newString, newReportFile); logger.info("isStoreSuccess:: " + isStoreSuccess); + + /* Need to figure how to handle EXTENT report handling */ - // EXTENT REPORT - /* - * File repotFile2 = new File(System.getProperty("user.dir") + "/" + - * System.getProperty("testng.outpur.dir") + "/" + - * System.getProperty("emailable.report3.name")); logger.info("reportFile is::" - * + System.getProperty("user.dir") + "/" + - * System.getProperty("testng.outpur.dir") + "/" + - * System.getProperty("emailable.report2.name")); isStoreSuccess = - * s3Adapter.putObject(ConfigManager.getS3Account(), BaseTestCase.testLevel, - * null, null, System.getProperty("emailable.report3.name"), repotFile2); - */ + + File extentReport = new File(BaseTestCaseUtil.getExtentReportName()); + + isStoreSuccess2 =s3Adapter.putObject(ConfigManager.getS3Account(), BaseTestCase.testLevel, + null, null, null, extentReport); + } catch (Exception e) { logger.error("error occured while pushing the object" + e.getMessage()); } - if (isStoreSuccess) { + if (isStoreSuccess && isStoreSuccess2 ) { logger.info("Pushed report to S3"); } else { logger.error("Failed while pushing file to S3"); diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/Orchestrator.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/Orchestrator.java index d03379b74..e71c3b5ed 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/Orchestrator.java +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/Orchestrator.java @@ -93,10 +93,16 @@ 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")); - htmlReporter = new ExtentHtmlReporter( - - System.getProperty("user.dir") + "/" + System.getProperty("testng.outpur.dir") + "/" - + this.properties.getProperty("ivv._path.reports")); + + + String emailableReportName=System.getProperty("user.dir") + "/" + System.getProperty("testng.outpur.dir") + "/" + + this.properties.getProperty("ivv._path.reports")+BaseTestCase.generateRandomAlphaNumericString(7)+".html"; + + BaseTestCaseUtil.setExtentReportName(emailableReportName); + + htmlReporter = new ExtentHtmlReporter(BaseTestCaseUtil.getExtentReportName()); + + ; extent = new ExtentReports(); extent.attachReporter(htmlReporter); diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/TestResources.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/TestResources.java index 613ac6776..c5feb62cb 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/TestResources.java +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/TestResources.java @@ -44,11 +44,12 @@ public static void copyPreRegTestResource() { public static void copyTestResource(String resPath) { try { File source = new File(TestResources.getGlobalResourcePaths().replace("MosipTestResource/MosipTemporaryTestResource", "") + resPath); - - //target\classes\MosipTestResource\MosipTemporaryTestResource\config\Kernel.properties (The system cannot find the path specified) + //D:\gitauto\mosip-automation-tests\mosip-acceptance-tests\ivv-orchestrator\target\classes\idaData File destination = new File(TestResources.getGlobalResourcePaths()); + //D:\gitauto\mosip-automation-tests\mosip-acceptance-tests\ivv-orchestrator\target\classes\MosipTestResource\MosipTemporaryTestResource FileUtils.copyDirectoryToDirectory(source, destination); - logger.info("Copied "+resPath+" the preReg test resource successfully to "+destination); + logger.info("source file path :" +source); + logger.info("resPath: "+resPath+" destination: "+destination); } catch (Exception e) { logger.error("Exception occured while copying the file: "+e.getMessage()); } diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetPostalCode/GetPostalCode.yml b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetPostalCode/GetPostalCode.yml index 9facca122..4a22c99db 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetPostalCode/GetPostalCode.yml +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetPostalCode/GetPostalCode.yml @@ -1,6 +1,6 @@ GetPostalCode: Admin_GetLeafZones_allValid_smoke: - endPoint: /v1/masterdata/locations/locationhierarchy/postal code + endPoint: /v1/masterdata/locations/locationhierarchy/postalcode role: globalAdmin checkErrorsOnlyInResponse: true restMethod: get diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/GetPostalCodeKey.yml b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/GetPostalCodeKey.yml new file mode 100644 index 000000000..bd2b88c50 --- /dev/null +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/GetPostalCodeKey.yml @@ -0,0 +1,12 @@ +GetPostalCode: + Admin_GetLeafZones_allValid_smoke: + endPoint: /v1/masterdata/locationHierarchyLevels/langcode + role: globalAdmin + checkErrorsOnlyInResponse: true + restMethod: get + inputTemplate: ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKey + outputTemplate: ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeResultKey + input: '{ + }' + output: '{ + }' \ No newline at end of file diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKey.hbs b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKey.hbs new file mode 100644 index 000000000..7a73a41bf --- /dev/null +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKey.hbs @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKeyResult.hbs b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKeyResult.hbs new file mode 100644 index 000000000..7a73a41bf --- /dev/null +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/resources/ivv_masterdata/GetThirdLevelPostalCodeKey/getPostalCodeKeyResult.hbs @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file From bb946a484cbc0d31377d0a2d0cf630ad68b473cf Mon Sep 17 00:00:00 2001 From: neeharikatech <76684248+neeharikatech@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:43:49 +0530 Subject: [PATCH 2/3] fixed reportname Signed-off-by: neeharikatech <76684248+neeharikatech@users.noreply.github.com> --- .../mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java index 56bbf342e..e1b850ebc 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java @@ -120,7 +120,7 @@ public void generateReport(List xmlSuites, List suites, String File extentReport = new File(BaseTestCaseUtil.getExtentReportName()); isStoreSuccess2 =s3Adapter.putObject(ConfigManager.getS3Account(), BaseTestCase.testLevel, - null, null, null, extentReport); + null, null, "extentReport-"+BaseTestCase.generateRandomAlphabeticString(6), extentReport); } catch (Exception e) { logger.error("error occured while pushing the object" + e.getMessage()); From 969e63160fd00712a2edb01038e35e306e917157 Mon Sep 17 00:00:00 2001 From: neeharikatech <76684248+neeharikatech@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:49:37 +0530 Subject: [PATCH 3/3] fixed reportname Signed-off-by: neeharikatech <76684248+neeharikatech@users.noreply.github.com> --- .../mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java index e1b850ebc..0f43a26d1 100644 --- a/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java +++ b/mosip-acceptance-tests/ivv-orchestrator/src/main/java/io/mosip/testrig/dslrig/ivv/orchestrator/EmailableReport.java @@ -120,7 +120,7 @@ public void generateReport(List xmlSuites, List suites, String File extentReport = new File(BaseTestCaseUtil.getExtentReportName()); isStoreSuccess2 =s3Adapter.putObject(ConfigManager.getS3Account(), BaseTestCase.testLevel, - null, null, "extentReport-"+BaseTestCase.generateRandomAlphabeticString(6), extentReport); + null, null, "ExtentReport-"+newString, extentReport); } catch (Exception e) { logger.error("error occured while pushing the object" + e.getMessage());