@Value.Default public ProjectName projectName() { return ProjectName.random(); }
private ProjectName projectName() { return Strings.isFilled(project) && !Sirius.isStartedAsTest() ? ProjectName.fromString(project) : ProjectName.random(); }
@Check protected void validate() { checkState(projectName().trim().length() > 0, "ProjectName must not be blank."); checkState(validCharacters(), "ProjectName '%s' not allowed, please use lowercase letters and numbers only.", projectName()); }
@Test public void produce_different_names_on_successive_calls_to_random() { List<String> firstCommand = ProjectName.random().constructComposeFileCommand(); List<String> secondCommand = ProjectName.random().constructComposeFileCommand(); assertThat(firstCommand, is(not(equalTo(secondCommand)))); }
@Test public void should_disallow_names_in_from_string_factory() { List<String> command = ProjectName.fromString("projectname").constructComposeFileCommand(); assertThat(command, contains("--project-name", "projectname")); }
public String asString() { return projectName(); }
@Override public Process execute(String... commands) throws IOException { List<String> args = ImmutableList.<String>builder() .add(dockerComposePath()) .addAll(projectName().constructComposeFileCommand()) .addAll(dockerComposeFiles().constructComposeFileCommand()) .add(commands) .build(); return dockerConfiguration().configuredDockerComposeProcess() .command(args) .redirectErrorStream(true) .start(); }
public static DockerCompositionBuilder of(DockerComposeFiles dockerComposeFiles, DockerMachine dockerMachine, String projectName) { return new DockerCompositionBuilder() .files(dockerComposeFiles) .machine(dockerMachine) .projectName(ProjectName.fromString(projectName)); }
@Test public void should_return_the_project_name_when_asString_called() { String projectName = ProjectName.fromString("projectname").asString(); assertThat(projectName, is("projectname")); } }
@Test public void use_project_name_prefix_in_construct_compose_command() { List<String> command = ProjectName.random().constructComposeFileCommand(); assertThat(command, hasSize(2)); assertThat(command.get(0), is("--project-name")); }
@Test public void should_pass_name_to_command_in_from_string_factory() { List<String> command = ProjectName.fromString("projectname").constructComposeFileCommand(); assertThat(command, contains("--project-name", "projectname")); }
public String asString() { return projectName(); }
@Override public Process execute(String... commands) throws IOException { List<String> args = ImmutableList.<String>builder() .add(dockerComposePath()) .addAll(projectName().constructComposeFileCommand()) .addAll(dockerComposeFiles().constructComposeFileCommand()) .add(commands) .build(); return dockerConfiguration().configuredDockerComposeProcess() .command(args) .redirectErrorStream(true) .start(); }
@Test public void match_validation_behavior_of_docker_compose_cli() { exception.expect(IllegalStateException.class); exception.expectMessage("ProjectName 'Crazy#Proj ect!Name' not allowed, please use lowercase letters and numbers only."); ProjectName.fromString("Crazy#Proj ect!Name"); }
@Value.Default public ProjectName projectName() { return ProjectName.random(); }
@Test public void have_eight_characters_long_random() { String randomName = ProjectName.random().constructComposeFileCommand().get(1); assertThat(randomName.length(), is(8)); }
@Check protected void validate() { checkState(projectName().trim().length() > 0, "ProjectName must not be blank."); checkState(validCharacters(), "ProjectName '%s' not allowed, please use lowercase letters and numbers only.", projectName()); }
public String asString() { return projectName(); }
@Override public Process execute(String... commands) throws IOException { DockerForMacHostsIssue.issueWarning(); List<String> args = ImmutableList.<String>builder() .add(dockerComposePath()) .addAll(projectName().constructComposeFileCommand()) .addAll(dockerComposeFiles().constructComposeFileCommand()) .add(commands) .build(); return dockerConfiguration().configuredDockerComposeProcess() .command(args) .redirectErrorStream(true) .start(); }
@Test public void reject_blanks_in_from_string() { exception.expect(IllegalStateException.class); exception.expectMessage("ProjectName must not be blank."); ProjectName.fromString(" "); }