Skip to content

Commit d7c1383

Browse files
Jeevant KumarJeevant Kumar
Jeevant Kumar
authored and
Jeevant Kumar
committed
api demo tests
1 parent 217c33f commit d7c1383

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1683
-0
lines changed
Binary file not shown.

pom.xml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.demoApi.tests</groupId>
5+
<artifactId>demo_api_tests</artifactId>
6+
<packaging>jar</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>demo_api_tests</name>
9+
<url>http://maven.apache.org</url>
10+
<dependencies>
11+
<dependency>
12+
<groupId>junit</groupId>
13+
<artifactId>junit</artifactId>
14+
<version>3.8.1</version>
15+
<scope>test</scope>
16+
</dependency>
17+
18+
<dependency>
19+
<groupId>org.testng</groupId>
20+
<artifactId>testng</artifactId>
21+
<version>6.14.3</version>
22+
<scope>test</scope>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>commons-io</groupId>
27+
<artifactId>commons-io</artifactId>
28+
<version>2.6</version>
29+
</dependency>
30+
31+
<!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl -->
32+
<dependency>
33+
<groupId>net.sourceforge.jexcelapi</groupId>
34+
<artifactId>jxl</artifactId>
35+
<version>2.6.12</version>
36+
</dependency>
37+
38+
39+
<dependency>
40+
<groupId>javax.json</groupId>
41+
<artifactId>javax.json-api</artifactId>
42+
<version>1.1</version>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>net.javacrumbs.json-unit</groupId>
47+
<artifactId>json-unit</artifactId>
48+
<version>1.25.0</version>
49+
<scope>test</scope>
50+
</dependency>
51+
52+
<!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl -->
53+
<dependency>
54+
<groupId>net.sourceforge.jexcelapi</groupId>
55+
<artifactId>jxl</artifactId>
56+
<version>2.6.12</version>
57+
</dependency>
58+
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
59+
<dependency>
60+
<groupId>com.fasterxml.jackson.core</groupId>
61+
<artifactId>jackson-databind</artifactId>
62+
<version>2.9.8</version>
63+
</dependency>
64+
65+
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
66+
<dependency>
67+
<groupId>com.fasterxml.jackson.core</groupId>
68+
<artifactId>jackson-annotations</artifactId>
69+
<version>2.9.8</version>
70+
</dependency>
71+
72+
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
73+
<dependency>
74+
<groupId>com.fasterxml.jackson.core</groupId>
75+
<artifactId>jackson-core</artifactId>
76+
<version>2.9.8</version>
77+
</dependency>
78+
79+
80+
<!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-asl -->
81+
<dependency>
82+
<groupId>org.codehaus.jackson</groupId>
83+
<artifactId>jackson-core-asl</artifactId>
84+
<version>1.9.13</version>
85+
</dependency>
86+
87+
<!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl -->
88+
<dependency>
89+
<groupId>org.codehaus.jackson</groupId>
90+
<artifactId>jackson-mapper-asl</artifactId>
91+
<version>1.9.13</version>
92+
</dependency>
93+
94+
<dependency>
95+
<groupId>org.mongodb</groupId>
96+
<artifactId>mongodb-driver</artifactId>
97+
<version>3.4.3</version>
98+
</dependency>
99+
<!-- https://mvnrepository.com/artifact/net.javacrumbs.json-unit/json-unit -->
100+
<dependency>
101+
<groupId>net.javacrumbs.json-unit</groupId>
102+
<artifactId>json-unit</artifactId>
103+
<version>1.25.0</version>
104+
<scope>test</scope>
105+
</dependency>
106+
<dependency>
107+
<groupId>javax.json</groupId>
108+
<artifactId>javax.json-api</artifactId>
109+
<version>1.1</version>
110+
</dependency>
111+
<dependency>
112+
<groupId>org.glassfish</groupId>
113+
<artifactId>javax.json</artifactId>
114+
<version>1.0.4</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>com.googlecode.json-simple</groupId>
118+
<artifactId>json-simple</artifactId>
119+
<version>1.1.1</version>
120+
</dependency>
121+
122+
123+
<dependency>
124+
<groupId>org.json</groupId>
125+
<artifactId>json</artifactId>
126+
<version>20171018</version>
127+
</dependency>
128+
129+
<dependency>
130+
<groupId>io.rest-assured</groupId>
131+
<artifactId>rest-assured</artifactId>
132+
<version>3.0.0</version>
133+
<scope>test</scope>
134+
</dependency>
135+
136+
137+
<dependency>
138+
<groupId>com.auth0</groupId>
139+
<artifactId>java-jwt</artifactId>
140+
<version>3.8.3</version>
141+
</dependency>
142+
143+
</dependencies>
144+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.baseutils;
2+
3+
public class AutoConstants {
4+
5+
//json request and response keywords
6+
public static String message="message";
7+
public static String data="data";
8+
public static String jwtSecret="jwtSecret";
9+
public static String payerAppID="id";
10+
11+
public static String callbackURL="callbackURL";
12+
public static String name="name";
13+
14+
public static String bills="bills";
15+
16+
public static String bearer="Bearer ";
17+
18+
public static String amount="amount";
19+
20+
public static String ifsc="ifsc";
21+
22+
public static String accountNumber="accountNumber";
23+
24+
25+
public static String jwtToket="jwtToket";
26+
27+
28+
29+
30+
31+
32+
}

src/test/java/com/baseutils/Data.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.baseutils;
2+
3+
public class Data {
4+
5+
public String id;
6+
public String amount;
7+
public String billerName;
8+
public String ifsc;
9+
public String accountNumber;
10+
11+
12+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.baseutils;
2+
3+
import java.io.File;
4+
5+
import org.testng.Reporter;
6+
7+
import jxl.Cell;
8+
import jxl.Sheet;
9+
import jxl.Workbook;
10+
import jxl.WorkbookSettings;
11+
12+
public class ExcelUtilities {
13+
14+
public static String[][] getTableArray(String xlFilePath, String sheetName, String tableName) {
15+
String[][] tabArray = null;
16+
try {
17+
final WorkbookSettings settings = new WorkbookSettings();
18+
settings.setSuppressWarnings(true);
19+
final Workbook workbook = Workbook.getWorkbook(new File(xlFilePath), settings);
20+
Reporter.log("Accessing file :" + xlFilePath);
21+
final Sheet sheet = workbook.getSheet(sheetName);
22+
Reporter.log("Accessing sheet :" + sheetName);
23+
int startRow, startCol, endRow, endCol, ci, cj;
24+
final Cell tableStart = sheet.findCell(tableName);
25+
Reporter.log("Looking for prefix :" + tableName);
26+
startRow = tableStart.getRow() + 1;
27+
startCol = tableStart.getColumn();
28+
final Cell tableEnd = sheet.findCell(tableName, startCol + 1, startRow + 1, 100, 64000, false);
29+
endRow = tableEnd.getRow();
30+
endCol = tableEnd.getColumn();
31+
tabArray = new String[endRow - startRow][endCol - startCol - 1];
32+
ci = 0;
33+
for (int i = startRow + 1; i <= endRow; ++i, ++ci) {
34+
cj = 0;
35+
for (int j = startCol + 1; j < endCol; j++, cj++) {
36+
tabArray[ci][cj] = sheet.getCell(j, i).getContents().trim();
37+
}
38+
}
39+
workbook.close();
40+
} catch (final Exception e) {
41+
System.out.println("Table not found. Verify the start tag in the sheet :" + tableName);
42+
System.out.println(e);
43+
}
44+
return (tabArray);
45+
}
46+
47+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.baseutils;
2+
3+
import java.util.Map;
4+
5+
import org.json.simple.JSONObject;
6+
import org.testng.ITestContext;
7+
@SuppressWarnings("unchecked")
8+
public class JsonFileParserUtils {
9+
10+
11+
public JSONObject createOnBoardAPIRequest(String callBackUrl, String name) {
12+
13+
14+
15+
final JSONObject obj_rc = new JSONObject();
16+
17+
18+
19+
obj_rc.put("callbackURL", callBackUrl);
20+
obj_rc.put("name", name);
21+
22+
return obj_rc;
23+
24+
}
25+
26+
27+
28+
public String createMakePaymentAPIRequest(ITestContext context) {
29+
30+
final JSONObject obj_rc = new JSONObject();
31+
obj_rc.put("ifsc", context.getAttribute("ifsc"));
32+
obj_rc.put("accountNumber", context.getAttribute("accountNumber"));
33+
obj_rc.put("amount", context.getAttribute("amount"));
34+
return obj_rc.toJSONString();
35+
36+
}
37+
38+
39+
public JSONObject createCallBackPayLoadAPIRequest(ITestContext context) {
40+
41+
final JSONObject obj_rc = new JSONObject();
42+
final JSONObject bill_obj = new JSONObject();
43+
44+
45+
46+
obj_rc.put("success",true);
47+
48+
obj_rc.put("transactionId",context.getAttribute("transactionId"));
49+
50+
bill_obj.put("id", context.getAttribute("bills_id"));
51+
bill_obj.put("amount", context.getAttribute("amount"));
52+
bill_obj.put("ifsc", context.getAttribute("ifsc"));
53+
bill_obj.put("billerName", context.getAttribute("billerName"));
54+
bill_obj.put("accountNumber", context.getAttribute("accountNumber"));
55+
56+
57+
58+
return obj_rc;
59+
60+
}
61+
62+
63+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.baseutils;
2+
3+
import com.auth0.jwt.JWT;
4+
import com.auth0.jwt.algorithms.Algorithm;
5+
import com.auth0.jwt.exceptions.JWTCreationException;
6+
7+
public class JwtUtils {
8+
9+
10+
public String createJwt(String jwtSecretKey) {
11+
String token = null;
12+
try {
13+
Algorithm algorithm = Algorithm.HMAC256(jwtSecretKey);
14+
token = JWT.create()
15+
.withIssuer("auth0")
16+
.sign(algorithm);
17+
} catch (JWTCreationException exception){
18+
//Invalid Signing configuration / Couldn't convert Claims.
19+
}
20+
return token;
21+
}
22+
23+
}

0 commit comments

Comments
 (0)