use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method changeSetExists.
@Test
public void changeSetExists() {
TaskListener taskListener = Mockito.mock(TaskListener.class);
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().withChanges(new Change()));
Assertions.assertThat(stack.changeSetExists("bar")).isTrue();
}
use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method stackExists.
@Test
public void stackExists() {
TaskListener taskListener = Mockito.mock(TaskListener.class);
AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
Mockito.when(client.describeStacks(new DescribeStacksRequest().withStackName("foo"))).thenReturn(new DescribeStacksResult().withStacks(new Stack()));
Assertions.assertThat(stack.exists()).isTrue();
}
use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method deleteStack.
@Test
public void deleteStack() 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.delete(7);
ArgumentCaptor<DeleteStackRequest> captor = ArgumentCaptor.forClass(DeleteStackRequest.class);
Mockito.verify(client).deleteStack(captor.capture());
Assertions.assertThat(captor.getValue()).isEqualTo(new DeleteStackRequest().withStackName("foo"));
Mockito.verify(this.eventPrinter).waitAndPrintStackEvents(Mockito.eq("foo"), Mockito.any(Waiter.class), Mockito.eq(7L));
}
use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method updateStackWithTemplateUrl.
@Test
public void updateStackWithTemplateUrl() 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.update(null, "bar", Collections.<Parameter>emptyList(), Collections.<Tag>emptyList(), 21, "myarn");
ArgumentCaptor<UpdateStackRequest> captor = ArgumentCaptor.forClass(UpdateStackRequest.class);
Mockito.verify(client).updateStack(captor.capture());
Assertions.assertThat(captor.getValue()).isEqualTo(new UpdateStackRequest().withStackName("foo").withTemplateURL("bar").withCapabilities(Capability.values()).withParameters(Collections.<Parameter>emptyList()).withRoleARN("myarn"));
Mockito.verify(this.eventPrinter).waitAndPrintStackEvents(Mockito.eq("foo"), Mockito.any(Waiter.class), Mockito.eq(21L));
}
use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method createStackWithNoTemplate.
@Test(expected = IllegalArgumentException.class)
public void createStackWithNoTemplate() throws ExecutionException {
AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
try {
TaskListener taskListener = Mockito.mock(TaskListener.class);
Mockito.when(client.waiters()).thenReturn(new AmazonCloudFormationWaiters(client));
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
stack.create(null, null, Collections.<Parameter>emptyList(), Collections.<Tag>emptyList(), 3, 21, "myarn", OnFailure.ROLLBACK.toString());
} finally {
Mockito.verifyZeroInteractions(client);
}
}
Aggregations