### Question:
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; }### Answer:
@Test public void filename_without_variant_has_variant_empty() { assertEquals("",converterToTest.getVariantFromFilename("filename1.txt")); }
@Test public void filename_with_variant1_has_variant1() { assertEquals("variant1",converterToTest.getVariantFromFilename("filename1-variant_variant1.txt")); assertEquals("variant1",converterToTest.getVariantFromFilename("filename1-variant_variant1.pdf")); }
@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")); }