### Question:
FilenameVariantConverter { public String getFilenameWithoutVariant(String fileName) { if (fileName == null) { return null; } int index = fileName.indexOf(variantIdentifier); if (index == -1) { return fileName; } String before = fileName.substring(0,index); String subString = fileName.substring(index + variantIdentifier.length()); index = subString.indexOf('.'); if (index == -1) { throw new IllegalArgumentException("no '.' found, but this is not allowed!"); } String ending = subString.substring(index); return before+ending; } 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 getFilenameWithoutVariant_when_variants_defined() { assertEquals("filename1.txt",converterToTest.getFilenameWithoutVariant("filename1-variant_variant1.txt")); assertEquals("filename21.pdf",converterToTest.getFilenameWithoutVariant("filename21-variant_variantXY.pdf")); assertEquals("filename22.xyz.pdf",converterToTest.getFilenameWithoutVariant("filename22-variant_variant21.xyz.pdf")); }
@Test public void getFilenameWithoutVariant_when_no_variant_defined() { assertEquals("filename1.txt",converterToTest.getFilenameWithoutVariant("filename1.txt")); }