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"));
}
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);
}
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);
}
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));
}
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));
}
Aggregations