GH-2760: use assertThatExceptionOfType in tests

Fixes https://github.com/spring-projects/spring-integration/issues/2760

* The `assertThatExceptionOfType()` is more convenient,
than `assertThatThrownBy`, so, replace all the usages accordingly
* Fix JavaDoc typo in the `AbstractScriptExecutingMessageProcessor`
* Fix Sonar smells for `throws Exception` in `AbstractScriptExecutingMessageProcessor`
hierarchy and some code polishing for them
This commit is contained in:
Artem Bilan
2019-02-22 13:54:36 -05:00
parent 82ecd5a75d
commit 1d54f9663a
22 changed files with 187 additions and 159 deletions

View File

@@ -17,7 +17,7 @@
package org.springframework.integration.file.remote;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willReturn;
import static org.mockito.BDDMockito.willThrow;
@@ -132,14 +132,14 @@ public class StreamingInboundTests {
}
@Test
public void testExceptionOnFetch() throws Exception {
public void testExceptionOnFetch() {
StringSessionFactory sessionFactory = new StringSessionFactory();
Streamer streamer = new Streamer(new StringRemoteFileTemplate(sessionFactory), null);
streamer.setBeanFactory(mock(BeanFactory.class));
streamer.setRemoteDirectory("/bad");
streamer.afterPropertiesSet();
assertThatThrownBy(streamer::receive)
.isInstanceOf(MessagingException.class);
assertThatExceptionOfType(MessagingException.class)
.isThrownBy(streamer::receive);
}
@SuppressWarnings("unchecked")