Skip to content

Commit

Permalink
Replace @test(expected=...) in InvocationNotifierHandlerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
temp-droid committed Dec 22, 2021
1 parent dc2231c commit 367fb12
Showing 1 changed file with 16 additions and 16 deletions.
Expand Up @@ -5,6 +5,7 @@
package org.mockito.internal.handler;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.fail;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willThrow;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class InvocationNotifierHandlerTest {
@Before
public void setUp() throws Exception {
notifier =
new InvocationNotifierHandler<ArrayList<Answer<?>>>(
new InvocationNotifierHandler<>(
mockHandler,
(MockCreationSettings<ArrayList<Answer<?>>>)
new MockSettingsImpl<ArrayList<Answer<?>>>()
Expand Down Expand Up @@ -90,7 +91,7 @@ public void should_notify_all_listeners_when_called_delegate_handler_returns_ex(
new NotifiedMethodInvocationReport(invocation, (Object) computedException));
}

@Test(expected = ParseException.class)
@Test
public void
should_notify_all_listeners_when_called_delegate_handler_throws_exception_and_rethrow_it()
throws Throwable {
Expand All @@ -99,18 +100,18 @@ public void should_notify_all_listeners_when_called_delegate_handler_returns_ex(
given(mockHandler.handle(invocation)).willThrow(parseException);

// when
try {
notifier.handle(invocation);
fail();
} finally {
// then
verify(listener1)
.reportInvocation(
new NotifiedMethodInvocationReport(invocation, parseException));
verify(listener2)
.reportInvocation(
new NotifiedMethodInvocationReport(invocation, parseException));
}
assertThatThrownBy(
() -> {
notifier.handle(invocation);
})
.isInstanceOf(ParseException.class)
.hasMessage("");

// then
verify(listener1)
.reportInvocation(new NotifiedMethodInvocationReport(invocation, parseException));
verify(listener2)
.reportInvocation(new NotifiedMethodInvocationReport(invocation, parseException));
}

@Test
Expand All @@ -132,8 +133,7 @@ public void should_report_listener_exception() throws Throwable {
}

@Test
public void should_delegate_all_MockHandlerInterface_to_the_parameterized_MockHandler()
throws Exception {
public void should_delegate_all_MockHandlerInterface_to_the_parameterized_MockHandler() {
notifier.getInvocationContainer();
notifier.getMockSettings();

Expand Down

0 comments on commit 367fb12

Please sign in to comment.