JCLOUDS-990: fix condition DockerTemplateOptions.copyTo() method

This commit is contained in:
Josef Cacek 2015-08-16 15:13:25 +02:00 committed by Andrea Turli
parent 586e31805a
commit 644541a2f4
2 changed files with 19 additions and 1 deletions

View File

@ -80,7 +80,7 @@ public class DockerTemplateOptions extends TemplateOptions implements Cloneable
}
eTo.memory(memory);
eTo.cpuShares(cpuShares);
if (commands.isEmpty()) {
if (!commands.isEmpty()) {
eTo.commands(commands);
}
if (!env.isEmpty()) {

View File

@ -92,4 +92,22 @@ public class DockerTemplateOptionsTest {
assertEquals(options.as(DockerTemplateOptions.class).getCpuShares(), Integer.valueOf(4));
}
@Test
public void testCopyTo() {
DockerTemplateOptions options = DockerTemplateOptions.Builder
.memory(512)
.cpuShares(4)
.commands("test")
.portBindings(
ImmutableMap.<Integer, Integer> builder()
.put(8443, 443).build()).hostname("hostname")
.userMetadata(ImmutableMap.of("key", "value"))
.env(ImmutableList.of("HOST=abc", "PORT=1234"))
.dns("8.8.8.8", "8.8.4.4")
.volumes(ImmutableMap.of("/tmp", "/tmp"));
DockerTemplateOptions optionsCopy = new DockerTemplateOptions();
options.copyTo(optionsCopy);
assertEquals(optionsCopy, options);
}
}