@Test public void generateReportFileName_ShouldReplaceSpacesWithDashes_WhenScenarioNameHasSpaces() { when(dateService.now()).thenReturn(timestamp(2018, 1, 1, 1, 1, 1)); final String fileName = cut.generateReportFileName("Scenario Name", null); assertThat(fileName).isEqualTo("2018.02.01-01h01m01.000-Scenario-Name"); }
String generateReportFileName(final String scenarioName, final String extension) { final String truncatedScenarioName = StringUtils.left(scenarioName, MAX_SCENARIO_NAME_LENGTH); final String safeScenarioName = truncatedScenarioName.replace(' ', '-').replaceAll("[^a-zA-Z0-9\\-]", ""); final String formattedDate = new SimpleDateFormat(HUMAN_AND_MACHINE_READABLE_TIMESTAMP_PATTERN).format(dateService.now()); return formattedDate + "-" + safeScenarioName + (StringUtils.isEmpty(extension) ? "" : ("." + extension)); }
FileNameService { String generateReportFileName(final String scenarioName, final String extension) { final String truncatedScenarioName = StringUtils.left(scenarioName, MAX_SCENARIO_NAME_LENGTH); final String safeScenarioName = truncatedScenarioName.replace(' ', '-').replaceAll("[^a-zA-Z0-9\\-]", ""); final String formattedDate = new SimpleDateFormat(HUMAN_AND_MACHINE_READABLE_TIMESTAMP_PATTERN).format(dateService.now()); return formattedDate + "-" + safeScenarioName + (StringUtils.isEmpty(extension) ? "" : ("." + extension)); } }
FileNameService { String generateReportFileName(final String scenarioName, final String extension) { final String truncatedScenarioName = StringUtils.left(scenarioName, MAX_SCENARIO_NAME_LENGTH); final String safeScenarioName = truncatedScenarioName.replace(' ', '-').replaceAll("[^a-zA-Z0-9\\-]", ""); final String formattedDate = new SimpleDateFormat(HUMAN_AND_MACHINE_READABLE_TIMESTAMP_PATTERN).format(dateService.now()); return formattedDate + "-" + safeScenarioName + (StringUtils.isEmpty(extension) ? "" : ("." + extension)); }  }
FileNameService { String generateReportFileName(final String scenarioName, final String extension) { final String truncatedScenarioName = StringUtils.left(scenarioName, MAX_SCENARIO_NAME_LENGTH); final String safeScenarioName = truncatedScenarioName.replace(' ', '-').replaceAll("[^a-zA-Z0-9\\-]", ""); final String formattedDate = new SimpleDateFormat(HUMAN_AND_MACHINE_READABLE_TIMESTAMP_PATTERN).format(dateService.now()); return formattedDate + "-" + safeScenarioName + (StringUtils.isEmpty(extension) ? "" : ("." + extension)); }   }
FileNameService { String generateReportFileName(final String scenarioName, final String extension) { final String truncatedScenarioName = StringUtils.left(scenarioName, MAX_SCENARIO_NAME_LENGTH); final String safeScenarioName = truncatedScenarioName.replace(' ', '-').replaceAll("[^a-zA-Z0-9\\-]", ""); final String formattedDate = new SimpleDateFormat(HUMAN_AND_MACHINE_READABLE_TIMESTAMP_PATTERN).format(dateService.now()); return formattedDate + "-" + safeScenarioName + (StringUtils.isEmpty(extension) ? "" : ("." + extension)); }    }