38
38
import static org .assertj .core .api .Assertions .assertThat ;
39
39
import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
40
40
import static org .mockito .ArgumentMatchers .any ;
41
+ import static org .mockito .BDDMockito .given ;
41
42
import static org .mockito .Mockito .mock ;
42
43
import static org .mockito .Mockito .verify ;
43
44
import static org .mockito .Mockito .verifyNoInteractions ;
44
- import static org .mockito .Mockito .when ;
45
45
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
46
46
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .post ;
47
47
@@ -66,7 +66,7 @@ class OneTimeTokenAuthenticationFilterTests {
66
66
67
67
@ BeforeEach
68
68
void setUp () {
69
- this .filter .setAuthenticationManager (authenticationManager );
69
+ this .filter .setAuthenticationManager (this . authenticationManager );
70
70
}
71
71
72
72
@ Test
@@ -103,7 +103,7 @@ void doFilterWhenMissingTokenThenUnauthorized() throws ServletException, IOExcep
103
103
104
104
@ Test
105
105
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" ));
107
107
this .filter .doFilter (
108
108
post ("/login/ott" ).param ("token" , "some-token-value" ).buildRequest (new MockServletContext ()),
109
109
this .response , this .chain );
@@ -113,7 +113,8 @@ void doFilterWhenInvalidTokenThenUnauthorized() throws ServletException, IOExcep
113
113
114
114
@ Test
115
115
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 ));
117
118
this .filter .doFilter (
118
119
post ("/login/ott" ).param ("token" , "some-token-value" ).buildRequest (new MockServletContext ()),
119
120
this .response , this .chain );
0 commit comments