-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Spotbugs issues with new Uluru checker (#63)
* Fix Spotbugs issues with AWS::Transfer::Agreement * Fix Spotbugs issues with AWS::Transfer::Certificate * Fix Spotbugs issues with AWS::Transfer::Connector * Fix Spotbugs issues with AWS::Transfer::Profile * Fix Spotbugs issues with AWS::Transfer::Workflow * Fix Spotbugs issues with AWS::Transfer::(Server|User) Also added coverage improvement tests for BaseHandlerStd classes. This change is necessary due to the fact that Uluru is adding Spotbugs and specifically a new Spotbugs plugin designed to catch problems in handler implementations. Signed-off-by: Alex Volanis <[email protected]>
- Loading branch information
1 parent
73f5849
commit 558258e
Showing
78 changed files
with
1,898 additions
and
1,555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<FindBugsFilter> | ||
<Match> | ||
<Class name="software.amazon.transfer.agreement.HandlerWrapperExecutable"/> | ||
</Match> | ||
<Match> | ||
<Class name="software.amazon.transfer.agreement.HandlerWrapper"/> | ||
</Match> | ||
<Match> | ||
<Class name="software.amazon.transfer.agreement.ResourceModel"/> | ||
</Match> | ||
<Match> | ||
<Bug code="RCN,EI,EI2"/> | ||
</Match> | ||
</FindBugsFilter> |
40 changes: 40 additions & 0 deletions
40
aws-transfer-agreement/src/main/java/software/amazon/transfer/agreement/BaseHandlerStd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package software.amazon.transfer.agreement; | ||
|
||
import software.amazon.awssdk.services.transfer.TransferClient; | ||
import software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy; | ||
import software.amazon.cloudformation.proxy.Logger; | ||
import software.amazon.cloudformation.proxy.ProgressEvent; | ||
import software.amazon.cloudformation.proxy.ProxyClient; | ||
import software.amazon.cloudformation.proxy.ResourceHandlerRequest; | ||
|
||
/** | ||
* The purpose of this base class is to allow a simple calling pattern that | ||
* makes testing Uluru handlers easier and avoids having to store context | ||
* in class fields. The {@link MockableBaseHandler} interface is used to | ||
* make isolation of the inner call such that in testing we guarantee that | ||
* the caller will not pick the wrong method and avoid human error. | ||
*/ | ||
public abstract class BaseHandlerStd extends BaseHandler<CallbackContext> | ||
implements MockableBaseHandler<CallbackContext> { | ||
@Override | ||
public final ProgressEvent<ResourceModel, CallbackContext> handleRequest( | ||
final AmazonWebServicesClientProxy proxy, | ||
final ResourceHandlerRequest<ResourceModel> request, | ||
final CallbackContext callbackContext, | ||
final Logger logger) { | ||
return handleRequest( | ||
proxy, | ||
request, | ||
callbackContext != null ? callbackContext : new CallbackContext(), | ||
proxy.newProxy(ClientBuilder::getClient), | ||
logger); | ||
} | ||
|
||
@Override | ||
public abstract ProgressEvent<ResourceModel, CallbackContext> handleRequest( | ||
final AmazonWebServicesClientProxy proxy, | ||
final ResourceHandlerRequest<ResourceModel> request, | ||
final CallbackContext callbackContext, | ||
final ProxyClient<TransferClient> proxyClient, | ||
final Logger logger); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...nsfer-agreement/src/main/java/software/amazon/transfer/agreement/MockableBaseHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package software.amazon.transfer.agreement; | ||
|
||
import software.amazon.awssdk.services.transfer.TransferClient; | ||
import software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy; | ||
import software.amazon.cloudformation.proxy.Logger; | ||
import software.amazon.cloudformation.proxy.ProgressEvent; | ||
import software.amazon.cloudformation.proxy.ProxyClient; | ||
import software.amazon.cloudformation.proxy.ResourceHandlerRequest; | ||
|
||
/** | ||
* Interface exposing the only handler method that should be used when | ||
* testing Uluru handlers. This provides a mechanism to feed the call chain | ||
* a mock client as needed without complex static mocking of the ClientBuilder. | ||
* | ||
* @param <CallbackT> | ||
*/ | ||
interface MockableBaseHandler<CallbackT> { | ||
ProgressEvent<ResourceModel, CallbackT> handleRequest( | ||
final AmazonWebServicesClientProxy proxy, | ||
final ResourceHandlerRequest<ResourceModel> request, | ||
final CallbackT callbackContext, | ||
final ProxyClient<TransferClient> proxyClient, | ||
final Logger logger); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.