use of hudson.model.TaskListener in project pipeline-aws-plugin by jenkinsci.
the class CloudFormationStackSetTest method setup.
@Before
public void setup() {
TaskListener listener = Mockito.mock(TaskListener.class);
Mockito.when(listener.getLogger()).thenReturn(System.out);
client = Mockito.mock(AmazonCloudFormation.class);
sleepStrategy = Mockito.mock(SleepStrategy.class);
stackSet = new CloudFormationStackSet(client, "foo", listener, sleepStrategy);
}
use of hudson.model.TaskListener in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method createStackWithStackChangeSetReviewInProgress.
@Test
public void createStackWithStackChangeSetReviewInProgress() 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));
Mockito.when(client.describeStacks(new DescribeStacksRequest().withStackName("foo"))).thenReturn(new DescribeStacksResult().withStacks(new Stack().withStackStatus("REVIEW_IN_PROGRESS")));
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
stack.createChangeSet("c1", "templateBody", null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, ChangeSetType.UPDATE, "myarn", null);
ArgumentCaptor<CreateChangeSetRequest> captor = ArgumentCaptor.forClass(CreateChangeSetRequest.class);
Mockito.verify(client).createChangeSet(captor.capture());
Assertions.assertThat(captor.getValue()).isEqualTo(new CreateChangeSetRequest().withChangeSetType(ChangeSetType.CREATE).withStackName("foo").withTemplateBody("templateBody").withCapabilities(Capability.values()).withParameters(Collections.emptyList()).withChangeSetName("c1").withRoleARN("myarn"));
Mockito.verify(this.eventPrinter).waitAndPrintChangeSetEvents(Mockito.eq("foo"), Mockito.eq("c1"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
}
use of hudson.model.TaskListener in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method executeChangeSetIfNoChangesButSuccessfulStatus.
@Test
public void executeChangeSetIfNoChangesButSuccessfulStatus() 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().withStatus(ChangeSetStatus.CREATE_COMPLETE));
Mockito.when(client.describeStacks(new DescribeStacksRequest().withStackName("foo"))).thenReturn(new DescribeStacksResult().withStacks(new Stack().withStackStatus(StackStatus.CREATE_COMPLETE).withOutputs(new Output().withOutputKey("bar").withOutputValue("baz"))));
Mockito.when(client.waiters()).thenReturn(new AmazonCloudFormationWaiters(client));
Map<String, String> outputs = stack.executeChangeSet("bar", PollConfiguration.DEFAULT);
Mockito.verify(client).executeChangeSet(Mockito.any(ExecuteChangeSetRequest.class));
Mockito.verify(this.eventPrinter).waitAndPrintStackEvents(Mockito.eq("foo"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
Assertions.assertThat(outputs).containsEntry("bar", "baz");
}
use of hudson.model.TaskListener in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method createNewStackChangeSet_NoSubmittedChanges.
@Test
public void createNewStackChangeSet_NoSubmittedChanges() 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));
Mockito.when(client.describeStacks(Mockito.any())).thenReturn(new DescribeStacksResult());
Mockito.when(client.describeChangeSet(Mockito.any())).thenReturn(new DescribeChangeSetResult().withStatus(ChangeSetStatus.FAILED).withStatusReason("The submitted information didn't contain changes"));
Mockito.doThrow(new ExecutionException(new WaiterUnrecoverableException("foo"))).when(this.eventPrinter).waitAndPrintChangeSetEvents(Mockito.eq("foo"), Mockito.eq("c1"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
stack.createChangeSet("c1", "templateBody", null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, ChangeSetType.CREATE, "myarn", null);
Mockito.verify(this.eventPrinter, Mockito.atLeastOnce()).waitAndPrintChangeSetEvents(Mockito.any(), Mockito.any(), Mockito.any(Waiter.class), Mockito.any());
}
use of hudson.model.TaskListener in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method createNewStackChangeSet.
@Test
public void createNewStackChangeSet() 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));
Mockito.when(client.describeStacks(new DescribeStacksRequest().withStackName("foo"))).thenReturn(new DescribeStacksResult());
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
stack.createChangeSet("c1", "templateBody", null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, ChangeSetType.CREATE, "myarn", null);
ArgumentCaptor<CreateChangeSetRequest> captor = ArgumentCaptor.forClass(CreateChangeSetRequest.class);
Mockito.verify(client).createChangeSet(captor.capture());
Assertions.assertThat(captor.getValue()).isEqualTo(new CreateChangeSetRequest().withChangeSetType(ChangeSetType.CREATE).withStackName("foo").withTemplateBody("templateBody").withCapabilities(Capability.values()).withParameters(Collections.emptyList()).withChangeSetName("c1").withRoleARN("myarn"));
Mockito.verify(this.eventPrinter).waitAndPrintChangeSetEvents(Mockito.eq("foo"), Mockito.eq("c1"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
}
Aggregations