use of hudson.model.TaskListener in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method changeSetExists.
@Test
public void changeSetExists() {
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().withChanges(new Change()));
Assertions.assertThat(stack.changeSetExists("bar")).isTrue();
}
use of hudson.model.TaskListener 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));
Mockito.when(client.describeStacks(new DescribeStacksRequest().withStackName("foo"))).thenReturn(new DescribeStacksResult().withStacks(new Stack().withOutputs(new Output().withOutputKey("bar").withOutputValue("baz"))));
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
RollbackConfiguration rollbackConfig = new RollbackConfiguration().withMonitoringTimeInMinutes(10);
Map<String, String> outputs = stack.update(null, "bar", Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, "myarn", rollbackConfig);
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.emptyList()).withRoleARN("myarn").withRollbackConfiguration(rollbackConfig));
Mockito.verify(this.eventPrinter).waitAndPrintStackEvents(Mockito.eq("foo"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
Assertions.assertThat(outputs).containsEntry("bar", "baz").containsEntry("jenkinsStackUpdateStatus", "true");
}
use of hudson.model.TaskListener 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(PollConfiguration.DEFAULT, new String[] { "myresourcetoretain" }, "myarn", "myclientrequesttoken");
ArgumentCaptor<DeleteStackRequest> captor = ArgumentCaptor.forClass(DeleteStackRequest.class);
Mockito.verify(client).deleteStack(captor.capture());
Assertions.assertThat(captor.getValue()).isEqualTo(new DeleteStackRequest().withStackName("foo").withClientRequestToken("myclientrequesttoken").withRoleARN("myarn").withRetainResources("myresourcetoretain"));
Mockito.verify(this.eventPrinter).waitAndPrintStackEvents(Mockito.eq("foo"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
}
use of hudson.model.TaskListener 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.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, "myarn", OnFailure.ROLLBACK.toString(), null);
} finally {
Mockito.verifyZeroInteractions(client);
}
}
use of hudson.model.TaskListener in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method createNewStackChangeSet_UnknownWaiterError.
@Test(expected = ExecutionException.class)
public void createNewStackChangeSet_UnknownWaiterError() 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("someother failure"));
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);
try {
stack.createChangeSet("c1", "templateBody", null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, ChangeSetType.CREATE, "myarn", null);
} finally {
Mockito.verify(this.eventPrinter, Mockito.atLeastOnce()).waitAndPrintChangeSetEvents(Mockito.any(), Mockito.any(), Mockito.any(Waiter.class), Mockito.any());
}
}
Aggregations