Migrate Hamcrest assertions to AssertJ

Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
This commit is contained in:
Phillip Webb
2019-05-23 15:48:03 -07:00
parent 2294625cf0
commit 95a9d46a87
322 changed files with 4358 additions and 4814 deletions

View File

@@ -27,11 +27,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willReturn;
@@ -54,7 +52,7 @@ public class SharedEntityManagerCreatorTests {
EntityManagerFactory emf = mock(EntityManagerFactory.class,
withSettings().extraInterfaces(EntityManagerFactoryInfo.class));
// EntityManagerFactoryInfo.getEntityManagerInterface returns null
assertThat(SharedEntityManagerCreator.createSharedEntityManager(emf), is(notNullValue()));
assertThat(SharedEntityManagerCreator.createSharedEntityManager(emf)).isNotNull();
}
@Test

View File

@@ -23,8 +23,9 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.orm.jpa.domain.Person;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link DefaultPersistenceUnitManager}.
@@ -54,9 +55,9 @@ public class DefaultPersistenceUnitManagerTests {
private void testDefaultDomain() {
SpringPersistenceUnitInfo puInfo = buildDefaultPersistenceUnitInfo();
assertThat(puInfo.getManagedClassNames(), containsInAnyOrder(
assertThat(puInfo.getManagedClassNames()).contains(
"org.springframework.orm.jpa.domain.Person",
"org.springframework.orm.jpa.domain.DriversLicense"));
"org.springframework.orm.jpa.domain.DriversLicense");
}
private SpringPersistenceUnitInfo buildDefaultPersistenceUnitInfo() {