Migrate tests to AssertJ
Mostly thanks to IDEA's plugin: https://plugins.jetbrains.com/plugin/10345-assertions2assertj There is still a lot of work to do when complex and composite matchers are used. * Add `awaitility` dependency and deprecate `EventuallyMatcher` in favor of `awaitility` * Remove Hamcrest from dependencies and disable JUnit & Hamcrest static imports to encourage to use only AssertJ * Migrate JUnit assumptions in rules to AssertJ's assumptions * Deprecate some custom matchers in favor of existing in Hamcrest after upgrading the last to version `2.1` * Replace `ExpectedException` rules with `assertThatThrownBy()` * Mention `MessagePredicate` in the `testing.adoc`
This commit is contained in:
@@ -77,26 +77,14 @@
|
||||
<module name="AvoidStarImport" />
|
||||
<module name="AvoidStaticImport">
|
||||
<property name="excludes"
|
||||
value="org.custommonkey.xmlunit.XMLAssert.*,
|
||||
org.assertj.core.api.Assertions.*,
|
||||
org.hamcrest.CoreMatchers.*,
|
||||
org.hamcrest.Matchers.*,
|
||||
org.hamcrest.collection.IsCollectionWithSize.*,
|
||||
org.junit.Assert.*,
|
||||
org.junit.Assume.*,
|
||||
value="org.assertj.core.api.Assertions.*,
|
||||
org.assertj.core.api.Assumptions.*,
|
||||
org.awaitility.Awaitility.*,
|
||||
org.mockito.Mockito.*,
|
||||
org.mockito.BDDMockito.*,
|
||||
org.mockito.AdditionalAnswers.*,
|
||||
org.mockito.ArgumentMatchers.*,
|
||||
org.mockito.hamcrest.MockitoHamcrest.*,
|
||||
org.springframework.integration.gemfire.config.xml.ParserTestUtil.*,
|
||||
org.springframework.integration.test.matcher.EqualsResultMatcher.*,
|
||||
org.springframework.integration.test.matcher.EventuallyMatcher.*,
|
||||
org.springframework.integration.test.matcher.HeaderMatcher.*,
|
||||
org.springframework.integration.test.matcher.MapContentMatchers.*,
|
||||
org.springframework.integration.test.matcher.MockitoMessageMatchers.*,
|
||||
org.springframework.integration.test.matcher.PayloadAndHeaderMatcher.*,
|
||||
org.springframework.integration.test.matcher.PayloadMatcher.*,
|
||||
org.springframework.integration.test.mock.MockIntegration.*,
|
||||
org.springframework.integration.test.util.TestUtils.*,
|
||||
org.springframework.test.web.client.match.MockRestRequestMatchers.*,
|
||||
@@ -104,9 +92,7 @@
|
||||
org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*,
|
||||
org.springframework.test.web.servlet.result.MockMvcResultMatchers.*,
|
||||
org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*,
|
||||
org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*,
|
||||
org.springframework.web.reactive.function.client.ExchangeFilterFunctions.*,
|
||||
org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.*" />
|
||||
org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*" />
|
||||
</module>
|
||||
<module name="IllegalImport" />
|
||||
<module name="RedundantImport" />
|
||||
|
||||
@@ -227,6 +227,11 @@ assertThat(channel.send(message), is(false));
|
||||
----
|
||||
====
|
||||
|
||||
==== AssertJ conditions and predicates
|
||||
|
||||
Starting with version 5.2, the `MessagePredicate` is introduced to be used in the AssertJ `matches()` assertion.
|
||||
It requires a `Message` object as an expectation.
|
||||
And also ot can be configured with headers to exclude from expectation as well as from actual message to assert.
|
||||
|
||||
|
||||
[[test-context]]
|
||||
|
||||
Reference in New Issue
Block a user