Skip to content

Commit a5aa6b3

Browse files
philwebbrwinch
authored andcommitted
Remove blank lines from all tests
Remove all blank lines from test code so that test methods are visually grouped together. This generally helps to make the test classes easer to scan, however, the "given" / "when" / "then" blocks used by some tests are now not as easy to discern. Issue gh-8945
1 parent 5bdd757 commit a5aa6b3

File tree

787 files changed

+9
-10241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

787 files changed

+9
-10241
lines changed

acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java

-11
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,18 @@ public final void testDemergePatternsParametersConstraints() {
3939
}
4040
catch (IllegalArgumentException expected) {
4141
}
42-
4342
try {
4443
AclFormattingUtils.demergePatterns("SOME STRING", null);
4544
fail("It should have thrown IllegalArgumentException");
4645
}
4746
catch (IllegalArgumentException expected) {
4847
}
49-
5048
try {
5149
AclFormattingUtils.demergePatterns("SOME STRING", "LONGER SOME STRING");
5250
fail("It should have thrown IllegalArgumentException");
5351
}
5452
catch (IllegalArgumentException expected) {
5553
}
56-
5754
try {
5855
AclFormattingUtils.demergePatterns("SOME STRING", "SAME LENGTH");
5956
}
@@ -68,7 +65,6 @@ public final void testDemergePatterns() {
6865
String removeBits = "...............................R";
6966
assertThat(AclFormattingUtils.demergePatterns(original, removeBits))
7067
.isEqualTo("...........................A....");
71-
7268
assertThat(AclFormattingUtils.demergePatterns("ABCDEF", "......")).isEqualTo("ABCDEF");
7369
assertThat(AclFormattingUtils.demergePatterns("ABCDEF", "GHIJKL")).isEqualTo("......");
7470
}
@@ -81,21 +77,18 @@ public final void testMergePatternsParametersConstraints() {
8177
}
8278
catch (IllegalArgumentException expected) {
8379
}
84-
8580
try {
8681
AclFormattingUtils.mergePatterns("SOME STRING", null);
8782
fail("It should have thrown IllegalArgumentException");
8883
}
8984
catch (IllegalArgumentException expected) {
9085
}
91-
9286
try {
9387
AclFormattingUtils.mergePatterns("SOME STRING", "LONGER SOME STRING");
9488
fail("It should have thrown IllegalArgumentException");
9589
}
9690
catch (IllegalArgumentException expected) {
9791
}
98-
9992
try {
10093
AclFormattingUtils.mergePatterns("SOME STRING", "SAME LENGTH");
10194
}
@@ -108,29 +101,25 @@ public final void testMergePatterns() {
108101
String original = "...............................R";
109102
String extraBits = "...........................A....";
110103
assertThat(AclFormattingUtils.mergePatterns(original, extraBits)).isEqualTo("...........................A...R");
111-
112104
assertThat(AclFormattingUtils.mergePatterns("ABCDEF", "......")).isEqualTo("ABCDEF");
113105
assertThat(AclFormattingUtils.mergePatterns("ABCDEF", "GHIJKL")).isEqualTo("GHIJKL");
114106
}
115107

116108
@Test
117109
public final void testBinaryPrints() {
118110
assertThat(AclFormattingUtils.printBinary(15)).isEqualTo("............................****");
119-
120111
try {
121112
AclFormattingUtils.printBinary(15, Permission.RESERVED_ON);
122113
fail("It should have thrown IllegalArgumentException");
123114
}
124115
catch (IllegalArgumentException notExpected) {
125116
}
126-
127117
try {
128118
AclFormattingUtils.printBinary(15, Permission.RESERVED_OFF);
129119
fail("It should have thrown IllegalArgumentException");
130120
}
131121
catch (IllegalArgumentException notExpected) {
132122
}
133-
134123
assertThat(AclFormattingUtils.printBinary(15, 'x')).isEqualTo("............................xxxx");
135124
}
136125

acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java

-4
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ public void eagerlyLoadsRequiredAcls() {
5454
ObjectIdentity[] oids = { new ObjectIdentityImpl("A", "1"), new ObjectIdentityImpl("A", "2") };
5555
given(oidStrat.getObjectIdentity(dos[0])).willReturn(oids[0]);
5656
given(oidStrat.getObjectIdentity(dos[2])).willReturn(oids[1]);
57-
5857
pco.cachePermissionsFor(mock(Authentication.class), Arrays.asList(dos));
59-
6058
// AclService should be invoked with the list of required Oids
6159
verify(service).readAclsById(eq(Arrays.asList(oids)), any(List.class));
6260
}
@@ -69,9 +67,7 @@ public void ignoresEmptyCollection() {
6967
SidRetrievalStrategy sids = mock(SidRetrievalStrategy.class);
7068
pco.setObjectIdentityRetrievalStrategy(oids);
7169
pco.setSidRetrievalStrategy(sids);
72-
7370
pco.cachePermissionsFor(mock(Authentication.class), Collections.emptyList());
74-
7571
verifyZeroInteractions(service, sids, oids);
7672
}
7773

acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java

-6
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,15 @@ public void hasPermissionReturnsTrueIfAclGrantsPermission() {
5050
pe.setObjectIdentityRetrievalStrategy(oidStrategy);
5151
pe.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
5252
Acl acl = mock(Acl.class);
53-
5453
given(service.readAclById(any(ObjectIdentity.class), anyList())).willReturn(acl);
5554
given(acl.isGranted(anyList(), anyList(), eq(false))).willReturn(true);
56-
5755
assertThat(pe.hasPermission(mock(Authentication.class), new Object(), "READ")).isTrue();
5856
}
5957

6058
@Test
6159
public void resolvePermissionNonEnglishLocale() {
6260
Locale systemLocale = Locale.getDefault();
6361
Locale.setDefault(new Locale("tr"));
64-
6562
AclService service = mock(AclService.class);
6663
AclPermissionEvaluator pe = new AclPermissionEvaluator(service);
6764
ObjectIdentity oid = mock(ObjectIdentity.class);
@@ -70,12 +67,9 @@ public void resolvePermissionNonEnglishLocale() {
7067
pe.setObjectIdentityRetrievalStrategy(oidStrategy);
7168
pe.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
7269
Acl acl = mock(Acl.class);
73-
7470
given(service.readAclById(any(ObjectIdentity.class), anyList())).willReturn(acl);
7571
given(acl.isGranted(anyList(), anyList(), eq(false))).willReturn(true);
76-
7772
assertThat(pe.hasPermission(mock(Authentication.class), new Object(), "write")).isTrue();
78-
7973
Locale.setDefault(systemLocale);
8074
}
8175

acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProviderTests.java

-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public void objectsAreRemovedIfPermissionDenied() {
5858
provider.setObjectIdentityRetrievalStrategy(mock(ObjectIdentityRetrievalStrategy.class));
5959
provider.setProcessDomainObjectClass(Object.class);
6060
provider.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
61-
6261
Object returned = provider.decide(mock(Authentication.class), new Object(),
6362
SecurityConfig.createList("AFTER_ACL_COLLECTION_READ"),
6463
new ArrayList(Arrays.asList(new Object(), new Object())));
@@ -76,7 +75,6 @@ public void accessIsGrantedIfNoAttributesDefined() {
7675
AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider(
7776
mock(AclService.class), Arrays.asList(mock(Permission.class)));
7877
Object returned = new Object();
79-
8078
assertThat(returned).isSameAs(provider.decide(mock(Authentication.class), new Object(),
8179
Collections.<ConfigAttribute>emptyList(), returned));
8280
}
@@ -86,7 +84,6 @@ public void nullReturnObjectIsIgnored() {
8684
AclService service = mock(AclService.class);
8785
AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider(
8886
service, Arrays.asList(mock(Permission.class)));
89-
9087
assertThat(provider.decide(mock(Authentication.class), new Object(),
9188
SecurityConfig.createList("AFTER_ACL_COLLECTION_READ"), null)).isNull();
9289
verify(service, never()).readAclById(any(ObjectIdentity.class), any(List.class));

acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationProviderTests.java

-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public void accessIsAllowedIfPermissionIsGranted() {
7474
provider.setProcessDomainObjectClass(Object.class);
7575
provider.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
7676
Object returned = new Object();
77-
7877
assertThat(returned).isSameAs(provider.decide(mock(Authentication.class), new Object(),
7978
SecurityConfig.createList("AFTER_ACL_READ"), returned));
8079
}
@@ -84,7 +83,6 @@ public void accessIsGrantedIfNoAttributesDefined() {
8483
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(mock(AclService.class),
8584
Arrays.asList(mock(Permission.class)));
8685
Object returned = new Object();
87-
8886
assertThat(returned).isSameAs(provider.decide(mock(Authentication.class), new Object(),
8987
Collections.<ConfigAttribute>emptyList(), returned));
9088
}
@@ -96,7 +94,6 @@ public void accessIsGrantedIfObjectTypeNotSupported() {
9694
provider.setProcessDomainObjectClass(String.class);
9795
// Not a String
9896
Object returned = new Object();
99-
10097
assertThat(returned).isSameAs(provider.decide(mock(Authentication.class), new Object(),
10198
SecurityConfig.createList("AFTER_ACL_READ"), returned));
10299
}
@@ -133,7 +130,6 @@ public void nullReturnObjectIsIgnored() {
133130
AclService service = mock(AclService.class);
134131
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(service,
135132
Arrays.asList(mock(Permission.class)));
136-
137133
assertThat(provider.decide(mock(Authentication.class), new Object(),
138134
SecurityConfig.createList("AFTER_ACL_COLLECTION_READ"), null)).isNull();
139135
verify(service, never()).readAclById(any(ObjectIdentity.class), any(List.class));

acl/src/test/java/org/springframework/security/acls/domain/AccessControlImplEntryTests.java

-7
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ public void testConstructorRequiredFields() {
4646
}
4747
catch (IllegalArgumentException expected) {
4848
}
49-
5049
// Check Sid field is present
5150
try {
5251
new AccessControlEntryImpl(null, mock(Acl.class), null, BasePermission.ADMINISTRATION, true, true, true);
5352
fail("It should have thrown IllegalArgumentException");
5453
}
5554
catch (IllegalArgumentException expected) {
5655
}
57-
5856
// Check Permission field is present
5957
try {
6058
new AccessControlEntryImpl(null, mock(Acl.class), new PrincipalSid("johndoe"), null, true, true, true);
@@ -68,11 +66,9 @@ public void testConstructorRequiredFields() {
6866
public void testAccessControlEntryImplGetters() {
6967
Acl mockAcl = mock(Acl.class);
7068
Sid sid = new PrincipalSid("johndoe");
71-
7269
// Create a sample entry
7370
AccessControlEntry ace = new AccessControlEntryImpl(1L, mockAcl, sid, BasePermission.ADMINISTRATION, true, true,
7471
true);
75-
7672
// and check every get() method
7773
assertThat(ace.getId()).isEqualTo(1L);
7874
assertThat(ace.getAcl()).isEqualTo(mockAcl);
@@ -87,13 +83,10 @@ public void testAccessControlEntryImplGetters() {
8783
public void testEquals() {
8884
final Acl mockAcl = mock(Acl.class);
8985
final ObjectIdentity oid = mock(ObjectIdentity.class);
90-
9186
given(mockAcl.getObjectIdentity()).willReturn(oid);
9287
Sid sid = new PrincipalSid("johndoe");
93-
9488
AccessControlEntry ace = new AccessControlEntryImpl(1L, mockAcl, sid, BasePermission.ADMINISTRATION, true, true,
9589
true);
96-
9790
assertThat(ace).isNotNull();
9891
assertThat(ace).isNotEqualTo(100L);
9992
assertThat(ace).isEqualTo(ace);

0 commit comments

Comments
 (0)