1919
2020package org .apache .cloudstack ;
2121
22+ import static org .mockito .Mockito .never ;
23+ import static org .mockito .Mockito .verify ;
24+ import static org .mockito .Mockito .when ;
25+
2226import java .lang .reflect .Field ;
2327import java .lang .reflect .Method ;
2428
@@ -132,11 +136,11 @@ public void testAuthorizeUserStoresPreSamlSourceOnEnable() {
132136 UserVO user = new UserVO (200L );
133137 user .setUsername ("someuser" );
134138 user .setSource (User .Source .LDAP );
135- Mockito . when (userDao .getUser (Mockito .anyLong ())).thenReturn (user );
139+ when (userDao .getUser (Mockito .anyLong ())).thenReturn (user );
136140
137141 saml2AuthManager .authorizeUser (200L , "someID" , true );
138142
139- Mockito . verify (userDetailsDao ).addDetail (200L , "PreSamlSource" , "LDAP" , false );
143+ verify (userDetailsDao ).addDetail (200L , "PreSamlSource" , "LDAP" , false );
140144 assertEquals (User .Source .SAML2 , user .getSource ());
141145 }
142146
@@ -145,30 +149,30 @@ public void testAuthorizeUserDoesNotRestorePreSamlSourceWhenAlreadyAuthorized()
145149 UserVO user = new UserVO (200L );
146150 user .setUsername ("someuser" );
147151 user .setSource (User .Source .SAML2 );
148- Mockito . when (userDao .getUser (Mockito .anyLong ())).thenReturn (user );
152+ when (userDao .getUser (Mockito .anyLong ())).thenReturn (user );
149153
150154 saml2AuthManager .authorizeUser (200L , "someID" , true );
151155
152- Mockito . verify (userDetailsDao , Mockito . never ()).addDetail (Mockito .anyLong (), Mockito .anyString (), Mockito .anyString (), Mockito .anyBoolean ());
156+ verify (userDetailsDao , never ()).addDetail (Mockito .anyLong (), Mockito .anyString (), Mockito .anyString (), Mockito .anyBoolean ());
153157 }
154158
155159 @ Test
156160 public void testGetPreSamlSourceRestoresStoredSource () throws Exception {
157- Mockito . when (userDetailsDao .findDetail (200L , "PreSamlSource" )).thenReturn (new UserDetailVO (200L , "PreSamlSource" , "LDAP" ));
161+ when (userDetailsDao .findDetail (200L , "PreSamlSource" )).thenReturn (new UserDetailVO (200L , "PreSamlSource" , "LDAP" ));
158162
159163 assertEquals (User .Source .LDAP , invokeGetPreSamlSource (200L ));
160164 }
161165
162166 @ Test
163167 public void testGetPreSamlSourceDefaultsToUnknownWhenNothingStored () throws Exception {
164- Mockito . when (userDetailsDao .findDetail (200L , "PreSamlSource" )).thenReturn (null );
168+ when (userDetailsDao .findDetail (200L , "PreSamlSource" )).thenReturn (null );
165169
166170 assertEquals (User .Source .UNKNOWN , invokeGetPreSamlSource (200L ));
167171 }
168172
169173 @ Test
170174 public void testGetPreSamlSourceDefaultsToUnknownOnGarbageValue () throws Exception {
171- Mockito . when (userDetailsDao .findDetail (200L , "PreSamlSource" )).thenReturn (new UserDetailVO (200L , "PreSamlSource" , "not-a-real-source" ));
175+ when (userDetailsDao .findDetail (200L , "PreSamlSource" )).thenReturn (new UserDetailVO (200L , "PreSamlSource" , "not-a-real-source" ));
172176
173177 assertEquals (User .Source .UNKNOWN , invokeGetPreSamlSource (200L ));
174178 }
0 commit comments