Tools { public static boolean isSimilar(String expected, String real, char wildcard) throws ComparisonFailure { if (!expected.equals(String.valueOf(wildcard))) { StringBuilder sb = new StringBuilder(); if (expected.startsWith(String.valueOf(wildcard))) { sb.append(".*"); } boolean first = true; for (String token : expected.split(Pattern.quote(String.valueOf(wildcard)))) { if (token.isEmpty()) { continue; } if (!first) { sb.append(".*"); } first = false; sb.append(Pattern.quote(token)); } if (expected.endsWith(String.valueOf(wildcard))) { sb.append(".*"); } if (!Pattern.compile(sb.toString(), Pattern.DOTALL).matcher(real).matches()) { return false; } } return true; }  static String[] tokenizeArgs(String args); static String convertToHtml(String str); static String getFilename(String filePath); static String getDir(String filePath); static String ensureDir(String dir, String basedir); static String ensureFileDir(String file, String basedir); static String ensureDir(String outputDir); static String modifyUrl(final String url, Integer mods); static void openURL(String url); static ByteArrayOutputStream readAll(InputStream instream, long maxSize); static void readAndWrite(InputStream instream, long maxSize, OutputStream outstream); static int copyFile(File source, File target, boolean overwrite); static String joinRelativeUrl(String baseUrl, String url); static boolean isEmpty(String str); static long writeAll(OutputStream out, InputStream in); static String expandProperties(StringToStringMap values, String content, boolean leaveMissing); static String replaceHost(String endpoint, String host); static String getEndpointFromUrl(URL baseUrl); static String getContentTypeFromFilename(String fileName); static String getExtensionForContentType(String contentType); static String getFileContent(String path); static String getTitleProperty(String path); static String normalizeFileSeparators(String input); static void assertSimilar(String expected, String real, char wildcard); static boolean isSimilar(String expected, String real, char wildcard); static void main(String[] args); static File createTemporaryDirectory(); static void deleteDirectoryOnExit(final File directory); static boolean isPropertyExpansion(@Nullable String value); static String removePropertyExpansions(String definitionUrl, String definition); static final int COPY_BUFFER_SIZE; static final long READ_ALL; }
@Test public void wildcardMatchesMultipleLine() { assertThat(Tools.isSimilar("first*rd line", "first line\nsecond line\third line", '*'), is(true)); }