Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mayya-sharipova committed Sep 18, 2024
1 parent e8f8a08 commit eee5308
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
Expand Down Expand Up @@ -243,20 +244,26 @@ public void testTermIntervals() throws IOException {
public void testPrefixIntervals() throws IOException {
MappedFieldType ft = createFieldType();
IntervalsSource prefixIntervals = ft.prefixIntervals(new BytesRef("foo"), MOCK_CONTEXT);
assertEquals(Intervals.prefix(new BytesRef("foo")), prefixIntervals);
assertEquals(Intervals.prefix(new BytesRef("foo"), IndexSearcher.getMaxClauseCount()), prefixIntervals);
}

public void testWildcardIntervals() throws IOException {
public void testWildcardIntervals() {
MappedFieldType ft = createFieldType();
IntervalsSource wildcardIntervals = ft.wildcardIntervals(new BytesRef("foo"), MOCK_CONTEXT);
assertEquals(Intervals.wildcard(new BytesRef("foo")), wildcardIntervals);
assertEquals(Intervals.wildcard(new BytesRef("foo"), IndexSearcher.getMaxClauseCount()), wildcardIntervals);
}

public void testFuzzyIntervals() throws IOException {
public void testRegexpIntervals() {
MappedFieldType ft = createFieldType();
IntervalsSource regexpIntervals = ft.regexpIntervals(new BytesRef("foo"), MOCK_CONTEXT);
assertEquals(Intervals.regexp(new BytesRef("foo"), IndexSearcher.getMaxClauseCount()), regexpIntervals);
}

public void testFuzzyIntervals() {
MappedFieldType ft = createFieldType();
IntervalsSource fuzzyIntervals = ft.fuzzyIntervals("foo", 1, 2, true, MOCK_CONTEXT);
FuzzyQuery fq = new FuzzyQuery(new Term("field", "foo"), 1, 2, 128, true);
IntervalsSource expectedIntervals = Intervals.multiterm(fq.getAutomata(), "foo");
IntervalsSource expectedIntervals = Intervals.multiterm(fq.getAutomata(), IndexSearcher.getMaxClauseCount(), "foo");
assertEquals(expectedIntervals, fuzzyIntervals);
}

Expand All @@ -271,6 +278,15 @@ public void testWildcardIntervalsWithIndexedPrefixes() {
TextFieldType ft = createFieldType();
ft.setIndexPrefixes(1, 4);
IntervalsSource wildcardIntervals = ft.wildcardIntervals(new BytesRef("foo"), MOCK_CONTEXT);
assertEquals(Intervals.wildcard(new BytesRef("foo")), wildcardIntervals);
assertEquals(Intervals.wildcard(new BytesRef("foo"), IndexSearcher.getMaxClauseCount()), wildcardIntervals);
}

public void testRangeIntervals() {
MappedFieldType ft = createFieldType();
IntervalsSource rangeIntervals = ft.rangeIntervals(new BytesRef("foo"), new BytesRef("foo1"), true, true, MOCK_CONTEXT);
assertEquals(
Intervals.range(new BytesRef("foo"), new BytesRef("foo1"), true, true, IndexSearcher.getMaxClauseCount()),
rangeIntervals
);
}
}

0 comments on commit eee5308

Please sign in to comment.