Search in sources :

Example 1 with ValidateTemplateRequest

use of com.amazonaws.services.cloudformation.model.ValidateTemplateRequest in project pipeline-aws-plugin by jenkinsci.

the class CFNValidateStepTests method validateWithUrlSuccess.

@Test
public void validateWithUrlSuccess() throws Exception {
    WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
    job.setDefinition(new CpsFlowDefinition("" + "node {\n" + "  cfnValidate(url: 'foo')" + "}\n", true));
    this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
    ArgumentCaptor<ValidateTemplateRequest> captor = ArgumentCaptor.forClass(ValidateTemplateRequest.class);
    Mockito.verify(this.cloudFormation).validateTemplate(captor.capture());
    Assertions.assertThat(captor.getValue()).isEqualTo(new ValidateTemplateRequest().withTemplateURL("foo"));
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) ValidateTemplateRequest(com.amazonaws.services.cloudformation.model.ValidateTemplateRequest) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with ValidateTemplateRequest

use of com.amazonaws.services.cloudformation.model.ValidateTemplateRequest in project pipeline-aws-plugin by jenkinsci.

the class CFNValidateStepTests method validateWithUrlFailure.

@Test
public void validateWithUrlFailure() throws Exception {
    WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
    AmazonCloudFormationException ex = new AmazonCloudFormationException("invalid template");
    Mockito.when(this.cloudFormation.validateTemplate(Mockito.any(ValidateTemplateRequest.class))).thenThrow(ex);
    job.setDefinition(new CpsFlowDefinition("" + "node {\n" + "  cfnValidate(url: 'foo')" + "}\n", true));
    this.jenkinsRule.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0));
    ArgumentCaptor<ValidateTemplateRequest> captor = ArgumentCaptor.forClass(ValidateTemplateRequest.class);
    Mockito.verify(this.cloudFormation).validateTemplate(captor.capture());
    Assertions.assertThat(captor.getValue()).isEqualTo(new ValidateTemplateRequest().withTemplateURL("foo"));
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) ValidateTemplateRequest(com.amazonaws.services.cloudformation.model.ValidateTemplateRequest) AmazonCloudFormationException(com.amazonaws.services.cloudformation.model.AmazonCloudFormationException) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

ValidateTemplateRequest (com.amazonaws.services.cloudformation.model.ValidateTemplateRequest)2 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)2 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 AmazonCloudFormationException (com.amazonaws.services.cloudformation.model.AmazonCloudFormationException)1