Skip to content

Commit 65ad786

Browse files
committed
Example code added
1 parent 623342b commit 65ad786

23 files changed

+316
-52
lines changed

demo-all/api-testing.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
3+
<suite name="End-2-End API automation Suite" parallel="methods" thread-count="4">
4+
<test name="End-2-End API automation Suite" group-by-instances="true">
5+
<classes >
6+
<class name="io.virtualan.test.demo.RestTestPlanExecutor" />
7+
</classes>
8+
</test>
9+
</suite>

demo-all/demo-all/Multi-Run-1.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[{
2+
"input": "{\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"id\": <petId>,\n \"name\": \"<petName>\",\n \"photoUrls\": [\n \"string\"\n ],\n \"status\": \"available\",\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"type\": \"DOGS\"\n}",
3+
"requestType": "REST",
4+
"method": "POST",
5+
"scenario": "post API Testing",
6+
"resource": "ep",
7+
"rule": [
8+
{
9+
"petName": "Test1",
10+
"petId": "1000"
11+
},
12+
{
13+
"petName": "Test2",
14+
"petId": "2000"
15+
}
16+
],
17+
"availableParams": [
18+
{
19+
"parameterType": "ADDIFY_PARAM",
20+
"value": "<petId>",
21+
"key": "petId"
22+
},
23+
{
24+
"parameterType": "ADDIFY_PARAM",
25+
"value": "<petName>",
26+
"key": "petName"
27+
},
28+
{
29+
"parameterType": "HEADER_PARAM",
30+
"value": "application/json",
31+
"key": "contentType"
32+
}
33+
],
34+
"type": "PARAMS",
35+
"contentType": "application/json",
36+
"scenarioId": "PetPost",
37+
"url": "/pets",
38+
"httpStatusCode": "201"
39+
}]

demo-all/demo-all/Rest-Get-0.json

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
[
2+
{
3+
"requestType": "REST",
4+
"method": "GET",
5+
"scenario": "Read user infos - Example",
6+
"resource": "ep",
7+
"csvson": [
8+
"dateOfBirth,firstName,lastName,lastTimeOnline,spokenLanguages/additionalProp1:additionalProp2:additionalProp3,username",
9+
"1955-10-28,Bill,Gates,2020-08-30T20:28:36.267Z,Tamil:English:Spanish,bgates"
10+
],
11+
"availableParams": [{
12+
"parameterType": "HEADER_PARAM",
13+
"value": "application/json",
14+
"key": "contentType"
15+
}],
16+
"contentType": "application/json",
17+
"scenarioId": "ReadPerson-Simple",
18+
"url": "/persons/bgates",
19+
"tags": "@examples",
20+
"httpStatusCode": "200"
21+
},
22+
{
23+
"outputFields": {"status": "available"},
24+
"requestType": "REST",
25+
"method": "GET",
26+
"scenario": "Read pet by customer by query params",
27+
"resource": "ep",
28+
"csvson": [
29+
"id,name, category/id:name,status",
30+
"i~201,,i~200:Bulldog,available"
31+
],
32+
"availableParams": [
33+
{
34+
"parameterType": "HEADER_PARAM",
35+
"value": "application/json",
36+
"key": "contentType"
37+
},
38+
{
39+
"parameterType": "QUERY_PARAM",
40+
"value": "validateEmpty",
41+
"key": "tags"
42+
}
43+
],
44+
"contentType": "application/json",
45+
"scenarioId": "ReadPetByQueryparams-Simple",
46+
"url": "/pets/findByTags",
47+
"tags": "@empty_test",
48+
"httpStatusCode": "200"
49+
},
50+
{
51+
"outputFields": {
52+
"name==null": "true",
53+
"status": "available"
54+
},
55+
"requestType": "REST",
56+
"method": "GET",
57+
"scenario": "Read pet by customer by query params",
58+
"resource": "ep",
59+
"csvson": [
60+
"id,category/id:name,status",
61+
"i~201,i~200:Bulldog,available"
62+
],
63+
"availableParams": [
64+
{
65+
"parameterType": "HEADER_PARAM",
66+
"value": "application/json",
67+
"key": "contentType"
68+
},
69+
{
70+
"parameterType": "QUERY_PARAM",
71+
"value": "validateNull",
72+
"key": "tags"
73+
}
74+
],
75+
"contentType": "application/json",
76+
"scenarioId": "ReadPetByQueryparams-Simple",
77+
"url": "/pets/findByTags",
78+
"tags": "@test_2",
79+
"httpStatusCode": "200"
80+
}
81+
]
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#This is a cucumblan.properties properties file
2+
#Sun Mar 06 15:37:24 CST 2022
3+
virtualan.data.heading=Rest-Get - Workflow;Multi-Run - Workflow;
4+
virtualan.data.type=VIRTUALAN
5+
service.api.ep=https\://live.virtualandemo.com/api
6+
service.api.live=https\://live.virtualandemo.com
7+
virtualan.data.load=Rest-Get-0.json;Multi-Run-1.json;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Feature: Multi-Run - Workflow
2+
3+
Scenario: Load initial set of data
4+
Given provided all the feature level parameters from file
5+
6+
@ep
7+
Scenario: post API Testing - api call
8+
Given a user perform a api action
9+
And add the <petId> value of the key as petId
10+
And add the <petName> value of the key as petName
11+
And add request with given header params
12+
| contentType | application/json |
13+
And create api with given input
14+
| photoUrls[0] | string |
15+
| name | <petName> |
16+
| id | <petId> |
17+
| category.name | string |
18+
| category.id | i~0 |
19+
| type | DOGS |
20+
| status | available |
21+
| tags[0].name | string |
22+
| tags[0].id | i~0 |
23+
When a user post application/json in /pets resource on ep
24+
Then the status code is 201
25+
26+
Examples:
27+
| petName | petId |
28+
| Test1 | 1000 |
29+
| Test2 | 2000 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Feature: Rest-Get - Workflow
2+
3+
Scenario: Load initial set of data
4+
Given provided all the feature level parameters from file
5+
6+
@examples @ep
7+
Scenario: Read user infos - Example - api call
8+
Given a user perform a api action
9+
And add request with given header params
10+
| contentType | application/json |
11+
When a user get application/json in /persons/bgates resource on ep
12+
Then the status code is 200
13+
And verify api response csvson includes in the response
14+
| dateOfBirth,firstName,lastName,lastTimeOnline,spokenLanguages/additionalProp1:additionalProp2:additionalProp3,username |
15+
| 1955-10-28,Bill,Gates,2020-08-30T20:28:36.267Z,Tamil:English:Spanish,bgates |
16+
17+
@empty_test @ep
18+
Scenario: Read pet by customer by query params - api call
19+
Given a user perform a api action
20+
And add request with given query params
21+
| tags | validateEmpty |
22+
And add request with given header params
23+
| contentType | application/json |
24+
When a user get application/json in /pets/findByTags resource on ep
25+
Then the status code is 200
26+
And verify api response csvson includes in the response
27+
| id,name, category/id:name,status |
28+
| i~201,,i~200:Bulldog,available |
29+
And verify across response includes following in the response
30+
| status | available |
31+
32+
@test_2 @ep
33+
Scenario: Read pet by customer by query params - api call
34+
Given a user perform a api action
35+
And add request with given query params
36+
| tags | validateNull |
37+
And add request with given header params
38+
| contentType | application/json |
39+
When a user get application/json in /pets/findByTags resource on ep
40+
Then the status code is 200
41+
And verify api response csvson includes in the response
42+
| id,category/id:name,status |
43+
| i~201,i~200:Bulldog,available |
44+
And verify across response includes following in the response
45+
| name==null | true |
46+
| status | available |

demo-all/pom.xml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>io.virtualan.idaithalam</groupId>
7+
<artifactId>demo-all</artifactId>
8+
<version>0.1.0-SNAPSHOT</version>
9+
<properties>
10+
<maven.compiler.source>8</maven.compiler.source>
11+
<maven.compiler.target>8</maven.compiler.target>
12+
<idaithalam.version>1.6.0</idaithalam.version>
13+
<mysql.version>8.0.13</mysql.version>
14+
<testng.ver>7.4.0</testng.ver>
15+
</properties>
16+
<dependencies>
17+
<dependency>
18+
<groupId>io.virtualan</groupId>
19+
<artifactId>idaithalam</artifactId>
20+
<version>${idaithalam.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.testng</groupId>
24+
<artifactId>testng</artifactId>
25+
<version>${testng.ver}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>mysql</groupId>
29+
<artifactId>mysql-connector-java</artifactId>
30+
<version>${mysql.version}</version>
31+
</dependency>
32+
</dependencies>
33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-surefire-plugin</artifactId>
38+
<version>3.0.0-M3</version>
39+
<configuration>
40+
<skipTests>false</skipTests>
41+
<suiteXmlFiles>
42+
<suiteXmlFile>api-testing.xml</suiteXmlFile>
43+
</suiteXmlFiles>
44+
<testFailureIgnore>true</testFailureIgnore>
45+
</configuration>
46+
</plugin>
47+
</plugins>
48+
</build>
49+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.virtualan.test.demo;
2+
3+
import io.virtualan.idaithalam.core.api.VirtualanTestPlanExecutor;
4+
import org.testng.Assert;
5+
import org.testng.annotations.Test;
6+
7+
8+
@Test
9+
public class RestTestPlanExecutor {
10+
11+
@Test
12+
public void workflowExecution_xl() {
13+
try {
14+
boolean isSuccess = VirtualanTestPlanExecutor
15+
.invoke("demo-all.yml");
16+
Assert.assertTrue(isSuccess);
17+
} catch (Exception e) {
18+
Assert.assertTrue(false);
19+
}
20+
}
21+
22+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parallelExecution: 4
2+
timeout: 1
3+
apiExecutor:
4+
- reportTitle: "Demo code"
5+
env: test
6+
outputDir: demo-all
7+
inputExcel: rest/demo-all.xlsx
8+
outputJsonDir: target/idaithalam
9+
cucumblanProperties:
10+
service.api.ep: https://live.virtualandemo.com/api
11+
service.api.live: https://live.virtualandemo.com
13.3 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--tags,@test_2

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
</plugins>
6262
</build>
6363
<modules>
64+
<module>demo-all</module>
6465
<module>rest-get</module>
6566
<module>rest-post</module>
6667
<module>graphql</module>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#This is a cucumblan-env.properties properties file
2-
#Sun Feb 20 09:32:38 CST 2022
2+
#Sun Mar 06 13:51:01 CST 2022
33
password=1password
44

workflow-rest/LakesideMutual/Customer-Self-Service/DB/cucumblan.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#This is a cucumblan.properties properties file
2-
#Sun Feb 20 09:32:38 CST 2022
2+
#Sun Mar 06 13:51:01 CST 2022
33
css.cucumblan.jdbc.url=jdbc\:mysql\://microservices.virtualandemo.com\:3306/customerselfservice?useSSL\=false
44
virtualan.data.heading=CSS-Accept-DB - Workflow;CSS-Reject-DB - Workflow;
55
virtualan.data.load=CSS-Accept-DB-0.json;CSS-Reject-DB-1.json;

workflow-rest/LakesideMutual/Customer-Self-Service/EXCEL/Customer_Self-Service-Reject-1.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"httpStatusCode": "200"
116116
},
117117
{
118-
"input": "{\n \"statusHistory\": [],\n \"customerInfo\": {\n \"customerId\": \"[customerId]\",\n \"firstname\": \"[firstname]\",\n \"lastname\": \"[lastname]\",\n \"contactAddress\": {\n \"streetAddress\": \"[streetAddress]\",\n \"postalCode\": \"[postalCode]\",\n \"city\": \"[city]\"\n },\n \"billingAddress\": {\n \"streetAddress\": \"[streetAddress]\",\n \"postalCode\": \"[postalCode]\",\n \"city\": \"[city]\"\n }\n },\n \"insuranceOptions\": {\n \"startDate\": \"2021-06-20\",\n \"insuranceType\": \"Life Insurance\",\n \"deductible\": {\n \"amount\": 500,\n \"currency\": \"CHF\"\n }\n }\n}",
118+
"input": "{\n \"statusHistory\": [],\n \"customerInfo\": {\n \"customerId\": \"[customerId]\",\n \"firstname\": \"[firstname]\",\n \"lastname\": \"[lastname]\",\n \"contactAddress\": {\n \"streetAddress\": \"[streetAddress]\",\n \"postalCode\": \"[postalCode]\",\n \"city\": \"[city]\"\n },\n \"billingAddress\": {\n \"streetAddress\": \"[streetAddress]\",\n \"postalCode\": \"[postalCode]\",\n \"city\": \"[city]\"\n }\n },\n \"insuranceOptions\": {\n \"startDate\": \"[startDate]\",\n \"insuranceType\": \"Life Insurance\",\n \"deductible\": {\n \"amount\": 500,\n \"currency\": \"CHF\"\n }\n }\n}",
119119
"requestType": "REST",
120120
"method": "POST",
121121
"scenario": "CreateInsuranceQuoteForReject",
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#This is a cucumblan-env.properties properties file
2-
#Sun Feb 20 09:32:38 CST 2022
2+
#Sun Mar 06 13:51:01 CST 2022
33
password=1password
44

workflow-rest/LakesideMutual/Customer-Self-Service/EXCEL/cucumblan.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#This is a cucumblan.properties properties file
2-
#Sun Feb 20 09:32:38 CST 2022
2+
#Sun Mar 06 13:51:01 CST 2022
33
virtualan.data.heading=Customer Self Service-Accept - Workflow;Customer Self-Service-Reject - Workflow;
44
virtualan.data.type=VIRTUALAN
55
service.api.quote=http\://microservices.virtualandemo.com\:8090

workflow-rest/LakesideMutual/Customer-Self-Service/EXCEL/feature/Customer_Self-Service-Reject-1.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Feature: Customer Self-Service-Reject - Workflow
6767
| insuranceOptions.deductible.amount | i~500 |
6868
| insuranceOptions.deductible.currency | CHF |
6969
| insuranceOptions.insuranceType | Life Insurance |
70-
| insuranceOptions.startDate | 2021-06-20 |
70+
| insuranceOptions.startDate | [startDate] |
7171
When a user post application/json in /insurance-quote-requests resource on css
7272
Then the status code is 200
7373
And store rejectQuoteId as key and api's id as value

workflow-rest/src/test/java/io/virtualan/test/demo/WFExecuteTestPlanExecutor.java

-13
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,4 @@ public void workflowExecution_xl() {
2424
}
2525
}
2626

27-
28-
@Test
29-
public void workflowExecution_xl_db() {
30-
try {
31-
boolean isSuccess = VirtualanTestPlanExecutor
32-
.invoke("Customer-Self-Service-xl-db.yml");
33-
Assert.assertTrue(isSuccess);
34-
} catch (Exception e) {
35-
e.printStackTrace();
36-
Assert.assertTrue(false);
37-
}
38-
}
39-
4027
}

0 commit comments

Comments
 (0)