3838import static org .assertj .core .api .Assertions .assertThat ;
3939import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
4040import static org .mockito .ArgumentMatchers .any ;
41+ import static org .mockito .BDDMockito .given ;
4142import static org .mockito .Mockito .mock ;
4243import static org .mockito .Mockito .verify ;
4344import static org .mockito .Mockito .verifyNoInteractions ;
44- import static org .mockito .Mockito .when ;
4545import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
4646import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .post ;
4747
@@ -66,7 +66,7 @@ class OneTimeTokenAuthenticationFilterTests {
6666
6767 @ BeforeEach
6868 void setUp () {
69- this .filter .setAuthenticationManager (authenticationManager );
69+ this .filter .setAuthenticationManager (this . authenticationManager );
7070 }
7171
7272 @ Test
@@ -103,7 +103,7 @@ void doFilterWhenMissingTokenThenUnauthorized() throws ServletException, IOExcep
103103
104104 @ Test
105105 void doFilterWhenInvalidTokenThenUnauthorized () throws ServletException , IOException {
106- when (this .authenticationManager .authenticate (any ())).thenThrow (new BadCredentialsException ("invalid token" ));
106+ given (this .authenticationManager .authenticate (any ())).willThrow (new BadCredentialsException ("invalid token" ));
107107 this .filter .doFilter (
108108 post ("/login/ott" ).param ("token" , "some-token-value" ).buildRequest (new MockServletContext ()),
109109 this .response , this .chain );
@@ -113,7 +113,8 @@ void doFilterWhenInvalidTokenThenUnauthorized() throws ServletException, IOExcep
113113
114114 @ Test
115115 void doFilterWhenValidThenRedirectsToSavedRequest () throws ServletException , IOException {
116- when (this .authenticationManager .authenticate (any ())).thenReturn (OneTimeTokenAuthenticationToken .authenticated ("username" , AuthorityUtils .NO_AUTHORITIES ));
116+ given (this .authenticationManager .authenticate (any ()))
117+ .willReturn (OneTimeTokenAuthenticationToken .authenticated ("username" , AuthorityUtils .NO_AUTHORITIES ));
117118 this .filter .doFilter (
118119 post ("/login/ott" ).param ("token" , "some-token-value" ).buildRequest (new MockServletContext ()),
119120 this .response , this .chain );
0 commit comments