Skip to content

Commit

Permalink
Merge pull request #672 from Sohandey/develop
Browse files Browse the repository at this point in the history
Develop, New Testcases Automated For Prereg
  • Loading branch information
ckm007 authored May 21, 2024
2 parents 336bd10 + 02bd2bb commit 4b9908a
Show file tree
Hide file tree
Showing 8 changed files with 372 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,28 @@
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.restassured.response.Response;

public class AuditValidator extends AdminTestUtil implements ITest {
private static final Logger logger = Logger.getLogger(AuditValidator.class);
public class PreregAuditValidator extends AdminTestUtil implements ITest {
private static final Logger logger = Logger.getLogger(PreregAuditValidator.class);
protected String testCaseName = "";
public static List<String> templateFields = new ArrayList<>();
public Response response = null;

/**
* get current testcaseName
*/
@Override
public String getTestName() {
public String getTestName() {
return testCaseName;
}

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
}

/**
* Data provider class provides test case list
*
Expand All @@ -66,52 +67,52 @@ public Object[] getTestCaseList(ITestContext context) {
logger.info("Started executing yml: " + ymlFile);
return getYmlTestData(ymlFile);
}



@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
String[] templateFields = testCaseDTO.getTemplateFields();
List<String> queryProp = Arrays.asList(templateFields);
logger.info(queryProp);
String query = "select * from audit.app_audit_log where cr_by = '"+BaseTestCase.currentModule +"-"+propsKernel.getProperty("partner_userName")+"'";



String query = "select * from audit.app_audit_log where app_name = 'PREREGISTRATION' && session_user_name = '"
+ "[email protected]" + "'";

logger.info(query);
Map<String, Object> response = AuditDBManager.executeQueryAndGetRecord(testCaseDTO.getRole(), query);



Map<String, List<OutputValidationDto>> objMap = new HashMap<>();
List<OutputValidationDto> objList = new ArrayList<>();
OutputValidationDto objOpDto = new OutputValidationDto();
if(response.size()>0) {
if (response.size() > 0) {

objOpDto.setStatus("PASS");
}
else {
} else {
objOpDto.setStatus(GlobalConstants.FAIL_STRING);
}

objList.add(objOpDto);
objMap.put(GlobalConstants.EXPECTED_VS_ACTUAL, objList);

if (!OutputValidationUtil.publishOutputResult(objMap))
throw new AdminTestException("Failed at output validation");
}



/**
* The method ser current test name to result
*
* @param result
*/
@AfterMethod(alwaysRun = true)
public void setResultTestName(ITestResult result) {

String deleteQuery = "delete from audit.app_audit_log where cr_by = '"+propsKernel.getProperty("partner_userName")+"'";

String deleteQuery = "delete from audit.app_audit_log where app_name = 'PREREGISTRATION' and session_user_name = '"
+ "[email protected]" + "'";

logger.info(deleteQuery);
AuditDBManager.executeQueryAndDeleteRecord("audit", deleteQuery);
try {
Expand Down
4 changes: 2 additions & 2 deletions apitest/src/main/resources/preReg/AuditLog/AuditLog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ addContact:
Prereg_AddContact_All_Valid_Smoke:
endPoint: SELECT module_name,cr_by FROM audit.app_audit_log where module_name LIKE '%partner%' order by action_dtimes desc LIMIT 5
role: audit
templateFields: ["partnerQuery","partner service"]
templateFields: ["preregQuery","prereg service"]
restMethod: post
inputTemplate: partner/authPartner/AddContacts/addContact
outputTemplate: partner/authPartner/AddContacts/addContactResult
input: '{
}'
output: '{
"module_name": "partner service"
"module_name": "prereg service"
"cr_by": "111997"
}'
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,40 @@ CancelAppointment:
"preRegistrationId": "$ID:CreatePrereg_Smoke_CancellAppointment_sid_preRegistrationId$"
}'
output: '{
}'
Prereg_CancelAppointment_with_already_cancelled_appoinment:
endPoint: /preregistration/v1/appointment/{preRegistrationId}
role: batch
checkErrorsOnlyInResponse: true
restMethod: put
inputTemplate: preReg/CancelAppointment/cancelAppointment
outputTemplate: preReg/error
input: '{
"preRegistrationId": "$ID:CreatePrereg_Smoke_CancellAppointment_sid_preRegistrationId$"
}'
output: '{
"errors": [
{
"errorCode": "PRG_APP_013"
}
]
}'
Prereg_CancelAppointment_cancell_incomplete_appoinment:
endPoint: /preregistration/v1/appointment/{preRegistrationId}
role: batch
checkErrorsOnlyInResponse: true
restMethod: put
inputTemplate: preReg/CancelAppointment/cancelAppointment
outputTemplate: preReg/error
input: '{
"preRegistrationId": "$ID:CreatePrereg_cancell_incomplete_prid_sid_preRegistrationId$"
}'
output: '{
"errors": [
{
"errorCode": "PRG_APP_013"
}
]
}'
Prereg_CancelAppointment_inValid_preRegistrationId_sid:
endPoint: /preregistration/v1/appointment/{preRegistrationId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ GetAppointmentDetails:
}'
output: '{
"registration_center_id": "10003"
}'
Prereg_GetAppointmentDetails_with_cancelled_appoinment:
endPoint: /preregistration/v1/appointment/{preRegistrationId}
role: batch
restMethod: get
inputTemplate: preReg/GetAppointmentDetails/getAppointmentDetails
outputTemplate: preReg/GetAppointmentDetails/getAppointmentDetailsResult
input: '{
"preRegistrationId": "$ID:CreatePrereg_Smoke_CancelApplicationsAppointment_sid_preRegistrationId$"
}'
output: '{
"registration_center_id": "10003"
}'
Prereg_GetAppointmentDetails_AllValid_Smoke_sid:
endPoint: /preregistration/v1/appointment/{preRegistrationId}
Expand Down Expand Up @@ -39,4 +51,20 @@ GetAppointmentDetails:
"errorCode": "PRG_APP_013"
}
]
}'
Prereg_GetAppointmentDetails_empty_space_preRegistrationId:
endPoint: /preregistration/v1/appointment/{preRegistrationId}
role: batch
restMethod: get
inputTemplate: preReg/GetAppointmentDetails/getAppointmentDetails
outputTemplate: preReg/error
input: '{
"preRegistrationId": " "
}'
output: '{
"errors": [
{
"errorCode": "PRG_APP_013"
}
]
}'
Original file line number Diff line number Diff line change
Expand Up @@ -644,4 +644,28 @@ BookAppointment:
}
]
}'

Prereg_BookAppointment_with_All_InValid_data:
endPoint: /preregistration/v1/applications/appointment/{preRegistrationId}
role: batch
checkErrorsOnlyInResponse: true
restMethod: post
inputTemplate: preReg/bookAppointment/bookAppointment
outputTemplate: preReg/error
input: '{
"preRegistrationId":"$nId$",
"registration_center_id": "$333on_center_id$",
"id": "mosip.pre-regooking.book",
"version": "1.0.3fhffu",
"appointment_date": "$233ntment_date$",
"time_slot_from": "$time_2y6373gdg_from$",
"time_slot_to": "$time_slo373$",
"requesttime": "$TIMEST33dd"
}'
output: '{
"errors": [
{
"errorCode": "PRG_CORE_REQ_013"
}
]
}'
40 changes: 40 additions & 0 deletions apitest/src/main/resources/preReg/createPrereg/createPrereg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -605,4 +605,44 @@ CreatePrereg:
"id": "mosip.pre-registration.demographic.create"
}'
output: '{
}'
Prereg_CreatePrereg_cancell_incomplete_prid_sid:
endPoint: /preregistration/v1/applications/prereg
role: batch
checkErrorsOnlyInResponse: true
restMethod: post
inputTemplate: preReg/createPrereg/createPrereg
outputTemplate: preReg/createPrereg/createPreregResult
input: '{
"postalCode": "14022",
"phone": "8249742850",
"email": "[email protected]",
"IDSchemaVersion": $SCHEMAVERSION$,
"dateOfBirth": "1996/01/01",
"version": "1.0",
"langCode": "$1STLANG$",
"requesttime": "$TIMESTAMP$",
"id": "mosip.pre-registration.demographic.create"
}'
output: '{
}'
Prereg_CreatePrereg_cancell_pending_appoinment_prid_sid:
endPoint: /preregistration/v1/applications/prereg
role: batch
checkErrorsOnlyInResponse: true
restMethod: post
inputTemplate: preReg/createPrereg/createPrereg
outputTemplate: preReg/createPrereg/createPreregResult
input: '{
"postalCode": "14022",
"phone": "8249742850",
"email": "[email protected]",
"IDSchemaVersion": $SCHEMAVERSION$,
"dateOfBirth": "1996/01/01",
"version": "1.0",
"langCode": "$1STLANG$",
"requesttime": "$TIMESTAMP$",
"id": "mosip.pre-registration.demographic.create"
}'
output: '{
}'
Original file line number Diff line number Diff line change
Expand Up @@ -994,4 +994,97 @@ UploadDocument:
"docCatCode":"POR",
"docTypCode":"CRN",
"docFileFormat":"pdf"
}'

Prereg_UploadDocument_All_Valid_Smoke_cancell_pending_appoinment_prid:
endPoint: /preregistration/v1/documents/{preRegistrationId}
role: batch
restMethod: post
inputTemplate: preReg/uploadDocument/uploadDocument
outputTemplate: preReg/uploadDocument/uploadDocumentResult
input: '{
"id": "mosip.pre-registration.document.upload",
"docCatCode" : "POA",
"docTypCode" : "RNC",
"langCode" : "$1STLANG$",
"requesttime" : "$TIMESTAMP$",
"preRegistrationId": "$ID:CreatePrereg_cancell_pending_appoinment_prid_sid_preRegistrationId$",
"filePath": "preReg/uploadDocument/doc_POA.pdf",
"fileKeyName": "file"
}'
output: '{
"id":"mosip.pre-registration.document.upload",
"docName":"doc_POA.pdf",
"docCatCode":"POA",
"docTypCode":"RNC",
"docFileFormat":"pdf"
}'
Prereg_UploadDocument_All_Valid_Smoke_POI_cancell_pending_appoinment_prid_sid:
endPoint: /preregistration/v1/documents/{preRegistrationId}
role: batch
restMethod: post
inputTemplate: preReg/uploadDocument/uploadDocument
outputTemplate: preReg/uploadDocument/uploadDocumentResult
input: '{
"id": "mosip.pre-registration.document.upload",
"docCatCode" : "POI",
"docTypCode" : "CIN",
"langCode" : "$1STLANG$",
"requesttime" : "$TIMESTAMP$",
"preRegistrationId": "$ID:CreatePrereg_cancell_pending_appoinment_prid_sid_preRegistrationId$",
"filePath": "preReg/uploadDocument/doc_POI.pdf",
"fileKeyName": "file"
}'
output: '{
"id":"mosip.pre-registration.document.upload",
"docName":"doc_POI.pdf",
"docCatCode":"POI",
"docTypCode":"CIN",
"docFileFormat":"pdf"
}'
Prereg_UploadDocument_All_Valid_Smoke_POB_cancell_pending_appoinment_prid_sid:
endPoint: /preregistration/v1/documents/{preRegistrationId}
role: batch
restMethod: post
inputTemplate: preReg/uploadDocument/uploadDocument
outputTemplate: preReg/uploadDocument/uploadDocumentResult
input: '{
"id": "mosip.pre-registration.document.upload",
"docCatCode" : "POB",
"docTypCode" : "COB",
"langCode" : "$1STLANG$",
"requesttime" : "$TIMESTAMP$",
"preRegistrationId": "$ID:CreatePrereg_cancell_pending_appoinment_prid_sid_preRegistrationId$",
"filePath": "preReg/uploadDocument/doc_POB.pdf",
"fileKeyName": "file"
}'
output: '{
"id":"mosip.pre-registration.document.upload",
"docName":"doc_POB.pdf",
"docCatCode":"POB",
"docTypCode":"COB",
"docFileFormat":"pdf"
}'
Prereg_UploadDocument_All_Valid_Smoke_POR_cancell_pending_appoinment_prid_sid:
endPoint: /preregistration/v1/documents/{preRegistrationId}
role: batch
restMethod: post
inputTemplate: preReg/uploadDocument/uploadDocument
outputTemplate: preReg/uploadDocument/uploadDocumentResult
input: '{
"id": "mosip.pre-registration.document.upload",
"docCatCode" : "POR",
"docTypCode" : "CRN",
"langCode" : "$1STLANG$",
"requesttime" : "$TIMESTAMP$",
"preRegistrationId": "$ID:CreatePrereg_cancell_pending_appoinment_prid_sid_preRegistrationId$",
"filePath": "preReg/uploadDocument/doc_POR.pdf",
"fileKeyName": "file"
}'
output: '{
"id":"mosip.pre-registration.document.upload",
"docName":"doc_POR.pdf",
"docCatCode":"POR",
"docTypCode":"CRN",
"docFileFormat":"pdf"
}'
Loading

0 comments on commit 4b9908a

Please sign in to comment.