46
46
import static org .assertj .core .api .Assertions .assertThat ;
47
47
import static org .junit .jupiter .api .Assumptions .assumeFalse ;
48
48
import static org .junit .jupiter .api .Assumptions .assumeTrue ;
49
+ import static org .assertj .core .api .Assertions .assertThat ;
50
+ import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
51
+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
52
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
53
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
54
+ import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
55
+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
56
+ import static org .junit .jupiter .api .Assertions .assertNotSame ;
57
+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
58
+ import static org .junit .jupiter .api .Assertions .assertNull ;
59
+ import static org .junit .jupiter .api .Assertions .assertSame ;
60
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
61
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
62
+ import static org .junit .jupiter .api .Assertions .fail ;
63
+ import static org .junit .jupiter .api .Assumptions .assumeFalse ;
64
+ import static org .junit .jupiter .api .Assumptions .assumeTrue ;
49
65
import static org .mockito .ArgumentMatchers .any ;
66
+ import static org .mockito .ArgumentMatchers .nullable ;
67
+ import static org .mockito .Mockito .any ;
68
+ import static org .mockito .Mockito .anyBoolean ;
69
+ import static org .mockito .Mockito .anyInt ;
70
+ import static org .mockito .Mockito .anyLong ;
71
+ import static org .mockito .Mockito .anyList ;
50
72
import static org .mockito .Mockito .anyString ;
73
+ import static org .mockito .Mockito .atMost ;
74
+ import static org .mockito .Mockito .atLeast ;
75
+ import static org .mockito .Mockito .atLeastOnce ;
76
+ import static org .mockito .Mockito .doAnswer ;
77
+ import static org .mockito .Mockito .doCallRealMethod ;
78
+ import static org .mockito .Mockito .doNothing ;
51
79
import static org .mockito .Mockito .doReturn ;
52
80
import static org .mockito .Mockito .doThrow ;
53
81
import static org .mockito .Mockito .mock ;
@@ -365,17 +393,17 @@ public void testNameSpaceConfig() throws Exception {
365
393
AbfsConfiguration abfsConfig = new AbfsConfiguration (configuration , "bogusAccountName" );
366
394
367
395
// Test that the namespace value when config is not set
368
- Assertions . assertThat (abfsConfig .getIsNamespaceEnabledAccount ())
396
+ assertThat (abfsConfig .getIsNamespaceEnabledAccount ())
369
397
.describedAs ("Namespace enabled should be unknown in case config is not set" )
370
398
.isEqualTo (Trilean .UNKNOWN );
371
399
372
400
// In case no namespace config is present, file system init calls getAcl() to determine account type.
373
- Assertions . assertThat (abfs .getIsNamespaceEnabled (getTestTracingContext (abfs , false )))
401
+ assertThat (abfs .getIsNamespaceEnabled (getTestTracingContext (abfs , false )))
374
402
.describedAs ("getIsNamespaceEnabled should return account type based on getAcl() call" )
375
403
.isEqualTo (abfs .getAbfsClient ().getIsNamespaceEnabled ());
376
404
377
405
// In case no namespace config is present, file system init calls getAcl() to determine account type.
378
- Assertions . assertThat (abfs .getAbfsStore ().getAbfsConfiguration ().getIsNamespaceEnabledAccount ())
406
+ assertThat (abfs .getAbfsStore ().getAbfsConfiguration ().getIsNamespaceEnabledAccount ())
379
407
.describedAs ("getIsNamespaceEnabled() should return updated account type based on getAcl() call" )
380
408
.isNotEqualTo (Trilean .UNKNOWN );
381
409
@@ -384,17 +412,17 @@ public void testNameSpaceConfig() throws Exception {
384
412
abfsConfig = new AbfsConfiguration (configuration , "bogusAccountName" );
385
413
386
414
// Test that the namespace enabled config is set correctly
387
- Assertions . assertThat (abfsConfig .getIsNamespaceEnabledAccount ())
415
+ assertThat (abfsConfig .getIsNamespaceEnabledAccount ())
388
416
.describedAs ("Namespace enabled should be true in case config is set to true" )
389
417
.isEqualTo (Trilean .TRUE );
390
418
391
419
// In case namespace config is present, same value will be return.
392
- Assertions . assertThat (abfs .getIsNamespaceEnabled (getTestTracingContext (abfs , false )))
420
+ assertThat (abfs .getIsNamespaceEnabled (getTestTracingContext (abfs , false )))
393
421
.describedAs ("getIsNamespaceEnabled() should return true when config is set to true" )
394
422
.isEqualTo (true );
395
423
396
424
// In case namespace config is present, same value will be return.
397
- Assertions . assertThat (abfs .getAbfsClient ().getIsNamespaceEnabled ())
425
+ assertThat (abfs .getAbfsClient ().getIsNamespaceEnabled ())
398
426
.describedAs ("Client's getIsNamespaceEnabled() should return true when config is set to true" )
399
427
.isEqualTo (true );
400
428
@@ -403,17 +431,17 @@ public void testNameSpaceConfig() throws Exception {
403
431
abfsConfig = new AbfsConfiguration (configuration , "bogusAccountName" );
404
432
405
433
// Test that the namespace enabled config is set correctly
406
- Assertions . assertThat (abfsConfig .getIsNamespaceEnabledAccount ())
434
+ assertThat (abfsConfig .getIsNamespaceEnabledAccount ())
407
435
.describedAs ("Namespace enabled should be false in case config is set to false" )
408
436
.isEqualTo (Trilean .FALSE );
409
437
410
438
// In case namespace config is present, same value will be return.
411
- Assertions . assertThat (abfs .getIsNamespaceEnabled (getTestTracingContext (abfs , false )))
439
+ assertThat (abfs .getIsNamespaceEnabled (getTestTracingContext (abfs , false )))
412
440
.describedAs ("getIsNamespaceEnabled() should return false when config is set to false" )
413
441
.isEqualTo (false );
414
442
415
443
// In case namespace config is present, same value will be return.
416
- Assertions . assertThat (abfs .getAbfsClient ().getIsNamespaceEnabled ())
444
+ assertThat (abfs .getAbfsClient ().getIsNamespaceEnabled ())
417
445
.describedAs ("Client's getIsNamespaceEnabled() should return false when config is set to false" )
418
446
.isEqualTo (false );
419
447
}
@@ -428,15 +456,15 @@ public void testNameSpaceConfig() throws Exception {
428
456
@ Test
429
457
public void testFsInitShouldSetNamespaceConfig () throws Exception {
430
458
// Mock the AzureBlobFileSystem and its dependencies
431
- AzureBlobFileSystem mockFileSystem = Mockito . spy ((AzureBlobFileSystem )
459
+ AzureBlobFileSystem mockFileSystem = spy ((AzureBlobFileSystem )
432
460
FileSystem .newInstance (getConfigurationWithoutHnsConfig ()));
433
- AzureBlobFileSystemStore mockStore = Mockito . spy (mockFileSystem .getAbfsStore ());
434
- AbfsClient abfsClient = Mockito . spy (mockStore .getClient ());
435
- Mockito . doReturn (abfsClient ).when (mockStore ).getClient ();
436
- Mockito . doReturn (abfsClient ).when (mockStore ).getClient (any ());
461
+ AzureBlobFileSystemStore mockStore = spy (mockFileSystem .getAbfsStore ());
462
+ AbfsClient abfsClient = spy (mockStore .getClient ());
463
+ doReturn (abfsClient ).when (mockStore ).getClient ();
464
+ doReturn (abfsClient ).when (mockStore ).getClient (any ());
437
465
abfsClient .getIsNamespaceEnabled ();
438
466
// Verify that getAclStatus is called once during initialization
439
- Mockito . verify (abfsClient , times (0 ))
467
+ verify (abfsClient , times (0 ))
440
468
.getAclStatus (anyString (), any (TracingContext .class ));
441
469
442
470
mockStore .getAbfsConfiguration ().setIsNamespaceEnabledAccountForTesting (Trilean .UNKNOWN );
@@ -445,19 +473,19 @@ public void testFsInitShouldSetNamespaceConfig() throws Exception {
445
473
String errorMessage = intercept (InvalidConfigurationValueException .class , () -> {
446
474
abfsClient .getIsNamespaceEnabled ();
447
475
}).getMessage ();
448
- Assertions . assertThat (errorMessage )
476
+ assertThat (errorMessage )
449
477
.describedAs ("Client should throw exception when namespace is unknown" )
450
478
.contains ("Failed to determine account type" );
451
479
452
480
// In case of unknown namespace, store's getIsNamespaceEnabled should call getAclStatus
453
481
// to determine the namespace status.
454
482
mockStore .getIsNamespaceEnabled (getTestTracingContext (mockFileSystem , false ));
455
- Mockito . verify (abfsClient , times (1 ))
483
+ verify (abfsClient , times (1 ))
456
484
.getAclStatus (anyString (), any (TracingContext .class ));
457
485
458
486
abfsClient .getIsNamespaceEnabled ();
459
487
// Verify that client's getNamespaceEnabled will not call getAclStatus again
460
- Mockito . verify (abfsClient , times (1 ))
488
+ verify (abfsClient , times (1 ))
461
489
.getAclStatus (anyString (), any (TracingContext .class ));
462
490
}
463
491
0 commit comments