diff --git a/pom.xml b/pom.xml index d2856749..855ae6c3 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ assertj-db - 3.0.1 + 3.0.2-SNAPSHOT AssertJ-DB - Assertions for database AssertJ-DB - Rich and fluent assertions for testing with database diff --git a/src/main/java/org/assertj/db/type/Changes.java b/src/main/java/org/assertj/db/type/Changes.java index c79eddf1..d279e3dc 100644 --- a/src/main/java/org/assertj/db/type/Changes.java +++ b/src/main/java/org/assertj/db/type/Changes.java @@ -24,6 +24,9 @@ import java.util.List; import java.util.function.Consumer; +import org.assertj.core.api.AssertProvider; +import org.assertj.db.api.Assertions; +import org.assertj.db.api.ChangesAssert; import org.assertj.db.exception.AssertJDBException; import org.assertj.db.util.ChangeComparator; @@ -85,7 +88,7 @@ * @author Régis Pouiller * @author Julien Roy */ -public class Changes extends AbstractDbElement { +public class Changes extends AbstractDbElement implements AssertProvider { /** * The list of the tables. @@ -679,4 +682,16 @@ public Changes build() { return new Changes(this.connectionProvider); } } + + /** + * Makes both AssertJ Core and AssertJ DB assertions able to coexist in the same class with {@link org.assertj.core.api.Assertions org.assertj.core.api.Assertions.assertThat} as the only import necessary.

+ * Also works for both BDDAssertions.then static methods from AssertJ Core and AssertJ DB.

+ * + * @see org.assertj.core.api.Assertions#assertThat(AssertProvider) <T> org.assertj.core.api.Assertions.assertThat(AssertProvider<T> component) + * @see org.assertj.core.api.BDDAssertions#then(AssertProvider) <T> org.assertj.core.api.BDDAssertions.then(AssertProvider<T> component) + */ + @Override + public ChangesAssert assertThat() { + return Assertions.assertThat(this); + } } diff --git a/src/main/java/org/assertj/db/type/Request.java b/src/main/java/org/assertj/db/type/Request.java index 5fade7a8..3123700f 100644 --- a/src/main/java/org/assertj/db/type/Request.java +++ b/src/main/java/org/assertj/db/type/Request.java @@ -21,6 +21,9 @@ import java.util.Arrays; import java.util.List; +import org.assertj.core.api.AssertProvider; +import org.assertj.core.api.Assertions; +import org.assertj.db.api.RequestAssert; import org.assertj.db.type.lettercase.LetterCase; /** @@ -62,7 +65,7 @@ * @author Régis Pouiller * @author Julien Roy */ -public class Request extends AbstractDbData { +public class Request extends AbstractDbData implements AssertProvider { /** * SQL request to get the values. @@ -226,4 +229,16 @@ public Request build() { return new Request(this.connectionProvider, this.request, this.parameters, this.pksName); } } + + /** + * Makes both AssertJ Core and AssertJ DB assertions able to coexist in the same class with {@link org.assertj.core.api.Assertions org.assertj.core.api.Assertions.assertThat} as the only import necessary.

+ * Also works for both BDDAssertions.then static methods from AssertJ Core and AssertJ DB.

+ * + * @see org.assertj.core.api.Assertions#assertThat(AssertProvider) <T> org.assertj.core.api.Assertions.assertThat(AssertProvider<T> component) + * @see org.assertj.core.api.BDDAssertions#then(AssertProvider) <T> org.assertj.core.api.BDDAssertions.then(AssertProvider<T> component) + */ + @Override + public RequestAssert assertThat() { + return Assertions.assertThat(this); + } } diff --git a/src/main/java/org/assertj/db/type/Table.java b/src/main/java/org/assertj/db/type/Table.java index 44ac1d40..ccbf3dd3 100644 --- a/src/main/java/org/assertj/db/type/Table.java +++ b/src/main/java/org/assertj/db/type/Table.java @@ -22,6 +22,9 @@ import java.util.Arrays; import java.util.List; +import org.assertj.core.api.AssertProvider; +import org.assertj.db.api.Assertions; +import org.assertj.db.api.TableAssert; import org.assertj.db.exception.AssertJDBException; import org.assertj.db.type.lettercase.LetterCase; import org.assertj.db.util.NameComparator; @@ -73,7 +76,7 @@ * @author Régis Pouiller * @author Julien Roy */ -public class Table extends AbstractDbData { +public class Table extends AbstractDbData
implements AssertProvider { /** * The name of the table. @@ -726,4 +729,16 @@ public enum OrderType { DESC } } + + /** + * Makes both AssertJ Core and AssertJ DB assertions able to coexist in the same class with {@link org.assertj.core.api.Assertions org.assertj.core.api.Assertions.assertThat} as the only import necessary.

+ * Also works for both BDDAssertions.then static methods from AssertJ Core and AssertJ DB.

+ * + * @see org.assertj.core.api.Assertions#assertThat(AssertProvider) <T> org.assertj.core.api.Assertions.assertThat(AssertProvider<T> component) + * @see org.assertj.core.api.BDDAssertions#then(AssertProvider) <T> org.assertj.core.api.BDDAssertions.then(AssertProvider<T> component) + */ + @Override + public TableAssert assertThat() { + return Assertions.assertThat(this); + } } 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 633754a1..e670b2bc 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 @@ -12,8 +12,11 @@ */ package org.assertj.db.type; -import static org.assertj.core.api.Assertions.assertThat; +import java.util.List; +import org.assertj.core.api.Assertions; +import org.assertj.core.api.ListAssert; +import org.assertj.core.api.ObjectAssert; import org.assertj.db.common.AbstractTest; import org.junit.Test; @@ -193,4 +196,12 @@ public void test_constructor_request() { assertThat(changes.getTablesAtStartPointList()).isNull(); assertThat(changes.getTablesAtEndPointList()).isNull(); } + + private static ObjectAssert assertThat(Object o) { + return Assertions.assertThat(o); + } + + private static ListAssert assertThat(List list) { + return Assertions.assertThat(list); + } }