position =
@@ -361,7 +361,7 @@ public void test_value_from_column_of_request_with_index_with_assertions() throw
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestAssert requestAssert = assertThat(request);
RequestColumnAssert requestColumnAssert = requestAssert.column();
Position position = (Position) fieldPosition.get(requestColumnAssert);
@@ -435,7 +435,7 @@ public void test_value_from_row_of_request_with_index_with_assertions() throws E
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestAssert requestAssert = assertThat(request);
RequestRowAssert requestRowAssert = requestAssert.row();
Position position = (Position) fieldPosition.get(requestRowAssert);
@@ -517,7 +517,7 @@ public void test_value_from_row_of_request_with_index_with_assertions() throws E
@Test
@NeedReload
public void test_value_from_row_of_change_with_index_with_displays() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -627,7 +627,7 @@ public void test_value_from_column_of_table_with_index_with_displays() throws Ex
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
TableOutputter tableOutputter = Outputs.output(table);
TableColumnOutputter tableColumnOutputter = tableOutputter.column();
Position position = (Position) fieldPosition.get(tableColumnOutputter);
@@ -701,7 +701,7 @@ public void test_value_from_row_of_table_with_index_with_displays() throws Excep
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
TableOutputter tableOutputter = Outputs.output(table);
TableRowOutputter tableRowOutputter = tableOutputter.row();
Position position = (Position) fieldPosition.get(tableRowOutputter);
@@ -789,7 +789,7 @@ public void test_value_from_column_of_request_with_index_with_displays() throws
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestOutputter requestOutputter = Outputs.output(request);
RequestColumnOutputter requestColumnOutputter = requestOutputter.column();
Position position = (Position) fieldPosition.get(requestColumnOutputter);
@@ -863,7 +863,7 @@ public void test_value_from_row_of_request_with_index_with_displays() throws Exc
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestOutputter requestOutputter = Outputs.output(request);
RequestRowOutputter requestRowOutputter = requestOutputter.row();
Position position = (Position) fieldPosition.get(requestRowOutputter);
diff --git a/src/test/java/org/assertj/db/navigation/ToValue_Value_Test.java b/src/test/java/org/assertj/db/navigation/ToValue_Value_Test.java
index 6e10200d..a1096b19 100644
--- a/src/test/java/org/assertj/db/navigation/ToValue_Value_Test.java
+++ b/src/test/java/org/assertj/db/navigation/ToValue_Value_Test.java
@@ -83,7 +83,7 @@ public class ToValue_Value_Test extends AbstractTest {
@Test
@NeedReload
public void test_value_from_row_of_change_with_assertions() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -177,7 +177,7 @@ public void test_value_from_column_of_table_with_assertions() throws Exception {
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
TableAssert tableAssert = assertThat(table);
TableColumnAssert tableColumnAssert = tableAssert.column();
Position position = (Position) fieldPosition.get(tableColumnAssert);
@@ -235,7 +235,7 @@ public void test_value_from_row_of_table_with_assertions() throws Exception {
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
TableAssert tableAssert = assertThat(table);
TableRowAssert tableRowAssert = tableAssert.row();
Position position = (Position) fieldPosition.get(tableRowAssert);
@@ -307,7 +307,7 @@ public void test_value_from_column_of_request_with_assertions() throws Exception
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestAssert requestAssert = assertThat(request);
RequestColumnAssert requestColumnAssert = requestAssert.column();
Position position = (Position) fieldPosition.get(requestColumnAssert);
@@ -365,7 +365,7 @@ public void test_value_from_row_of_request_with_assertions() throws Exception {
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestAssert requestAssert = assertThat(request);
RequestRowAssert requestRowAssert = requestAssert.row();
Position position = (Position) fieldPosition.get(requestRowAssert);
@@ -431,7 +431,7 @@ public void test_value_from_row_of_request_with_assertions() throws Exception {
@Test
@NeedReload
public void test_value_from_row_of_change_with_displays() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -525,7 +525,7 @@ public void test_value_from_column_of_table_with_displays() throws Exception {
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
TableOutputter tableOutputter = Outputs.output(table);
TableColumnOutputter tableColumnOutputter = tableOutputter.column();
Position position = (Position) fieldPosition.get(tableColumnOutputter);
@@ -583,7 +583,7 @@ public void test_value_from_row_of_table_with_displays() throws Exception {
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
TableOutputter tableOutputter = Outputs.output(table);
TableRowOutputter tableRowOutputter = tableOutputter.row();
Position position = (Position) fieldPosition.get(tableRowOutputter);
@@ -655,7 +655,7 @@ public void test_value_from_column_of_request_with_displays() throws Exception {
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestOutputter requestOutputter = Outputs.output(request);
RequestColumnOutputter requestColumnOutputter = requestOutputter.column();
Position position = (Position) fieldPosition.get(requestColumnOutputter);
@@ -713,7 +713,7 @@ public void test_value_from_row_of_request_with_displays() throws Exception {
Field fieldIndex = Position.class.getDeclaredField("nextIndex");
fieldIndex.setAccessible(true);
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestOutputter requestOutputter = Outputs.output(request);
RequestRowOutputter requestRowOutputter = requestOutputter.row();
Position position = (Position) fieldPosition.get(requestRowOutputter);
diff --git a/src/test/java/org/assertj/db/output/OutputterChange_Test.java b/src/test/java/org/assertj/db/output/OutputterChange_Test.java
index d60f63e8..ae8c18e9 100644
--- a/src/test/java/org/assertj/db/output/OutputterChange_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterChange_Test.java
@@ -36,7 +36,7 @@ public class OutputterChange_Test extends AbstractTest {
@Test
@NeedReload
public void test_output() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -56,7 +56,7 @@ public void test_output() throws Exception {
.change().toStream(byteArrayOutputStream5)
.change().toStream(byteArrayOutputStream6)
.change().toStream(byteArrayOutputStream7);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------|-------|---------|----------------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | | | | * | | | | |%n"
+ "| TYPE | TABLE | PRIMARY | | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -67,7 +67,7 @@ public void test_output() throws Exception {
+ "| CREATION | ACTOR | 4 |----------------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | | | At end point | 4 | Murray | Bill | 1950-09-21 | 30b443ae-c0c9-4790-9bec-ce1380808435 |%n"
+ "|----------|-------|---------|----------------|-----------|-----------|-----------|------------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Change at index 1 (on table : INTERPRETATION and with primary key : [6]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Change at index 1 (on table : INTERPRETATION and with primary key : [6]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------|----------------|---------|----------------|-----------|-----------|-----------|------------------|%n"
+ "| | | | | * | | | |%n"
+ "| TYPE | TABLE | PRIMARY | | ID | ID_MOVIE | ID_ACTOR | CHARACTER |%n"
@@ -78,7 +78,7 @@ public void test_output() throws Exception {
+ "| CREATION | INTERPRETATION | 6 |----------------|-----------|-----------|-----------|------------------|%n"
+ "| | | | At end point | 6 | 4 | 4 | Dr Peter Venkman |%n"
+ "|----------|----------------|---------|----------------|-----------|-----------|-----------|------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Change at index 2 (on table : MOVIE and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Change at index 2 (on table : MOVIE and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------|-------|---------|----------------|-----------|--------------|-----------|--------------------------------------|%n"
+ "| | | | | * | | | |%n"
+ "| TYPE | TABLE | PRIMARY | | ID | TITLE | YEAR | MOVIE_IMDB |%n"
@@ -89,7 +89,7 @@ public void test_output() throws Exception {
+ "| CREATION | MOVIE | 4 |----------------|-----------|--------------|-----------|--------------------------------------|%n"
+ "| | | | At end point | 4 | Ghostbusters | 1984 | 30b443ae-c0c9-4790-9bec-ce1380808435 |%n"
+ "|----------|-------|---------|----------------|-----------|--------------|-----------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream3.toString()).isEqualTo(String.format("[Change at index 3 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream3).hasToString(String.format("[Change at index 3 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|--------------|-------|---------|----------------|-----------|-----------|-----------------|------------|--------------------------------------|%n"
+ "| | | | | * | | | | |%n"
+ "| TYPE | TABLE | PRIMARY | | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -100,7 +100,7 @@ public void test_output() throws Exception {
+ "| MODIFICATION | ACTOR | 1 |----------------|-----------|-----------|-----------------|------------|--------------------------------------|%n"
+ "| | | | At end point | 1 | Weaver | Susan Alexandra | 1949-10-08 | 30b443ae-c0c9-4790-9bec-ce1380808435 |%n"
+ "|--------------|-------|---------|----------------|-----------|-----------|-----------------|------------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream4.toString()).isEqualTo(String.format("[Change at index 4 (on table : INTERPRETATION and with primary key : [3]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream4).hasToString(String.format("[Change at index 4 (on table : INTERPRETATION and with primary key : [3]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|--------------|----------------|---------|----------------|-----------|-----------|-----------|------------------------|%n"
+ "| | | | | * | | | |%n"
+ "| TYPE | TABLE | PRIMARY | | ID | ID_MOVIE | ID_ACTOR | CHARACTER |%n"
@@ -111,7 +111,7 @@ public void test_output() throws Exception {
+ "| MODIFICATION | INTERPRETATION | 3 |----------------|-----------|-----------|-----------|------------------------|%n"
+ "| | | | At end point | 3 | 3 | 1 | Doctor Grace Augustine |%n"
+ "|--------------|----------------|---------|----------------|-----------|-----------|-----------|------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream5.toString()).isEqualTo(String.format("[Change at index 5 (on table : MOVIE and with primary key : [3]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream5).hasToString(String.format("[Change at index 5 (on table : MOVIE and with primary key : [3]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|--------------|-------|---------|----------------|-----------|------------|-----------|--------------------------------------|%n"
+ "| | | | | * | | | |%n"
+ "| TYPE | TABLE | PRIMARY | | ID | TITLE | YEAR | MOVIE_IMDB |%n"
@@ -122,7 +122,7 @@ public void test_output() throws Exception {
+ "| MODIFICATION | MOVIE | 3 |----------------|-----------|------------|-----------|--------------------------------------|%n"
+ "| | | | At end point | 3 | The Avatar | 2009 | d735221b-5de5-4112-aa1e-49090cb75ada |%n"
+ "|--------------|-------|---------|----------------|-----------|------------|-----------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream6.toString()).isEqualTo(String.format("[Change at index 6 (on table : ACTOR and with primary key : [3]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream6).hasToString(String.format("[Change at index 6 (on table : ACTOR and with primary key : [3]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------|-------|---------|----------------|-----------|-------------|-----------|------------|--------------------------------------|%n"
+ "| | | | | * | | | | |%n"
+ "| TYPE | TABLE | PRIMARY | | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -133,7 +133,7 @@ public void test_output() throws Exception {
+ "| DELETION | ACTOR | 3 |----------------|-----------|-------------|-----------|------------|--------------------------------------|%n"
+ "| | | | At end point | | | | | |%n"
+ "|----------|-------|---------|----------------|-----------|-------------|-----------|------------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream7.toString()).isEqualTo(String.format("[Change at index 7 (on table : INTERPRETATION and with primary key : [5]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream7).hasToString(String.format("[Change at index 7 (on table : INTERPRETATION and with primary key : [5]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------|----------------|---------|----------------|-----------|-----------|-----------|------------|%n"
+ "| | | | | * | | | |%n"
+ "| TYPE | TABLE | PRIMARY | | ID | ID_MOVIE | ID_ACTOR | CHARACTER |%n"
diff --git a/src/test/java/org/assertj/db/output/OutputterChanges_Test.java b/src/test/java/org/assertj/db/output/OutputterChanges_Test.java
index cea4f6c1..787fb08a 100644
--- a/src/test/java/org/assertj/db/output/OutputterChanges_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterChanges_Test.java
@@ -36,13 +36,13 @@ public class OutputterChanges_Test extends AbstractTest {
@Test
@NeedReload
public void test_output() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
output(changes).toStream(byteArrayOutputStream);
- Assertions.assertThat(byteArrayOutputStream.toString()).isEqualTo(String.format("[Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream).hasToString(String.format("[Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|-----------|--------------|----------------|---------|----------------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | | | | | * | | | | |%n"
+ "| | TYPE | TABLE | PRIMARY | | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
diff --git a/src/test/java/org/assertj/db/output/OutputterColumn_Test.java b/src/test/java/org/assertj/db/output/OutputterColumn_Test.java
index 4959e768..5f47b318 100644
--- a/src/test/java/org/assertj/db/output/OutputterColumn_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterColumn_Test.java
@@ -37,7 +37,7 @@ public class OutputterColumn_Test extends AbstractTest {
*/
@Test
public void test_output_for_table() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream();
@@ -45,7 +45,7 @@ public void test_output_for_table() throws Exception {
Outputs.output(table).column().toStream(byteArrayOutputStream0)
.column(1).toStream(byteArrayOutputStream1)
.column().toStream(byteArrayOutputStream2);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Column at index 0 (column name : ID) of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Column at index 0 (column name : ID) of ACTOR table]%n"
+ "|-----------|----------|%n"
+ "| | ID |%n"
+ "| | (NUMBER) |%n"
@@ -54,7 +54,7 @@ public void test_output_for_table() throws Exception {
+ "| Index : 1 | 2 |%n"
+ "| Index : 2 | 3 |%n"
+ "|-----------|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Column at index 1 (column name : NAME) of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Column at index 1 (column name : NAME) of ACTOR table]%n"
+ "|-----------|-------------|%n"
+ "| | NAME |%n"
+ "| | (TEXT) |%n"
@@ -63,7 +63,7 @@ public void test_output_for_table() throws Exception {
+ "| Index : 1 | Phoenix |%n"
+ "| Index : 2 | Worthington |%n"
+ "|-----------|-------------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Column at index 2 (column name : FIRSTNAME) of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Column at index 2 (column name : FIRSTNAME) of ACTOR table]%n"
+ "|-----------|-----------|%n"
+ "| | FIRSTNAME |%n"
+ "| | (TEXT) |%n"
@@ -79,7 +79,7 @@ public void test_output_for_table() throws Exception {
*/
@Test
public void test_output_for_request() throws Exception {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream();
@@ -87,7 +87,7 @@ public void test_output_for_request() throws Exception {
Outputs.output(request).column().toStream(byteArrayOutputStream0)
.column(1).toStream(byteArrayOutputStream1)
.column().toStream(byteArrayOutputStream2);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Column at index 0 (column name : ID) of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Column at index 0 (column name : ID) of 'select * from actor' request]%n"
+ "|-----------|----------|%n"
+ "| | ID |%n"
+ "| | (NUMBER) |%n"
@@ -96,7 +96,7 @@ public void test_output_for_request() throws Exception {
+ "| Index : 1 | 2 |%n"
+ "| Index : 2 | 3 |%n"
+ "|-----------|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Column at index 1 (column name : NAME) of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Column at index 1 (column name : NAME) of 'select * from actor' request]%n"
+ "|-----------|-------------|%n"
+ "| | NAME |%n"
+ "| | (TEXT) |%n"
@@ -105,7 +105,7 @@ public void test_output_for_request() throws Exception {
+ "| Index : 1 | Phoenix |%n"
+ "| Index : 2 | Worthington |%n"
+ "|-----------|-------------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Column at index 2 (column name : FIRSTNAME) of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Column at index 2 (column name : FIRSTNAME) of 'select * from actor' request]%n"
+ "|-----------|-----------|%n"
+ "| | FIRSTNAME |%n"
+ "| | (TEXT) |%n"
@@ -122,7 +122,7 @@ public void test_output_for_request() throws Exception {
@Test
@NeedReload
public void test_output_for_change() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -132,7 +132,7 @@ public void test_output_for_change() throws Exception {
output(changes).change().column().toStream(byteArrayOutputStream0)
.column().toStream(byteArrayOutputStream1)
.column().toStream(byteArrayOutputStream2);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Column at index 0 (column name : ID) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Column at index 0 (column name : ID) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------------|----------|%n"
+ "| | ID |%n"
+ "| | (NUMBER) |%n"
@@ -141,7 +141,7 @@ public void test_output_for_change() throws Exception {
+ "|----------------|----------|%n"
+ "| At end point | 4 |%n"
+ "|----------------|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Column at index 1 (column name : NAME) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Column at index 1 (column name : NAME) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------------|--------|%n"
+ "| | NAME |%n"
+ "| | (TEXT) |%n"
@@ -150,7 +150,7 @@ public void test_output_for_change() throws Exception {
+ "|----------------|--------|%n"
+ "| At end point | Murray |%n"
+ "|----------------|--------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Column at index 2 (column name : FIRSTNAME) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Column at index 2 (column name : FIRSTNAME) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------------|-----------|%n"
+ "| | FIRSTNAME |%n"
+ "| | (TEXT) |%n"
diff --git a/src/test/java/org/assertj/db/output/OutputterException_Test.java b/src/test/java/org/assertj/db/output/OutputterException_Test.java
index 638ca9cc..93113aa2 100644
--- a/src/test/java/org/assertj/db/output/OutputterException_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterException_Test.java
@@ -39,7 +39,7 @@ public class OutputterException_Test extends AbstractTest {
*/
@Test
public void test_display_from_column_for_table() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
try {
Outputs.output(table).column(null);
@@ -63,7 +63,7 @@ public void test_display_from_column_for_table() throws Exception {
*/
@Test
public void test_display_from_column_for_request() throws Exception {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
try {
Outputs.output(request).column(null);
@@ -88,7 +88,7 @@ public void test_display_from_column_for_request() throws Exception {
@Test
@NeedReload
public void test_output_for_row_from_change() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -119,7 +119,7 @@ public void test_output_for_row_from_change() throws Exception {
*/
@Test
public void test_display_from_value_from_row_for_table() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
try {
Outputs.output(table).row().value(null);
@@ -143,7 +143,7 @@ public void test_display_from_value_from_row_for_table() throws Exception {
*/
@Test
public void test_display_from_value_from_row_for_request() throws Exception {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
try {
Outputs.output(request).row().value(null);
@@ -164,7 +164,7 @@ public void test_display_from_value_from_row_for_request() throws Exception {
@Test
public void test_display_to_file() {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
try {
Outputs.output(request).toFile("test" + File.separator + "test.txt");
diff --git a/src/test/java/org/assertj/db/output/OutputterRequest_Test.java b/src/test/java/org/assertj/db/output/OutputterRequest_Test.java
index ed25f40b..00ac7afa 100644
--- a/src/test/java/org/assertj/db/output/OutputterRequest_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterRequest_Test.java
@@ -34,11 +34,11 @@ public class OutputterRequest_Test extends AbstractTest {
*/
@Test
public void test_output() throws Exception {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
output(request).toStream(byteArrayOutputStream);
- Assertions.assertThat(byteArrayOutputStream.toString()).isEqualTo(String.format("['select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream).hasToString(String.format("['select * from actor' request]%n"
+ "|-----------|---------|-----------|-------------|-----------|------------|--------------------------------------|%n"
+ "| | | | | | | |%n"
+ "| | PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -56,7 +56,7 @@ public void test_output() throws Exception {
*/
@Test
public void test_navigation() throws Exception {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
RequestOutputter requestOutputter = output(request);
diff --git a/src/test/java/org/assertj/db/output/OutputterRow_Test.java b/src/test/java/org/assertj/db/output/OutputterRow_Test.java
index 10e35b61..85453164 100644
--- a/src/test/java/org/assertj/db/output/OutputterRow_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterRow_Test.java
@@ -37,7 +37,7 @@ public class OutputterRow_Test extends AbstractTest {
*/
@Test
public void test_output_for_table() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream();
@@ -45,7 +45,7 @@ public void test_output_for_table() throws Exception {
Outputs.output(table).row().toStream(byteArrayOutputStream0)
.row(1).toStream(byteArrayOutputStream1)
.row().toStream(byteArrayOutputStream2);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Row at index 0 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Row at index 0 of ACTOR table]%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | * | | | | |%n"
+ "| PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -54,7 +54,7 @@ public void test_output_for_table() throws Exception {
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| 1 | 1 | Weaver | Sigourney | 1949-10-08 | 30b443ae-c0c9-4790-9bec-ce1380808435 |%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Row at index 1 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Row at index 1 of ACTOR table]%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | * | | | | |%n"
+ "| PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -63,7 +63,7 @@ public void test_output_for_table() throws Exception {
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| 2 | 2 | Phoenix | Joaquim | 1974-10-28 | 16319617-ae95-4087-9264-d3d21bf611b6 |%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Row at index 2 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Row at index 2 of ACTOR table]%n"
+ "|---------|-----------|-------------|-----------|------------|--------------------------------------|%n"
+ "| | * | | | | |%n"
+ "| PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -79,7 +79,7 @@ public void test_output_for_table() throws Exception {
*/
@Test
public void test_output_for_request() throws Exception {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream();
@@ -87,7 +87,7 @@ public void test_output_for_request() throws Exception {
Outputs.output(request).row().toStream(byteArrayOutputStream0)
.row(1).toStream(byteArrayOutputStream1)
.row().toStream(byteArrayOutputStream2);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Row at index 0 of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Row at index 0 of 'select * from actor' request]%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | | | | | |%n"
+ "| PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -96,7 +96,7 @@ public void test_output_for_request() throws Exception {
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | 1 | Weaver | Sigourney | 1949-10-08 | 30b443ae-c0c9-4790-9bec-ce1380808435 |%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Row at index 1 of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Row at index 1 of 'select * from actor' request]%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | | | | | |%n"
+ "| PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -105,7 +105,7 @@ public void test_output_for_request() throws Exception {
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | 2 | Phoenix | Joaquim | 1974-10-28 | 16319617-ae95-4087-9264-d3d21bf611b6 |%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Row at index 2 of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Row at index 2 of 'select * from actor' request]%n"
+ "|---------|-----------|-------------|-----------|------------|--------------------------------------|%n"
+ "| | | | | | |%n"
+ "| PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -122,7 +122,7 @@ public void test_output_for_request() throws Exception {
@Test
@NeedReload
public void test_output_for_change() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -132,9 +132,9 @@ public void test_output_for_change() throws Exception {
output(changes).change().rowAtStartPoint().toStream(byteArrayOutputStream0)
.rowAtEndPoint().toStream(byteArrayOutputStream1)
.changeOfModification().rowAtStartPoint().toStream(byteArrayOutputStream2);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Row at start point of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Row at start point of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "Row does not exist%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Row at end point of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Row at end point of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | * | | | | |%n"
+ "| PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -143,7 +143,7 @@ public void test_output_for_change() throws Exception {
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| 4 | 4 | Murray | Bill | 1950-09-21 | 30b443ae-c0c9-4790-9bec-ce1380808435 |%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Row at start point of Change at index 0 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test' (only modification changes)]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Row at start point of Change at index 0 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test' (only modification changes)]%n"
+ "|---------|-----------|-----------|-----------|------------|--------------------------------------|%n"
+ "| | * | | | | |%n"
+ "| PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
diff --git a/src/test/java/org/assertj/db/output/OutputterTable_Test.java b/src/test/java/org/assertj/db/output/OutputterTable_Test.java
index 8fa8d8c4..c61d0abf 100644
--- a/src/test/java/org/assertj/db/output/OutputterTable_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterTable_Test.java
@@ -34,11 +34,11 @@ public class OutputterTable_Test extends AbstractTest {
*/
@Test
public void test_output() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
output(table).toStream(byteArrayOutputStream);
- Assertions.assertThat(byteArrayOutputStream.toString()).isEqualTo(String.format("[ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream).hasToString(String.format("[ACTOR table]%n"
+ "|-----------|---------|-----------|-------------|-----------|------------|--------------------------------------|%n"
+ "| | | * | | | | |%n"
+ "| | PRIMARY | ID | NAME | FIRSTNAME | BIRTH | ACTOR_IMDB |%n"
@@ -56,7 +56,7 @@ public void test_output() throws Exception {
*/
@Test
public void test_navigation() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
TableOutputter tableOutputter = output(table);
diff --git a/src/test/java/org/assertj/db/output/OutputterToConsole_Test.java b/src/test/java/org/assertj/db/output/OutputterToConsole_Test.java
index defa44ca..1f97b9d3 100644
--- a/src/test/java/org/assertj/db/output/OutputterToConsole_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterToConsole_Test.java
@@ -33,13 +33,13 @@ public class OutputterToConsole_Test extends AbstractTest {
*/
@Test
public void test_output_to_console() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
System.setOut(new PrintStream(byteArrayOutputStream0));
Outputs.output(table).row().value().toConsole();
System.setOut(System.out);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Value at index 0 (column name : ID) of Row at index 0 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Value at index 0 (column name : ID) of Row at index 0 of ACTOR table]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
diff --git a/src/test/java/org/assertj/db/output/OutputterToFile_Test.java b/src/test/java/org/assertj/db/output/OutputterToFile_Test.java
index fe4e2d68..957d11d4 100644
--- a/src/test/java/org/assertj/db/output/OutputterToFile_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterToFile_Test.java
@@ -34,7 +34,7 @@ public class OutputterToFile_Test extends AbstractTest {
*/
@Test
public void test_output_to_file() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
Outputs.output(table).row().value().toFile("target" + File.separator + "test.txt");
try (InputStream inputStream = new FileInputStream(new File("target" + File.separator + "test.txt"))) {
diff --git a/src/test/java/org/assertj/db/output/OutputterToStream_Test.java b/src/test/java/org/assertj/db/output/OutputterToStream_Test.java
index 55d7e2b0..9530f26f 100644
--- a/src/test/java/org/assertj/db/output/OutputterToStream_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterToStream_Test.java
@@ -32,11 +32,11 @@ public class OutputterToStream_Test extends AbstractTest {
*/
@Test
public void test_output_to_stream() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
Outputs.output(table).row().value().toStream(byteArrayOutputStream0);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Value at index 0 (column name : ID) of Row at index 0 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Value at index 0 (column name : ID) of Row at index 0 of ACTOR table]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
diff --git a/src/test/java/org/assertj/db/output/OutputterValue_Test.java b/src/test/java/org/assertj/db/output/OutputterValue_Test.java
index 635cd8bf..75888eda 100644
--- a/src/test/java/org/assertj/db/output/OutputterValue_Test.java
+++ b/src/test/java/org/assertj/db/output/OutputterValue_Test.java
@@ -37,7 +37,7 @@ public class OutputterValue_Test extends AbstractTest {
*/
@Test
public void test_output_for_row_from_table() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream();
@@ -47,28 +47,28 @@ public void test_output_for_row_from_table() throws Exception {
.value(1).toStream(byteArrayOutputStream1)
.value().toStream(byteArrayOutputStream2)
.row(2).value(2).toStream(byteArrayOutputStream3);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Value at index 0 (column name : ID) of Row at index 0 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Value at index 0 (column name : ID) of Row at index 0 of ACTOR table]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 1 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Value at index 1 (column name : NAME) of Row at index 0 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Value at index 1 (column name : NAME) of Row at index 0 of ACTOR table]%n"
+ "|--------|%n"
+ "| NAME |%n"
+ "| (TEXT) |%n"
+ "|--------|%n"
+ "| Weaver |%n"
+ "|--------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at index 0 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at index 0 of ACTOR table]%n"
+ "|-----------|%n"
+ "| FIRSTNAME |%n"
+ "| (TEXT) |%n"
+ "|-----------|%n"
+ "| Sigourney |%n"
+ "|-----------|%n"));
- Assertions.assertThat(byteArrayOutputStream3.toString()).isEqualTo(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at index 2 of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream3).hasToString(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at index 2 of ACTOR table]%n"
+ "|-----------|%n"
+ "| FIRSTNAME |%n"
+ "| (TEXT) |%n"
@@ -82,7 +82,7 @@ public void test_output_for_row_from_table() throws Exception {
*/
@Test
public void test_output_for_row_from_request() throws Exception {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream();
@@ -92,28 +92,28 @@ public void test_output_for_row_from_request() throws Exception {
.value(1).toStream(byteArrayOutputStream1)
.value().toStream(byteArrayOutputStream2)
.row(2).value(2).toStream(byteArrayOutputStream3);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Value at index 0 (column name : ID) of Row at index 0 of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Value at index 0 (column name : ID) of Row at index 0 of 'select * from actor' request]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 1 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Value at index 1 (column name : NAME) of Row at index 0 of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Value at index 1 (column name : NAME) of Row at index 0 of 'select * from actor' request]%n"
+ "|--------|%n"
+ "| NAME |%n"
+ "| (TEXT) |%n"
+ "|--------|%n"
+ "| Weaver |%n"
+ "|--------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at index 0 of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at index 0 of 'select * from actor' request]%n"
+ "|-----------|%n"
+ "| FIRSTNAME |%n"
+ "| (TEXT) |%n"
+ "|-----------|%n"
+ "| Sigourney |%n"
+ "|-----------|%n"));
- Assertions.assertThat(byteArrayOutputStream3.toString()).isEqualTo(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at index 2 of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream3).hasToString(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at index 2 of 'select * from actor' request]%n"
+ "|-----------|%n"
+ "| FIRSTNAME |%n"
+ "| (TEXT) |%n"
@@ -128,7 +128,7 @@ public void test_output_for_row_from_request() throws Exception {
@Test
@NeedReload
public void test_output_for_row_from_change() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -140,28 +140,28 @@ public void test_output_for_row_from_change() throws Exception {
.changeOfModification().rowAtStartPoint().value().toStream(byteArrayOutputStream1)
.rowAtEndPoint().value().toStream(byteArrayOutputStream2)
.value("firstname").toStream(byteArrayOutputStream3);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Value at index 0 (column name : ID) of Row at end point of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Value at index 0 (column name : ID) of Row at end point of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 4 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Value at index 0 (column name : ID) of Row at start point of Change at index 0 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test' (only modification changes)]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Value at index 0 (column name : ID) of Row at start point of Change at index 0 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test' (only modification changes)]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 1 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Value at index 0 (column name : ID) of Row at end point of Change at index 0 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test' (only modification changes)]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Value at index 0 (column name : ID) of Row at end point of Change at index 0 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test' (only modification changes)]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 1 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream3.toString()).isEqualTo(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at end point of Change at index 0 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test' (only modification changes)]%n"
+ Assertions.assertThat(byteArrayOutputStream3).hasToString(String.format("[Value at index 2 (column name : FIRSTNAME) of Row at end point of Change at index 0 (on table : ACTOR and with primary key : [1]) of Changes on tables of 'sa/jdbc:h2:mem:test' (only modification changes)]%n"
+ "|-----------------|%n"
+ "| FIRSTNAME |%n"
+ "| (TEXT) |%n"
@@ -175,7 +175,7 @@ public void test_output_for_row_from_change() throws Exception {
*/
@Test
public void test_output_for_column_from_table() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "actor");
+ Table table = assertDbConnection.table("actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream();
@@ -185,28 +185,28 @@ public void test_output_for_column_from_table() throws Exception {
.value(1).toStream(byteArrayOutputStream1)
.value().toStream(byteArrayOutputStream2)
.column("name").value(2).toStream(byteArrayOutputStream3);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Value at index 0 of Column at index 0 (column name : ID) of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Value at index 0 of Column at index 0 (column name : ID) of ACTOR table]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 1 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Value at index 1 of Column at index 0 (column name : ID) of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Value at index 1 of Column at index 0 (column name : ID) of ACTOR table]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 2 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Value at index 2 of Column at index 0 (column name : ID) of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Value at index 2 of Column at index 0 (column name : ID) of ACTOR table]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 3 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream3.toString()).isEqualTo(String.format("[Value at index 2 of Column at index 1 (column name : NAME) of ACTOR table]%n"
+ Assertions.assertThat(byteArrayOutputStream3).hasToString(String.format("[Value at index 2 of Column at index 1 (column name : NAME) of ACTOR table]%n"
+ "|-------------|%n"
+ "| NAME |%n"
+ "| (TEXT) |%n"
@@ -220,7 +220,7 @@ public void test_output_for_column_from_table() throws Exception {
*/
@Test
public void test_output_for_column_from_request() throws Exception {
- Request request = new Request(jdbcConnectionProvider, "select * from actor");
+ Request request = assertDbConnection.request("select * from actor").build();
ByteArrayOutputStream byteArrayOutputStream0 = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream();
@@ -230,7 +230,7 @@ public void test_output_for_column_from_request() throws Exception {
.value(1).toStream(byteArrayOutputStream1)
.value().toStream(byteArrayOutputStream2)
.column("name").value(2).toStream(byteArrayOutputStream3);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format(
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format(
"[Value at index 0 of Column at index 0 (column name : ID) of 'select * from actor' request]%n"
+ "|----------|%n"
+ "| ID |%n"
@@ -238,21 +238,21 @@ public void test_output_for_column_from_request() throws Exception {
+ "|----------|%n"
+ "| 1 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Value at index 1 of Column at index 0 (column name : ID) of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Value at index 1 of Column at index 0 (column name : ID) of 'select * from actor' request]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 2 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Value at index 2 of Column at index 0 (column name : ID) of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Value at index 2 of Column at index 0 (column name : ID) of 'select * from actor' request]%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 3 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream3.toString()).isEqualTo(String.format("[Value at index 2 of Column at index 1 (column name : NAME) of 'select * from actor' request]%n"
+ Assertions.assertThat(byteArrayOutputStream3).hasToString(String.format("[Value at index 2 of Column at index 1 (column name : NAME) of 'select * from actor' request]%n"
+ "|-------------|%n"
+ "| NAME |%n"
+ "| (TEXT) |%n"
@@ -267,7 +267,7 @@ public void test_output_for_column_from_request() throws Exception {
@Test
@NeedReload
public void test_output_for_column_from_change() throws Exception {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -277,21 +277,21 @@ public void test_output_for_column_from_change() throws Exception {
output(changes).change().column().valueAtStartPoint().toStream(byteArrayOutputStream0)
.valueAtEndPoint().toStream(byteArrayOutputStream1)
.column().valueAtEndPoint().toStream(byteArrayOutputStream2);
- Assertions.assertThat(byteArrayOutputStream0.toString()).isEqualTo(String.format("[Value at start point of Column at index 0 (column name : ID) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream0).hasToString(String.format("[Value at start point of Column at index 0 (column name : ID) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|------------------|%n"
+ "| ID |%n"
+ "| (NOT_IDENTIFIED) |%n"
+ "|------------------|%n"
+ "| null |%n"
+ "|------------------|%n"));
- Assertions.assertThat(byteArrayOutputStream1.toString()).isEqualTo(String.format("[Value at end point of Column at index 0 (column name : ID) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream1).hasToString(String.format("[Value at end point of Column at index 0 (column name : ID) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|----------|%n"
+ "| ID |%n"
+ "| (NUMBER) |%n"
+ "|----------|%n"
+ "| 4 |%n"
+ "|----------|%n"));
- Assertions.assertThat(byteArrayOutputStream2.toString()).isEqualTo(String.format("[Value at end point of Column at index 1 (column name : NAME) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ Assertions.assertThat(byteArrayOutputStream2).hasToString(String.format("[Value at end point of Column at index 1 (column name : NAME) of Change at index 0 (on table : ACTOR and with primary key : [4]) of Changes on tables of 'sa/jdbc:h2:mem:test']%n"
+ "|--------|%n"
+ "| NAME |%n"
+ "| (TEXT) |%n"
diff --git a/src/test/java/org/assertj/db/type/CachedSchemaMetaData_Test.java b/src/test/java/org/assertj/db/type/CachedSchemaMetaData_Test.java
index f1d5d61d..9dc6e478 100644
--- a/src/test/java/org/assertj/db/type/CachedSchemaMetaData_Test.java
+++ b/src/test/java/org/assertj/db/type/CachedSchemaMetaData_Test.java
@@ -12,16 +12,14 @@
*/
package org.assertj.db.type;
-import org.assertj.db.common.AbstractTest;
-import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
-import javax.xml.validation.Schema;
-import java.sql.Time;
-import java.text.ParseException;
-import java.time.LocalTime;
-import java.util.Calendar;
+import java.sql.DriverManager;
+import java.sql.SQLException;
-import static org.assertj.core.api.Assertions.assertThat;
+import org.assertj.db.common.AbstractTest;
+import org.assertj.db.common.DefaultConnectionProvider;
+import org.junit.Test;
/**
* Tests on the cached schema metadata.
@@ -30,21 +28,27 @@
*/
public class CachedSchemaMetaData_Test extends AbstractTest {
+ final DefaultConnectionProvider provider;
+
+ public CachedSchemaMetaData_Test() throws SQLException {
+ this.provider = new DefaultConnectionProvider(DriverManager.getConnection("jdbc:h2:mem:test", "sa", ""));
+ }
+
@Test
public void test_get_tables() {
- CachedSchemaMetaData metaData = new CachedSchemaMetaData(jdbcConnectionProvider);
+ CachedSchemaMetaData metaData = new CachedSchemaMetaData(provider);
assertThat(metaData.getTablesName()).containsExactly("ACTOR", "INTERPRETATION", "MOVIE", "TEST", "TEST2");
}
@Test
public void test_get_columns() {
- CachedSchemaMetaData metaData = new CachedSchemaMetaData(jdbcConnectionProvider);
+ CachedSchemaMetaData metaData = new CachedSchemaMetaData(provider);
assertThat(metaData.getColumnsName("ACTOR")).containsExactly("ID", "NAME", "FIRSTNAME", "BIRTH", "ACTOR_IMDB");
}
@Test
public void test_get_primary_keys() {
- CachedSchemaMetaData metaData = new CachedSchemaMetaData(jdbcConnectionProvider);
+ CachedSchemaMetaData metaData = new CachedSchemaMetaData(provider);
assertThat(metaData.getPrimaryKeys("ACTOR")).containsExactly("ID");
}
}
diff --git a/src/test/java/org/assertj/db/type/Change_Exception_Test.java b/src/test/java/org/assertj/db/type/Change_Exception_Test.java
index 5fbf6054..13c690f7 100644
--- a/src/test/java/org/assertj/db/type/Change_Exception_Test.java
+++ b/src/test/java/org/assertj/db/type/Change_Exception_Test.java
@@ -19,7 +19,7 @@
import org.junit.Test;
/**
- * Tests on the exceptions of Change
+ * Tests on the exceptions to the Change
*
* @author RĂ©gis Pouiller
*/
diff --git a/src/test/java/org/assertj/db/type/Change_GetDataType_Test.java b/src/test/java/org/assertj/db/type/Change_GetDataType_Test.java
index 28ab6c3c..f2892a68 100644
--- a/src/test/java/org/assertj/db/type/Change_GetDataType_Test.java
+++ b/src/test/java/org/assertj/db/type/Change_GetDataType_Test.java
@@ -32,7 +32,7 @@ public class Change_GetDataType_Test extends AbstractTest {
@Test
@NeedReload
public void test_getDataTypeOfTable() {
- Changes changes = new Changes(jdbcConnectionProvider).setStartPointNow();
+ Changes changes = assertDbConnection.changes().build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
@@ -45,7 +45,7 @@ public void test_getDataTypeOfTable() {
@Test
@NeedReload
public void test_getDataTypeOfRequest() {
- Changes changes = new Changes(new Request(jdbcConnectionProvider, "select * from movie")).setStartPointNow();
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from movie").build()).build().setStartPointNow();
updateChangesForTests();
changes.setEndPointNow();
diff --git a/src/test/java/org/assertj/db/type/Changes_Constructor_Test.java b/src/test/java/org/assertj/db/type/Changes_Constructor_Test.java
index 97ac7e0d..0a88f6f7 100644
--- a/src/test/java/org/assertj/db/type/Changes_Constructor_Test.java
+++ b/src/test/java/org/assertj/db/type/Changes_Constructor_Test.java
@@ -30,7 +30,7 @@ public class Changes_Constructor_Test extends AbstractTest {
*/
@Test
public void test_constructor_jdbc() {
- Changes changes = new Changes(jdbcConnectionProvider);
+ Changes changes = assertDbConnection.changes().build();
assertThat(changes.getRequestAtStartPoint()).isNull();
assertThat(changes.getRequestAtEndPoint()).isNull();
@@ -43,19 +43,19 @@ public void test_constructor_jdbc() {
assertThat(changes.getRequestAtEndPoint()).isNull();
assertThat(changes.getTablesAtStartPointList()).isNotNull();
assertThat(changes.getTablesAtStartPointList()).hasSize(5);
- assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(0).getName()).isEqualTo("ACTOR");
assertThat(changes.getTablesAtStartPointList().get(0).getRequest()).isEqualTo("SELECT * FROM ACTOR");
- assertThat(changes.getTablesAtStartPointList().get(1).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(1).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(1).getName()).isEqualTo("INTERPRETATION");
assertThat(changes.getTablesAtStartPointList().get(1).getRequest()).isEqualTo("SELECT * FROM INTERPRETATION");
- assertThat(changes.getTablesAtStartPointList().get(2).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(2).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(2).getName()).isEqualTo("MOVIE");
assertThat(changes.getTablesAtStartPointList().get(2).getRequest()).isEqualTo("SELECT * FROM MOVIE");
- assertThat(changes.getTablesAtStartPointList().get(3).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(3).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(3).getName()).isEqualTo("TEST");
assertThat(changes.getTablesAtStartPointList().get(3).getRequest()).isEqualTo("SELECT * FROM TEST");
- assertThat(changes.getTablesAtStartPointList().get(4).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(4).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(4).getName()).isEqualTo("TEST2");
assertThat(changes.getTablesAtStartPointList().get(4).getRequest()).isEqualTo("SELECT * FROM TEST2");
assertThat(changes.getTablesAtEndPointList()).isNull();
@@ -66,111 +66,36 @@ public void test_constructor_jdbc() {
assertThat(changes.getRequestAtEndPoint()).isNull();
assertThat(changes.getTablesAtStartPointList()).isNotNull();
assertThat(changes.getTablesAtStartPointList()).hasSize(5);
- assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(0).getName()).isEqualTo("ACTOR");
assertThat(changes.getTablesAtStartPointList().get(0).getRequest()).isEqualTo("SELECT * FROM ACTOR");
- assertThat(changes.getTablesAtStartPointList().get(1).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(1).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(1).getName()).isEqualTo("INTERPRETATION");
assertThat(changes.getTablesAtStartPointList().get(1).getRequest()).isEqualTo("SELECT * FROM INTERPRETATION");
- assertThat(changes.getTablesAtStartPointList().get(2).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(2).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(2).getName()).isEqualTo("MOVIE");
assertThat(changes.getTablesAtStartPointList().get(2).getRequest()).isEqualTo("SELECT * FROM MOVIE");
- assertThat(changes.getTablesAtStartPointList().get(3).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(3).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(3).getName()).isEqualTo("TEST");
assertThat(changes.getTablesAtStartPointList().get(3).getRequest()).isEqualTo("SELECT * FROM TEST");
- assertThat(changes.getTablesAtStartPointList().get(4).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(4).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(4).getName()).isEqualTo("TEST2");
assertThat(changes.getTablesAtStartPointList().get(4).getRequest()).isEqualTo("SELECT * FROM TEST2");
assertThat(changes.getTablesAtEndPointList()).isNotNull();
assertThat(changes.getTablesAtEndPointList()).hasSize(5);
- assertThat(changes.getTablesAtEndPointList().get(0).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtEndPointList().get(0).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtEndPointList().get(0).getName()).isEqualTo("ACTOR");
assertThat(changes.getTablesAtEndPointList().get(0).getRequest()).isEqualTo("SELECT * FROM ACTOR");
- assertThat(changes.getTablesAtEndPointList().get(1).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtEndPointList().get(1).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtEndPointList().get(1).getName()).isEqualTo("INTERPRETATION");
assertThat(changes.getTablesAtEndPointList().get(1).getRequest()).isEqualTo("SELECT * FROM INTERPRETATION");
- assertThat(changes.getTablesAtEndPointList().get(2).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtEndPointList().get(2).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtEndPointList().get(2).getName()).isEqualTo("MOVIE");
assertThat(changes.getTablesAtEndPointList().get(2).getRequest()).isEqualTo("SELECT * FROM MOVIE");
- assertThat(changes.getTablesAtEndPointList().get(3).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtEndPointList().get(3).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtEndPointList().get(3).getName()).isEqualTo("TEST");
assertThat(changes.getTablesAtEndPointList().get(3).getRequest()).isEqualTo("SELECT * FROM TEST");
- assertThat(changes.getTablesAtEndPointList().get(4).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
- assertThat(changes.getTablesAtEndPointList().get(4).getName()).isEqualTo("TEST2");
- assertThat(changes.getTablesAtEndPointList().get(4).getRequest()).isEqualTo("SELECT * FROM TEST2");
- }
-
- /**
- * This method test the constructor with datasource.
- */
- @Test
- public void test_constructor_datasource() {
- Changes changes = new Changes(dsConnectionProvider);
-
- assertThat(changes.getRequestAtStartPoint()).isNull();
- assertThat(changes.getRequestAtEndPoint()).isNull();
- assertThat(changes.getTablesAtStartPointList()).isNull();
- assertThat(changes.getTablesAtEndPointList()).isNull();
-
- changes.setStartPointNow();
-
- assertThat(changes.getRequestAtStartPoint()).isNull();
- assertThat(changes.getRequestAtEndPoint()).isNull();
- assertThat(changes.getTablesAtStartPointList()).isNotNull();
- assertThat(changes.getTablesAtStartPointList()).hasSize(5);
- assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(0).getName()).isEqualTo("ACTOR");
- assertThat(changes.getTablesAtStartPointList().get(0).getRequest()).isEqualTo("SELECT * FROM ACTOR");
- assertThat(changes.getTablesAtStartPointList().get(1).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(1).getName()).isEqualTo("INTERPRETATION");
- assertThat(changes.getTablesAtStartPointList().get(1).getRequest()).isEqualTo("SELECT * FROM INTERPRETATION");
- assertThat(changes.getTablesAtStartPointList().get(2).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(2).getName()).isEqualTo("MOVIE");
- assertThat(changes.getTablesAtStartPointList().get(2).getRequest()).isEqualTo("SELECT * FROM MOVIE");
- assertThat(changes.getTablesAtStartPointList().get(3).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(3).getName()).isEqualTo("TEST");
- assertThat(changes.getTablesAtStartPointList().get(3).getRequest()).isEqualTo("SELECT * FROM TEST");
- assertThat(changes.getTablesAtStartPointList().get(4).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(4).getName()).isEqualTo("TEST2");
- assertThat(changes.getTablesAtStartPointList().get(4).getRequest()).isEqualTo("SELECT * FROM TEST2");
- assertThat(changes.getTablesAtEndPointList()).isNull();
-
- changes.setEndPointNow();
-
- assertThat(changes.getRequestAtStartPoint()).isNull();
- assertThat(changes.getRequestAtEndPoint()).isNull();
- assertThat(changes.getTablesAtStartPointList()).isNotNull();
- assertThat(changes.getTablesAtStartPointList()).hasSize(5);
- assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(0).getName()).isEqualTo("ACTOR");
- assertThat(changes.getTablesAtStartPointList().get(0).getRequest()).isEqualTo("SELECT * FROM ACTOR");
- assertThat(changes.getTablesAtStartPointList().get(1).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(1).getName()).isEqualTo("INTERPRETATION");
- assertThat(changes.getTablesAtStartPointList().get(1).getRequest()).isEqualTo("SELECT * FROM INTERPRETATION");
- assertThat(changes.getTablesAtStartPointList().get(2).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(2).getName()).isEqualTo("MOVIE");
- assertThat(changes.getTablesAtStartPointList().get(2).getRequest()).isEqualTo("SELECT * FROM MOVIE");
- assertThat(changes.getTablesAtStartPointList().get(3).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(3).getName()).isEqualTo("TEST");
- assertThat(changes.getTablesAtStartPointList().get(3).getRequest()).isEqualTo("SELECT * FROM TEST");
- assertThat(changes.getTablesAtStartPointList().get(4).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtStartPointList().get(4).getName()).isEqualTo("TEST2");
- assertThat(changes.getTablesAtStartPointList().get(4).getRequest()).isEqualTo("SELECT * FROM TEST2");
- assertThat(changes.getTablesAtEndPointList()).isNotNull();
- assertThat(changes.getTablesAtEndPointList()).hasSize(5);
- assertThat(changes.getTablesAtEndPointList().get(0).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtEndPointList().get(0).getName()).isEqualTo("ACTOR");
- assertThat(changes.getTablesAtEndPointList().get(0).getRequest()).isEqualTo("SELECT * FROM ACTOR");
- assertThat(changes.getTablesAtEndPointList().get(1).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtEndPointList().get(1).getName()).isEqualTo("INTERPRETATION");
- assertThat(changes.getTablesAtEndPointList().get(1).getRequest()).isEqualTo("SELECT * FROM INTERPRETATION");
- assertThat(changes.getTablesAtEndPointList().get(2).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtEndPointList().get(2).getName()).isEqualTo("MOVIE");
- assertThat(changes.getTablesAtEndPointList().get(2).getRequest()).isEqualTo("SELECT * FROM MOVIE");
- assertThat(changes.getTablesAtEndPointList().get(3).getConnectionProvider()).isSameAs(dsConnectionProvider);
- assertThat(changes.getTablesAtEndPointList().get(3).getName()).isEqualTo("TEST");
- assertThat(changes.getTablesAtEndPointList().get(3).getRequest()).isEqualTo("SELECT * FROM TEST");
- assertThat(changes.getTablesAtEndPointList().get(4).getConnectionProvider()).isSameAs(dsConnectionProvider);
+ assertThat(changes.getTablesAtEndPointList().get(4).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtEndPointList().get(4).getName()).isEqualTo("TEST2");
assertThat(changes.getTablesAtEndPointList().get(4).getRequest()).isEqualTo("SELECT * FROM TEST2");
}
@@ -180,7 +105,7 @@ public void test_constructor_datasource() {
*/
@Test
public void test_constructor_one_table() {
- Changes changes = new Changes(new Table(jdbcConnectionProvider, "test"));
+ Changes changes = assertDbConnection.changes().tables(assertDbConnection.table("test").build()).build();
assertThat(changes.getRequestAtStartPoint()).isNull();
assertThat(changes.getRequestAtEndPoint()).isNull();
@@ -189,7 +114,8 @@ public void test_constructor_one_table() {
changes.setStartPointNow();
assertThat(changes.getTablesAtStartPointList()).isNotNull();
assertThat(changes.getTablesAtStartPointList()).hasSize(1);
- assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isNotNull();
+ assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(0).getName()).isEqualTo("TEST");
assertThat(changes.getTablesAtStartPointList().get(0).getRequest()).isEqualTo("SELECT * FROM TEST");
@@ -197,7 +123,7 @@ public void test_constructor_one_table() {
changes.setEndPointNow();
assertThat(changes.getTablesAtEndPointList()).isNotNull();
assertThat(changes.getTablesAtEndPointList()).hasSize(1);
- assertThat(changes.getTablesAtEndPointList().get(0).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtEndPointList().get(0).getConnectionProvider()).isNotNull();
assertThat(changes.getTablesAtEndPointList().get(0).getName()).isEqualTo("TEST");
assertThat(changes.getTablesAtEndPointList().get(0).getRequest()).isEqualTo("SELECT * FROM TEST");
}
@@ -207,7 +133,9 @@ public void test_constructor_one_table() {
*/
@Test
public void test_constructor_two_tables() {
- Changes changes = new Changes(new Table(jdbcConnectionProvider, "test"), new Table(dsConnectionProvider, "test2"));
+ Changes changes = assertDbConnection.changes()
+ .tables(assertDbConnection.table("test").build(), assertDbConnection.table("test2").build())
+ .build();
assertThat(changes.getRequestAtStartPoint()).isNull();
assertThat(changes.getRequestAtEndPoint()).isNull();
@@ -216,10 +144,10 @@ public void test_constructor_two_tables() {
changes.setStartPointNow();
assertThat(changes.getTablesAtStartPointList()).isNotNull();
assertThat(changes.getTablesAtStartPointList()).hasSize(2);
- assertThat(changes.getTablesAtStartPointList().get(0).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(0)).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(0).getName()).isEqualTo("TEST");
assertThat(changes.getTablesAtStartPointList().get(0).getRequest()).isEqualTo("SELECT * FROM TEST");
- assertThat(changes.getTablesAtStartPointList().get(1).getConnectionProvider()).isSameAs(dsConnectionProvider);
+ assertThat(changes.getTablesAtStartPointList().get(1).getName()).isNotNull();
assertThat(changes.getTablesAtStartPointList().get(1).getName()).isEqualTo("TEST2");
assertThat(changes.getTablesAtStartPointList().get(1).getRequest()).isEqualTo("SELECT * FROM TEST2");
@@ -227,10 +155,10 @@ public void test_constructor_two_tables() {
changes.setEndPointNow();
assertThat(changes.getTablesAtEndPointList()).isNotNull();
assertThat(changes.getTablesAtEndPointList()).hasSize(2);
- assertThat(changes.getTablesAtEndPointList().get(0).getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getTablesAtEndPointList().get(0).getName()).isNotNull();
assertThat(changes.getTablesAtEndPointList().get(0).getName()).isEqualTo("TEST");
assertThat(changes.getTablesAtEndPointList().get(0).getRequest()).isEqualTo("SELECT * FROM TEST");
- assertThat(changes.getTablesAtEndPointList().get(1).getConnectionProvider()).isSameAs(dsConnectionProvider);
+ assertThat(changes.getTablesAtEndPointList().get(1).getName()).isNotNull();
assertThat(changes.getTablesAtEndPointList().get(1).getName()).isEqualTo("TEST2");
assertThat(changes.getTablesAtEndPointList().get(1).getRequest()).isEqualTo("SELECT * FROM TEST2");
}
@@ -240,7 +168,7 @@ public void test_constructor_two_tables() {
*/
@Test
public void test_constructor_request() {
- Changes changes = new Changes(new Request(jdbcConnectionProvider, "select * from test"));
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from test").build()).build();
assertThat(changes.getRequestAtStartPoint()).isNull();
assertThat(changes.getRequestAtEndPoint()).isNull();
@@ -250,7 +178,7 @@ public void test_constructor_request() {
changes.setStartPointNow();
assertThat(changes.getRequestAtStartPoint()).isNotNull();
- assertThat(changes.getRequestAtStartPoint().getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getRequestAtStartPoint().getConnectionProvider()).isNotNull();
assertThat(changes.getRequestAtStartPoint().getRequest()).isEqualTo("select * from test");
assertThat(changes.getRequestAtEndPoint()).isNull();
assertThat(changes.getTablesAtStartPointList()).isNull();
@@ -260,7 +188,7 @@ public void test_constructor_request() {
assertThat(changes.getRequestAtStartPoint()).isNotNull();
assertThat(changes.getRequestAtEndPoint()).isNotNull();
- assertThat(changes.getRequestAtEndPoint().getConnectionProvider()).isSameAs(jdbcConnectionProvider);
+ assertThat(changes.getRequestAtEndPoint().getConnectionProvider()).isNotNull();
assertThat(changes.getRequestAtEndPoint().getRequest()).isEqualTo("select * from test");
assertThat(changes.getTablesAtStartPointList()).isNull();
assertThat(changes.getTablesAtEndPointList()).isNull();
diff --git a/src/test/java/org/assertj/db/type/Changes_Exception_Test.java b/src/test/java/org/assertj/db/type/Changes_Exception_Test.java
index adfe4d7d..65021d2e 100644
--- a/src/test/java/org/assertj/db/type/Changes_Exception_Test.java
+++ b/src/test/java/org/assertj/db/type/Changes_Exception_Test.java
@@ -39,9 +39,9 @@ public class Changes_Exception_Test extends AbstractTest {
*/
@Test(expected = AssertJDBException.class)
public void should_fail_because_connection_throws_exception_when_getting_an_object() {
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(new DefaultDataSource(dataSource)).create();
- Table table = new Table(connectionProvider, "movi");
- Changes changes = new Changes().setTables(table);
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(new DefaultDataSource(dataSource)).create();
+ Table table = connectionProvider.table("movi").build();
+ Changes changes = connectionProvider.changes().tables(table).build();
changes.setStartPointNow();
}
@@ -63,9 +63,9 @@ public DatabaseMetaData getMetaData() throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
- Changes changes = new Changes().setTables(table);
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
+ Changes changes = connectionProvider.changes().tables(table).build();
changes.setStartPointNow();
}
@@ -93,9 +93,9 @@ public ResultSet executeQuery(String sql) throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
- Changes changes = new Changes().setTables(table);
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
+ Changes changes = connectionProvider.changes().tables(table).build();
changes.setStartPointNow();
}
@@ -116,9 +116,9 @@ public DatabaseMetaData getMetaData() throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
- Changes changes = new Changes().setTables(table);
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
+ Changes changes = connectionProvider.changes().tables(table).build();
changes.setStartPointNow();
}
@@ -139,9 +139,9 @@ public Statement createStatement() throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
- Changes changes = new Changes().setTables(table);
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
+ Changes changes = connectionProvider.changes().tables(table).build();
changes.setStartPointNow();
}
@@ -156,35 +156,19 @@ public Connection getConnection() throws SQLException {
throw new SQLException();
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
- Changes changes = new Changes().setTables(table);
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
+ Changes changes = connectionProvider.changes().tables(table).build();
changes.setStartPointNow();
}
- /**
- * This method should fail because the table is null.
- */
- @Test(expected = NullPointerException.class)
- public void should_fail_because_table_is_null() {
- new Changes().setTables((Table) null);
- }
-
- /**
- * This method should fail because the request is null.
- */
- @Test(expected = NullPointerException.class)
- public void should_fail_because_request_is_null() {
- new Changes().setRequest(null);
- }
-
/**
* This method should fail because setting end point before start point.
*/
@Test(expected = AssertJDBException.class)
public void should_fail_because_end_before_start() {
- Table table = new Table(dsConnectionProvider, "test");
- Changes changes = new Changes().setTables(table);
+ Table table = assertDbConnection.table("test").build();
+ Changes changes = assertDbConnection.changes().tables(table).build();
changes.setEndPointNow();
}
@@ -193,8 +177,8 @@ public void should_fail_because_end_before_start() {
*/
@Test(expected = AssertJDBException.class)
public void should_fail_because_getting_list_of_changes_before_end() {
- Table table = new Table(dsConnectionProvider, "test");
- Changes changes = new Changes().setTables(table);
+ Table table = assertDbConnection.table("test").build();
+ Changes changes = assertDbConnection.changes().tables(table).build();
changes.setStartPointNow();
changes.getChangesList();
}
@@ -204,7 +188,7 @@ public void should_fail_because_getting_list_of_changes_before_end() {
*/
@Test(expected = NullPointerException.class)
public void should_fail_because_tablename_is_null() {
- new Changes(jdbcConnectionProvider).getChangesOfTable(null);
+ assertDbConnection.changes().build().getChangesOfTable(null);
}
/**
@@ -212,6 +196,6 @@ public void should_fail_because_tablename_is_null() {
*/
@Test(expected = NullPointerException.class)
public void should_fail_because_type_is_null() {
- new Changes(jdbcConnectionProvider).getChangesOfType(null);
+ assertDbConnection.changes().build().getChangesOfType(null);
}
}
diff --git a/src/test/java/org/assertj/db/type/Changes_GetChangesOfTable_Test.java b/src/test/java/org/assertj/db/type/Changes_GetChangesOfTable_Test.java
index 916fbfca..087d244f 100644
--- a/src/test/java/org/assertj/db/type/Changes_GetChangesOfTable_Test.java
+++ b/src/test/java/org/assertj/db/type/Changes_GetChangesOfTable_Test.java
@@ -36,11 +36,10 @@ public class Changes_GetChangesOfTable_Test extends AbstractTest {
@Test
@NeedReload
public void test_getChangesOfTable() {
- Changes changesSource = new Changes(jdbcConnectionProvider);
- Changes changesRequest = new Changes(new Request(jdbcConnectionProvider,
- "select interpretation.id, character, movie.title, actor.name "
- + " from interpretation, movie, actor " + " where interpretation.id_movie = movie.id "
- + " and interpretation.id_actor = actor.id ").setPksName("id"));
+ Changes changesSource = assertDbConnection.changes().build();
+ Changes changesRequest = assertDbConnection.changes().request(assertDbConnection.request("select interpretation.id, character, movie.title, actor.name "
+ + " from interpretation, movie, actor " + " where interpretation.id_movie = movie.id "
+ + " and interpretation.id_actor = actor.id ").pksName("id").build()).build();
changesRequest.setStartPointNow();
changesSource.setStartPointNow();
diff --git a/src/test/java/org/assertj/db/type/Changes_GetChangesOfType_Test.java b/src/test/java/org/assertj/db/type/Changes_GetChangesOfType_Test.java
index 2d8cc2c3..d614429c 100644
--- a/src/test/java/org/assertj/db/type/Changes_GetChangesOfType_Test.java
+++ b/src/test/java/org/assertj/db/type/Changes_GetChangesOfType_Test.java
@@ -36,11 +36,10 @@ public class Changes_GetChangesOfType_Test extends AbstractTest {
@Test
@NeedReload
public void test_getChangesOfTable() {
- Changes changesSource = new Changes(jdbcConnectionProvider);
- Changes changesRequest = new Changes(new Request(jdbcConnectionProvider,
- "select interpretation.id, character, movie.title, actor.name "
- + " from interpretation, movie, actor " + " where interpretation.id_movie = movie.id "
- + " and interpretation.id_actor = actor.id ").setPksName("id"));
+ Changes changesSource = assertDbConnection.changes().build();
+ Changes changesRequest = assertDbConnection.changes().request(assertDbConnection.request("select interpretation.id, character, movie.title, actor.name "
+ + " from interpretation, movie, actor " + " where interpretation.id_movie = movie.id "
+ + " and interpretation.id_actor = actor.id ").pksName("id").build()).build();
changesRequest.setStartPointNow();
changesSource.setStartPointNow();
diff --git a/src/test/java/org/assertj/db/type/Changes_GetChanges_Test.java b/src/test/java/org/assertj/db/type/Changes_GetChanges_Test.java
index 3e038cfc..6a60defd 100644
--- a/src/test/java/org/assertj/db/type/Changes_GetChanges_Test.java
+++ b/src/test/java/org/assertj/db/type/Changes_GetChanges_Test.java
@@ -35,7 +35,7 @@ public class Changes_GetChanges_Test extends AbstractTest {
@Test
@NeedReload
public void test_getChangesOfTableAndType() {
- Changes changesSource = new Changes(jdbcConnectionProvider);
+ Changes changesSource = assertDbConnection.changes().build();
changesSource.setStartPointNow();
updateChangesForTests();
@@ -66,7 +66,7 @@ public void test_getChangesOfTableAndType() {
@Test
@NeedReload
public void test_getChangesOfTypeAndTable() {
- Changes changesSource = new Changes(jdbcConnectionProvider);
+ Changes changesSource = assertDbConnection.changes().build();
changesSource.setStartPointNow();
updateChangesForTests();
diff --git a/src/test/java/org/assertj/db/type/Changes_Request_GetChangesList_Test.java b/src/test/java/org/assertj/db/type/Changes_Request_GetChangesList_Test.java
index 77fb41f5..206a3ad3 100644
--- a/src/test/java/org/assertj/db/type/Changes_Request_GetChangesList_Test.java
+++ b/src/test/java/org/assertj/db/type/Changes_Request_GetChangesList_Test.java
@@ -16,7 +16,6 @@
import java.math.BigDecimal;
import java.sql.Date;
-import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.UUID;
@@ -38,7 +37,7 @@ public class Changes_Request_GetChangesList_Test extends AbstractTest {
*/
@Test
public void test_when_there_is_no_change() {
- Changes changes = new Changes(new Request(dsConnectionProvider, "select * from test"));
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from test").build()).build();
changes.setStartPointNow();
changes.setEndPointNow();
assertThat(changes.getChangesList()).hasSize(0);
@@ -46,13 +45,11 @@ public void test_when_there_is_no_change() {
/**
* This method test when there is no change found because it is another table.
- *
- * @throws SQLException
*/
@Test
@NeedReload
- public void test_when_there_is_no_change_found() throws SQLException {
- Changes changes = new Changes(new Request(dsConnectionProvider, "select * from test"));
+ public void test_when_there_is_no_change_found() {
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from test").build()).build();
changes.setStartPointNow();
update("delete from test2 where VAR1 is null");
changes.setEndPointNow();
@@ -61,13 +58,11 @@ public void test_when_there_is_no_change_found() throws SQLException {
/**
* This method test when there is a deletion change.
- *
- * @throws SQLException
*/
@Test
@NeedReload
- public void test_when_there_is_deletion_change() throws SQLException {
- Changes changes = new Changes(new Request(dsConnectionProvider, "select * from test2"));
+ public void test_when_there_is_deletion_change() {
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from test2").build()).build();
changes.setStartPointNow();
update("delete from test2 where VAR1 is null");
changes.setEndPointNow();
@@ -100,13 +95,11 @@ public void test_when_there_is_deletion_change() throws SQLException {
/**
* This method test when there is a creation change.
- *
- * @throws SQLException
*/
@Test
@NeedReload
- public void test_when_there_is_creation_change() throws SQLException {
- Changes changes = new Changes(new Request(dsConnectionProvider, "select * from test2"));
+ public void test_when_there_is_creation_change() {
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from test2").build()).build();
changes.setStartPointNow();
update("insert into test2(VAR1) values(200)");
changes.setEndPointNow();
@@ -139,13 +132,11 @@ public void test_when_there_is_creation_change() throws SQLException {
/**
* This method test when there is a modification change without primary key.
- *
- * @throws SQLException
*/
@Test
@NeedReload
- public void test_when_there_is_modification_change_without_primary_key() throws SQLException {
- Changes changes = new Changes(new Request(dsConnectionProvider, "select * from test2"));
+ public void test_when_there_is_modification_change_without_primary_key() {
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from test2").build()).build();
changes.setStartPointNow();
update("update test2 set VAR12 = 'modification' where VAR1 = 1");
changes.setEndPointNow();
@@ -206,13 +197,11 @@ public void test_when_there_is_modification_change_without_primary_key() throws
/**
* This method test when there is a modification change with primary key.
- *
- * @throws SQLException
*/
@Test
@NeedReload
- public void test_when_there_is_modification_change_with_primary_key() throws SQLException {
- Changes changes = new Changes(new Request(dsConnectionProvider, "select * from interpretation").setPksName("id"));
+ public void test_when_there_is_modification_change_with_primary_key() {
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from interpretation").pksName("id").build()).build();
changes.setStartPointNow();
update("update interpretation set character = 'Doctor Grace Augustine' where id = 3");
changes.setEndPointNow();
@@ -234,13 +223,11 @@ public void test_when_there_is_modification_change_with_primary_key() throws SQL
/**
* This method test when there is a creation change with primary key.
- *
- * @throws SQLException
*/
@Test
@NeedReload
- public void test_when_there_is_creation_change_with_primary_key() throws SQLException {
- Changes changes = new Changes(new Request(dsConnectionProvider, "select * from movie").setPksName("id"));
+ public void test_when_there_is_creation_change_with_primary_key() {
+ Changes changes = assertDbConnection.changes().request(assertDbConnection.request("select * from movie").pksName("id").build()).build();
changes.setStartPointNow();
update("insert into movie values(4, 'Ghostbusters', 1984, '16319617-AE95-4087-9264-D3D21BF611B6')");
changes.setEndPointNow();
@@ -261,13 +248,11 @@ public void test_when_there_is_creation_change_with_primary_key() throws SQLExce
/**
* This method test when there is a deletion change with primary key.
- *
- * @throws SQLException
*/
@Test
@NeedReload
- public void test_when_there_is_deletion_change_with_primary_key() throws SQLException {
- Changes changes = new Changes(new Request(dsConnectionProvider, "select * from interpretation").setPksName("id"));
+ public void test_when_there_is_deletion_change_with_primary_key() {
+ Changes changes = assertDbConnection.changes().request((assertDbConnection.request("select * from interpretation").pksName("id").build())).build();
changes.setStartPointNow();
update("delete interpretation where id = 3");
changes.setEndPointNow();
diff --git a/src/test/java/org/assertj/db/type/Changes_SetTables_Test.java b/src/test/java/org/assertj/db/type/Changes_SetTables_Test.java
deleted file mode 100644
index 561fca75..00000000
--- a/src/test/java/org/assertj/db/type/Changes_SetTables_Test.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- *
- * Copyright 2015-2024 the original author or authors.
- */
-package org.assertj.db.type;
-
-import org.assertj.db.common.AbstractTest;
-import org.junit.Test;
-
-/**
- * Tests on the setTables method.
- *
- * @author RĂ©gis Pouiller
- * @author Julien Roy
- */
-public class Changes_SetTables_Test extends AbstractTest {
-
- /**
- * This method test when setting with empty parameters.
- */
- @Test
- public void test_when_setting_tables_with_empty_parameters() {
- Changes changes = new Changes(jdbcConnectionProvider);
- changes.setTables();
- }
-}
diff --git a/src/test/java/org/assertj/db/type/Changes_Table_GetChangesList_Test.java b/src/test/java/org/assertj/db/type/Changes_Table_GetChangesList_Test.java
index c2bf257d..1a815a0b 100644
--- a/src/test/java/org/assertj/db/type/Changes_Table_GetChangesList_Test.java
+++ b/src/test/java/org/assertj/db/type/Changes_Table_GetChangesList_Test.java
@@ -39,7 +39,7 @@ public class Changes_Table_GetChangesList_Test extends AbstractTest {
*/
@Test
public void test_when_there_is_no_change() {
- Changes changes = new Changes(jdbcConnectionProvider);
+ Changes changes = assertDbConnection.changes().build();
changes.setStartPointNow();
changes.setEndPointNow();
assertThat(changes.getChangesList()).hasSize(0);
@@ -52,8 +52,8 @@ public void test_when_there_is_no_change() {
*/
@Test
@NeedReload
- public void test_when_there_is_no_change_found() throws SQLException {
- Changes changes = new Changes(new Table(jdbcConnectionProvider, "test"));
+ public void test_when_there_is_no_change_found() {
+ Changes changes = assertDbConnection.changes().tables(assertDbConnection.table("test").build()).build();
changes.setStartPointNow();
update("delete from test2 where VAR1 is null");
changes.setEndPointNow();
@@ -67,8 +67,8 @@ public void test_when_there_is_no_change_found() throws SQLException {
*/
@Test
@NeedReload
- public void test_when_there_is_deletion_change() throws SQLException {
- Changes changes = new Changes(jdbcConnectionProvider);
+ public void test_when_there_is_deletion_change() {
+ Changes changes = assertDbConnection.changes().build();
changes.setStartPointNow();
update("delete from test2 where VAR1 is null");
changes.setEndPointNow();
@@ -106,8 +106,8 @@ public void test_when_there_is_deletion_change() throws SQLException {
*/
@Test
@NeedReload
- public void test_when_there_is_creation_change() throws SQLException {
- Changes changes = new Changes(jdbcConnectionProvider);
+ public void test_when_there_is_creation_change() {
+ Changes changes = assertDbConnection.changes().build();
changes.setStartPointNow();
update("insert into test2(VAR1) values(200)");
changes.setEndPointNow();
@@ -146,8 +146,8 @@ public void test_when_there_is_creation_change() throws SQLException {
*/
@Test
@NeedReload
- public void test_when_there_is_modification_change_without_primary_key() throws SQLException {
- Changes changes = new Changes(jdbcConnectionProvider);
+ public void test_when_there_is_modification_change_without_primary_key() {
+ Changes changes = assertDbConnection.changes().build();
changes.setStartPointNow();
update("update test2 set VAR12 = 'modification' where VAR1 = 1");
changes.setEndPointNow();
@@ -218,8 +218,8 @@ public void test_when_there_is_modification_change_without_primary_key() throws
*/
@Test
@NeedReload
- public void test_when_there_is_modification_change_with_primary_key() throws SQLException {
- Changes changes = new Changes(jdbcConnectionProvider);
+ public void test_when_there_is_modification_change_with_primary_key() {
+ Changes changes = assertDbConnection.changes().build();
changes.setStartPointNow();
update("update interpretation set character = 'Doctor Grace Augustine' where id = 3");
changes.setEndPointNow();
@@ -246,8 +246,8 @@ public void test_when_there_is_modification_change_with_primary_key() throws SQL
*/
@Test
@NeedReload
- public void test_when_there_is_creation_change_with_primary_key() throws SQLException {
- Changes changes = new Changes(new Table(jdbcConnectionProvider, "movie"));
+ public void test_when_there_is_creation_change_with_primary_key() {
+ Changes changes = assertDbConnection.changes().tables(assertDbConnection.table("movie").build()).build();
changes.setStartPointNow();
update("insert into movie values(4, 'Ghostbusters', 1984, '16319617-AE95-4087-9264-D3D21BF611B6')");
changes.setEndPointNow();
@@ -273,8 +273,8 @@ public void test_when_there_is_creation_change_with_primary_key() throws SQLExce
*/
@Test
@NeedReload
- public void test_when_there_is_deletion_change_with_primary_key() throws SQLException {
- Changes changes = new Changes(new Table(jdbcConnectionProvider, "interpretation"));
+ public void test_when_there_is_deletion_change_with_primary_key() {
+ Changes changes = assertDbConnection.changes().tables(assertDbConnection.table("interpretation").build()).build();
changes.setStartPointNow();
update("delete interpretation where id = 3");
changes.setEndPointNow();
diff --git a/src/test/java/org/assertj/db/type/DateTimeValue_Test.java b/src/test/java/org/assertj/db/type/DateTimeValue_Test.java
index 724d305a..534c2fd7 100644
--- a/src/test/java/org/assertj/db/type/DateTimeValue_Test.java
+++ b/src/test/java/org/assertj/db/type/DateTimeValue_Test.java
@@ -474,9 +474,9 @@ public void test_of() throws ParseException {
*/
@Test
public void test_toString() {
- assertThat(DateTimeValue.of(DateValue.of(2007, 12, 23), TimeValue.of(9, 1, 6, 3)).toString()).isEqualTo(
+ assertThat(DateTimeValue.of(DateValue.of(2007, 12, 23), TimeValue.of(9, 1, 6, 3))).hasToString(
"2007-12-23T09:01:06.000000003");
- assertThat(DateTimeValue.of(DateValue.of(2007, 2, 3), TimeValue.of(9, 1, 6, 3)).toString()).isEqualTo(
+ assertThat(DateTimeValue.of(DateValue.of(2007, 2, 3), TimeValue.of(9, 1, 6, 3))).hasToString(
"2007-02-03T09:01:06.000000003");
}
diff --git a/src/test/java/org/assertj/db/type/DateValue_Test.java b/src/test/java/org/assertj/db/type/DateValue_Test.java
index 5103463b..e820b9fa 100644
--- a/src/test/java/org/assertj/db/type/DateValue_Test.java
+++ b/src/test/java/org/assertj/db/type/DateValue_Test.java
@@ -282,8 +282,8 @@ public void test_of() throws ParseException {
*/
@Test
public void test_toString() {
- assertThat(DateValue.of(2007, 12, 23).toString()).isEqualTo("2007-12-23");
- assertThat(DateValue.of(2007, 2, 3).toString()).isEqualTo("2007-02-03");
+ assertThat(DateValue.of(2007, 12, 23)).hasToString("2007-12-23");
+ assertThat(DateValue.of(2007, 2, 3)).hasToString("2007-02-03");
}
/**
diff --git a/src/test/java/org/assertj/db/type/Request_Columns_Name_Test.java b/src/test/java/org/assertj/db/type/Request_Columns_Name_Test.java
index e1723aed..fe0f692c 100644
--- a/src/test/java/org/assertj/db/type/Request_Columns_Name_Test.java
+++ b/src/test/java/org/assertj/db/type/Request_Columns_Name_Test.java
@@ -33,30 +33,12 @@ public class Request_Columns_Name_Test extends AbstractTest {
* This method test the columns name got from a {@code ConnectionProvider}.
*/
@Test
- public void test_columns_name_with_jdbc_set() {
- Request request = new Request(jdbcConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
-
- assertThat(request.getColumnsNameList()).as("Columns of the request")
- .hasSize(4)
- .containsExactly("NAME", "FIRSTNAME", "YEAR", "CHARACTER");
- }
-
- /**
- * This method test the columns name got from a {@code DataSource}.
- */
- @Test
- public void test_columns_name_with_datasource_set() {
- Request request = new Request(dsConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
+ public void test_columns_name() {
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ + " FROM movie, actor, interpretation"
+ + " WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id"
+ + " ORDER BY actor.name, movie.year").build();
assertThat(request.getColumnsNameList()).as("Columns of the request")
.hasSize(4)
@@ -67,33 +49,16 @@ public void test_columns_name_with_datasource_set() {
* This method test the columns name got from a {@code ConnectionProvider}.
*/
@Test
- public void test_columns_name_with_jdbc_and_parameters_set() {
- Request request = new Request(jdbcConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " AND movie.year > ?"
- + " ORDER BY actor.name, movie.year", 2000);
-
- assertThat(request.getColumnsNameList()).as("Columns of the request")
- .hasSize(4)
- .containsExactly("NAME", "FIRSTNAME", "YEAR", "CHARACTER");
- }
-
- /**
- * This method test the columns name got from a {@code DataSource}.
- */
- @Test
- public void test_columns_name_with_datasource_and_parameters_set() {
- Request request = new Request(dsConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " AND movie.year > ?"
- + " ORDER BY actor.name, movie.year")
- .setParameters(2000);
+ public void test_columns_name_with_parameters_set() {
+ Request request = assertDbConnection.request(
+ "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ + " FROM movie, actor, interpretation"
+ + " WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id"
+ + " AND movie.year > ?"
+ + " ORDER BY actor.name, movie.year")
+ .parameters(2000)
+ .build();
assertThat(request.getColumnsNameList()).as("Columns of the request")
.hasSize(4)
@@ -106,7 +71,7 @@ public void test_columns_name_with_datasource_and_parameters_set() {
*/
@Test(expected = AssertJDBException.class)
public void should_throw_AssertJDBException_because_SQLException_caused_by_table_not_found() {
- Table table = new Table(dsConnectionProvider, "select * from interpret");
+ Table table = assertDbConnection.table("select * from interpret").build();
table.getColumnsNameList();
}
diff --git a/src/test/java/org/assertj/db/type/Request_Columns_Test.java b/src/test/java/org/assertj/db/type/Request_Columns_Test.java
index 31873329..bc5bd5c1 100644
--- a/src/test/java/org/assertj/db/type/Request_Columns_Test.java
+++ b/src/test/java/org/assertj/db/type/Request_Columns_Test.java
@@ -12,11 +12,11 @@
*/
package org.assertj.db.type;
-import static org.assertj.core.api.Assertions.assertThat;
-
import org.assertj.db.common.AbstractTest;
import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+
/**
* Tests on the columns of {@code Request}.
*
@@ -32,12 +32,12 @@ public class Request_Columns_Test extends AbstractTest {
* This method test the columns got from a {@code ConnectionProvider}.
*/
@Test
- public void test_columns_with_jdbc_set() {
- Request request = new Request(jdbcConnectionProvider, "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ public void test_columns() {
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ " FROM movie, actor, interpretation"
+ " WHERE movie.id = interpretation.id_movie"
+ " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
+ + " ORDER BY actor.name, movie.year").build();
Column columnFromIndex = request.getColumn(1);
@@ -55,11 +55,11 @@ public void test_columns_with_jdbc_set() {
*/
@Test
public void test_columns_with_datasource_set() {
- Request request = new Request(dsConnectionProvider, "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ " FROM movie, actor, interpretation"
+ " WHERE movie.id = interpretation.id_movie"
+ " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
+ + " ORDER BY actor.name, movie.year").build();
Column columnFromIndex = request.getColumn(1);
diff --git a/src/test/java/org/assertj/db/type/Request_Exception_Test.java b/src/test/java/org/assertj/db/type/Request_Exception_Test.java
index 0c5cf56a..0f974732 100644
--- a/src/test/java/org/assertj/db/type/Request_Exception_Test.java
+++ b/src/test/java/org/assertj/db/type/Request_Exception_Test.java
@@ -38,15 +38,7 @@ public class Request_Exception_Test extends AbstractTest {
*/
@Test(expected = AssertJDBException.class)
public void should_fail_because_setting_primarykey_which_donot_exist() {
- new Request(dsConnectionProvider, "select var1 from test").setPksName("var2").getRowsList();
- }
-
- /**
- * This method should fail because setting the connection provider to null.
- */
- @Test(expected = NullPointerException.class)
- public void should_fail_because_setting_connection_provider_to_null() {
- new Request().setConnectionProvider(null);
+ assertDbConnection.request("select var1 from test").pksName("var2").build().getRowsList();
}
/**
@@ -55,8 +47,8 @@ public void should_fail_because_setting_connection_provider_to_null() {
@Test(expected = AssertJDBException.class)
public void should_fail_because_connection_throws_exception_when_getting_an_object() {
DataSource ds = new DefaultDataSource(dataSource);
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Request request = new Request(connectionProvider, "select * from movi where id = ?", 1);
+ AssertDbConnection connection = AssertDbConnectionFactory.of(ds).create();
+ Request request = connection.request("select * from movi where id = ?").parameters(1).build();
request.getColumnsNameList();
}
@@ -83,8 +75,8 @@ public ResultSet executeQuery() throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Request request = new Request(connectionProvider, "select * from movi where id = ?", 1);
+ AssertDbConnection connection = AssertDbConnectionFactory.of(ds).create();
+ Request request = connection.request("select * from movi where id = ?").parameters(1).build();
request.getColumnsNameList();
}
@@ -105,8 +97,8 @@ public DatabaseMetaData getMetaData() throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Request request = new Request(connectionProvider, "select * from movi where id = ?", 1);
+ AssertDbConnection connection = AssertDbConnectionFactory.of(ds).create();
+ Request request = connection.request("select * from movi where id = ?").parameters(1).build();
request.getColumnsNameList();
}
@@ -127,8 +119,8 @@ public PreparedStatement prepareStatement(String sql) throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Request request = new Request(connectionProvider, "select * from movi where id = ?", 1);
+ AssertDbConnection connection = AssertDbConnectionFactory.of(ds).create();
+ Request request = connection.request("select * from movi where id = ?").parameters(1).build();
request.getColumnsNameList();
}
@@ -143,8 +135,8 @@ public Connection getConnection() throws SQLException {
throw new SQLException();
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Request request = new Request(connectionProvider, "select * from movi where id = ?", 1);
+ AssertDbConnection connection = AssertDbConnectionFactory.of(ds).create();
+ Request request = connection.request("select * from movi where id = ?").parameters(1).build();
request.getColumnsNameList();
}
}
diff --git a/src/test/java/org/assertj/db/type/Request_GetRowFromPksValues_Test.java b/src/test/java/org/assertj/db/type/Request_GetRowFromPksValues_Test.java
index beece44f..d793b129 100644
--- a/src/test/java/org/assertj/db/type/Request_GetRowFromPksValues_Test.java
+++ b/src/test/java/org/assertj/db/type/Request_GetRowFromPksValues_Test.java
@@ -32,15 +32,15 @@ public class Request_GetRowFromPksValues_Test extends AbstractTest {
*/
@Test
public void test_getting_row_from_primary_keys_values_without_finding() throws Exception {
- Request request = new Request(jdbcConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.id, interpretation.character "
- + " FROM movie, actor, interpretation WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id ORDER BY actor.name, movie.year");
+ String sqlRequest = "SELECT actor.name, actor.firstname, movie.year, interpretation.id, interpretation.character "
+ + " FROM movie, actor, interpretation WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id ORDER BY actor.name, movie.year";
+ Request request = assertDbConnection.request(sqlRequest).build();
assertThat(request.getRowFromPksValues(getValue(null, 1L))).isNull();
assertThat(request.getRowFromPksValues(getValue(null, 3))).isNull();
- request.setPksName("id");
+ request = assertDbConnection.request(sqlRequest).pksName("id").build();
assertThat(request.getRowFromPksValues()).isNull();
assertThat(request.getRowFromPksValues(getValue(null, 1L), getValue(null, 3))).isNull();
@@ -51,10 +51,10 @@ public void test_getting_row_from_primary_keys_values_without_finding() throws E
*/
@Test
public void test_getting_row_from_primary_keys_values_with_finding() throws Exception {
- Request request = new Request(jdbcConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.id, interpretation.character "
- + " FROM movie, actor, interpretation WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id ORDER BY actor.name, movie.year").setPksName("id");
+ String sqlRequest = "SELECT actor.name, actor.firstname, movie.year, interpretation.id, interpretation.character "
+ + " FROM movie, actor, interpretation WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id ORDER BY actor.name, movie.year";
+ Request request = assertDbConnection.request(sqlRequest).pksName("id").build();
assertThat(request.getRowFromPksValues(getValue(null, 3)).getValuesList().get(0).getValue()).isEqualTo("Weaver");
assertThat(request.getRowFromPksValues(getValue(null, 3)).getValuesList().get(1).getValue()).isEqualTo("Sigourney");
@@ -67,7 +67,7 @@ public void test_getting_row_from_primary_keys_values_with_finding() throws Exce
assertThat(request.getRowFromPksValues(getValue(null, 1L)).getValuesList().get(3).getValue()).isEqualTo(new BigDecimal(1));
assertThat(request.getRowFromPksValues(getValue(null, 1L)).getValuesList().get(4).getValue()).isEqualTo("Ellen Louise Ripley");
- request.setPksName("character");
+ request = assertDbConnection.request(sqlRequest).pksName("character").build();
assertThat(request.getRowFromPksValues(getValue(null, "Lucius Hunt")).getValuesList().get(0).getValue()).isEqualTo("Phoenix");
assertThat(request.getRowFromPksValues(getValue(null, "Lucius Hunt")).getValuesList().get(1).getValue()).isEqualTo("Joaquim");
@@ -75,7 +75,7 @@ public void test_getting_row_from_primary_keys_values_with_finding() throws Exce
assertThat(request.getRowFromPksValues(getValue(null, "Lucius Hunt")).getValuesList().get(3).getValue()).isEqualTo(new BigDecimal(4));
assertThat(request.getRowFromPksValues(getValue(null, "Lucius Hunt")).getValuesList().get(4).getValue()).isEqualTo("Lucius Hunt");
- request.setPksName("name", "year");
+ request = assertDbConnection.request(sqlRequest).pksName("name", "year").build();
assertThat(request.getRowFromPksValues(getValue(null, "Weaver"), getValue(null, "2004")).getValuesList().get(0).getValue()).isEqualTo("Weaver");
assertThat(request.getRowFromPksValues(getValue(null, "Weaver"), getValue(null, "2004")).getValuesList().get(1).getValue()).isEqualTo("Sigourney");
diff --git a/src/test/java/org/assertj/db/type/Request_Getters_Test.java b/src/test/java/org/assertj/db/type/Request_Getters_Test.java
index 240a06c0..c702e5e3 100644
--- a/src/test/java/org/assertj/db/type/Request_Getters_Test.java
+++ b/src/test/java/org/assertj/db/type/Request_Getters_Test.java
@@ -28,31 +28,18 @@
*/
public class Request_Getters_Test extends AbstractTest {
- /**
- * This method test the getters of a {@code Table} when only the jdbc connection is set.
- */
- @Test
- public void test_getters_with_only_jdbc_connection_set() {
- Request request = new Request().setConnectionProvider(jdbcConnectionProvider);
-
- assertThat(request.getConnectionProvider()).isSameAs(jdbcConnectionProvider);
- assertThat(request.getRequest()).isNull();
- assertThat(request.getParameters()).isNull();
- }
-
/**
* This method test the getters of a {@code Table} when the jdbc connection and the name are set.
*/
@Test
- public void test_getters_with_jdbc_and_name_set() {
- Request request = new Request(jdbcConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
+ public void test_getters_with_name_set() {
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ + " FROM movie, actor, interpretation"
+ + " WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id"
+ + " ORDER BY actor.name, movie.year").build();
- assertThat(request.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(request.getConnectionProvider()).isNotNull();
assertThat(request.getRequest()).isEqualTo("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ " FROM movie, actor, interpretation"
+ " WHERE movie.id = interpretation.id_movie"
@@ -66,16 +53,18 @@ public void test_getters_with_jdbc_and_name_set() {
* are set.
*/
@Test
- public void test_getters_with_jdbc_name_and_columns_set() {
- Request request = new Request(jdbcConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " AND movie.year > ?"
- + " ORDER BY actor.name, movie.year", 2000);
+ public void test_getters_with_name_and_columns_set() {
+ Request request = assertDbConnection.request(
+ "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ + " FROM movie, actor, interpretation"
+ + " WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id"
+ + " AND movie.year > ?"
+ + " ORDER BY actor.name, movie.year")
+ .parameters(2000)
+ .build();
- assertThat(request.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(request.getConnectionProvider()).isNotNull();
assertThat(request.getRequest()).isEqualTo("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ " FROM movie, actor, interpretation"
+ " WHERE movie.id = interpretation.id_movie"
diff --git a/src/test/java/org/assertj/db/type/Request_Instantiation_Test.java b/src/test/java/org/assertj/db/type/Request_Instantiation_Test.java
index f8128810..4981161a 100644
--- a/src/test/java/org/assertj/db/type/Request_Instantiation_Test.java
+++ b/src/test/java/org/assertj/db/type/Request_Instantiation_Test.java
@@ -28,47 +28,11 @@
public class Request_Instantiation_Test extends AbstractTest {
/**
- * This method should throw a {@code NullPointerException}, because the {@code ConnectionProvider} parameter is {@code null}.
+ * This method should throw a {@code IllegalArgumentException}, because request is {@code null}.
*/
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_instantiate_with_connection_provider_null() {
- new Request(null, null);
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code ConnectionProvider} parameter is not {@code null}
- * and request is {@code null}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_instantiate_with_jdbc_not_null_and_table_name_null() {
- new Request(jdbcConnectionProvider, null);
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code ConnectionProvider} parameter is {@code null}
- * and request is {@code null}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_instantiate_with_data_source_not_null_and_table_name_null() {
- new Request(dsConnectionProvider, null);
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code DataSource} and the {@code ConnectionProvider}
- * fields are not set when call {@code getColumnsNameList()}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_get_list_of_columns_name_without_setting_connection_provider_or_datasource() {
- new Request().getColumnsNameList();
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code ConnectionProvider} field is set but not the table
- * name when call {@code getColumnsNameList()}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_get_list_of_columns_name_with_setting_connection_provider_and_without_setting_table_name() {
- new Request().setConnectionProvider(jdbcConnectionProvider).getColumnsNameList();
+ @Test(expected = IllegalArgumentException.class)
+ public void should_throw_IllegalArgumentException_if_instantiate_with_table_name_null() {
+ assertDbConnection.request(null).build();
}
/**
@@ -77,7 +41,7 @@ public void should_throw_NullPointerException_if_get_list_of_columns_name_with_s
*/
@Test(expected = AssertJDBException.class)
public void should_throw_AssertJDBException_if_get_list_of_rows_with_setting_connection_provider_having_bad_user() {
- Request request = new Request(ConnectionProviderFactory.of("jdbc:h2:mem:test", "", "").create(), "");
+ Request request = AssertDbConnectionFactory.of("jdbc:h2:mem:test", "", "").create().request("").build();
request.getRowsList();
}
}
diff --git a/src/test/java/org/assertj/db/type/Request_PrimaryKeys_Name_Test.java b/src/test/java/org/assertj/db/type/Request_PrimaryKeys_Name_Test.java
index 5ec0dcc4..b61bef1a 100644
--- a/src/test/java/org/assertj/db/type/Request_PrimaryKeys_Name_Test.java
+++ b/src/test/java/org/assertj/db/type/Request_PrimaryKeys_Name_Test.java
@@ -34,12 +34,11 @@ public class Request_PrimaryKeys_Name_Test extends AbstractTest {
*/
@Test
public void test_pks_name_with_jdbc_set_but_not_primary_keys() {
- Request request = new Request(jdbcConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ + " FROM movie, actor, interpretation"
+ + " WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id"
+ + " ORDER BY actor.name, movie.year").build();
assertThat(request.getPksNameList()).as("Primary Keys of the request")
.hasSize(0);
@@ -49,13 +48,12 @@ public void test_pks_name_with_jdbc_set_but_not_primary_keys() {
* This method test the primary keys name got from a {@code JdbcUrlConnectionProvider}.
*/
@Test
- public void test_pks_name_with_jdbc_set() {
- Request request = new Request(jdbcConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year").setPksName("NAME");
+ public void test_pks_name() {
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ + " FROM movie, actor, interpretation"
+ + " WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id"
+ + " ORDER BY actor.name, movie.year").pksName("NAME").build();
assertThat(request.getPksNameList()).as("Primary Keys of the request")
.hasSize(1)
@@ -66,31 +64,17 @@ public void test_pks_name_with_jdbc_set() {
* This method test the primary keys name got from a {@code DataSourceConnectionProvider}.
*/
@Test
- public void test_pks_name_with_datasource_set() {
- Request request = new Request(dsConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year").setPksName("NAME");
-
- assertThat(request.getPksNameList()).as("Primary Keys of the request")
- .hasSize(1)
- .containsExactly("NAME");
- }
-
- /**
- * This method test the primary keys name got from a {@code DataSourceConnectionProvider}.
- */
- @Test
- public void test_pks_name_with_jdbc_and_parameters_set() {
- Request request = new Request(dsConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " AND movie.year > ?"
- + " ORDER BY actor.name, movie.year", 2000).setPksName("NAME", "ID");
+ public void test_pks_name_with_parameters_set() {
+ Request request = assertDbConnection.request(
+ "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ + " FROM movie, actor, interpretation"
+ + " WHERE movie.id = interpretation.id_movie"
+ + " AND interpretation.id_actor = actor.id"
+ + " AND movie.year > ?"
+ + " ORDER BY actor.name, movie.year")
+ .parameters(2000)
+ .pksName("NAME", "ID")
+ .build();
assertThat(request.getPksNameList()).as("Primary Keys of the request")
.hasSize(2)
@@ -102,14 +86,15 @@ public void test_pks_name_with_jdbc_and_parameters_set() {
*/
@Test
public void test_pks_name_with_datasource_and_parameters_set() {
- Request request = new Request(dsConnectionProvider,
- "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ " FROM movie, actor, interpretation"
+ " WHERE movie.id = interpretation.id_movie"
+ " AND interpretation.id_actor = actor.id"
+ " AND movie.year > ?"
+ " ORDER BY actor.name, movie.year")
- .setParameters(2000).setPksName("NAME", "ID");
+ .parameters(2000)
+ .pksName("NAME", "ID")
+ .build();
assertThat(request.getPksNameList()).as("Primary Keys of the request")
.hasSize(2)
@@ -122,8 +107,8 @@ public void test_pks_name_with_datasource_and_parameters_set() {
*/
@Test(expected = AssertJDBException.class)
public void should_throw_AssertJDBException_because_SQLException_caused_by_table_not_found() {
- Table table = new Table(dsConnectionProvider, "select * from interpret");
- table.getPksNameList();
+ Request request = assertDbConnection.request("select * from interpret").build();
+ request.getPksNameList();
}
}
diff --git a/src/test/java/org/assertj/db/type/Request_Rows_Test.java b/src/test/java/org/assertj/db/type/Request_Rows_Test.java
index 1769dc53..832ce1b2 100644
--- a/src/test/java/org/assertj/db/type/Request_Rows_Test.java
+++ b/src/test/java/org/assertj/db/type/Request_Rows_Test.java
@@ -34,12 +34,12 @@ public class Request_Rows_Test extends AbstractTest {
* This method test the rows got from a {@code ConnectionProvider}.
*/
@Test
- public void test_rows_with_jdbc_set() {
- Request request = new Request(jdbcConnectionProvider, "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ public void test_rows() {
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ " FROM movie, actor, interpretation"
+ " WHERE movie.id = interpretation.id_movie"
+ " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
+ + " ORDER BY actor.name, movie.year").build();
assertThat(request.getRowsList()).as("Values of the request")
.hasSize(5);
@@ -70,51 +70,16 @@ public void test_rows_with_jdbc_set() {
assertThat(request.getRow(4).getValuesList().get(3).getValue()).isEqualTo("Jake Sully");
}
- /**
- * This method test the rows got from a {@code DataSource}.
- */
- @Test
- public void test_rows_with_datasource_set() {
- Request request = new Request(dsConnectionProvider, "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
- + " FROM movie, actor, interpretation"
- + " WHERE movie.id = interpretation.id_movie"
- + " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
-
- assertThat(request.getRowsList()).as("Values of the request")
- .hasSize(5);
- assertThat(request.getRow(0).getValuesList().get(0).getValue()).isEqualTo("Phoenix");
- assertThat(request.getRow(0).getValuesList().get(1).getValue()).isEqualTo("Joaquim");
- assertThat(request.getRow(0).getValuesList().get(2).getValue()).isEqualTo(new BigDecimal(2004));
- assertThat(request.getRow(0).getValuesList().get(3).getValue()).isEqualTo("Lucius Hunt");
- assertThat(request.getRow(1).getValuesList().get(0).getValue()).isEqualTo("Weaver");
- assertThat(request.getRow(1).getValuesList().get(1).getValue()).isEqualTo("Sigourney");
- assertThat(request.getRow(1).getValuesList().get(2).getValue()).isEqualTo(new BigDecimal(1979));
- assertThat(request.getRow(1).getValuesList().get(3).getValue()).isEqualTo("Ellen Louise Ripley");
- assertThat(request.getRow(2).getValuesList().get(0).getValue()).isEqualTo("Weaver");
- assertThat(request.getRow(2).getValuesList().get(1).getValue()).isEqualTo("Sigourney");
- assertThat(request.getRow(2).getValuesList().get(2).getValue()).isEqualTo(new BigDecimal(2004));
- assertThat(request.getRow(2).getValuesList().get(3).getValue()).isEqualTo("Alice Hunt");
- assertThat(request.getRow(3).getValuesList().get(0).getValue()).isEqualTo("Weaver");
- assertThat(request.getRow(3).getValuesList().get(1).getValue()).isEqualTo("Sigourney");
- assertThat(request.getRow(3).getValuesList().get(2).getValue()).isEqualTo(new BigDecimal(2009));
- assertThat(request.getRow(3).getValuesList().get(3).getValue()).isEqualTo("Dr Grace Augustine");
- assertThat(request.getRow(4).getValuesList().get(0).getValue()).isEqualTo("Worthington");
- assertThat(request.getRow(4).getValuesList().get(1).getValue()).isEqualTo("Sam");
- assertThat(request.getRow(4).getValuesList().get(2).getValue()).isEqualTo(new BigDecimal(2009));
- assertThat(request.getRow(4).getValuesList().get(3).getValue()).isEqualTo("Jake Sully");
- }
-
/**
* This method should throw a {@code NullPointerException} because of calling {@code getColumnValue} with null in parameter.
*/
@Test(expected = NullPointerException.class)
public void should_throw_NullPointerException_because_column_name_parameter_is_null_when_calling_getColumnValue() {
- Request request = new Request(dsConnectionProvider, "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ " FROM movie, actor, interpretation"
+ " WHERE movie.id = interpretation.id_movie"
+ " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
+ + " ORDER BY actor.name, movie.year").build();
request.getRow(0).getColumnValue(null);
}
@@ -123,11 +88,11 @@ public void should_throw_NullPointerException_because_column_name_parameter_is_n
*/
@Test
public void test_that_we_get_null_when_calling_getColumnValue_and_the_column_name_dont_exist() {
- Request request = new Request(dsConnectionProvider, "SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ Request request = assertDbConnection.request("SELECT actor.name, actor.firstname, movie.year, interpretation.character "
+ " FROM movie, actor, interpretation"
+ " WHERE movie.id = interpretation.id_movie"
+ " AND interpretation.id_actor = actor.id"
- + " ORDER BY actor.name, movie.year");
+ + " ORDER BY actor.name, movie.year").build();
assertThat(request.getRow(0).getColumnValue("not_exist")).isNull();
}
diff --git a/src/test/java/org/assertj/db/type/Table_Columns_Name_Test.java b/src/test/java/org/assertj/db/type/Table_Columns_Name_Test.java
index be6cb9aa..3d331bd6 100644
--- a/src/test/java/org/assertj/db/type/Table_Columns_Name_Test.java
+++ b/src/test/java/org/assertj/db/type/Table_Columns_Name_Test.java
@@ -30,70 +30,38 @@
public class Table_Columns_Name_Test extends AbstractTest {
/**
- * This method test the columns got from a {@code ConnectionProvider}.
+ * This method test the columns got from a {@code Connection}.
*/
@Test
- public void test_columns_name_with_jdbc_set() {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ public void test_columns_name() {
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getColumnsNameList()).as("Columns of MOVIE table").hasSize(4)
.containsExactly("ID", "TITLE", "YEAR", "MOVIE_IMDB");
}
/**
- * This method test the columns got from a {@code DataSource}.
+ * This method test the columns got from a {@code Connection} when the columns to check are set.
*/
@Test
- public void test_columns_name_with_datasource_set() {
- Table table = new Table(dsConnectionProvider, "movie");
-
- assertThat(table.getColumnsNameList()).as("Columns of MOVIE table").hasSize(4)
- .containsExactly("ID", "TITLE", "YEAR", "MOVIE_IMDB");
- }
-
- /**
- * This method test the columns got from a {@code ConnectionProvider} when the columns to check are set.
- */
- @Test
- public void test_columns_name_to_check_with_jdbc_set() {
- Table table = new Table(jdbcConnectionProvider, "actor", new String[]{"id", "name", "birth"}, null);
+ public void test_columns_name_to_check() {
+ Table table = assertDbConnection.table("actor").columnsToCheck(new String[]{"id", "name", "birth"}).build();
assertThat(table.getColumnsNameList()).as("Columns of ACTOR table").hasSize(3)
.containsExactly("ID", "NAME", "BIRTH");
}
/**
- * This method test the columns got from a {@code DataSource} when the columns to check are set.
+ * This method test the columns got from a {@code Connection} when the columns to exclude are set.
*/
@Test
- public void test_columns_name_to_check_with_datasource_set() {
- Table table = new Table(dsConnectionProvider, "actor", new String[]{"id", "name", "birth"}, null);
-
- assertThat(table.getColumnsNameList()).as("Columns of ACTOR table").hasSize(3)
- .containsExactly("ID", "NAME", "BIRTH");
- }
-
- /**
- * This method test the columns got from a {@code ConnectionProvider} when the columns to exclude are set.
- */
- @Test
- public void test_columns_name_to_exclude_with_jdbc_set() {
- Table table = new Table(jdbcConnectionProvider, "interpretation", null, new String[]{"id"});
+ public void test_columns_name_to_exclude() {
+ Table table = assertDbConnection.table("interpretation").columnsToExclude(new String[]{"id"}).build();
assertThat(table.getColumnsNameList()).as("Columns of INTERPRETATION table").hasSize(3)
.containsExactly("ID_MOVIE", "ID_ACTOR", "CHARACTER");
}
- /**
- * This method test the columns got from a {@code DataSource} when the columns to exclude are set.
- */
- @Test
- public void test_columns_name_to_exclude_with_datasource_set() {
- Table table = new Table(dsConnectionProvider, "interpretation", null, new String[]{"id"});
-
- assertThat(table.getColumnsNameList()).as("Columns of INTERPRETATION table").hasSize(3)
- .containsExactly("ID_MOVIE", "ID_ACTOR", "CHARACTER");
- }
/**
* This method should throw a {@code AssertJDBException} because of a {@code SQLException} caused by a table not
@@ -101,7 +69,7 @@ public void test_columns_name_to_exclude_with_datasource_set() {
*/
@Test(expected = AssertJDBException.class)
public void should_throw_AssertJDBException_because_SQLException_caused_by_table_not_found() {
- Table table = new Table(dsConnectionProvider, "interpret");
+ Table table = assertDbConnection.table("interpret").build();
table.getColumnsNameList();
}
}
diff --git a/src/test/java/org/assertj/db/type/Table_Columns_Test.java b/src/test/java/org/assertj/db/type/Table_Columns_Test.java
index 95e71389..f20af99c 100644
--- a/src/test/java/org/assertj/db/type/Table_Columns_Test.java
+++ b/src/test/java/org/assertj/db/type/Table_Columns_Test.java
@@ -33,24 +33,8 @@ public class Table_Columns_Test extends AbstractTest {
* This method test the columns got from a {@code ConnectionProvider}.
*/
@Test
- public void test_columns_with_jdbc_set() {
- Table table = new Table(jdbcConnectionProvider, "movie");
-
- Column columnFromIndex = table.getColumn(1);
-
- assertThat(columnFromIndex.getName()).isEqualTo("TITLE");
- assertThat(columnFromIndex.getValuesList().get(0).getValue()).isEqualTo("Alien");
- assertThat(columnFromIndex.getValuesList().get(1).getValue()).isEqualTo("The Village");
- assertThat(columnFromIndex.getValuesList().get(2).getValue()).isEqualTo("Avatar");
- assertThat(columnFromIndex.getRowValue(1).getValue()).isEqualTo("The Village");
- }
-
- /**
- * This method test the columns got from a {@code DataSource}.
- */
- @Test
- public void test_columns_with_datasource_set() {
- Table table = new Table(dsConnectionProvider, "movie");
+ public void test_columns() {
+ Table table = assertDbConnection.table("movie").build();
Column columnFromIndex = table.getColumn(1);
@@ -66,14 +50,16 @@ public void test_columns_with_datasource_set() {
*/
@Test
public void test_columns_to_check() {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getColumnsToCheck()).isNull();
- table.setColumnsToCheck(new String[]{"title", "test"});
+ Table tableWithCheck = assertDbConnection.table("movie")
+ .columnsToCheck(new String[]{"title", "test"})
+ .build();
- assertThat(table.getColumnsToCheck()).hasSize(1);
- assertThat(table.getColumnsToCheck()).contains("TITLE");
+ assertThat(tableWithCheck.getColumnsToCheck()).hasSize(1);
+ assertThat(tableWithCheck.getColumnsToCheck()).contains("TITLE");
}
/**
@@ -81,14 +67,17 @@ public void test_columns_to_check() {
*/
@Test
public void test_columns_to_exclude() {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getColumnsToExclude()).isNull();
- table.setColumnsToExclude(new String[]{"title", "test"});
- assertThat(table.getColumnsToExclude()).hasSize(1);
- assertThat(table.getColumnsToExclude()).contains("TITLE");
+ Table tableWithExclude = assertDbConnection.table("movie")
+ .columnsToExclude(new String[]{"title", "test"})
+ .build();
+
+ assertThat(tableWithExclude.getColumnsToExclude()).hasSize(1);
+ assertThat(tableWithExclude.getColumnsToExclude()).contains("TITLE");
}
/**
@@ -96,13 +85,15 @@ public void test_columns_to_exclude() {
*/
@Test
public void test_columns_to_order() {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getColumnsToOrder()).isNull();
- table.setColumnsToOrder(new Order[]{Order.asc("title"), Order.asc("test")});
+ Table tableWithOrder = assertDbConnection.table("movie")
+ .columnsToOrder(new Order[]{Order.asc("title"), Order.asc("test")})
+ .build();
- assertThat(table.getColumnsToOrder()).hasSize(1);
- assertThat(table.getColumnsToOrder()).contains(Order.asc("TITLE"));
+ assertThat(tableWithOrder.getColumnsToOrder()).hasSize(1);
+ assertThat(tableWithOrder.getColumnsToOrder()).contains(Order.asc("TITLE"));
}
}
diff --git a/src/test/java/org/assertj/db/type/Table_Exception_Test.java b/src/test/java/org/assertj/db/type/Table_Exception_Test.java
index 31f8fb15..0ef2f907 100644
--- a/src/test/java/org/assertj/db/type/Table_Exception_Test.java
+++ b/src/test/java/org/assertj/db/type/Table_Exception_Test.java
@@ -12,8 +12,6 @@
*/
package org.assertj.db.type;
-import static org.junit.Assert.fail;
-
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
@@ -21,13 +19,11 @@
import java.sql.Statement;
import javax.sql.DataSource;
-import org.assertj.core.api.Assertions;
import org.assertj.db.common.AbstractTest;
import org.assertj.db.common.DefaultConnection;
import org.assertj.db.common.DefaultDataSource;
import org.assertj.db.common.DefaultStatement;
import org.assertj.db.exception.AssertJDBException;
-import org.assertj.db.type.Table.Order;
import org.junit.Test;
/**
@@ -37,91 +33,6 @@
* @author Julien Roy
*/
public class Table_Exception_Test extends AbstractTest {
-
- /**
- * This method should fail because setting the connection provider to null.
- */
- @Test(expected = NullPointerException.class)
- public void should_fail_because_setting_connection_provider_to_null() {
- new Table().setConnectionProvider(null);
- }
-
- /**
- * This method should fail because the connection throw an exception when getting an object.
- */
- @Test(expected = AssertJDBException.class)
- public void should_fail_because_connection_throws_exception_when_getting_an_object() {
- DataSource ds = new DefaultDataSource(dataSource);
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
- table.getColumnsNameList();
- }
-
- /**
- * This method should fail because trying to set the columns to check first.
- */
- @Test
- public void should_fail_because_trying_to_set_columns_to_check_first() {
- try {
- new Table().setColumnsToCheck(new String[]{"test"});
- fail("An exception must be raised");
- } catch (AssertJDBException e) {
- Assertions.assertThat(e.getMessage()).isEqualTo("The table name and the connectionProvider must be set first");
- }
- }
-
- /**
- * This method should fail because trying to set the columns to exclude first.
- */
- @Test
- public void should_fail_because_trying_to_set_columns_to_exclude_first() {
- try {
- new Table().setColumnsToExclude(new String[]{"test"});
- fail("An exception must be raised");
- } catch (AssertJDBException e) {
- Assertions.assertThat(e.getMessage()).isEqualTo("The table name and the connectionProvider must be set first");
- }
- }
-
- /**
- * This method should fail because trying to set the columns order first.
- */
- @Test
- public void should_fail_because_trying_to_set_columns_order_first() {
- try {
- new Table().setColumnsToOrder(new Order[]{Order.asc("test")});
- fail("An exception must be raised");
- } catch (AssertJDBException e) {
- Assertions.assertThat(e.getMessage()).isEqualTo("The table name and the connectionProvider must be set first");
- }
- }
-
- /**
- * This method should fail because trying to set the columns order with order null.
- */
- @Test
- public void should_fail_because_trying_to_set_columns_order_with_order_null() {
- try {
- new Table(jdbcConnectionProvider, "test").setColumnsToOrder(new Order[]{null});
- fail("An exception must be raised");
- } catch (NullPointerException e) {
- Assertions.assertThat(e.getMessage()).isEqualTo("The order can not be null");
- }
- }
-
- /**
- * This method should fail because trying to set the columns order with column null.
- */
- @Test
- public void should_fail_because_trying_to_set_columns_order_with_column_null() {
- try {
- new Table(jdbcConnectionProvider, "test").setColumnsToOrder(new Order[]{Order.asc(null)});
- fail("An exception must be raised");
- } catch (NullPointerException e) {
- Assertions.assertThat(e.getMessage()).isEqualTo("The name of the column for order can not be null");
- }
- }
-
/**
* This method should fail because the connection throw an exception when executing a query.
*/
@@ -145,8 +56,8 @@ public ResultSet executeQuery(String sql) throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
table.getColumnsNameList();
}
@@ -167,8 +78,8 @@ public DatabaseMetaData getMetaData() throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
table.getColumnsNameList();
}
@@ -189,8 +100,8 @@ public Statement createStatement() throws SQLException {
};
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
table.getColumnsNameList();
}
@@ -205,8 +116,8 @@ public Connection getConnection() throws SQLException {
throw new SQLException();
}
};
- ConnectionProvider connectionProvider = ConnectionProviderFactory.of(ds).create();
- Table table = new Table(connectionProvider, "movi");
+ AssertDbConnection connectionProvider = AssertDbConnectionFactory.of(ds).create();
+ Table table = connectionProvider.table("movi").build();
table.getColumnsNameList();
}
}
diff --git a/src/test/java/org/assertj/db/type/Table_GetRowFromPksValues_Test.java b/src/test/java/org/assertj/db/type/Table_GetRowFromPksValues_Test.java
index 891b862c..adf012e2 100644
--- a/src/test/java/org/assertj/db/type/Table_GetRowFromPksValues_Test.java
+++ b/src/test/java/org/assertj/db/type/Table_GetRowFromPksValues_Test.java
@@ -33,7 +33,7 @@ public class Table_GetRowFromPksValues_Test extends AbstractTest {
*/
@Test
public void test_getting_row_from_primary_keys_values_without_finding() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getRowFromPksValues()).isNull();
assertThat(table.getRowFromPksValues(getValue(null, 1L), getValue(null, 3))).isNull();
@@ -44,7 +44,7 @@ public void test_getting_row_from_primary_keys_values_without_finding() throws E
*/
@Test
public void test_getting_row_from_primary_keys_values_with_finding() throws Exception {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getRowFromPksValues(getValue(null, 3)).getValuesList().get(0).getValue()).isEqualTo(new BigDecimal(3));
assertThat(table.getRowFromPksValues(getValue(null, 3)).getValuesList().get(1).getValue()).isEqualTo("Avatar");
diff --git a/src/test/java/org/assertj/db/type/Table_Getters_Test.java b/src/test/java/org/assertj/db/type/Table_Getters_Test.java
index 575b6ab6..961d2906 100644
--- a/src/test/java/org/assertj/db/type/Table_Getters_Test.java
+++ b/src/test/java/org/assertj/db/type/Table_Getters_Test.java
@@ -30,29 +30,14 @@
*/
public class Table_Getters_Test extends AbstractTest {
- /**
- * This method test the getters of a {@code Table} when only the connection provider is set.
- */
- @Test
- public void test_getters_with_only_connection_provider_set() {
- Table table = new Table().setConnectionProvider(jdbcConnectionProvider);
-
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
- assertThat(table.getName()).isNull();
- assertThat(table.getColumnsToCheck()).isNull();
- assertThat(table.getColumnsToExclude()).isNull();
- assertThat(table.getStartDelimiter()).isNull();
- assertThat(table.getEndDelimiter()).isNull();
- }
-
/**
* This method test the getters of a {@code Table} when the connection provider and the name are set.
*/
@Test
public void test_getters_with_connection_provider_and_name_set() {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ Table table = assertDbConnection.table("movie").build();
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isNotNull();
assertThat(table.getName()).isEqualTo("MOVIE");
assertThat(table.getColumnsToCheck()).isNull();
assertThat(table.getColumnsToExclude()).isNull();
@@ -67,9 +52,12 @@ public void test_getters_with_connection_provider_and_name_set() {
*/
@Test
public void test_getters_with_connection_provider_name_and_columns_set() {
- Table table = new Table(jdbcConnectionProvider, "movie", new String[]{"title", "year"}, new String[]{"id"});
+ Table table = assertDbConnection.table("movie")
+ .columnsToCheck(new String[]{"title", "year"})
+ .columnsToExclude(new String[]{"id"})
+ .build();
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isNotNull();
assertThat(table.getName()).isEqualTo("MOVIE");
assertThat(table.getColumnsToCheck()).containsExactly("TITLE", "YEAR");
assertThat(table.getColumnsToExclude()).containsExactly("ID");
@@ -84,11 +72,13 @@ public void test_getters_with_connection_provider_name_and_columns_set() {
*/
@Test
public void test_getters_with_connection_provider_name_columns_and_order_set() {
- Table table = new Table(jdbcConnectionProvider, "movie",
- new Table.Order[]{asc("title"), desc("year")},
- new String[]{"title", "year"}, new String[]{"id"});
+ Table table = assertDbConnection.table("movie")
+ .columnsToOrder(new Table.Order[]{asc("title"), desc("year")})
+ .columnsToCheck(new String[]{"title", "year"})
+ .columnsToExclude(new String[]{"id"})
+ .build();
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isNotNull();
assertThat(table.getName()).isEqualTo("MOVIE");
assertThat(table.getColumnsToCheck()).containsExactly("TITLE", "YEAR");
assertThat(table.getColumnsToExclude()).containsExactly("ID");
@@ -104,10 +94,11 @@ public void test_getters_with_connection_provider_name_columns_and_order_set() {
*/
@Test
public void test_getters_with_connection_provider_name_and_order_set() {
- Table table = new Table(jdbcConnectionProvider, "movie",
- new Table.Order[]{asc("title"), desc("year")});
+ Table table = assertDbConnection.table("movie")
+ .columnsToOrder(new Table.Order[]{asc("title"), desc("year")})
+ .build();
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isNotNull();
assertThat(table.getName()).isEqualTo("MOVIE");
assertThat(table.getColumnsToCheck()).isNull();
assertThat(table.getColumnsToExclude()).isNull();
@@ -122,9 +113,9 @@ public void test_getters_with_connection_provider_name_and_order_set() {
*/
@Test
public void test_getters_with_connection_provider_delimiters_and_name_set() {
- Table table = new Table(jdbcConnectionProvider, "movie", '1', '2');
+ Table table = assertDbConnection.table("movie").delimiters('1', '2').build();
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isNotNull();
assertThat(table.getName()).isEqualTo("MOVIE");
assertThat(table.getColumnsToCheck()).isNull();
assertThat(table.getColumnsToExclude()).isNull();
@@ -139,10 +130,12 @@ public void test_getters_with_connection_provider_delimiters_and_name_set() {
*/
@Test
public void test_getters_with_connection_provider_name_delimiters_and_columns_set() {
- Table table = new Table(jdbcConnectionProvider, "movie", '1', '2',
- new String[]{"title", "year"}, new String[]{"id"});
+ Table table = assertDbConnection.table("movie").delimiters('1', '2')
+ .columnsToCheck(new String[]{"title", "year"})
+ .columnsToExclude(new String[]{"id"})
+ .build();
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isNotNull();
assertThat(table.getName()).isEqualTo("MOVIE");
assertThat(table.getColumnsToCheck()).containsExactly("TITLE", "YEAR");
assertThat(table.getColumnsToExclude()).containsExactly("ID");
@@ -157,11 +150,13 @@ public void test_getters_with_connection_provider_name_delimiters_and_columns_se
*/
@Test
public void test_getters_with_connection_provider_name_columns_delimiters_and_order_set() {
- Table table = new Table(jdbcConnectionProvider, "movie", '1', '2',
- new Table.Order[]{asc("title"), desc("year")},
- new String[]{"title", "year"}, new String[]{"id"});
+ Table table = assertDbConnection.table("movie").delimiters('1', '2')
+ .columnsToOrder(new Table.Order[]{asc("title"), desc("year")})
+ .columnsToCheck(new String[]{"title", "year"})
+ .columnsToExclude(new String[]{"id"})
+ .build();
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isNotNull();
assertThat(table.getName()).isEqualTo("MOVIE");
assertThat(table.getColumnsToCheck()).containsExactly("TITLE", "YEAR");
assertThat(table.getColumnsToExclude()).containsExactly("ID");
@@ -177,10 +172,11 @@ public void test_getters_with_connection_provider_name_columns_delimiters_and_or
*/
@Test
public void test_getters_with_connection_provider_name_delimiters_and_order_set() {
- Table table = new Table(jdbcConnectionProvider, "movie", '1', '2',
- new Table.Order[]{asc("title"), desc("year")});
+ Table table = assertDbConnection.table("movie").delimiters('1', '2')
+ .columnsToOrder(new Table.Order[]{asc("title"), desc("year")})
+ .build();
- assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isSameAs(jdbcConnectionProvider);
+ assertThat(table.getConnectionProvider()).as("Source of MOVIE table").isNotNull();
assertThat(table.getName()).isEqualTo("MOVIE");
assertThat(table.getColumnsToCheck()).isNull();
assertThat(table.getColumnsToExclude()).isNull();
diff --git a/src/test/java/org/assertj/db/type/Table_Instantiation_Test.java b/src/test/java/org/assertj/db/type/Table_Instantiation_Test.java
index b356b3d8..af3061d2 100644
--- a/src/test/java/org/assertj/db/type/Table_Instantiation_Test.java
+++ b/src/test/java/org/assertj/db/type/Table_Instantiation_Test.java
@@ -13,6 +13,7 @@
package org.assertj.db.type;
import org.assertj.db.common.AbstractTest;
+import org.assertj.db.common.DefaultConnectionProvider;
import org.assertj.db.exception.AssertJDBException;
import org.junit.Test;
@@ -27,76 +28,24 @@
*/
public class Table_Instantiation_Test extends AbstractTest {
+ private final ConnectionProvider connectionProvider = new DefaultConnectionProvider(null);
+
/**
* This method should throw a {@code NullPointerException}, because the {@code ConnectionProvider} parameter is
* {@code null}.
*/
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_instantiate_with_connection_provider_null() {
- new Table(null, null);
+ @Test(expected = IllegalArgumentException.class)
+ public void should_throw_IllegalArgumentException_if_instantiate_with_connection_provider_null() {
+ new Table.Builder(null, null).build();
}
/**
* This method should throw a {@code NullPointerException}, because the {@code ConnectionProvider} parameter is not
* {@code null} and table name is {@code null}.
*/
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_instantiate_with_jdbc_connection_provider_not_null_and_table_name_null() {
- new Table(jdbcConnectionProvider, null);
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code DataSource} parameter is
- * {@code null} and table name is {@code null}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_instantiate_with_ds_connection_provider_not_null_and_table_name_null() {
- new Table(dsConnectionProvider, null);
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code DataSource} and the
- * {@code ConnectionProvider} fields are not set when call {@code getColumnsNameList()}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_get_list_of_columns_name_without_setting_connection_provider_or_datasource() {
- new Table().getColumnsNameList();
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code ConnectionProvider} field is set but not
- * the table name when call {@code getColumnsNameList()}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_get_list_of_columns_name_with_setting_connection_provider_and_without_setting_table_name() {
- new Table().setConnectionProvider(jdbcConnectionProvider).getColumnsNameList();
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code DataSource} field is set but
- * not the table name when call {@code getColumnsNameList()}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_get_list_of_columns_name_with_setting_datasource_and_without_setting_table_name() {
- new Table().setConnectionProvider(dsConnectionProvider).getColumnsNameList();
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code ConnectionProvider} field is set but not
- * the table name when call {@code getRequest()}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_get_request_with_setting_jdbc_connection_and_without_setting_table_name() {
- new Table().setConnectionProvider(jdbcConnectionProvider).getRequest();
- }
-
- /**
- * This method should throw a {@code NullPointerException}, because the {@code DataSource} field is set but
- * not the table name when call {@code getRequest()}.
- */
- @Test(expected = NullPointerException.class)
- public void should_throw_NullPointerException_if_get_request_with_setting_datasource_and_without_setting_table_name() {
- new Table().setConnectionProvider(dsConnectionProvider).getRequest();
+ @Test(expected = IllegalArgumentException.class)
+ public void should_throw_IllegalArgumentException_if_instantiate_with_connection_provider_not_null_and_table_name_null() {
+ new Table.Builder(connectionProvider, null).build();
}
/**
@@ -105,7 +54,7 @@ public void should_throw_NullPointerException_if_get_request_with_setting_dataso
*/
@Test(expected = AssertJDBException.class)
public void should_throw_AssertJDBException_if_get_list_of_rows_with_setting_connection_provider_having_bad_user() {
- Table table = new Table(ConnectionProviderFactory.of("jdbc:h2:mem:test", "", "").create(), "");
+ Table table = AssertDbConnectionFactory.of("jdbc:h2:mem:test", "", "").create().table("test").build();
table.getRowsList();
}
@@ -114,7 +63,7 @@ public void should_throw_AssertJDBException_if_get_list_of_rows_with_setting_con
*/
@Test(expected = NullPointerException.class)
public void should_throw_NullPointerException_if_one_of_the_columns_to_check_is_null() {
- new Table(jdbcConnectionProvider, "movie", new String[]{"id", null, "birth"}, null);
+ assertDbConnection.table("movie").columnsToCheck(new String[]{"id", null, "birth"}).build();
}
/**
@@ -122,6 +71,6 @@ public void should_throw_NullPointerException_if_one_of_the_columns_to_check_is_
*/
@Test(expected = NullPointerException.class)
public void should_throw_NullPointerException_if_one_of_the_columns_to_exclude_is_null() {
- new Table(jdbcConnectionProvider, "movie", new String[]{"id", "name", "birth"}, new String[]{null});
+ assertDbConnection.table("movie").columnsToExclude(new String[]{null}).build();
}
}
diff --git a/src/test/java/org/assertj/db/type/Table_PrimaryKeys_Name_Test.java b/src/test/java/org/assertj/db/type/Table_PrimaryKeys_Name_Test.java
index d093d9d9..7520e872 100644
--- a/src/test/java/org/assertj/db/type/Table_PrimaryKeys_Name_Test.java
+++ b/src/test/java/org/assertj/db/type/Table_PrimaryKeys_Name_Test.java
@@ -33,19 +33,8 @@ public class Table_PrimaryKeys_Name_Test extends AbstractTest {
* This method test the primary keys got from a {@code ConnectionProvider}.
*/
@Test
- public void test_pks_name_with_jdbc_set() {
- Table table = new Table(jdbcConnectionProvider, "movie");
-
- assertThat(table.getPksNameList()).as("Primary Keys of MOVIE table").hasSize(1)
- .containsExactly("ID");
- }
-
- /**
- * This method test the primary keys got from a {@code DataSource}.
- */
- @Test
- public void test_pks_name_with_datasource_set() {
- Table table = new Table(dsConnectionProvider, "movie");
+ public void test_pks_name() {
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getPksNameList()).as("Primary Keys of MOVIE table").hasSize(1)
.containsExactly("ID");
@@ -55,19 +44,8 @@ public void test_pks_name_with_datasource_set() {
* This method test the primary keys got from a {@code ConnectionProvider} when the columns to check are set.
*/
@Test
- public void test_pks_name_to_check_with_jdbc_set() {
- Table table = new Table(jdbcConnectionProvider, "actor", new String[]{"id", "name", "birth"}, null);
-
- assertThat(table.getPksNameList()).as("Primary Keys of ACTOR table").hasSize(1)
- .containsExactly("ID");
- }
-
- /**
- * This method test the primary keys got from a {@code DataSource} when the columns to check are set.
- */
- @Test
- public void test_pks_name_to_check_with_datasource_set() {
- Table table = new Table(dsConnectionProvider, "actor", new String[]{"id", "name", "birth"}, null);
+ public void test_pks_name_to_check() {
+ Table table = assertDbConnection.table("actor").columnsToCheck(new String[]{"id", "name", "birth"}).build();
assertThat(table.getPksNameList()).as("Primary Keys of ACTOR table").hasSize(1)
.containsExactly("ID");
@@ -77,18 +55,8 @@ public void test_pks_name_to_check_with_datasource_set() {
* This method test the primary keys got from a {@code ConnectionProvider} when the columns to exclude are set.
*/
@Test
- public void test_pks_name_to_exclude_with_jdbc_set() {
- Table table = new Table(jdbcConnectionProvider, "interpretation", null, new String[]{"ID"});
-
- assertThat(table.getPksNameList()).as("Primary Keys of INTERPRETATION table").hasSize(0);
- }
-
- /**
- * This method test the primary keys got from a {@code DataSource} when the columns to exclude are set.
- */
- @Test
- public void test_pks_name_to_exclude_with_datasource_set() {
- Table table = new Table(dsConnectionProvider, "interpretation", null, new String[]{"id"});
+ public void test_pks_name_to_exclude() {
+ Table table = assertDbConnection.table("interpretation").columnsToExclude(new String[]{"ID"}).build();
assertThat(table.getPksNameList()).as("Primary Keys of INTERPRETATION table").hasSize(0);
}
@@ -99,7 +67,7 @@ public void test_pks_name_to_exclude_with_datasource_set() {
*/
@Test(expected = AssertJDBException.class)
public void should_throw_AssertJDBException_because_SQLException_caused_by_table_not_found() {
- Table table = new Table(dsConnectionProvider, "interpret");
+ Table table = assertDbConnection.table("interpret").build();
table.getPksNameList();
}
diff --git a/src/test/java/org/assertj/db/type/Table_Rows_Test.java b/src/test/java/org/assertj/db/type/Table_Rows_Test.java
index 1b8f8f0a..dbd63076 100644
--- a/src/test/java/org/assertj/db/type/Table_Rows_Test.java
+++ b/src/test/java/org/assertj/db/type/Table_Rows_Test.java
@@ -36,8 +36,8 @@ public class Table_Rows_Test extends AbstractTest {
* This method test the rows got from a {@code ConnectionProvider}.
*/
@Test
- public void test_rows_with_jdbc_set() {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ public void test_rows() {
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getRowsList()).as("Values of MOVIE table").hasSize(3);
@@ -73,42 +73,8 @@ public void test_rows_with_jdbc_set() {
* This method test the rows got from a {@code DataSource}.
*/
@Test
- public void test_rows_with_datasource_set() {
- Table table = new Table(dsConnectionProvider, "movie");
-
- assertThat(table.getRowsList()).as("Values of MOVIE table").hasSize(3);
-
- assertThat(table.getRow(0).getValuesList().get(0).getValue()).as("Row 1 of MOVIE table").isEqualTo(
- new BigDecimal(1));
- assertThat(table.getRow(0).getValuesList().get(1).getValue()).as("Row 1 of MOVIE table").isEqualTo("Alien");
- assertThat(table.getRow(0).getValuesList().get(2).getValue()).as("Row 1 of MOVIE table").isEqualTo(
- new BigDecimal(1979));
- assertThat(table.getRow(0).getValuesList().get(3).getValue()).as("Row 1 of MOVIE table").isEqualTo(
- UUID.fromString("30B443AE-C0C9-4790-9BEC-CE1380808435"));
- assertThat(table.getRow(1).getValuesList().get(0).getValue()).as("Row 2 of MOVIE table").isEqualTo(
- new BigDecimal(2));
- assertThat(table.getRow(1).getValuesList().get(1).getValue()).as("Row 2 of MOVIE table").isEqualTo("The Village");
- assertThat(table.getRow(1).getValuesList().get(2).getValue()).as("Row 2 of MOVIE table").isEqualTo(
- new BigDecimal(2004));
- assertThat(table.getRow(1).getValuesList().get(3).getValue()).as("Row 2 of MOVIE table").isEqualTo(
- UUID.fromString("16319617-AE95-4087-9264-D3D21BF611B6"));
- assertThat(table.getRow(2).getValuesList().get(0).getValue()).as("Row 3 of MOVIE table")
- .isEqualTo(new BigDecimal(3));
- assertThat(table.getRow(2).getValuesList().get(1).getValue()).as("Row 3 of MOVIE table")
- .isEqualTo("Avatar");
- assertThat(table.getRow(2).getValuesList().get(2).getValue()).as("Row 3 of MOVIE table")
- .isEqualTo(new BigDecimal(2009));
- assertThat(table.getRow(2).getValuesList().get(3).getValue()).as("Row 3 of MOVIE table")
- .isEqualTo(UUID.fromString(
- "D735221B-5DE5-4112-AA1E-49090CB75ADA"));
- }
-
- /**
- * This method test the rows got from a {@code DataSource}.
- */
- @Test
- public void test_rows_with_datasource_and_order_set() {
- Table table = new Table(dsConnectionProvider, "movie", new Table.Order[]{asc("title")});
+ public void test_rows_with_order_set() {
+ Table table = assertDbConnection.table("movie").columnsToOrder(new Table.Order[]{asc("title")}).build();
assertThat(table.getRowsList()).as("Values of MOVIE table").hasSize(3);
@@ -142,7 +108,7 @@ public void test_rows_with_datasource_and_order_set() {
*/
@Test(expected = NullPointerException.class)
public void should_throw_NullPointerException_because_column_name_parameter_is_null_when_calling_getColumnValue() {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ Table table = assertDbConnection.table("movie").build();
table.getRow(0).getColumnValue(null);
}
@@ -151,7 +117,7 @@ public void should_throw_NullPointerException_because_column_name_parameter_is_n
*/
@Test
public void test_that_we_get_null_when_calling_getColumnValue_and_the_column_name_dont_exist() {
- Table table = new Table(jdbcConnectionProvider, "movie");
+ Table table = assertDbConnection.table("movie").build();
assertThat(table.getRow(0).getColumnValue("not_exist")).isNull();
}
diff --git a/src/test/java/org/assertj/db/type/TimeValue_Test.java b/src/test/java/org/assertj/db/type/TimeValue_Test.java
index 8d8feeba..5287b306 100644
--- a/src/test/java/org/assertj/db/type/TimeValue_Test.java
+++ b/src/test/java/org/assertj/db/type/TimeValue_Test.java
@@ -413,7 +413,7 @@ public void test_of_with_two_values() throws ParseException {
*/
@Test
public void test_toString() {
- assertThat(TimeValue.of(9, 1, 6, 3).toString()).isEqualTo("09:01:06.000000003");
+ assertThat(TimeValue.of(9, 1, 6, 3)).hasToString("09:01:06.000000003");
}
/**
diff --git a/src/test/java/org/assertj/db/util/Changes_Constructor_Test.java b/src/test/java/org/assertj/db/util/Changes_Constructor_Test.java
index 1de5b826..b0ab5337 100644
--- a/src/test/java/org/assertj/db/util/Changes_Constructor_Test.java
+++ b/src/test/java/org/assertj/db/util/Changes_Constructor_Test.java
@@ -12,13 +12,13 @@
*/
package org.assertj.db.util;
-import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.Test;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
-import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Test on the utility class {@code Changes} : the private constructor.
diff --git a/src/test/java/org/assertj/db/util/Changes_GetIndexesOfModifiedColumns_Test.java b/src/test/java/org/assertj/db/util/Changes_GetIndexesOfModifiedColumns_Test.java
index 39236dc7..195a4ad4 100644
--- a/src/test/java/org/assertj/db/util/Changes_GetIndexesOfModifiedColumns_Test.java
+++ b/src/test/java/org/assertj/db/util/Changes_GetIndexesOfModifiedColumns_Test.java
@@ -12,8 +12,6 @@
*/
package org.assertj.db.util;
-import java.util.Arrays;
-
import org.assertj.core.api.Assertions;
import org.assertj.db.common.AbstractTest;
import org.assertj.db.type.Change;
@@ -21,6 +19,8 @@
import org.assertj.db.type.DataType;
import org.junit.Test;
+import java.util.Arrays;
+
/**
* Tests on {@code getIndexesOfModifiedColumns} method.
*
diff --git a/src/test/java/org/assertj/db/util/Descriptions_GetDescription_Test.java b/src/test/java/org/assertj/db/util/Descriptions_GetDescription_Test.java
index 3663334a..5db9f770 100644
--- a/src/test/java/org/assertj/db/util/Descriptions_GetDescription_Test.java
+++ b/src/test/java/org/assertj/db/util/Descriptions_GetDescription_Test.java
@@ -17,9 +17,12 @@
import org.assertj.core.api.WritableAssertionInfo;
import org.assertj.db.common.AbstractTest;
import org.assertj.db.common.NeedReload;
+import org.assertj.db.type.AssertDbConnection;
+import org.assertj.db.type.AssertDbConnectionFactory;
import org.assertj.db.type.ChangeType;
import org.assertj.db.type.Request;
import org.assertj.db.type.Table;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -30,13 +33,23 @@
*/
public class Descriptions_GetDescription_Test extends AbstractTest {
+ AssertDbConnection assertDbConnectionFromDs;
+
+ @Before
+ public void initAssertDbConnectionFromDs() {
+ if (assertDbConnectionFromDs != null) {
+ return;
+ }
+ assertDbConnectionFromDs = AssertDbConnectionFactory.of(this.dataSource).create();
+ }
+
/**
* This method tests the {@code getDescription} method for the {@code Table}s.
*/
@Test
public void test_get_description_for_table() {
- Table fromSource = new Table(jdbcConnectionProvider, "actor");
- Table fromDataSource = new Table(dsConnectionProvider, "actor");
+ Table fromSource = assertDbConnection.table("actor").build();
+ Table fromDataSource = assertDbConnectionFromDs.table("actor").build();
String descriptionFromSource = Descriptions.getDescription(fromSource);
String descriptionFromDataSource = Descriptions.getDescription(fromDataSource);
@@ -50,10 +63,10 @@ public void test_get_description_for_table() {
*/
@Test
public void test_get_description_for_request() {
- Request fromSource = new Request(jdbcConnectionProvider, "select * from actor");
- Request fromDataSource = new Request(dsConnectionProvider, "select * from actor");
- Request fromSourceLong = new Request(jdbcConnectionProvider, "select id, name, firstname, birth, actor_imdb from actor");
- Request fromDataSourceLong = new Request(dsConnectionProvider, "select id, name, firstname, birth, actor_imdb from actor");
+ Request fromSource = assertDbConnection.request("select * from actor").build();
+ Request fromDataSource = assertDbConnectionFromDs.request("select * from actor").build();
+ Request fromSourceLong = assertDbConnection.request("select id, name, firstname, birth, actor_imdb from actor").build();
+ Request fromDataSourceLong = assertDbConnectionFromDs.request("select id, name, firstname, birth, actor_imdb from actor").build();
String descriptionFromSource = Descriptions.getDescription(fromSource);
String descriptionFromDataSource = Descriptions.getDescription(fromDataSource);
@@ -72,8 +85,8 @@ public void test_get_description_for_request() {
@Test
@NeedReload
public void test_get_description_for_changes() {
- org.assertj.db.type.Changes fromSource = new org.assertj.db.type.Changes(jdbcConnectionProvider).setStartPointNow();
- org.assertj.db.type.Changes fromDataSource = new org.assertj.db.type.Changes(dsConnectionProvider).setStartPointNow();
+ org.assertj.db.type.Changes fromSource = assertDbConnection.changes().build().setStartPointNow();
+ org.assertj.db.type.Changes fromDataSource = assertDbConnectionFromDs.changes().build().setStartPointNow();
updateChangesForTests();
fromSource.setEndPointNow();
fromDataSource.setEndPointNow();
@@ -91,9 +104,9 @@ public void test_get_description_for_changes() {
@Test
@NeedReload
public void test_get_description_for_changes_from_table() {
- org.assertj.db.type.Changes fromSource = new org.assertj.db.type.Changes(new Table(jdbcConnectionProvider, "actor"))
+ org.assertj.db.type.Changes fromSource = assertDbConnection.changes().tables(assertDbConnection.table("actor").build()).build()
.setStartPointNow();
- org.assertj.db.type.Changes fromDataSource = new org.assertj.db.type.Changes(new Table(dsConnectionProvider, "actor"))
+ org.assertj.db.type.Changes fromDataSource = assertDbConnectionFromDs.changes().tables(assertDbConnectionFromDs.table("actor").build()).build()
.setStartPointNow();
updateChangesForTests();
fromSource.setEndPointNow();
@@ -112,14 +125,19 @@ public void test_get_description_for_changes_from_table() {
@Test
@NeedReload
public void test_get_description_for_changes_from_request() {
- org.assertj.db.type.Changes fromSource = new org.assertj.db.type.Changes(new Request(jdbcConnectionProvider, "select * from actor"))
+ org.assertj.db.type.Changes fromSource = assertDbConnection.changes().request(
+ assertDbConnection.request("select * from actor").build()).build()
+ .setStartPointNow();
+ org.assertj.db.type.Changes fromDataSource = assertDbConnectionFromDs.changes().request(
+ assertDbConnectionFromDs.request("select * from actor").build()).build()
+ .setStartPointNow();
+ org.assertj.db.type.Changes fromSourceLong = assertDbConnection.changes().request(
+ assertDbConnection.request("select id, name, firstname, birth, actor_imdb from actor").build()).build()
+ .setStartPointNow();
+ org.assertj.db.type.Changes fromDataSourceLong = assertDbConnectionFromDs.changes().request(
+ assertDbConnectionFromDs.request("select id, name, firstname, birth, actor_imdb from actor").build())
+ .build()
.setStartPointNow();
- org.assertj.db.type.Changes fromDataSource = new org.assertj.db.type.Changes(
- new Request(dsConnectionProvider, "select * from actor")).setStartPointNow();
- org.assertj.db.type.Changes fromSourceLong = new org.assertj.db.type.Changes(
- new Request(jdbcConnectionProvider, "select id, name, firstname, birth, actor_imdb from actor")).setStartPointNow();
- org.assertj.db.type.Changes fromDataSourceLong = new org.assertj.db.type.Changes(
- new Request(dsConnectionProvider, "select id, name, firstname, birth, actor_imdb from actor")).setStartPointNow();
updateChangesForTests();
fromSource.setEndPointNow();
fromDataSource.setEndPointNow();
@@ -261,9 +279,11 @@ public void test_get_description_for_changes_from_changes() {
@Test
@NeedReload
public void test_get_description_for_change_from_changes_from_table() {
- org.assertj.db.type.Changes fromSource = new org.assertj.db.type.Changes(new Table(jdbcConnectionProvider, "actor"))
+ org.assertj.db.type.Changes fromSource = assertDbConnection.changes().tables(assertDbConnection.table("actor").build())
+ .build()
.setStartPointNow();
- org.assertj.db.type.Changes fromDataSource = new org.assertj.db.type.Changes(new Table(dsConnectionProvider, "actor"))
+ org.assertj.db.type.Changes fromDataSource = assertDbConnectionFromDs.changes().tables(assertDbConnectionFromDs.table("actor").build())
+ .build()
.setStartPointNow();
updateChangesForTests();
fromSource.setEndPointNow();
@@ -297,14 +317,22 @@ public void test_get_description_for_change_from_changes_from_table() {
@Test
@NeedReload
public void test_get_description_for_change_from_changes_from_request() {
- org.assertj.db.type.Changes fromSource = new org.assertj.db.type.Changes(new Request(jdbcConnectionProvider, "select * from actor"))
+ org.assertj.db.type.Changes fromSource = assertDbConnection.changes().request(
+ assertDbConnection.request("select * from actor").build())
+ .build()
+ .setStartPointNow();
+ org.assertj.db.type.Changes fromDataSource = assertDbConnectionFromDs.changes().request(
+ assertDbConnectionFromDs.request("select * from actor").build())
+ .build()
+ .setStartPointNow();
+ org.assertj.db.type.Changes fromSourceLong = assertDbConnection.changes().request(
+ assertDbConnection.request("select id, name, firstname, birth, actor_imdb from actor").build())
+ .build()
+ .setStartPointNow();
+ org.assertj.db.type.Changes fromDataSourceLong = assertDbConnectionFromDs.changes().request(
+ assertDbConnectionFromDs.request("select id, name, firstname, birth, actor_imdb from actor").build())
+ .build()
.setStartPointNow();
- org.assertj.db.type.Changes fromDataSource = new org.assertj.db.type.Changes(
- new Request(dsConnectionProvider, "select * from actor")).setStartPointNow();
- org.assertj.db.type.Changes fromSourceLong = new org.assertj.db.type.Changes(
- new Request(jdbcConnectionProvider, "select id, name, firstname, birth, actor_imdb from actor")).setStartPointNow();
- org.assertj.db.type.Changes fromDataSourceLong = new org.assertj.db.type.Changes(
- new Request(dsConnectionProvider, "select id, name, firstname, birth, actor_imdb from actor")).setStartPointNow();
updateChangesForTests();
fromSource.setEndPointNow();
fromDataSource.setEndPointNow();