Skip to content

Commit

Permalink
Remove redundant throws clauses
Browse files Browse the repository at this point in the history
Removes exceptions that are declared in a method's signature but never thrown by the method itself or its implementations/derivatives.
  • Loading branch information
larsgrefer committed Aug 22, 2019
1 parent f0515a0 commit 34dd5fe
Show file tree
Hide file tree
Showing 418 changed files with 1,146 additions and 1,273 deletions.
Expand Up @@ -74,7 +74,7 @@ && canConvertFromStringTo(classIdTypeFrom(resultSet))) {
return identifier;
}

private boolean hasValidClassIdType(ResultSet resultSet) throws SQLException {
private boolean hasValidClassIdType(ResultSet resultSet) {
boolean hasClassIdType = false;
try {
hasClassIdType = classIdTypeFrom(resultSet) != null;
Expand Down
Expand Up @@ -32,7 +32,7 @@ public class AclFormattingUtilsTests {
// ~ Methods
// ========================================================================================================
@Test
public final void testDemergePatternsParametersConstraints() throws Exception {
public final void testDemergePatternsParametersConstraints() {
try {
AclFormattingUtils.demergePatterns(null, "SOME STRING");
fail("It should have thrown IllegalArgumentException");
Expand Down Expand Up @@ -63,7 +63,7 @@ public final void testDemergePatternsParametersConstraints() throws Exception {
}

@Test
public final void testDemergePatterns() throws Exception {
public final void testDemergePatterns() {
String original = "...........................A...R";
String removeBits = "...............................R";
assertThat(AclFormattingUtils.demergePatterns(original, removeBits)).isEqualTo(
Expand All @@ -76,7 +76,7 @@ public final void testDemergePatterns() throws Exception {
}

@Test
public final void testMergePatternsParametersConstraints() throws Exception {
public final void testMergePatternsParametersConstraints() {
try {
AclFormattingUtils.mergePatterns(null, "SOME STRING");
fail("It should have thrown IllegalArgumentException");
Expand Down Expand Up @@ -106,7 +106,7 @@ public final void testMergePatternsParametersConstraints() throws Exception {
}

@Test
public final void testMergePatterns() throws Exception {
public final void testMergePatterns() {
String original = "...............................R";
String extraBits = "...........................A....";
assertThat(AclFormattingUtils.mergePatterns(original, extraBits)).isEqualTo(
Expand All @@ -119,7 +119,7 @@ public final void testMergePatterns() throws Exception {
}

@Test
public final void testBinaryPrints() throws Exception {
public final void testBinaryPrints() {
assertThat(AclFormattingUtils.printBinary(15)).isEqualTo(
"............................****");

Expand Down
Expand Up @@ -36,7 +36,7 @@
public class AclPermissionCacheOptimizerTests {

@Test
public void eagerlyLoadsRequiredAcls() throws Exception {
public void eagerlyLoadsRequiredAcls() {
AclService service = mock(AclService.class);
AclPermissionCacheOptimizer pco = new AclPermissionCacheOptimizer(service);
ObjectIdentityRetrievalStrategy oidStrat = mock(ObjectIdentityRetrievalStrategy.class);
Expand Down
Expand Up @@ -37,7 +37,7 @@
public class AclPermissionEvaluatorTests {

@Test
public void hasPermissionReturnsTrueIfAclGrantsPermission() throws Exception {
public void hasPermissionReturnsTrueIfAclGrantsPermission() {
AclService service = mock(AclService.class);
AclPermissionEvaluator pe = new AclPermissionEvaluator(service);
ObjectIdentity oid = mock(ObjectIdentity.class);
Expand Down
Expand Up @@ -37,7 +37,7 @@
@SuppressWarnings({ "unchecked" })
public class AclEntryAfterInvocationCollectionFilteringProviderTests {
@Test
public void objectsAreRemovedIfPermissionDenied() throws Exception {
public void objectsAreRemovedIfPermissionDenied() {
AclService service = mock(AclService.class);
Acl acl = mock(Acl.class);
when(acl.isGranted(any(), any(), anyBoolean())).thenReturn(
Expand All @@ -63,7 +63,7 @@ public void objectsAreRemovedIfPermissionDenied() throws Exception {
}

@Test
public void accessIsGrantedIfNoAttributesDefined() throws Exception {
public void accessIsGrantedIfNoAttributesDefined() {
AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider(
mock(AclService.class), Arrays.asList(mock(Permission.class)));
Object returned = new Object();
Expand All @@ -75,7 +75,7 @@ public void accessIsGrantedIfNoAttributesDefined() throws Exception {
}

@Test
public void nullReturnObjectIsIgnored() throws Exception {
public void nullReturnObjectIsIgnored() {
AclService service = mock(AclService.class);
AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider(
service, Arrays.asList(mock(Permission.class)));
Expand Down
Expand Up @@ -37,7 +37,7 @@
public class AclEntryAfterInvocationProviderTests {

@Test(expected = IllegalArgumentException.class)
public void rejectsMissingPermissions() throws Exception {
public void rejectsMissingPermissions() {
try {
new AclEntryAfterInvocationProvider(mock(AclService.class), null);
fail("Exception expected");
Expand Down Expand Up @@ -72,7 +72,7 @@ public void accessIsAllowedIfPermissionIsGranted() {
}

@Test
public void accessIsGrantedIfNoAttributesDefined() throws Exception {
public void accessIsGrantedIfNoAttributesDefined() {
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
mock(AclService.class), Arrays.asList(mock(Permission.class)));
Object returned = new Object();
Expand All @@ -85,7 +85,7 @@ public void accessIsGrantedIfNoAttributesDefined() throws Exception {
}

@Test
public void accessIsGrantedIfObjectTypeNotSupported() throws Exception {
public void accessIsGrantedIfObjectTypeNotSupported() {
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
mock(AclService.class), Arrays.asList(mock(Permission.class)));
provider.setProcessDomainObjectClass(String.class);
Expand Down Expand Up @@ -131,7 +131,7 @@ public void accessIsDeniedIfPermissionIsNotGranted() {
}

@Test
public void nullReturnObjectIsIgnored() throws Exception {
public void nullReturnObjectIsIgnored() {
AclService service = mock(AclService.class);
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
service, Arrays.asList(mock(Permission.class)));
Expand Down
Expand Up @@ -54,7 +54,7 @@ public class AclImplTests {
// ========================================================================================================

@Before
public void setUp() throws Exception {
public void setUp() {
SecurityContextHolder.getContext().setAuthentication(auth);
authzStrategy = mock(AclAuthorizationStrategy.class);
mockAuditLogger = mock(AuditLogger.class);
Expand All @@ -63,12 +63,12 @@ public void setUp() throws Exception {
}

@After
public void tearDown() throws Exception {
public void tearDown() {
SecurityContextHolder.clearContext();
}

@Test(expected = IllegalArgumentException.class)
public void constructorsRejectNullObjectIdentity() throws Exception {
public void constructorsRejectNullObjectIdentity() {
try {
new AclImpl(null, 1, authzStrategy, pgs, null, null, true, new PrincipalSid(
"joe"));
Expand All @@ -80,7 +80,7 @@ public void constructorsRejectNullObjectIdentity() throws Exception {
}

@Test(expected = IllegalArgumentException.class)
public void constructorsRejectNullId() throws Exception {
public void constructorsRejectNullId() {
try {
new AclImpl(objectIdentity, null, authzStrategy, pgs, null, null, true,
new PrincipalSid("joe"));
Expand All @@ -93,7 +93,7 @@ public void constructorsRejectNullId() throws Exception {

@SuppressWarnings("deprecation")
@Test(expected = IllegalArgumentException.class)
public void constructorsRejectNullAclAuthzStrategy() throws Exception {
public void constructorsRejectNullAclAuthzStrategy() {
try {
new AclImpl(objectIdentity, 1, null, new DefaultPermissionGrantingStrategy(
mockAuditLogger), null, null, true, new PrincipalSid("joe"));
Expand All @@ -105,7 +105,7 @@ public void constructorsRejectNullAclAuthzStrategy() throws Exception {
}

@Test
public void insertAceRejectsNullParameters() throws Exception {
public void insertAceRejectsNullParameters() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
try {
Expand All @@ -123,7 +123,7 @@ public void insertAceRejectsNullParameters() throws Exception {
}

@Test
public void insertAceAddsElementAtCorrectIndex() throws Exception {
public void insertAceAddsElementAtCorrectIndex() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
MockAclService service = new MockAclService();
Expand Down Expand Up @@ -166,7 +166,7 @@ public void insertAceAddsElementAtCorrectIndex() throws Exception {
}

@Test(expected = NotFoundException.class)
public void insertAceFailsForNonExistentElement() throws Exception {
public void insertAceFailsForNonExistentElement() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
MockAclService service = new MockAclService();
Expand All @@ -180,7 +180,7 @@ public void insertAceFailsForNonExistentElement() throws Exception {
}

@Test
public void deleteAceKeepsInitialOrdering() throws Exception {
public void deleteAceKeepsInitialOrdering() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
MockAclService service = new MockAclService();
Expand Down Expand Up @@ -217,7 +217,7 @@ public void deleteAceKeepsInitialOrdering() throws Exception {
}

@Test
public void deleteAceFailsForNonExistentElement() throws Exception {
public void deleteAceFailsForNonExistentElement() {
AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl(
new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority(
"ROLE_AUDITING"), new SimpleGrantedAuthority("ROLE_GENERAL"));
Expand All @@ -232,7 +232,7 @@ public void deleteAceFailsForNonExistentElement() throws Exception {
}

@Test
public void isGrantingRejectsEmptyParameters() throws Exception {
public void isGrantingRejectsEmptyParameters() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
Sid ben = new PrincipalSid("ben");
Expand All @@ -251,7 +251,7 @@ public void isGrantingRejectsEmptyParameters() throws Exception {
}

@Test
public void isGrantingGrantsAccessForAclWithNoParent() throws Exception {
public void isGrantingGrantsAccessForAclWithNoParent() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_GENERAL", "ROLE_GUEST");
auth.setAuthenticated(true);
Expand Down Expand Up @@ -297,7 +297,7 @@ public void isGrantingGrantsAccessForAclWithNoParent() throws Exception {
}

@Test
public void isGrantingGrantsAccessForInheritableAcls() throws Exception {
public void isGrantingGrantsAccessForInheritableAcls() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_GENERAL");
auth.setAuthenticated(true);
Expand Down Expand Up @@ -379,7 +379,7 @@ public void isGrantingGrantsAccessForInheritableAcls() throws Exception {
}

@Test
public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception {
public void updatedAceValuesAreCorrectlyReflectedInAcl() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_GENERAL");
auth.setAuthenticated(true);
Expand Down Expand Up @@ -411,7 +411,7 @@ public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception {
}

@Test
public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception {
public void auditableEntryFlagsAreUpdatedCorrectly() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_AUDITING", "ROLE_GENERAL");
auth.setAuthenticated(true);
Expand Down Expand Up @@ -449,7 +449,7 @@ public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception {
}

@Test
public void gettersAndSettersAreConsistent() throws Exception {
public void gettersAndSettersAreConsistent() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_GENERAL");
auth.setAuthenticated(true);
Expand Down Expand Up @@ -485,7 +485,7 @@ public void gettersAndSettersAreConsistent() throws Exception {
}

@Test
public void isSidLoadedBehavesAsExpected() throws Exception {
public void isSidLoadedBehavesAsExpected() {
List<Sid> loadedSids = Arrays.asList(new PrincipalSid("ben"),
new GrantedAuthoritySid("ROLE_IGNORED"));
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null,
Expand Down Expand Up @@ -513,22 +513,21 @@ public void isSidLoadedBehavesAsExpected() throws Exception {
}

@Test(expected = NotFoundException.class)
public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception {
public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() {
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
acl.insertAce(-1, mock(Permission.class), mock(Sid.class), true);
}

@Test(expected = NotFoundException.class)
public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception {
public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() {
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
acl.deleteAce(-1);
}

@Test(expected = NotFoundException.class)
public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize()
throws Exception {
public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize() {
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
// Insert at zero, OK.
Expand All @@ -539,7 +538,7 @@ public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize()

// SEC-1151
@Test(expected = NotFoundException.class)
public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() throws Exception {
public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() {
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe"));
acl.insertAce(0, mock(Permission.class), mock(Sid.class), true);
Expand All @@ -549,7 +548,7 @@ public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() throws Excepti

// SEC-1795
@Test
public void changingParentIsSuccessful() throws Exception {
public void changingParentIsSuccessful() {
AclImpl parentAcl = new AclImpl(objectIdentity, 1L, authzStrategy,
mockAuditLogger);
AclImpl childAcl = new AclImpl(objectIdentity, 2L, authzStrategy, mockAuditLogger);
Expand Down
Expand Up @@ -41,17 +41,17 @@ public class AclImplementationSecurityCheckTests {
// ========================================================================================================

@Before
public void setUp() throws Exception {
public void setUp() {
SecurityContextHolder.clearContext();
}

@After
public void tearDown() throws Exception {
public void tearDown() {
SecurityContextHolder.clearContext();
}

@Test
public void testSecurityCheckNoACEs() throws Exception {
public void testSecurityCheckNoACEs() {
Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_GENERAL", "ROLE_AUDITING", "ROLE_OWNERSHIP");
auth.setAuthenticated(true);
Expand Down Expand Up @@ -103,7 +103,7 @@ public void testSecurityCheckNoACEs() throws Exception {
}

@Test
public void testSecurityCheckWithMultipleACEs() throws Exception {
public void testSecurityCheckWithMultipleACEs() {
// Create a simple authentication with ROLE_GENERAL
Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_GENERAL");
Expand Down Expand Up @@ -206,7 +206,7 @@ public void testSecurityCheckWithMultipleACEs() throws Exception {
}

@Test
public void testSecurityCheckWithInheritableACEs() throws Exception {
public void testSecurityCheckWithInheritableACEs() {
// Create a simple authentication with ROLE_GENERAL
Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_GENERAL");
Expand Down Expand Up @@ -273,7 +273,7 @@ public void testSecurityCheckWithInheritableACEs() throws Exception {
}

@Test
public void testSecurityCheckPrincipalOwner() throws Exception {
public void testSecurityCheckPrincipalOwner() {
Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_ONE");
auth.setAuthenticated(true);
Expand Down

0 comments on commit 34dd5fe

Please sign in to comment.