I have the below test case,
@Test
public void test_check_pattern_match_caseInSensitive_for_pre_sampling_filename() {
// given
String pattern = "Sample*.*Selection*.*Preliminary";
// when
// then
assertThat(Util.checkPatternMatchCaseInSensitive(pattern, "Sample selectiossn preliminary"), is(false));
assertThat(Util.checkPatternMatchCaseInSensitive(pattern, "sample selection preliminary"), is(true));
}
The Util method is:
public static boolean checkPatternMatchCaseInSensitive(String pattern, String value) {
Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
Matcher matcher = p.matcher(value);
if (matcher.find())
return true;
return false;
}
Can someone please help, why the regex Sample*.*Selection*.*Preliminary
matches the fileName = Sample selectiossn preliminary
?
This test case should pass, but it fails because of the first assert. :S