### Question:
FileNamePattern extends ContextAwareBase { public String toRegex() { return toRegex(false, false); } FileNamePattern(String patternArg, Context contextArg); String toString(); @Override int hashCode(); @Override boolean equals(Object obj); DateTokenConverter<Object> getPrimaryDateTokenConverter(); IntegerTokenConverter getIntegerTokenConverter(); boolean hasIntegerTokenCOnverter(); String convertMultipleArguments(Object... objectList); String convert(Object o); String convertInt(int i); void setPattern(String pattern); String getPattern(); String toRegexForFixedDate(Date date); String toRegex(); String toRegex(boolean capturePrimaryDate, boolean captureInteger);  }### Answer:
@Test public void asRegex() { { FileNamePattern fnp = new FileNamePattern("foo-%d{yyyy.MM.dd}-%i.txt", context); String regex = fnp.toRegex(); assertEquals("foo-" + FileFinder.regexEscapePath("\\d{4}\\.\\d{2}\\.\\d{2}") + "-" + FileFinder.regexEscapePath("\\d+") + ".txt", regex); } { FileNamePattern fnp = new FileNamePattern("foo-%d{yyyy.MM.dd'T'}-%i.txt", context); String regex = fnp.toRegex(); assertEquals("foo-" + FileFinder.regexEscapePath("\\d{4}\\.\\d{2}\\.\\d{2}T") + "-" + FileFinder.regexEscapePath("\\d+") + ".txt", regex); } }