Search in sources :

Example 11 with AmazonCloudFormation

use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.

the class CloudformationStackTests method describeChangeSet.

@Test
public void describeChangeSet() {
    TaskListener taskListener = Mockito.mock(TaskListener.class);
    Mockito.when(taskListener.getLogger()).thenReturn(System.out);
    AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
    DescribeChangeSetResult expected = new DescribeChangeSetResult().withChanges(new Change());
    Mockito.when(client.describeChangeSet(Mockito.any(DescribeChangeSetRequest.class))).thenReturn(expected);
    CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
    DescribeChangeSetResult result = stack.describeChangeSet("bar");
    Assertions.assertThat(result).isSameAs(expected);
    ArgumentCaptor<DescribeChangeSetRequest> captor = ArgumentCaptor.forClass(DescribeChangeSetRequest.class);
    Mockito.verify(client).describeChangeSet(captor.capture());
    Assertions.assertThat(captor.getValue()).isEqualTo(new DescribeChangeSetRequest().withStackName("foo").withChangeSetName("bar"));
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) TaskListener(hudson.model.TaskListener) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with AmazonCloudFormation

use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.

the class CFNDeleteStackSetStepTest method setupSdk.

@Before
public void setupSdk() throws Exception {
    stackSet = Mockito.mock(CloudFormationStackSet.class);
    PowerMockito.mockStatic(AWSClientFactory.class);
    PowerMockito.whenNew(CloudFormationStackSet.class).withAnyArguments().thenReturn(stackSet);
    AmazonCloudFormation cloudFormation = Mockito.mock(AmazonCloudFormation.class);
    PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class))).thenReturn(cloudFormation);
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) StepContext(org.jenkinsci.plugins.workflow.steps.StepContext) AwsSyncClientBuilder(com.amazonaws.client.builder.AwsSyncClientBuilder) Before(org.junit.Before)

Example 13 with AmazonCloudFormation

use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.

the class CFNUpdateStackSetStepTest method setupSdk.

@Before
public void setupSdk() throws Exception {
    stackSet = Mockito.mock(CloudFormationStackSet.class);
    PowerMockito.mockStatic(AWSClientFactory.class);
    PowerMockito.whenNew(CloudFormationStackSet.class).withAnyArguments().thenReturn(stackSet);
    AmazonCloudFormation cloudFormation = Mockito.mock(AmazonCloudFormation.class);
    PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(EnvVars.class))).thenReturn(cloudFormation);
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) EnvVars(hudson.EnvVars) AwsSyncClientBuilder(com.amazonaws.client.builder.AwsSyncClientBuilder) Before(org.junit.Before)

Example 14 with AmazonCloudFormation

use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.

the class CloudformationStackTests method updateStackWithStackChangeSet.

@Test
public void updateStackWithStackChangeSet() throws ExecutionException {
    TaskListener taskListener = Mockito.mock(TaskListener.class);
    Mockito.when(taskListener.getLogger()).thenReturn(System.out);
    AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
    Mockito.when(client.waiters()).thenReturn(new AmazonCloudFormationWaiters(client));
    CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
    stack.createChangeSet("c1", "templateBody", null, Collections.<Parameter>emptyList(), Collections.<Tag>emptyList(), 25, ChangeSetType.UPDATE, "myarn");
    ArgumentCaptor<CreateChangeSetRequest> captor = ArgumentCaptor.forClass(CreateChangeSetRequest.class);
    Mockito.verify(client).createChangeSet(captor.capture());
    Assertions.assertThat(captor.getValue()).isEqualTo(new CreateChangeSetRequest().withChangeSetType(ChangeSetType.UPDATE).withStackName("foo").withTemplateBody("templateBody").withCapabilities(Capability.values()).withParameters(Collections.<Parameter>emptyList()).withChangeSetName("c1").withRoleARN("myarn"));
    Mockito.verify(this.eventPrinter).waitAndPrintChangeSetEvents(Mockito.eq("foo"), Mockito.eq("c1"), Mockito.any(Waiter.class), Mockito.eq(25L));
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) TaskListener(hudson.model.TaskListener) AmazonCloudFormationWaiters(com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters) Waiter(com.amazonaws.waiters.Waiter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 15 with AmazonCloudFormation

use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.

the class CloudformationStackTests method noExecuteChangeSetIfNoChanges.

@Test
public void noExecuteChangeSetIfNoChanges() throws ExecutionException {
    TaskListener taskListener = Mockito.mock(TaskListener.class);
    Mockito.when(taskListener.getLogger()).thenReturn(System.out);
    AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
    CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
    Mockito.when(client.describeChangeSet(new DescribeChangeSetRequest().withStackName("foo").withChangeSetName("bar"))).thenReturn(new DescribeChangeSetResult());
    stack.executeChangeSet("bar", 1000L);
    Mockito.verify(client, Mockito.never()).executeChangeSet(Mockito.any(ExecuteChangeSetRequest.class));
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) TaskListener(hudson.model.TaskListener) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

AmazonCloudFormation (com.amazonaws.services.cloudformation.AmazonCloudFormation)21 TaskListener (hudson.model.TaskListener)17 Test (org.junit.Test)17 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)17 AmazonCloudFormationWaiters (com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters)10 Waiter (com.amazonaws.waiters.Waiter)9 AwsSyncClientBuilder (com.amazonaws.client.builder.AwsSyncClientBuilder)4 Before (org.junit.Before)4 EnvVars (hudson.EnvVars)3 StepContext (org.jenkinsci.plugins.workflow.steps.StepContext)1