@@ -233,7 +233,8 @@ public void logAboutAbsentPageShouldPassEmptyStringToDaoForUnknownUserAgent() {
233
233
234
234
@ Test
235
235
public void logAboutFailedAuthenticationShouldCallDao () {
236
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
236
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
237
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
237
238
238
239
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , null );
239
240
@@ -249,7 +250,7 @@ public void logAboutFailedAuthenticationShouldThrowExceptionWhenActivityTypeNotF
249
250
250
251
@ Test
251
252
public void logAboutFailedAuthenticationShouldPassActivityTypeToDao () {
252
- SuspiciousActivityType expectedType = getAuthFailedType ();
253
+ SuspiciousActivityType expectedType = TestObjects . createAuthFailedActivityType ();
253
254
when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (expectedType );
254
255
255
256
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , null );
@@ -261,7 +262,8 @@ public void logAboutFailedAuthenticationShouldPassActivityTypeToDao() {
261
262
262
263
@ Test
263
264
public void logAboutFailedAuthenticationShouldAssignOccuredAtToCurrentDate () {
264
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
265
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
266
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
265
267
266
268
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , null );
267
269
@@ -272,14 +274,16 @@ public void logAboutFailedAuthenticationShouldAssignOccuredAtToCurrentDate() {
272
274
273
275
@ Test (expected = IllegalArgumentException .class )
274
276
public void logAboutFailedAuthenticationShouldThrowExceptionWhenPageIsNull () {
275
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
277
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
278
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
276
279
277
280
service .logAboutFailedAuthentication (null , null , null , null , null );
278
281
}
279
282
280
283
@ Test
281
284
public void logAboutFailedAuthenticationShouldPassPageToDao () {
282
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
285
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
286
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
283
287
284
288
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , null );
285
289
@@ -290,7 +294,8 @@ public void logAboutFailedAuthenticationShouldPassPageToDao() {
290
294
291
295
@ Test
292
296
public void logAboutFailedAuthenticationShouldPassNullToDaoForUnknownUser () {
293
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
297
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
298
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
294
299
295
300
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , null );
296
301
@@ -302,7 +307,8 @@ public void logAboutFailedAuthenticationShouldPassNullToDaoForUnknownUser() {
302
307
@ Test
303
308
public void logAboutFailedAuthenticationShouldPassUserToDao () {
304
309
User user = getUser ();
305
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
310
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
311
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
306
312
307
313
service .logAboutFailedAuthentication (TEST_PAGE , user , null , null , null );
308
314
@@ -313,7 +319,8 @@ public void logAboutFailedAuthenticationShouldPassUserToDao() {
313
319
314
320
@ Test
315
321
public void logAboutFailedAuthenticationShouldPassIpToDao () {
316
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
322
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
323
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
317
324
318
325
service .logAboutFailedAuthentication (TEST_PAGE , null , TEST_IP , null , null );
319
326
@@ -324,7 +331,8 @@ public void logAboutFailedAuthenticationShouldPassIpToDao() {
324
331
325
332
@ Test
326
333
public void logAboutFailedAuthenticationShouldPassEmptyStringToDaoForUnknownIp () {
327
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
334
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
335
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
328
336
329
337
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , null );
330
338
@@ -335,7 +343,8 @@ public void logAboutFailedAuthenticationShouldPassEmptyStringToDaoForUnknownIp()
335
343
336
344
@ Test
337
345
public void logAboutFailedAuthenticationShouldPassRefererToDao () {
338
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
346
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
347
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
339
348
340
349
service .logAboutFailedAuthentication (TEST_PAGE , null , null , TEST_REFERER_PAGE , null );
341
350
@@ -346,7 +355,8 @@ public void logAboutFailedAuthenticationShouldPassRefererToDao() {
346
355
347
356
@ Test
348
357
public void logAboutFailedAuthenticationShouldPassEmptyStringToDaoForUnknownReferer () {
349
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
358
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
359
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
350
360
351
361
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , null );
352
362
@@ -357,7 +367,8 @@ public void logAboutFailedAuthenticationShouldPassEmptyStringToDaoForUnknownRefe
357
367
358
368
@ Test
359
369
public void logAboutFailedAuthenticationShouldPassUserAgentToDao () {
360
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
370
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
371
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
361
372
362
373
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , TEST_USER_AGENT );
363
374
@@ -368,7 +379,8 @@ public void logAboutFailedAuthenticationShouldPassUserAgentToDao() {
368
379
369
380
@ Test
370
381
public void logAboutFailedAuthenticationShouldPassEmptyStringToDaoForUnknownUserAgent () {
371
- when (suspiciousActivityTypeDao .findByName (anyString ())).thenReturn (getAuthFailedType ());
382
+ when (suspiciousActivityTypeDao .findByName (anyString ()))
383
+ .thenReturn (TestObjects .createAuthFailedActivityType ());
372
384
373
385
service .logAboutFailedAuthentication (TEST_PAGE , null , null , null , null );
374
386
@@ -377,13 +389,6 @@ public void logAboutFailedAuthenticationShouldPassEmptyStringToDaoForUnknownUser
377
389
assertThat (activityCaptor .getValue ().getUserAgent ()).isEmpty ();
378
390
}
379
391
380
- private SuspiciousActivityType getAuthFailedType () {
381
- SuspiciousActivityType type = new SuspiciousActivityType ();
382
- type .setId (2 );
383
- type .setName ("AuthenticationFailed" );
384
- return type ;
385
- }
386
-
387
392
private User getUser () {
388
393
final Integer anyId = 777 ;
389
394
User user = new User ();
0 commit comments