use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method setupSdk.
@Before
public void setupSdk() throws Exception {
this.stack = Mockito.mock(CloudFormationStack.class);
PowerMockito.mockStatic(AWSClientFactory.class);
PowerMockito.whenNew(CloudFormationStack.class).withAnyArguments().thenReturn(this.stack);
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 CFNExecuteChangeSetTests method setupSdk.
@Before
public void setupSdk() throws Exception {
this.stack = Mockito.mock(CloudFormationStack.class);
PowerMockito.mockStatic(AWSClientFactory.class);
PowerMockito.whenNew(CloudFormationStack.class).withAnyArguments().thenReturn(this.stack);
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 describeStack.
@Test
public void describeStack() {
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().withOutputs(new Output().withOutputKey("bar").withOutputValue("baz"))));
Assertions.assertThat(stack.describeOutputs()).isEqualTo(Collections.singletonMap("bar", "baz"));
}
use of com.amazonaws.services.cloudformation.AmazonCloudFormation in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method updateStack.
@Test
public void updateStack() 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("templateBody", null, Collections.<Parameter>emptyList(), Collections.<Tag>emptyList(), 25, "myarn");
ArgumentCaptor<UpdateStackRequest> captor = ArgumentCaptor.forClass(UpdateStackRequest.class);
Mockito.verify(client).updateStack(captor.capture());
Assertions.assertThat(captor.getValue()).isEqualTo(new UpdateStackRequest().withStackName("foo").withTemplateBody("templateBody").withCapabilities(Capability.values()).withParameters(Collections.<Parameter>emptyList()).withRoleARN("myarn"));
Mockito.verify(this.eventPrinter).waitAndPrintStackEvents(Mockito.eq("foo"), 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 stackDoesNotExists.
@Test
public void stackDoesNotExists() {
TaskListener taskListener = Mockito.mock(TaskListener.class);
AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
AmazonCloudFormationException ex = new AmazonCloudFormationException("foo");
ex.setErrorCode("ValidationError");
ex.setErrorMessage("stack foo does not exist");
Mockito.when(client.describeStacks(new DescribeStacksRequest().withStackName("foo"))).thenThrow(ex);
Assertions.assertThat(stack.exists()).isFalse();
}
Aggregations