use of com.amazonaws.services.cloudformation.model.Change in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetStackDoesNotExist.
@Test
public void createChangeSetStackDoesNotExist() throws Exception {
WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(this.stack.exists()).thenReturn(false);
Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withChanges(new Change()).withStatus(ChangeSetStatus.CREATE_COMPLETE));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true));
Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
this.jenkinsRule.assertLogContains("changesCount=1", run);
PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.anyString(), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.CREATE), Mockito.anyString(), Mockito.any());
}
use of com.amazonaws.services.cloudformation.model.Change 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 com.amazonaws.services.cloudformation.model.Change in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method updateChangeSetWithRawTemplate.
@Test
public void updateChangeSetWithRawTemplate() throws Exception {
WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(this.stack.exists()).thenReturn(false);
Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withChanges(new Change()).withStatus(ChangeSetStatus.CREATE_COMPLETE));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar', template: 'foobaz')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true));
Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
this.jenkinsRule.assertLogContains("changesCount=1", run);
PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.eq("foobaz"), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.CREATE), Mockito.anyString(), Mockito.any());
}
Aggregations