Polishing web socket test to use BDD Mockito

This commit is contained in:
Phillip Webb 2019-09-04 22:02:47 -07:00
parent bc81fa520e
commit 2f106fbb32
1 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@ import org.springframework.web.socket.server.HandshakeInterceptor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.when;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@ -70,8 +70,8 @@ public class WebSocketHttpRequestHandlerTests {
TestInterceptor interceptor = new TestInterceptor(true);
this.requestHandler.setHandshakeInterceptors(Collections.singletonList(interceptor));
when(this.handshakeHandler.doHandshake(any(), any(), any(), any()))
.thenThrow(new IllegalStateException("bad state"));
given(this.handshakeHandler.doHandshake(any(), any(), any(), any()))
.willThrow(new IllegalStateException("bad state"));
assertThatThrownBy(() -> this.requestHandler.handleRequest(new MockHttpServletRequest(), this.response))
.isInstanceOf(HandshakeFailureException.class)