when(computeService.templateBuilder()).thenReturn(templateBuilder);
when(templateBuilder.from((TemplateBuilderSpec)any())).thenReturn(templateBuilder);
when(templateBuilder.options((TemplateOptions)any())).thenReturn(templateBuilder);
Template template = mock(Template.class);
TemplateOptions options = mock(TemplateOptions.class);
Image image = mock(Image.class);
when(templateBuilder.build()).thenReturn(template);
when(template.getOptions()).thenReturn(options);
when(template.getImage()).thenReturn(image);
AWSEC2TemplateOptions awsEec2TemplateOptions = mock(AWSEC2TemplateOptions.class);
when(options.as((Class<TemplateOptions>) any())).thenReturn(awsEec2TemplateOptions);
BootstrapTemplate.build(clusterSpec, computeService,
statementBuilder, instanceTemplate);
verify(awsEec2TemplateOptions).spotPrice(spotPrice);