More tests

This commit is contained in:
Andrea Cavalli 2021-10-16 00:50:06 +02:00
parent f91617c7ec
commit f6aab7dafb
3 changed files with 19 additions and 16 deletions

View File

@ -26,7 +26,6 @@ import it.cavallium.dbengine.database.collections.SubStageGetterMap;
import it.cavallium.dbengine.database.disk.MemorySegmentUtils; import it.cavallium.dbengine.database.disk.MemorySegmentUtils;
import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.Serializer;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.cavallium.dbengine.lucene.StringIndicizer;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -36,7 +35,6 @@ import org.jetbrains.annotations.Nullable;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
public class DbTestUtils { public class DbTestUtils {

View File

@ -1,4 +1,4 @@
package it.cavallium.dbengine.lucene; package it.cavallium.dbengine;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs; import com.google.common.primitives.Longs;

View File

@ -137,13 +137,16 @@ public class TestLuceneSearches {
} }
private static final Flux<Boolean> multi = Flux.just(false, true); private static final Flux<Boolean> multi = Flux.just(false, true);
private static final Flux<MultiSort<SearchResultKey<String>>> multiSort = Flux.just(MultiSort.topScore(), private static final Flux<MultiSort<SearchResultKey<String>>> multiSort = Flux.just(
MultiSort.topScore(),
//todo: fix random sort field //todo: fix random sort field
//MultiSort.randomSortField(), //MultiSort.randomSortField(),
MultiSort.noSort(), MultiSort.noSort(),
MultiSort.docSort(), MultiSort.docSort(),
MultiSort.numericSort("longsort", false), MultiSort.numericSort("longsort", false),
MultiSort.numericSort("longsort", true) MultiSort.numericSort("longsort", true),
MultiSort.numericSort("intsort", false),
MultiSort.numericSort("intsort", true)
); );
private static Flux<LocalSearcher> getSearchers(ExpectedQueryType info) { private static Flux<LocalSearcher> getSearchers(ExpectedQueryType info) {
@ -283,7 +286,7 @@ public class TestLuceneSearches {
} }
Assertions.assertEquals(officialKeys.size(), keys.size()); Assertions.assertEquals(officialKeys.size(), keys.size());
assertResults(officialKeys, keys, expectedQueryType.sorted(), expectedQueryType.sortedByScore()); assertResults(officialKeys, keys, expectedQueryType.sorted(), expectedQueryType.sortedByScore());
} }
} }
@ -293,11 +296,12 @@ public class TestLuceneSearches {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideQueryArgumentsScoreModeAndSort") @MethodSource("provideQueryArgumentsScoreModeAndSort")
public void testSearchNoDocs(boolean shards, MultiSort<SearchResultKey<String>> multiSort) throws Throwable { public void testSearchNoDocs(boolean shards, MultiSort<SearchResultKey<String>> multiSort) throws Throwable {
ClientQueryParamsBuilder<SearchResultKey<String>> queryBuilder = ClientQueryParams.builder(); var queryBuilder = ClientQueryParams
queryBuilder.query(new MatchNoDocsQuery()); .<SearchResultKey<String>>builder()
queryBuilder.snapshot(null); .query(new MatchNoDocsQuery())
queryBuilder.complete(true); .snapshot(null)
queryBuilder.sort(multiSort); .complete(true)
.sort(multiSort);
ExpectedQueryType expectedQueryType = new ExpectedQueryType(shards, multiSort, true, false); ExpectedQueryType expectedQueryType = new ExpectedQueryType(shards, multiSort, true, false);
testSearch(queryBuilder, expectedQueryType); testSearch(queryBuilder, expectedQueryType);
@ -306,11 +310,12 @@ public class TestLuceneSearches {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideQueryArgumentsScoreModeAndSort") @MethodSource("provideQueryArgumentsScoreModeAndSort")
public void testSearchAllDocs(boolean shards, MultiSort<SearchResultKey<String>> multiSort) throws Throwable { public void testSearchAllDocs(boolean shards, MultiSort<SearchResultKey<String>> multiSort) throws Throwable {
ClientQueryParamsBuilder<SearchResultKey<String>> queryBuilder = ClientQueryParams.builder(); var queryBuilder = ClientQueryParams
queryBuilder.query(new MatchAllDocsQuery()); .<SearchResultKey<String>>builder()
queryBuilder.snapshot(null); .query(new MatchAllDocsQuery())
queryBuilder.complete(true); .snapshot(null)
queryBuilder.sort(multiSort); .complete(true)
.sort(multiSort);
ExpectedQueryType expectedQueryType = new ExpectedQueryType(shards, multiSort, true, false); ExpectedQueryType expectedQueryType = new ExpectedQueryType(shards, multiSort, true, false);
testSearch(queryBuilder, expectedQueryType); testSearch(queryBuilder, expectedQueryType);