forked from assertj/doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableAssertionExamples.java
More file actions
49 lines (40 loc) · 1.36 KB
/
TableAssertionExamples.java
File metadata and controls
49 lines (40 loc) · 1.36 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
48
49
package example.db;
// tag::user_guide[]
// From v3.0.2
import static org.assertj.core.api.Assertions.assertThat;
// For versions <= 3.0.1 :
// import static org.assertj.db.api.Assertions.assertThat;
import org.assertj.db.type.AssertDbConnection;
import org.assertj.db.type.AssertDbConnectionFactory;
import org.assertj.db.type.DateValue;
import org.assertj.db.type.Table;
// end::user_guide[]
import org.junit.jupiter.api.Test;
public class TableAssertionExamples {
// tag::user_guide[]
private AssertDbConnection assertDbConnection = AssertDbConnectionFactory.of("jdbc:h2:mem:test", "sa", "").create();
// end::user_guide[]
/**
* This example shows a simple case of test.
*/
@Test
public void basic_table_assertion_examples() {
// tag::user_guide[]
Table table = assertDbConnection.table("members").build();
// Check column "name" values
assertThat(table).column("name")
.value().isEqualTo("Hewson")
.value().isEqualTo("Evans")
.value().isEqualTo("Clayton")
.value().isEqualTo("Mullen");
// Check row at index 1 (the second row) values
assertThat(table).row(1)
.value().isEqualTo(2)
.value().isEqualTo("Evans")
.value().isEqualTo("David Howell")
.value().isEqualTo("The Edge")
.value().isEqualTo(DateValue.of(1961, 8, 8))
.value().isEqualTo(1.77);
// end::user_guide[]
}
}