Skip to content

Commit 832a77f

Browse files
Added DB assertion from *.sql file, Updated readme for the same
1 parent b8191c2 commit 832a77f

File tree

7 files changed

+48
-2
lines changed

7 files changed

+48
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ Auth token can be passed from maven command line as well as config file. If the
260260
#Execute select query to validate data does not exist in DB
261261
#Then validate data does not exist for select query "<sql query>"
262262
Then validate data does not exist for select query "select * from users where name = 'abhishek kadavil1'"
263+
264+
#Execute select query from file to validate data exist in DB
265+
#Then validate data exist for select query from file "<sql file>"
266+
Then validate data exist for select query from file "/DbOps/scenario9/SelQuery.sql"
267+
268+
#Execute select query from file to validate data does not exist in DB
269+
#Then validate data does not exist for select query from file "<sql query>"
270+
Then validate data does not exist for select query from file "/DbOps/scenario11/SelQuery.sql"
263271
264272
```
265273

src/test/java/testSuit/stepDef/DBOpsStepDef.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import javax.sql.DataSource;
1919
import java.net.URL;
20+
import java.nio.file.Files;
21+
import java.nio.file.Paths;
2022
import java.sql.ResultSet;
2123
import java.util.List;
2224

@@ -115,4 +117,20 @@ public void validate_data_exist_for_select_query_string(String sqlStatement) {
115117
public void validate_data_does_not_exist_for_select_query_string(String sqlStatement) {
116118
dbOpsUtil.executeSelQueryForDataNotExist(dataSource, sqlStatement);
117119
}
120+
121+
@SneakyThrows
122+
@Then("validate data exist for select query from file {string}")
123+
public void validate_data_exist_for_select_query_from_file_string(String filePath) {
124+
String sqlStatement =
125+
new String(Files.readAllBytes(Paths.get(System.getProperty("user.dir")+"/src/test/resources/testData"+filePath)));
126+
dbOpsUtil.executeSelQueryForDataExist(dataSource, sqlStatement);
127+
}
128+
129+
@SneakyThrows
130+
@Then("validate data does not exist for select query from file {string}")
131+
public void validate_data_does_not_exist_for_select_query_from_file_string(String filePath) {
132+
String sqlStatement =
133+
new String(Files.readAllBytes(Paths.get(System.getProperty("user.dir")+"/src/test/resources/testData"+filePath)));
134+
dbOpsUtil.executeSelQueryForDataNotExist(dataSource, sqlStatement);
135+
}
118136
}

src/test/resources/features/dbFeatures/DbOps.feature

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,21 @@ Feature: DB operations
4040
Then validate data does not exist for select query "select * from users where name = 'abhishek kadavil1'"
4141

4242
@DbOps08 @DBParallel @DbOpsAll
43-
Scenario: 08 Use select query to validate DB table - return 1 row - Success
44-
Then validate data does not exist for select query "select * from users where name = 'abhishek kadavil'"
43+
Scenario: 08 Use select query to validate DB table - return 1 row - Fail
44+
Then validate data does not exist for select query "select * from users where name = 'abhishek kadavil'"
45+
46+
@DbOps09 @DBParallel @DbOpsAll
47+
Scenario: 09 Use select query to validate DB table from file - return 1 row - Success
48+
Then validate data exist for select query from file "/DbOps/scenario9/SelQuery.sql"
49+
50+
@DbOps10 @DBParallel @DbOpsAll
51+
Scenario: 10 Use select query to validate DB table from file - return 0 row - Fail
52+
Then validate data exist for select query from file "/DbOps/scenario10/SelQuery.sql"
53+
54+
@DbOps11 @DBParallel @DbOpsAll
55+
Scenario: 11 Use select query to validate DB table from file - return 0 row - Success
56+
Then validate data does not exist for select query from file "/DbOps/scenario11/SelQuery.sql"
57+
58+
@DbOps12 @DBParallel @DbOpsAll
59+
Scenario: 12 Use select query to validate DB table from file - return 1 row - Fail
60+
Then validate data does not exist for select query from file "/DbOps/scenario12/SelQuery.sql"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select * from users where name = 'abhishek kadavil1'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select * from users where name = 'abhishek kadavil1'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select * from users where name = 'abhishek kadavil'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select * from users where name = 'abhishek kadavil';

0 commit comments

Comments
 (0)