Search in sources :

Example 1 with AliasConfiguration

use of com.amazonaws.services.lambda.model.AliasConfiguration in project pipeline-aws-plugin by jenkinsci.

the class LambdaVersionCleanupStepTest method ignoreAliases.

@Test
public void ignoreAliases() throws Exception {
    WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
    Mockito.when(this.awsLambda.listAliases(Mockito.eq(new ListAliasesRequest().withFunctionName("foo")))).thenReturn(new ListAliasesResult().withAliases(new AliasConfiguration().withFunctionVersion("myVersion")));
    Mockito.when(this.awsLambda.listVersionsByFunction(Mockito.eq(new ListVersionsByFunctionRequest().withFunctionName("foo")))).thenReturn(new ListVersionsByFunctionResult().withVersions(Arrays.asList(new FunctionConfiguration().withVersion("myVersion").withLastModified(ZonedDateTime.now().minusDays(15).format(DateTimeFormatter.ISO_ZONED_DATE_TIME)))));
    job.setDefinition(new CpsFlowDefinition("" + "node {\n" + "  lambdaVersionCleanup(functionName: 'foo', daysAgo: 5)\n" + "}\n", true));
    this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
    Mockito.verify(this.awsLambda).listVersionsByFunction(Mockito.any());
    Mockito.verify(this.awsLambda).listAliases(Mockito.any());
    Mockito.verifyNoMoreInteractions(this.awsLambda);
}
Also used : ListAliasesResult(com.amazonaws.services.lambda.model.ListAliasesResult) ListVersionsByFunctionResult(com.amazonaws.services.lambda.model.ListVersionsByFunctionResult) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) FunctionConfiguration(com.amazonaws.services.lambda.model.FunctionConfiguration) AliasConfiguration(com.amazonaws.services.lambda.model.AliasConfiguration) ListAliasesRequest(com.amazonaws.services.lambda.model.ListAliasesRequest) ListVersionsByFunctionRequest(com.amazonaws.services.lambda.model.ListVersionsByFunctionRequest) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

AliasConfiguration (com.amazonaws.services.lambda.model.AliasConfiguration)1 FunctionConfiguration (com.amazonaws.services.lambda.model.FunctionConfiguration)1 ListAliasesRequest (com.amazonaws.services.lambda.model.ListAliasesRequest)1 ListAliasesResult (com.amazonaws.services.lambda.model.ListAliasesResult)1 ListVersionsByFunctionRequest (com.amazonaws.services.lambda.model.ListVersionsByFunctionRequest)1 ListVersionsByFunctionResult (com.amazonaws.services.lambda.model.ListVersionsByFunctionResult)1 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)1 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1