String (@NotNull String beforeName, @NotNull String afterName) { if (isBeforeAfterPrefixedPair(beforeName, afterName)) { return BEFORE_AFTER_DISPLAY_NAME_PART + StringUtil.trimStart(beforeName, TESTDATA_FILE_BEFORE_MARKER); } String commonPrefix = StringUtil.commonPrefix(beforeName, afterName); if (!commonPrefix.isEmpty()) { String beforeNameExt = PathUtil.getFileExtension(beforeName); String beforeNameWithoutExt = beforeNameExt == null ? beforeName : StringUtil.substringBeforeLast(beforeName, "." + beforeNameExt); String beforeNameWithoutCommonPrefixAndExt = StringUtil.trimStart(beforeNameWithoutExt, commonPrefix.endsWith(".") ? StringUtil.trimEnd(commonPrefix, ".") : commonPrefix); String beforeNameWithoutCommonPrefixAndExtAndBefore = StringUtil.trimEnd(beforeNameWithoutCommonPrefixAndExt, TESTDATA_FILE_BEFORE_MARKER); if (!StringUtil.containsAlphaCharacters(beforeNameWithoutCommonPrefixAndExtAndBefore)) { String result = commonPrefix; char lastChar = commonPrefix.charAt(commonPrefix.length() - 1); if (Character.isDigit(lastChar) || Character.isLetter(lastChar)) { result += "_"; } result += BEFORE_AFTER_DISPLAY_NAME_PART; if (beforeNameExt != null) { result += "." + beforeNameExt; } return result; } } return beforeName + " | " + afterName; }