@Test public void filename_with_incorrect_variant1_has_variant_empty() { assertEquals("",converterToTest.getVariantFromFilename("filename1-variant_txt")); assertEquals("",converterToTest.getVariantFromFilename("filename1-variant_.txt")); assertEquals("",converterToTest.getVariantFromFilename("filename1-variant_variant1")); }
public String getVariantFromFilename(String fileName) { if (fileName == null) { return ""; } int index = fileName.indexOf(variantIdentifier); if (index == -1) { return ""; } String subString = fileName.substring(index + variantIdentifier.length()); index = subString.indexOf('.'); if (index == -1) { return ""; } return subString.substring(0, index); }
FilenameVariantConverter { public String getVariantFromFilename(String fileName) { if (fileName == null) { return ""; } int index = fileName.indexOf(variantIdentifier); if (index == -1) { return ""; } String subString = fileName.substring(index + variantIdentifier.length()); index = subString.indexOf('.'); if (index == -1) { return ""; } return subString.substring(0, index); } }
FilenameVariantConverter { public String getVariantFromFilename(String fileName) { if (fileName == null) { return ""; } int index = fileName.indexOf(variantIdentifier); if (index == -1) { return ""; } String subString = fileName.substring(index + variantIdentifier.length()); index = subString.indexOf('.'); if (index == -1) { return ""; } return subString.substring(0, index); } FilenameVariantConverter();  FilenameVariantConverter(String varIdentifier); }
FilenameVariantConverter { public String getVariantFromFilename(String fileName) { if (fileName == null) { return ""; } int index = fileName.indexOf(variantIdentifier); if (index == -1) { return ""; } String subString = fileName.substring(index + variantIdentifier.length()); index = subString.indexOf('.'); if (index == -1) { return ""; } return subString.substring(0, index); } FilenameVariantConverter();  FilenameVariantConverter(String varIdentifier); String getVariantFromFilename(String fileName); String toVariantFileName(String fileName, String variant); String getFilenameWithoutVariant(String fileName); }
FilenameVariantConverter { public String getVariantFromFilename(String fileName) { if (fileName == null) { return ""; } int index = fileName.indexOf(variantIdentifier); if (index == -1) { return ""; } String subString = fileName.substring(index + variantIdentifier.length()); index = subString.indexOf('.'); if (index == -1) { return ""; } return subString.substring(0, index); } FilenameVariantConverter();  FilenameVariantConverter(String varIdentifier); String getVariantFromFilename(String fileName); String toVariantFileName(String fileName, String variant); String getFilenameWithoutVariant(String fileName); static final String DEFAULT_IDENTIFIER; }