private void deleteFunction() { final DeleteFunctionRequest dlfrq = new DeleteFunctionRequest().withFunctionName(FunctionName); try { this.awsLambdaClient.deleteFunction(dlfrq); } catch (final ResourceNotFoundException rnfx) { // it is ok if the resource is not there, we simply succeed } }
private void setFunctionFound(Boolean found){ if(found) { when(awsLambdaClient.getFunction(any(GetFunctionRequest.class))) .thenReturn(new GetFunctionResult()); } else { when(awsLambdaClient.getFunction(any(GetFunctionRequest.class))) .thenThrow(new ResourceNotFoundException("")); } }
private void setAlias(String alias, Boolean exists){ this.createAlias = Boolean.TRUE; this.alias = alias; GetAliasResult getAliasResult = new GetAliasResult() .withName(alias) .withFunctionVersion(functionVersion); if(exists){ when(awsLambdaClient.getAlias(any(GetAliasRequest.class))) .thenReturn(getAliasResult); } else { when(awsLambdaClient.getAlias(any(GetAliasRequest.class))) .thenThrow(new ResourceNotFoundException("")); } CreateAliasResult createAliasResult = new CreateAliasResult() .withName(alias) .withFunctionVersion(functionVersion); when(awsLambdaClient.createAlias(any(CreateAliasRequest.class))) .thenReturn(createAliasResult); UpdateAliasResult updateAliasResult = new UpdateAliasResult() .withName(alias) .withFunctionVersion(functionVersion); when(awsLambdaClient.updateAlias(any(UpdateAliasRequest.class))) .thenReturn(updateAliasResult); }