Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-38871 - Fixed the DOB hardcording for infants in getApplicantType API #1157

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:

- name: Upload the springboot jars
if: ${{ !contains(github.ref, 'master') || !contains(github.ref, 'main') }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUILD_ARTIFACT }}
path: ${{ env.BUILD_ARTIFACT }}.zip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ public static void startTestRunner() {
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<>();
if (file.getName().toLowerCase().contains("mastertestsuite")) {
BaseTestCase.setReportName(GlobalConstants.MASTERDATA);
suitefiles.add(file.getAbsolutePath());
runner.setTestSuites(suitefiles);
System.getProperties().setProperty("testng.outpur.dir", "testng-report");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

public class SimplePost extends AdminTestUtil implements ITest {
private static final Logger logger = Logger.getLogger(SimplePost.class);
private MasterDataUtil masterDataUtil = new MasterDataUtil();
protected String testCaseName = "";
public Response response = null;
public boolean auditLogCheck = false;
Expand Down Expand Up @@ -88,6 +89,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
}

String inputJson = getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate());
inputJson = masterDataUtil.inputJsonKeyWordHandeler(inputJson, testCaseName);

if (testCaseDTO.getTemplateFields() != null && templateFields.length > 0) {
ArrayList<JSONObject> inputtestCases = AdminTestUtil.getInputTestCase(testCaseDTO);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package io.mosip.testrig.apirig.masterdata.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;

import org.apache.log4j.Logger;
import org.testng.SkipException;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.GlobalConstants;
Expand All @@ -11,14 +18,44 @@
public class MasterDataUtil extends AdminTestUtil {

private static final Logger logger = Logger.getLogger(MasterDataUtil.class);

public static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
public static String infantDob = LocalDateTime.now().minusYears(getInfantMaxAge()).format(dateFormatter);

public static String isTestCaseValidForExecution(TestCaseDTO testCaseDTO) {
String testCaseName = testCaseDTO.getTestCaseName();

if (SkipTestCaseHandler.isTestCaseInSkippedList(testCaseName)) {
throw new SkipException(GlobalConstants.KNOWN_ISSUES);
}
return testCaseName;
}


public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {

if (jsonString.contains("$INFANT$")) {
jsonString = replaceKeywordWithValue(jsonString, "$INFANT$", infantDob);
}

return jsonString;
}

private static int getInfantMaxAge() {
HashMap<String, String> map = null;
String ageGroup = getValueFromRegprocActuator("systemProperties",
"mosip.regproc.packet.classifier.tagging.agegroup.ranges");

try {
map = new Gson().fromJson(ageGroup, new TypeToken<HashMap<String, String>>() {
}.getType());
} catch (Exception e) {
logger.error(
GlobalConstants.ERROR_STRING_1 + ageGroup + GlobalConstants.EXCEPTION_STRING_1 + e.getMessage());
}

String infantAgeGroup = map.get("INFANT").toString();

String[] parts = infantAgeGroup.split("-");
return Integer.parseInt(parts[1]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GetApplicantType:
},
{
"attribute": "dateOfBirth",
"value": "2019/01/01"
"value": "$INFANT$"
},
{
"attribute": "gender",
Expand Down Expand Up @@ -76,7 +76,7 @@ GetApplicantType:
},
{
"attribute": "dateOfBirth",
"value": "2019/01/01"
"value": "$INFANT$"
},
{
"attribute": "gender",
Expand Down Expand Up @@ -169,7 +169,7 @@ GetApplicantType:
},
{
"attribute": "dateOfBirth",
"value": "2019/01/01"
"value": "$INFANT$"
},
{
"attribute": "gender",
Expand Down Expand Up @@ -428,7 +428,7 @@ GetApplicantType:
},
{
"attribute": "dateOfBirth",
"value": "2019/01/01"
"value": "$INFANT$"
},
{
"attribute": "gender",
Expand Down Expand Up @@ -459,7 +459,7 @@ GetApplicantType:
},
{
"attribute": "dateOfBirth",
"value": "2019/01/01"
"value": "$INFANT$"
},
{
"attribute": "gender",
Expand Down Expand Up @@ -552,7 +552,7 @@ GetApplicantType:
},
{
"attribute": "dateOfBirth",
"value": "2019/01/01"
"value": "$INFANT$"
},
{
"attribute": "gender",
Expand Down Expand Up @@ -583,7 +583,7 @@ GetApplicantType:
},
{
"attribute": "dateOfBirth",
"value": "2019/01/01"
"value": "$INFANT$"
},
{
"attribute": "gender",
Expand Down
Loading