Skip to content

Commit

Permalink
Merge pull request #471 from neeharikatech/develop
Browse files Browse the repository at this point in the history
MOSIP-29882 Handled Postal code and S3 bucket extent report movement
  • Loading branch information
neeharikatech authored Oct 21, 2023
2 parents adcdb4b + 7f07178 commit 193ee73
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 24 deletions.
2 changes: 1 addition & 1 deletion mosip-acceptance-tests/ivv-orchestrator/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public class BaseTestCaseUtil extends BaseStep {
public static String partnerKeyUrl = null;
public static String partnerId = null;
public static HashMap<String, HashMap<String, String>> prereqDataSet = new HashMap<String, HashMap<String, String>>();
public static String extentReportName="";

public static String getExtentReportName() {
return extentReportName;
}

public static void setExtentReportName(String emailableReportName) {
BaseTestCaseUtil.extentReportName = emailableReportName;
}

public BaseTestCaseUtil() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());

}

}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,24 @@ public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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: '{
}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}

0 comments on commit 193ee73

Please sign in to comment.