diff --git a/pom.xml b/pom.xml index 05b86dae..0d7e2413 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 assertj-db - 2.0.2 + 2.0.3-SNAPSHOT jar AssertJ-DB - Assertions for database AssertJ-DB - Rich and fluent assertions for testing with database diff --git a/src/main/java/org/assertj/db/api/assertions/impl/AssertionsOnRowEquality.java b/src/main/java/org/assertj/db/api/assertions/impl/AssertionsOnRowEquality.java index d415dd6f..84461364 100644 --- a/src/main/java/org/assertj/db/api/assertions/impl/AssertionsOnRowEquality.java +++ b/src/main/java/org/assertj/db/api/assertions/impl/AssertionsOnRowEquality.java @@ -65,13 +65,13 @@ public static > A hasValues(A assertion, WritableAss if (!value.isComparisonPossible(object)) { throw failures.failure(info, shouldBeCompatible(value, object)); } - if (!areEqual(value, expected[index])) { + if (!areEqual(value, object)) { if (value.getValueType() == ValueType.BYTES) { throw failures.failure(info, shouldBeEqual(index)); } else { throw failures.failure(info, shouldBeEqual(index, Values.getRepresentationFromValueInFrontOfExpected(value, - expected[index]), - expected[index])); + object), + object)); } } index++; diff --git a/src/main/java/org/assertj/db/navigation/PositionWithChanges.java b/src/main/java/org/assertj/db/navigation/PositionWithChanges.java index e789f2a1..d2187faa 100644 --- a/src/main/java/org/assertj/db/navigation/PositionWithChanges.java +++ b/src/main/java/org/assertj/db/navigation/PositionWithChanges.java @@ -125,7 +125,7 @@ public E getChangesInstance(Changes changes, ChangeType changeType, String table } try { - Class clazz = unProxy(myself.getClass()); + Class clazz = unProxy(myself.getClass()); Constructor constructor = actualElementClass.getDeclaredConstructor(clazz, Changes.class); instance = constructor.newInstance(myself, nextChanges); instance.as(getChangesDescription(changeType, tableName)); diff --git a/src/main/java/org/assertj/db/type/Value.java b/src/main/java/org/assertj/db/type/Value.java index 6065862c..bae8e7fe 100644 --- a/src/main/java/org/assertj/db/type/Value.java +++ b/src/main/java/org/assertj/db/type/Value.java @@ -12,6 +12,7 @@ */ package org.assertj.db.type; +import org.assertj.core.api.Condition; import org.assertj.db.type.lettercase.LetterCase; import org.assertj.db.type.lettercase.WithColumnLetterCase; @@ -174,6 +175,9 @@ public String getValueTypeRepresentation() { * @return {@code true} is comparison is possible. */ public boolean isComparisonPossible(Object object) { + if (object instanceof Condition) { + return true; + } if (valueType == ValueType.BYTES) { return (object instanceof byte[]); } diff --git a/src/main/java/org/assertj/db/util/Values.java b/src/main/java/org/assertj/db/util/Values.java index 081982a9..0e27b91e 100644 --- a/src/main/java/org/assertj/db/util/Values.java +++ b/src/main/java/org/assertj/db/util/Values.java @@ -12,6 +12,7 @@ */ package org.assertj.db.util; +import org.assertj.core.api.Condition; import org.assertj.db.exception.AssertJDBException; import org.assertj.db.type.*; @@ -128,6 +129,10 @@ else if (valueType == ValueType.DATE_TIME) { return object.equals(expected); } } + if (expected instanceof Condition) { + Condition condition = (Condition) expected; + return condition.matches(value.getValue()); + } return false; }