org.assertj
assertj-core
diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/LombokLazyEqualsAndHashcodeTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/LombokLazyEqualsAndHashcodeTest.java
index e99eeb868..8f0d031e4 100644
--- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/LombokLazyEqualsAndHashcodeTest.java
+++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/LombokLazyEqualsAndHashcodeTest.java
@@ -1,7 +1,6 @@
package nl.jqno.equalsverifier.integration.extra_features;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.StringContains.containsString;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import nl.jqno.equalsverifier.EqualsVerifier;
@@ -28,7 +27,7 @@ void defaultEqualsVerifierFailsForCachedLombokEqualsAndHashcode() {
final AssertionError error = assertThrows(
AssertionError.class,
() -> EqualsVerifier.forClass(LazyPojo.class).suppress(Warning.STRICT_INHERITANCE).verify());
- assertThat(error.getMessage(), containsString("hashCode relies on $hashCodeCache, but equals does not."));
+ assertThat(error.getMessage()).contains("hashCode relies on $hashCodeCache, but equals does not.");
}
@Test
@@ -40,15 +39,13 @@ void defaultEqualsVerifierFailsForCachedLombokEqualsAndHashcodeWhenUsingWithCach
.suppress(Warning.STRICT_INHERITANCE)
.withCachedHashCode("$hashCodeCache", "hashCode", new LazyPojo("bar", new Object()))
.verify());
- assertThat(
- error.getMessage(),
- containsString(
- "Cached hashCode: Could not find calculateHashCodeMethod: must be 'private int hashCode()'"));
+ assertThat(error.getMessage())
+ .contains("Cached hashCode: Could not find calculateHashCodeMethod: must be 'private int hashCode()'");
}
/**
* This class has been generated with Lombok (1.18.20). It is equivalent to:
- *
+ *
*
* @RequiredArgsConstructor
* @EqualsAndHashCode(cacheStrategy = EqualsAndHashCode.CacheStrategy.LAZY)
diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/MultipleTypeEqualsVerifierTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/MultipleTypeEqualsVerifierTest.java
index dc56d348a..c0ddf8472 100644
--- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/MultipleTypeEqualsVerifierTest.java
+++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/MultipleTypeEqualsVerifierTest.java
@@ -1,8 +1,6 @@
package nl.jqno.equalsverifier.integration.operational;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
import java.util.Arrays;
import java.util.List;
@@ -279,6 +277,6 @@ private void assertSuccessful(EqualsVerifierReport report, Class> type) {
private void assertUnsuccessful(EqualsVerifierReport report, Class> type, String message) {
assertThat(report.isSuccessful()).isFalse();
assertThat(report.getType()).isEqualTo(type);
- assertThat(report.getMessage(), containsString(message));
+ assertThat(report.getMessage()).contains(message);
}
}
diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java
index 337810094..af4fbb4f7 100644
--- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java
+++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java
@@ -2,8 +2,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.EqualsVerifierReport;
@@ -30,9 +28,8 @@ void containsAppropriateErrorMessageAndExceptionWhenClassIsIncorrect() {
assertThat(report.getType()).isEqualTo(Point.class);
assertThat(report.isSuccessful()).isFalse();
- assertThat(
- report.getMessage(),
- startsWith("EqualsVerifier found a problem in class nl.jqno.equalsverifier.testhelpers.types.Point"));
+ assertThat(report.getMessage())
+ .startsWith("EqualsVerifier found a problem in class nl.jqno.equalsverifier.testhelpers.types.Point");
assertThat(report.getCause().getClass()).isEqualTo(AssertionException.class);
assertThat(report.getCause().getMessage()).isNull();
}
diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/EqualsVerifierInternalBugExceptionTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/EqualsVerifierInternalBugExceptionTest.java
index d0c6caa7a..2b2bde395 100644
--- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/EqualsVerifierInternalBugExceptionTest.java
+++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/EqualsVerifierInternalBugExceptionTest.java
@@ -1,7 +1,6 @@
package nl.jqno.equalsverifier.internal.exceptions;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
@@ -47,24 +46,24 @@ void exceptionHasMessageAndCause() {
private void assertNoMessage() {
assertMessagePreamble();
- assertThat(actual.getMessage(), not(containsString("\n")));
+ assertThat(actual.getMessage()).doesNotContain("\n");
}
private void assertMessage(String message) {
assertMessagePreamble();
- assertThat(actual.getMessage(), containsString("\n"));
- assertThat(actual.getMessage(), containsString(message));
+ assertThat(actual.getMessage()).contains("\n");
+ assertThat(actual.getMessage()).contains(message);
}
private void assertMessagePreamble() {
- assertThat(actual.getMessage(), containsString("This is a bug in EqualsVerifier"));
+ assertThat(actual.getMessage()).contains("This is a bug in EqualsVerifier");
}
private void assertNoCause() {
- assertThat(actual.getCause(), is(nullValue()));
+ assertThat(actual.getCause()).isEqualTo(null);
}
private void assertCause(Throwable cause) {
- assertThat(actual.getCause(), is(cause));
+ assertThat(actual.getCause()).isEqualTo(cause);
}
}
diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ConditionalInstantiatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ConditionalInstantiatorTest.java
index 588e53582..0d6916296 100644
--- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ConditionalInstantiatorTest.java
+++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ConditionalInstantiatorTest.java
@@ -4,9 +4,6 @@
import static nl.jqno.equalsverifier.internal.reflection.Util.objects;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
import java.math.BigDecimal;
import java.util.Calendar;
@@ -36,7 +33,7 @@ void resolveReturnsNull_whenTypeDoesntExist() {
ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST);
Class> actual = ci.resolve();
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -45,14 +42,14 @@ void objectIsInstantiatedCorrectly_whenValidConstructorParametersAreProvided() {
Calendar expected = new GregorianCalendar(1999, 11, 31);
Calendar actual = ci.instantiate(classes(int.class, int.class, int.class), objects(1999, 11, 31));
- assertThat(actual, is(expected));
+ assertThat(actual).isEqualTo(expected);
}
@Test
void nullIsReturned_whenInstantiateIsCalled_givenTypeDoesNotExist() {
ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST);
Object actual = ci.instantiate(classes(String.class), objects("nope"));
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -68,7 +65,7 @@ void nullIsReturned_whenInvalidConstructorParametersAreProvided_givenFalse() {
ci = new ConditionalInstantiator("java.util.GregorianCalendar", false);
Object actual = ci.instantiate(classes(int.class, int.class, int.class), objects(1999, 31, "hello"));
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -77,14 +74,14 @@ void objectIsInstantiatedCorrectly_whenValidFactoryMethodAndParametersAreProvide
int expected = Integer.valueOf(42);
int actual = ci.callFactory("valueOf", classes(int.class), objects(42));
- assertThat(actual, is(expected));
+ assertThat(actual).isEqualTo(expected);
}
@Test
void nullIsReturned_whenFactoryIsCalled_givenTypeDoesNotExist() {
ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST);
Object actual = ci.callFactory("factory", classes(String.class), objects("nope"));
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -100,7 +97,7 @@ void nullIsReturned_whenInvalidMethodNameIsProvided_givenFalse() {
ci = new ConditionalInstantiator("java.lang.Integer", false);
Object actual = ci.callFactory("thisMethodDoesntExist", classes(int.class), objects(42));
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -116,7 +113,7 @@ void nullIsReturned_whenInvalidFactoryMethodParametersAreProvided_givenFalse() {
ci = new ConditionalInstantiator("java.lang.Integer", false);
Object actual = ci.callFactory("valueOf", classes(int.class, int.class), objects(42));
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -125,14 +122,14 @@ void objectIsInstantiatedCorrectly_whenValidExternalFactoryMethodAndParametersAr
List> expected = Collections.emptyList();
List> actual = ci.callFactory("java.util.Collections", "emptyList", classes(), objects());
- assertThat(actual, is(expected));
+ assertThat(actual).isEqualTo(expected);
}
@Test
void nullIsReturned_whenExternalFactoryIsCalled_givenTypeDoesNotExist() {
ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST);
Object actual = ci.callFactory("java.util.Collections", "emptyList", classes(), objects());
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -148,7 +145,7 @@ void nullIsReturned_whenExternalFactoryIsCalled_givenFactoryTypeDoesNotExist_giv
ci = new ConditionalInstantiator("java.util.List", false);
Object actual = ci.callFactory("java.util.ThisTypeDoesNotExist", "emptyList", classes(), objects());
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -165,7 +162,7 @@ void nullIsReturned_whenInvalidExternalFactoryMethodNameIsProvided_givenFalse()
ci = new ConditionalInstantiator("java.util.List", false);
Object actual = ci.callFactory("java.util.Collections", "thisMethodDoesntExist", classes(), objects());
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -182,14 +179,14 @@ void nullIsReturned_whenInvalidExternalFactoryMethodParametersAreProvided_givenF
ci = new ConditionalInstantiator("java.util.List", false);
Object actual = ci.callFactory("java.util.Collections", "emptyList", classes(int.class), objects(42));
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
void nullIsReturned_whenReturnConstantIsCalled_givenTypeDoesNotExist() {
ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST);
Object actual = ci.returnConstant("NOPE");
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
@Test
@@ -198,7 +195,7 @@ void objectIsReturned_whenValidConstantIsProvided() {
BigDecimal expected = BigDecimal.TEN;
BigDecimal actual = ci.returnConstant("TEN");
- assertThat(actual, is(expected));
+ assertThat(actual).isEqualTo(expected);
}
@Test
@@ -213,6 +210,6 @@ void nullIsReturned_whenConstantDoesNotExist_givenFalse() {
ci = new ConditionalInstantiator("java.math.BigDecimal", false);
Object actual = ci.returnConstant("FORTY-TWO");
- assertThat(actual, is(nullValue()));
+ assertThat(actual).isEqualTo(null);
}
}
diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FormatterTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FormatterTest.java
index ffe15f8a9..281d3db06 100644
--- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FormatterTest.java
+++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FormatterTest.java
@@ -2,8 +2,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
import nl.jqno.equalsverifier.internal.reflection.Instantiator;
import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException;
@@ -60,28 +58,28 @@ void oneParameterWithNoFieldsAndThrowsWithNullMessage() {
void oneAbstractParameter() {
Instantiator i = Instantiator.of(Abstract.class, objenesis);
Formatter f = Formatter.of("Abstract: %%", i.instantiate());
- assertThat(f.format(), containsString("Abstract: [Abstract x=0]"));
+ assertThat(f.format()).contains("Abstract: [Abstract x=0]");
}
@Test
void oneConcreteSubclassParameter() {
Instantiator i = Instantiator.of(AbstractImpl.class, objenesis);
Formatter f = Formatter.of("Concrete: %%", i.instantiate());
- assertThat(f.format(), containsString("Concrete: something concrete"));
+ assertThat(f.format()).contains("Concrete: something concrete");
}
@Test
void oneDelegatedAbstractParameter() {
Instantiator i = Instantiator.of(AbstractDelegation.class, objenesis);
Formatter f = Formatter.of("Abstract: %%", i.instantiate());
- assertThat(f.format(), containsString("Abstract: [AbstractDelegation y=0]"));
+ assertThat(f.format()).contains("Abstract: [AbstractDelegation y=0]");
}
@Test
void oneDelegatedConcreteSubclassParameter() {
Instantiator i = Instantiator.of(AbstractDelegationImpl.class, objenesis);
Formatter f = Formatter.of("Concrete: %%", i.instantiate());
- assertThat(f.format(), containsString("Concrete: something concrete"));
+ assertThat(f.format()).contains("Concrete: something concrete");
}
@Test
@@ -91,7 +89,7 @@ void oneThrowingContainerParameter() {
Formatter f = Formatter.of("TC: %%", tc);
String expected =
"TC: [ThrowingContainer t=[Throwing i=0 s=null]-throws IllegalStateException(msg)]-throws IllegalStateException(msg)";
- assertThat(f.format(), containsString(expected));
+ assertThat(f.format()).contains(expected);
}
@Test
@@ -100,7 +98,7 @@ void oneAbstractContainerParameter() {
AbstractContainer ac = new AbstractContainer(i.instantiate());
Formatter f = Formatter.of("AC: %%", ac);
- assertThat(f.format(), containsString("AC: [AbstractContainer ad=[AbstractDelegation y=0]]"));
+ assertThat(f.format()).contains("AC: [AbstractContainer ad=[AbstractDelegation y=0]]");
}
@Test
@@ -112,13 +110,13 @@ void parameterWithMixOfVariousFields() {
String expected =
"[Mix i=42 s=null t=not null throwing=[Throwing i=42 s=empty]-throws IllegalStateException(msg)]"
+ "-throws UnsupportedOperationException(null)";
- assertThat(f.format(), containsString(expected));
+ assertThat(f.format()).contains(expected);
}
@Test
void connectedParameters() {
Formatter f = Formatter.of("%%%%", 1, 2);
- assertThat(f.format(), containsString("12"));
+ assertThat(f.format()).contains("12");
}
@Test
diff --git a/pom.xml b/pom.xml
index ccb747538..e56c3850a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,7 +84,6 @@
2.3.100
0.2
33.3.1-jre
- 3.0
3.0.0
1.3.2
1.0