mirror of https://github.com/apache/jclouds.git
ensure setting options still uses the default template
This commit is contained in:
parent
3a1ff2e29c
commit
0f30c81466
|
@ -394,8 +394,12 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
|||
*/
|
||||
@Override
|
||||
public Template build() {
|
||||
if (nothingChangedExceptOptions())
|
||||
return defaultTemplateProvider.get().build();
|
||||
if (nothingChangedExceptOptions()) {
|
||||
TemplateBuilder defaultTemplate = defaultTemplateProvider.get();
|
||||
if (options != null)
|
||||
defaultTemplate.options(options);
|
||||
return defaultTemplate.build();
|
||||
}
|
||||
if (locationId == null)
|
||||
locationId = defaultLocation.getId();
|
||||
if (options == null)
|
||||
|
|
|
@ -50,6 +50,8 @@ public class TemplateBuilderImplTest {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testOptionsUsesDefaultTemplateBuilder() {
|
||||
TemplateOptions options = new TemplateOptions();
|
||||
|
||||
Set<Location> locations = ImmutableSet.<Location> of();
|
||||
Set<Image> images = ImmutableSet.<Image> of();
|
||||
Set<Size> sizes = ImmutableSet.<Size> of();
|
||||
|
@ -59,6 +61,7 @@ public class TemplateBuilderImplTest {
|
|||
TemplateBuilder defaultTemplate = createMock(TemplateBuilder.class);
|
||||
|
||||
expect(templateBuilderProvider.get()).andReturn(defaultTemplate);
|
||||
expect(defaultTemplate.options(options)).andReturn(defaultTemplate);
|
||||
expect(defaultTemplate.build()).andReturn(null);
|
||||
|
||||
replay(defaultTemplate);
|
||||
|
@ -69,13 +72,14 @@ public class TemplateBuilderImplTest {
|
|||
TemplateBuilderImpl template = createTemplateBuilder(locations, images, sizes,
|
||||
defaultLocation, optionsProvider, templateBuilderProvider);
|
||||
|
||||
template.options(new TemplateOptions()).build();
|
||||
template.options(options).build();
|
||||
|
||||
verify(defaultTemplate);
|
||||
verify(defaultLocation);
|
||||
verify(optionsProvider);
|
||||
verify(templateBuilderProvider);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testNothingUsesDefaultTemplateBuilder() {
|
||||
|
|
Loading…
Reference in New Issue