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
|
@Override
|
||||||
public Template build() {
|
public Template build() {
|
||||||
if (nothingChangedExceptOptions())
|
if (nothingChangedExceptOptions()) {
|
||||||
return defaultTemplateProvider.get().build();
|
TemplateBuilder defaultTemplate = defaultTemplateProvider.get();
|
||||||
|
if (options != null)
|
||||||
|
defaultTemplate.options(options);
|
||||||
|
return defaultTemplate.build();
|
||||||
|
}
|
||||||
if (locationId == null)
|
if (locationId == null)
|
||||||
locationId = defaultLocation.getId();
|
locationId = defaultLocation.getId();
|
||||||
if (options == null)
|
if (options == null)
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class TemplateBuilderImplTest {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testOptionsUsesDefaultTemplateBuilder() {
|
public void testOptionsUsesDefaultTemplateBuilder() {
|
||||||
|
TemplateOptions options = new TemplateOptions();
|
||||||
|
|
||||||
Set<Location> locations = ImmutableSet.<Location> of();
|
Set<Location> locations = ImmutableSet.<Location> of();
|
||||||
Set<Image> images = ImmutableSet.<Image> of();
|
Set<Image> images = ImmutableSet.<Image> of();
|
||||||
Set<Size> sizes = ImmutableSet.<Size> of();
|
Set<Size> sizes = ImmutableSet.<Size> of();
|
||||||
|
@ -59,6 +61,7 @@ public class TemplateBuilderImplTest {
|
||||||
TemplateBuilder defaultTemplate = createMock(TemplateBuilder.class);
|
TemplateBuilder defaultTemplate = createMock(TemplateBuilder.class);
|
||||||
|
|
||||||
expect(templateBuilderProvider.get()).andReturn(defaultTemplate);
|
expect(templateBuilderProvider.get()).andReturn(defaultTemplate);
|
||||||
|
expect(defaultTemplate.options(options)).andReturn(defaultTemplate);
|
||||||
expect(defaultTemplate.build()).andReturn(null);
|
expect(defaultTemplate.build()).andReturn(null);
|
||||||
|
|
||||||
replay(defaultTemplate);
|
replay(defaultTemplate);
|
||||||
|
@ -69,13 +72,14 @@ public class TemplateBuilderImplTest {
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(locations, images, sizes,
|
TemplateBuilderImpl template = createTemplateBuilder(locations, images, sizes,
|
||||||
defaultLocation, optionsProvider, templateBuilderProvider);
|
defaultLocation, optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
template.options(new TemplateOptions()).build();
|
template.options(options).build();
|
||||||
|
|
||||||
verify(defaultTemplate);
|
verify(defaultTemplate);
|
||||||
verify(defaultLocation);
|
verify(defaultLocation);
|
||||||
verify(optionsProvider);
|
verify(optionsProvider);
|
||||||
verify(templateBuilderProvider);
|
verify(templateBuilderProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testNothingUsesDefaultTemplateBuilder() {
|
public void testNothingUsesDefaultTemplateBuilder() {
|
||||||
|
|
Loading…
Reference in New Issue