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-32363 JAVA 21 upgrade #962

Merged
merged 1 commit into from
May 3, 2024
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
163 changes: 8 additions & 155 deletions apitest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<groupId>io.mosip.masterdata</groupId>
<artifactId>apitest-masterdata</artifactId>
<packaging>jar</packaging>
<name>automationtests-masterdata</name>
<description>Parent project of MOSIP functional tests</description>
<url>https://github.com/mosip/mosip-functional-tests</url>
<version>1.2.0.1-SNAPSHOT</version>
<name>apitest-masterdata</name>
<description>Parent project of MOSIP Admin Services apitests</description>
<url>https://github.com/mosip/admin-services</url>
<version>1.2.1-java21-SNAPSHOT</version>

<licenses>
<license>
Expand All @@ -18,166 +18,19 @@
</licenses>

<scm>
<connection>scm:git:git://github.com/mosip/mosip-functional-tests.git</connection>
<developerConnection>scm:git:ssh://github.com:mosip/mosip-functional-tests.git</developerConnection>
<url>https://github.com/mosip/mosip-functional-tests</url>
<connection>scm:git:git://github.com/mosip/admin-services.git</connection>
<developerConnection>scm:git:ssh://github.com:mosip/admin-services.git</developerConnection>
<url>https://github.com/mosip/admin-services</url>
<tag>HEAD</tag>
</scm>




<properties>
<!-- kernel versions -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- maven -->
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.version>3.7.0</maven.compiler.version>
<maven.jar.plugin.version>3.0.2</maven.jar.plugin.version>
<maven.war.plugin.version>3.1.0</maven.war.plugin.version>
<maven.surefire.plugin.version>2.9</maven.surefire.plugin.version>
<maven.jacoco.plugin.version>0.8.1</maven.jacoco.plugin.version>
<maven.sonar.plugin.version>3.2</maven.sonar.plugin.version>
<maven.javadoc.version>3.0.1</maven.javadoc.version>
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
<maven.javadoc.skip>false</maven.javadoc.skip>
<maven.sonar.plugin.version>3.7.0.1746</maven.sonar.plugin.version>
<!-- spring -->
<spring.boot.version>2.0.2.RELEASE</spring.boot.version>
<spring.data.jpa.version>2.0.7.RELEASE</spring.data.jpa.version>
<spring.security.test.version>5.0.5.RELEASE</spring.security.test.version>
<spring-cloud-config.version>2.0.0.RELEASE</spring-cloud-config.version>

<swagger.core.version>2.0.7</swagger.core.version>
<swagger.annotations.version>1.5.20</swagger.annotations.version>
<springfox.version>2.9.2</springfox.version>

<vertx.version>3.6.2</vertx.version>
<vertx.health.check.version>3.7.0</vertx.health.check.version>


<!-- javax -->
<javax.interceptor.version>1.2</javax.interceptor.version>
<javax.el-api.version>3.0.0</javax.el-api.version>
<javax.transaction.api.version>1.3</javax.transaction.api.version>
<javax.persistence.api.version>2.2</javax.persistence.api.version>
<javax.validation-api.version>2.0.1.Final</javax.validation-api.version>
<glassfish.javax.el>2.2.6</glassfish.javax.el>

<!-- data -->
<h2.version>1.4.197</h2.version>
<mysql.connector.version>5.1.46</mysql.connector.version>
<postgresql.version>42.2.2</postgresql.version>
<eclipselink.version>2.5.0</eclipselink.version>
<hibernate.validator.version>6.0.12.Final</hibernate.validator.version>

<!-- test -->
<mockito.version>1.10.19</mockito.version>
<powermock.version>1.7.4</powermock.version>
<powermock.beta.version>2.0.0-beta.5</powermock.beta.version>

<!-- utilities -->
<commons-math3>3.6.1</commons-math3>
<commons-lang3>3.7</commons-lang3>
<commons-io>2.6</commons-io>
<commons-codec>1.11</commons-codec>
<commons-collections4.version>4.3</commons-collections4.version>
<commons.beanutils.version>1.9.2</commons.beanutils.version>
<commons.configuration2.version>2.2</commons.configuration2.version>
<apache.httpcomponents.version>4.5.6</apache.httpcomponents.version>
<guava.version>19.0</guava.version>
<lombok.version>1.18.8</lombok.version>
<jsch.version>0.1.54</jsch.version>
<sshd.version>1.4.0</sshd.version>
<itextcore.version>7.1.0</itextcore.version>
<itexthtml2pdf.version>2.0.0</itexthtml2pdf.version>
<itext.version>5.5.13</itext.version>
<freemarker.version>2.3.23</freemarker.version>
<velocity.version>1.7</velocity.version>
<velocity.tool.version>2.0</velocity.tool.version>
<datamapper.orika>1.5.2</datamapper.orika>
<modelmapper.version>2.1.1</modelmapper.version>
<bouncycastle.version>1.60</bouncycastle.version>
<icu4j.version>63.1</icu4j.version>
<seventeam-otp.version>1.0.0</seventeam-otp.version>
<google.zxing.version>3.3.3</google.zxing.version>
<hadoop-client>2.8.1</hadoop-client>
<htrace-core4>4.1.0-incubating</htrace-core4>
<aws.javasdk.version>1.11.368</aws.javasdk.version>
<s3mock.version>0.2.4</s3mock.version>
<ignite.version>2.3.0</ignite.version>
<findbugs.version>3.0.1</findbugs.version>
<byte.buddy.version>1.9.12</byte.buddy.version>
<io.jsonwebtoken.jjwt.version>0.6.0</io.jsonwebtoken.jjwt.version>
<apache.directory.api.version>2.0.0.AM2</apache.directory.api.version>






<!-- registration versions -->
<maven.jacoco.version>0.8.2</maven.jacoco.version>
<javafx.version>2.2</javafx.version>
<maven.sonar.version>3.2</maven.sonar.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.version>3.7.0</maven.compiler.version>
<maven.javadoc.version>3.0.1</maven.javadoc.version>

<!-- Test & Logging -->
<logback.version>1.1.6</logback.version>
<slf4j.version>1.7.19</slf4j.version>
<mockito.version>1.10.19</mockito.version>

<!-- Orika Mapper -->
<orika.version>1.4.6</orika.version>

<!-- Spring version -->
<spring.version>5.0.6.RELEASE</spring.version>

<!-- Hibernate version -->
<hibernate.version>5.4.2.Final</hibernate.version>

<!-- Apache Commons DPC2 version -->
<apache.commons.dpce.version>2.1.1</apache.commons.dpce.version>

<!-- Derby Version -->
<apache.derby.version>10.13.1.1</apache.derby.version>

<!-- sourceafis Version -->
<sourceafis.version>3.4.0</sourceafis.version>

<!-- openimaj version -->
<org.openimaj.version>1.3.5</org.openimaj.version>

<!-- webcam-capture version -->
<webcam-capture.version>0.3.12</webcam-capture.version>

<!-- TSS Version -->
<tss.version>0.3.0</tss.version>

<!-- automationtests version -->
<wink-json4j-provider.version>1.1.2-incubating</wink-json4j-provider.version>
<kernel.version>1.2.0.1-B1</kernel.version>
<zjsonpatch.version>0.4.7</zjsonpatch.version>
<extentreports.aventstack.version>3.0.0</extentreports.aventstack.version>
<extentreports.relevantcodes.version>2.41.2</extentreports.relevantcodes.version>
<json-path.version>2.4.0</json-path.version>
<maven.model.version>3.3.9</maven.model.version>
<rest.assured.version>3.0.7</rest.assured.version>
<testng.version>6.11</testng.version>
<zt.zip.version>1.13</zt.zip.version>
<fileName>automationtests-commons-1.2.0.1-SNAPSHOT-jar-with-dependencies</fileName>

</properties>
<dependencies>

<dependency>
<groupId>io.mosip.testrig.apirig.automationtests.commons</groupId>
<artifactId>automationtests-commons</artifactId>
<version>1.2.0.1-SNAPSHOT</version>
<version>1.2.1-java21-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
package io.mosip.testrig.apirig.testscripts;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.testng.ITest;
import org.testng.ITestContext;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.internal.BaseTestMethod;
import org.testng.internal.TestResult;

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PutWithPathParamsAndBody extends AdminTestUtil implements ITest {
private static final Logger logger = Logger.getLogger(PutWithPathParamsAndBody.class);
protected String testCaseName = "";
String pathParams = null;
public Response response = null;

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

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

/**
* Data provider class provides test case list
*
* @return object of data provider
*/
@DataProvider(name = "testcaselist")
public Object[] getTestCaseList(ITestContext context) {
String ymlFile = context.getCurrentXmlTest().getLocalParameters().get("ymlFile");
pathParams = context.getCurrentXmlTest().getLocalParameters().get("pathParams");
logger.info("Started executing yml: " + ymlFile);
return getYmlTestData(ymlFile);
}

/**
* Test method for OTP Generation execution
*
* @param objTestParameters
* @param testScenario
* @param testcaseName
* @throws AuthenticationTestException
* @throws AdminTestException
*/
@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
String[] templateFields = testCaseDTO.getTemplateFields();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

testCaseDTO = AdminTestUtil.filterHbs(testCaseDTO);
String inputJson = filterInputHbs(testCaseDTO);

if (testCaseDTO.getTemplateFields() != null && templateFields.length > 0) {
ArrayList<JSONObject> inputtestCases = AdminTestUtil.getInputTestCase(testCaseDTO);
ArrayList<JSONObject> outputtestcase = AdminTestUtil.getOutputTestCase(testCaseDTO);
for (int i = 0; i < languageList.size(); i++) {
response = putWithPathParamsBodyAndCookie(ApplnURI + testCaseDTO.getEndPoint(),
getJsonFromTemplate(inputtestCases.get(i).toString(), testCaseDTO.getInputTemplate()),
COOKIENAME, testCaseDTO.getRole(), testCaseDTO.getTestCaseName(), pathParams);

Map<String, List<OutputValidationDto>> ouputValid = OutputValidationUtil.doJsonOutputValidation(
response.asString(),
getJsonFromTemplate(outputtestcase.get(i).toString(), testCaseDTO.getOutputTemplate()),
testCaseDTO, response.getStatusCode());
Reporter.log(ReportUtil.getOutputValidationReport(ouputValid));

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

else {
response = putWithPathParamsBodyAndCookie(ApplnURI + testCaseDTO.getEndPoint(), inputJson, COOKIENAME,
testCaseDTO.getRole(), testCaseDTO.getTestCaseName(), pathParams);
}
Map<String, List<OutputValidationDto>> ouputValid = null;

ouputValid = OutputValidationUtil.doJsonOutputValidation(response.asString(),
getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate()), testCaseDTO,
response.getStatusCode());

Reporter.log(ReportUtil.getOutputValidationReport(ouputValid));

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



private String filterOutputHbs(TestCaseDTO testCaseDTO) {
String outputJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());

if (outputJson.contains(GlobalConstants.$1STLANG$))
outputJson = outputJson.replace(GlobalConstants.$1STLANG$, BaseTestCase.languageList.get(0));
if (outputJson.contains(GlobalConstants.$2STLANG$))
outputJson = outputJson.replace(GlobalConstants.$2STLANG$, BaseTestCase.languageList.get(1));
if (outputJson.contains(GlobalConstants.$3STLANG$))
outputJson = outputJson.replace(GlobalConstants.$3STLANG$, BaseTestCase.languageList.get(2));
return outputJson;
}

private String filterInputHbs(TestCaseDTO testCaseDTO) {
String inputJson = getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate());

if (inputJson.contains(GlobalConstants.$1STLANG$))
inputJson = inputJson.replace(GlobalConstants.$1STLANG$, BaseTestCase.languageList.get(0));
if (inputJson.contains(GlobalConstants.$2STLANG$))
inputJson = inputJson.replace(GlobalConstants.$2STLANG$, BaseTestCase.languageList.get(1));
if (inputJson.contains(GlobalConstants.$3STLANG$))
inputJson = inputJson.replace(GlobalConstants.$3STLANG$, BaseTestCase.languageList.get(2));

return inputJson;
}

/**
* The method ser current test name to result
*
* @param result
*/
@AfterMethod(alwaysRun = true)
public void setResultTestName(ITestResult result) {
try {
Field method = TestResult.class.getDeclaredField("m_method");
method.setAccessible(true);
method.set(result, result.getMethod().clone());
BaseTestMethod baseTestMethod = (BaseTestMethod) result.getMethod();
Field f = baseTestMethod.getClass().getSuperclass().getDeclaredField("m_methodName");
f.setAccessible(true);
f.set(baseTestMethod, testCaseName);
} catch (Exception e) {
Reporter.log("Exception : " + e.getMessage());
}
}
}
2 changes: 1 addition & 1 deletion apitest/testNgXmlFiles/masterdataApi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- Passing Group as parmeter unsing "testType" Possible Groups are: smoke
regression smokeAndRegression -->
<listeners>
<listener class-name="io.mosip.testrig.apirig.customReport.EmailableReport"/>
<listener class-name="io.mosip.testrig.apirig.report.EmailableReport"/>
</listeners>

<test name="BulkUpload">
Expand Down
Loading