-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDBTest.java
More file actions
47 lines (42 loc) · 1.35 KB
/
DBTest.java
File metadata and controls
47 lines (42 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.DBHelper;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Testing work with DB and SQL query.
* Schema DB present in src/test/resources/database-diagram.pdf
*/
public class DBTest {
@Test
public void testDBConnect() throws SQLException {
ResultSet rs = new DBHelper().execSqlQuery("select * from city");
Assert.assertEquals(rs.findColumn("city_id"), 1);
}
/**
* Task: write a select query of the counts of customer whose email contains 'customer.org'
*/
@Test
public void checkSelectQuery() {
int count = new DBHelper().execCountSqlQuery("");
Assert.assertEquals(count, 599);
}
/**
* Task: write a select query of the counts of customer whose lives in Moscow
*/
@Test
public void checkSelectQuery2() {
int count = new DBHelper().execCountSqlQuery("");
Assert.assertEquals(count, 1);
}
/**
* Task: write a select query of the counts of staff whose username does not begin with M
* and whose store is located in a city starting with M
* The best practice is written query in database tools.
*/
@Test
public void checkSelectQuery3() {
int count = new DBHelper().execCountSqlQuery("");
Assert.assertEquals(count, 1);
}
}