@Test public void ignoresSuffixIfUnknown() { when(suffix.isKnown()).thenReturn(false); RegexInfoTransformation transformation = new SuffixToMatchTransformation(extractor); RegexInfo result = transformation.transform(info); assertThat(result.getMatch(), equalTo(match)); assertStringSetsUnchanged(result); }
@Test public void appendsExactInfoToMatchExpression() { when(extractor.ngrams(exact)).thenReturn(trigrams); when(match.and(trigrams)).thenReturn(newMatch); when(exact.isKnown()).thenReturn(true); RegexInfoTransformation transformation = new ExactToMatchTransformation(extractor); RegexInfo result = transformation.transform(info); verify(match).and(trigrams); assertThat(result.getMatch(), equalTo(newMatch)); assertStringSetsUnchanged(result); }
private void assertStringSetsUnchanged(RegexInfo result) { assertThat(result.getPrefix(), equalTo(prefix)); assertThat(result.getSuffix(), equalTo(suffix)); assertThat(result.getExact(), equalTo(exact)); }