summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search')
-rw-r--r--container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java114
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java43
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java60
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java21
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java26
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java21
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java55
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java13
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/FederationResultTest.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTest.java41
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTestCase.java30
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/HitCountTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SearchChainResolverTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/ContinuationTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/GroupingQueryParserTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/GroupingRequestTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java47
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/UniqueGroupingSearcherTestCase.java74
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/BucketResolverTestCase.java52
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/ExpressionVisitorTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/MathFunctionsTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/MathResolverTestCase.java38
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/RequestTestCase.java74
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserBenchmarkTest.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java380
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/result/FlatteningSearcherTestCase.java60
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/result/GroupIdTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/result/GroupTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/result/HitListTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/result/HitRendererTestCase.java132
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/CompositeContinuationTestCase.java44
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingExecutorTestCase.java263
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingTransformTestCase.java72
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerDecoderTestCase.java9
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerEmbedderTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/OffsetContinuationTestCase.java26
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java486
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultBuilderTestCase.java898
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultIdTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java160
-rw-r--r--container-search/src/test/java/com/yahoo/search/handler/Json2SinglelevelMapTestCase.java11
-rw-r--r--container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java224
-rw-r--r--container-search/src/test/java/com/yahoo/search/match/test/DocumentDbTest.java11
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/MapPageTemplateXMLReadingTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/PageTemplateXMLReadingTestCase.java38
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceTestCase.java50
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersTestCase.java36
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesTestCase.java30
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsTestCase.java72
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsTestCase.java68
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesTestCase.java96
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/test/PageTemplateSearcherTestCase.java80
-rw-r--r--container-search/src/test/java/com/yahoo/search/pagetemplates/test/SourceParametersTestCase.java48
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java13
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java72
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java49
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java19
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java17
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java40
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java42
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java48
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java46
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java69
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java54
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java230
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java240
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java34
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java95
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java376
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java1476
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java46
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java86
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java144
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java41
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java174
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java17
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java26
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java31
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java9
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java134
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java100
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java138
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java72
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java7
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java98
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java58
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java26
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java66
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java30
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/BooleanAttributeParserTest.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/BooleanSearcherTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java27
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java55
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/WeakAndReplacementSearcherTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java61
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java62
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java28
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/AsyncGroupPopulationTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java337
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java76
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/DefaultErrorHitTestCase.java23
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/FeatureDataTestCase.java24
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/NanNumberTestCase.java15
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/PositionsDataTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/test/DeepHitIteratorTestCase.java21
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/test/FillingTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/result/test/HitGroupTestCase.java122
-rw-r--r--container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java51
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java42
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java53
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java39
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java38
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.java19
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java30
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/test/CacheControlSearcherTestCase.java27
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/test/ConnectionControlSearcherTestCase.java17
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/test/InputCheckingSearcherTestCase.java35
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java8
-rwxr-xr-xcontainer-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java42
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java50
-rw-r--r--container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java341
-rw-r--r--container-search/src/test/java/com/yahoo/search/test/RequestParameterPreservationTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java108
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/ParameterListParserTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/TermListTestCase.java24
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java91
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java170
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java23
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java566
170 files changed, 5923 insertions, 5914 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java
index bf44c57a777..33d86658f8e 100644
--- a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java
@@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import com.yahoo.component.ComponentId;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.Ping;
import com.yahoo.prelude.Pong;
import com.yahoo.search.Query;
@@ -16,9 +18,7 @@ import com.yahoo.search.cluster.PingableSearcher;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
public class ClusterSearcherTestCase {
@@ -144,26 +144,26 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testSimple() {
+ void testSimple() {
Hit blockingHit = new Hit("blocking");
Hit nonblockingHit = new Hit("nonblocking");
BlockingBackendSearcher blockingSearcher = new BlockingBackendSearcher(blockingHit);
- List<Searcher> searchers=new ArrayList<>();
+ List<Searcher> searchers = new ArrayList<>();
searchers.add(blockingSearcher);
searchers.add(new TestingBackendSearcher(nonblockingHit));
- ClusterSearcher<?> provider = new SearcherClusterSearcher(new ComponentId("simple"),searchers,new SimpleHasher<>());
+ ClusterSearcher<?> provider = new SearcherClusterSearcher(new ComponentId("simple"), searchers, new SimpleHasher<>());
Result blockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals(blockingHit,blockingResult.hits().get(0));
+ assertEquals(blockingHit, blockingResult.hits().get(0));
Result nonblockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals(nonblockingHit,nonblockingResult.hits().get(0));
+ assertEquals(nonblockingHit, nonblockingResult.hits().get(0));
blockingSearcher.setBlocking(true);
blockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals(blockingResult.hits().get(0),nonblockingHit);
+ assertEquals(blockingResult.hits().get(0), nonblockingHit);
nonblockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals(nonblockingResult.hits().get(0),nonblockingHit);
+ assertEquals(nonblockingResult.hits().get(0), nonblockingHit);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java
index fa8d237aee0..8c98b344394 100644
--- a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java
@@ -12,14 +12,14 @@ import com.yahoo.search.cluster.Hasher;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author bratseth
@@ -27,83 +27,83 @@ import static org.junit.Assert.assertNull;
public class ClusteredConnectionTestCase {
@Test
- public void testClustering() {
- Connection connection0=new Connection("0");
- Connection connection1=new Connection("1");
- Connection connection2=new Connection("2");
- List<Connection> connections=new ArrayList<>();
+ void testClustering() {
+ Connection connection0 = new Connection("0");
+ Connection connection1 = new Connection("1");
+ Connection connection2 = new Connection("2");
+ List<Connection> connections = new ArrayList<>();
connections.add(connection0);
connections.add(connection1);
connections.add(connection2);
MyBackend myBackend = new MyBackend(new ComponentId("test"), connections);
Result r;
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:2",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:1",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:2", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:1", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
connection2.setInService(false);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:1",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:1", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
connection1.setInService(false);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
connection0.setInService(false);
r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
assertEquals("Failed calling connection '2' in searcher 'test' for query 'NULL': Connection failed",
- r.hits().getError().getDetailedMessage());
+ r.hits().getError().getDetailedMessage());
connection0.setInService(true);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
connection1.setInService(true);
connection2.setInService(true);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:2",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:1",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:2", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:1", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
}
@Test
- public void testClusteringWithPing() {
- Connection connection0=new Connection("0");
- Connection connection1=new Connection("1");
- Connection connection2=new Connection("2");
- List<Connection> connections=new ArrayList<>();
+ void testClusteringWithPing() {
+ Connection connection0 = new Connection("0");
+ Connection connection1 = new Connection("1");
+ Connection connection2 = new Connection("2");
+ List<Connection> connections = new ArrayList<>();
connections.add(connection0);
connections.add(connection1);
connections.add(connection2);
- MyBackend myBackend=new MyBackend(new ComponentId("test"),connections);
+ MyBackend myBackend = new MyBackend(new ComponentId("test"), connections);
Result r;
@@ -114,14 +114,14 @@ public class ClusteredConnectionTestCase {
connection1.setInService(false);
connection0.setInService(false);
forcePing(myBackend);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
assertEquals("No backends in service. Try later", r.hits().getError().getMessage());
connection2.setInService(true);
connection1.setInService(true);
connection0.setInService(true);
forcePing(myBackend);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
assertNull(r.hits().getError());
}
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
index 42df2a829e3..715154e85ba 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
@@ -12,17 +12,14 @@ import com.yahoo.search.dispatch.searchcluster.PingFactory;
import com.yahoo.search.dispatch.searchcluster.Pinger;
import com.yahoo.search.dispatch.searchcluster.PongHandler;
import com.yahoo.search.dispatch.searchcluster.SearchCluster;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import static com.yahoo.search.dispatch.MockSearchCluster.createDispatchConfig;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author ollivir
@@ -30,7 +27,7 @@ import static org.junit.Assert.fail;
public class DispatcherTest {
@Test
- public void requireThatDispatcherSupportsSearchPath() {
+ void requireThatDispatcherSupportsSearchPath() {
SearchCluster cl = new MockSearchCluster("1", 2, 2);
Query q = new Query();
q.getModel().setSearchPath("1/0"); // second node in first group
@@ -46,7 +43,7 @@ public class DispatcherTest {
}
@Test
- public void requireThatDispatcherSupportsSingleNodeDirectDispatch() {
+ void requireThatDispatcherSupportsSingleNodeDirectDispatch() {
SearchCluster cl = new MockSearchCluster("1", 0, 0) {
@Override
public Optional<Node> localCorpusDispatchTarget() {
@@ -61,7 +58,7 @@ public class DispatcherTest {
}
@Test
- public void requireThatInvokerConstructionIsRetriedAndLastAcceptsAnyCoverage() {
+ void requireThatInvokerConstructionIsRetriedAndLastAcceptsAnyCoverage() {
SearchCluster cl = new MockSearchCluster("1", 2, 1);
MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, (n, acceptIncompleteCoverage) -> {
@@ -78,7 +75,7 @@ public class DispatcherTest {
}
@Test
- public void requireThatInvokerConstructionDoesNotRepeatGroups() {
+ void requireThatInvokerConstructionDoesNotRepeatGroups() {
try {
SearchCluster cl = new MockSearchCluster("1", 2, 1);
@@ -94,49 +91,49 @@ public class DispatcherTest {
}
@Test
- public void testGroup0IsSelected() {
+ void testGroup0IsSelected() {
SearchCluster cluster = new MockSearchCluster("1", 3, 1);
Dispatcher dispatcher = new Dispatcher(new ClusterMonitor(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true), new MockMetric());
cluster.pingIterationCompleted();
assertEquals(0,
- dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue());
+ dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue());
dispatcher.deconstruct();
}
@Test
- public void testGroup0IsSkippedWhenItIsBlockingFeed() {
+ void testGroup0IsSkippedWhenItIsBlockingFeed() {
SearchCluster cluster = new MockSearchCluster("1", 3, 1);
Dispatcher dispatcher = new Dispatcher(new ClusterMonitor(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true), new MockMetric());
cluster.group(0).get().nodes().get(0).setBlockingWrites(true);
cluster.pingIterationCompleted();
- assertEquals("Blocking group is avoided",
- 1,
- (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue());
+ assertEquals(1,
+ (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue(),
+ "Blocking group is avoided");
dispatcher.deconstruct();
}
@Test
- public void testGroup0IsSelectedWhenMoreAreBlockingFeed() {
+ void testGroup0IsSelectedWhenMoreAreBlockingFeed() {
SearchCluster cluster = new MockSearchCluster("1", 3, 1);
Dispatcher dispatcher = new Dispatcher(new ClusterMonitor(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true), new MockMetric());
cluster.group(0).get().nodes().get(0).setBlockingWrites(true);
cluster.group(1).get().nodes().get(0).setBlockingWrites(true);
cluster.pingIterationCompleted();
- assertEquals("Blocking group is used when multiple groups are blocking",
- 0,
- dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue());
+ assertEquals(0,
+ dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue(),
+ "Blocking group is used when multiple groups are blocking");
dispatcher.deconstruct();
}
@Test
- public void testGroup0IsSelectedWhenItIsBlockingFeedWhenNoOthers() {
+ void testGroup0IsSelectedWhenItIsBlockingFeedWhenNoOthers() {
SearchCluster cluster = new MockSearchCluster("1", 1, 1);
Dispatcher dispatcher = new Dispatcher(new ClusterMonitor(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true), new MockMetric());
cluster.group(0).get().nodes().get(0).setBlockingWrites(true);
cluster.pingIterationCompleted();
- assertEquals("Blocking group is used when there is no alternative",
- 0,
- (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue());
+ assertEquals(0,
+ (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue(),
+ "Blocking group is used when there is no alternative");
dispatcher.deconstruct();
}
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
index e07d38fbf10..1293975deb5 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
@@ -20,7 +20,7 @@ import com.yahoo.searchlib.aggregation.MinAggregationResult;
import com.yahoo.searchlib.expression.IntegerResultNode;
import com.yahoo.searchlib.expression.StringResultNode;
import com.yahoo.test.ManualClock;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.time.Duration;
@@ -38,11 +38,7 @@ import java.util.stream.StreamSupport;
import static com.yahoo.container.handler.Coverage.DEGRADED_BY_MATCH_PHASE;
import static com.yahoo.container.handler.Coverage.DEGRADED_BY_TIMEOUT;
import static com.yahoo.search.dispatch.MockSearchCluster.createDispatchConfig;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author ollivir
@@ -55,7 +51,7 @@ public class InterleavedSearchInvokerTest {
private final List<SearchInvoker> invokers = new ArrayList<>();
@Test
- public void requireThatAdaptiveTimeoutsAreNotUsedWithFullCoverageRequirement() throws IOException {
+ void requireThatAdaptiveTimeoutsAreNotUsedWithFullCoverageRequirement() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(100.0), 1, 3);
SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 3);
@@ -65,11 +61,11 @@ public class InterleavedSearchInvokerTest {
invoker.search(query, null);
- assertTrue("All test scenario events processed", expectedEvents.isEmpty());
+ assertTrue(expectedEvents.isEmpty(), "All test scenario events processed");
}
@Test
- public void requireThatTimeoutsAreNotMarkedAsAdaptive() throws IOException {
+ void requireThatTimeoutsAreNotMarkedAsAdaptive() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(100.0), 1, 3);
SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 3);
@@ -79,15 +75,15 @@ public class InterleavedSearchInvokerTest {
Result result = invoker.search(query, null);
- assertTrue("All test scenario events processed", expectedEvents.isEmpty());
- assertNull("Result is not marked as an error", result.hits().getErrorHit());
+ assertTrue(expectedEvents.isEmpty(), "All test scenario events processed");
+ assertNull(result.hits().getErrorHit(), "Result is not marked as an error");
var message = findTrace(result, "Backend communication timeout");
- assertTrue("Timeout should be reported in a trace message", message.isPresent());
- assertTrue("Degradation reason is a normal timeout", result.getCoverage(false).isDegradedByTimeout());
+ assertTrue(message.isPresent(), "Timeout should be reported in a trace message");
+ assertTrue(result.getCoverage(false).isDegradedByTimeout(), "Degradation reason is a normal timeout");
}
@Test
- public void requireThatAdaptiveTimeoutDecreasesTimeoutWhenCoverageIsReached() throws IOException {
+ void requireThatAdaptiveTimeoutDecreasesTimeoutWhenCoverageIsReached() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(50.0), 1, 4);
SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 4);
@@ -98,15 +94,15 @@ public class InterleavedSearchInvokerTest {
Result result = invoker.search(query, null);
- assertTrue("All test scenario events processed", expectedEvents.isEmpty());
- assertNull("Result is not marked as an error", result.hits().getErrorHit());
+ assertTrue(expectedEvents.isEmpty(), "All test scenario events processed");
+ assertNull(result.hits().getErrorHit(), "Result is not marked as an error");
var message = findTrace(result, "Backend communication timeout");
- assertTrue("Timeout should be reported in a trace message", message.isPresent());
- assertTrue("Degradataion reason is an adaptive timeout", result.getCoverage(false).isDegradedByAdapativeTimeout());
+ assertTrue(message.isPresent(), "Timeout should be reported in a trace message");
+ assertTrue(result.getCoverage(false).isDegradedByAdapativeTimeout(), "Degradataion reason is an adaptive timeout");
}
@Test
- public void requireCorrectCoverageCalculationWhenAllNodesOk() throws IOException {
+ void requireCorrectCoverageCalculationWhenAllNodesOk() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 50155, 1, 1, 0)));
invokers.add(new MockInvoker(1, createCoverage(49845, 49845, 49845, 1, 1, 0)));
@@ -127,7 +123,7 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireCorrectCoverageCalculationWhenResultsAreLimitedByMatchPhase() throws IOException {
+ void requireCorrectCoverageCalculationWhenResultsAreLimitedByMatchPhase() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(10101, 50155, 50155, 1, 1, DEGRADED_BY_MATCH_PHASE)));
invokers.add(new MockInvoker(1, createCoverage(13319, 49845, 49845, 1, 1, DEGRADED_BY_MATCH_PHASE)));
@@ -149,11 +145,11 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireCorrectCoverageCalculationWhenResultsAreLimitedBySoftTimeout() throws IOException {
+ void requireCorrectCoverageCalculationWhenResultsAreLimitedBySoftTimeout() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(5000, 50155, 50155, 1, 1, DEGRADED_BY_TIMEOUT)));
invokers.add(new MockInvoker(1, createCoverage(4900, 49845, 49845, 1, 1, DEGRADED_BY_TIMEOUT)));
- SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()),0);
+ SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0);
expectedEvents.add(new Event(null, 100, 0));
expectedEvents.add(new Event(null, 200, 1));
@@ -171,7 +167,7 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireCorrectCoverageCalculationWhenOneNodeIsUnexpectedlyDown() throws IOException {
+ void requireCorrectCoverageCalculationWhenOneNodeIsUnexpectedlyDown() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 50155, 1, 1, 0)));
invokers.add(new MockInvoker(1, createCoverage(49845, 49845, 49845, 1, 1, 0)));
@@ -231,13 +227,13 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireThatTopKProbabilityOverrideTakesEffect() throws IOException {
+ void requireThatTopKProbabilityOverrideTakesEffect() throws IOException {
validateThatTopKProbabilityOverrideTakesEffect(null, 8, new Group(0, List.of()));
validateThatTopKProbabilityOverrideTakesEffect(0.8, 7, new Group(0, List.of()));
}
@Test
- public void requireThatTopKProbabilityOverrideIsDisabledOnContentSkew() throws IOException {
+ void requireThatTopKProbabilityOverrideIsDisabledOnContentSkew() throws IOException {
Node node0 = new Node(0, "host0", 0);
Node node1 = new Node(1, "host1", 0);
Group group = new Group(0, List.of(node0, node1));
@@ -249,7 +245,7 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireThatTopKProbabilityOverrideIsDisabledOnLittleContent() throws IOException {
+ void requireThatTopKProbabilityOverrideIsDisabledOnLittleContent() throws IOException {
Node node0 = new Node(0, "host0", 0);
Node node1 = new Node(1, "host1", 0);
Group group = new Group(0, List.of(node0, node1));
@@ -261,7 +257,7 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireThatMergeOfConcreteHitsObeySorting() throws IOException {
+ void requireThatMergeOfConcreteHitsObeySorting() throws IOException {
InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5, B5, new Group(0, List.of()));
query.setHits(12);
Result result = invoker.search(query, null);
@@ -281,7 +277,7 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireThatMergeOfConcreteHitsObeyOffset() throws IOException {
+ void requireThatMergeOfConcreteHitsObeyOffset() throws IOException {
InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5, B5, new Group(0, List.of()));
query.setHits(3);
query.setOffset(5);
@@ -303,7 +299,7 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireThatMergeOfConcreteHitsObeyOffsetWithAuxilliaryStuff() throws IOException {
+ void requireThatMergeOfConcreteHitsObeyOffsetWithAuxilliaryStuff() throws IOException {
InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5Aux, B5Aux, new Group(0, List.of()));
query.setHits(3);
query.setOffset(5);
@@ -327,7 +323,7 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireThatGroupingsAreMerged() throws IOException {
+ void requireThatGroupingsAreMerged() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", 1, 2);
List<SearchInvoker> invokers = new ArrayList<>();
@@ -386,7 +382,7 @@ public class InterleavedSearchInvokerTest {
}
@Test
- public void requireCorrectCoverageCalculationWhenDegradedCoverageIsExpected() throws IOException {
+ void requireCorrectCoverageCalculationWhenDegradedCoverageIsExpected() throws IOException {
SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 50155, 1, 1, 0)));
Coverage errorCoverage = new Coverage(0, 0, 0);
@@ -468,7 +464,7 @@ public class InterleavedSearchInvokerTest {
public SearchInvoker process(Query query, long currentTimeout) {
if (expectedTimeout != null) {
- assertEquals("Expecting timeout to be " + expectedTimeout, (long) expectedTimeout, currentTimeout);
+ assertEquals((long) expectedTimeout, currentTimeout, "Expecting timeout to be " + expectedTimeout);
}
clock.advance(Duration.ofMillis(delay));
if (query.getTimeLeft() < 0) {
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java
index a2080ce6b05..3d2ab17b15d 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java
@@ -1,11 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.dispatch;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
public class LeanHitTest {
private static final byte [] gidA = {'a'};
@@ -20,34 +18,39 @@ public class LeanHitTest {
assertTrue(c.compareTo(b) > 0);
assertTrue(c.compareTo(a) > 0);
}
+
@Test
- public void testOrderingByRelevance() {
+ void testOrderingByRelevance() {
assertEquals(0, new LeanHit(gidA, 0, 0, 1).compareTo(new LeanHit(gidA, 0, 0, 1)));
verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 1),
new LeanHit(gidA, 0, 0, 0),
new LeanHit(gidA, 0, 0, -1));
}
+
@Test
- public void testOrderingByGid() {
+ void testOrderingByGid() {
assertEquals(0, new LeanHit(gidA, 0, 0, 1).compareTo(new LeanHit(gidA, 0, 0, 1)));
verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 1),
new LeanHit(gidB, 0, 0, 1),
new LeanHit(gidC, 0, 0, 1));
}
+
@Test
- public void testOrderingBySortData() {
+ void testOrderingBySortData() {
assertEquals(0, new LeanHit(gidA, 0, 0, 0.0, gidA).compareTo(new LeanHit(gidA, 0, 0, 0.0, gidA)));
verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 0.0, gidA),
new LeanHit(gidA, 0, 0, 0.0, gidB),
new LeanHit(gidA, 0, 0, 0.0, gidC));
}
+
@Test
- public void testRelevanceIsKeptEvenWithBySortData() {
+ void testRelevanceIsKeptEvenWithBySortData() {
assertEquals(1.3, new LeanHit(gidA, 0, 0, 1.3, gidA).getRelevance(), 0.0);
}
+
@Test
- public void testNaN2negativeInfinity() {
+ void testNaN2negativeInfinity() {
LeanHit nan = new LeanHit(gidA, 0, 0, Double.NaN);
assertFalse(Double.isNaN(nan.getRelevance()));
assertTrue(Double.isInfinite(nan.getRelevance()));
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
index e95fbc366a6..e9ed1c48302 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
@@ -6,8 +6,8 @@ import com.yahoo.search.dispatch.LoadBalancer.GroupStatus;
import com.yahoo.search.dispatch.searchcluster.Group;
import com.yahoo.search.dispatch.searchcluster.Node;
import com.yahoo.search.dispatch.searchcluster.SearchCluster;
-import junit.framework.AssertionFailedError;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.opentest4j.AssertionFailedError;
import java.util.ArrayList;
import java.util.Collections;
@@ -16,9 +16,9 @@ import java.util.Optional;
import java.util.Random;
import static com.yahoo.search.dispatch.MockSearchCluster.createDispatchConfig;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author ollivir
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue;
public class LoadBalancerTest {
@Test
- public void requireThatLoadBalancerServesSingleNodeSetups() {
+ void requireThatLoadBalancerServesSingleNodeSetups() {
Node n1 = new Node(0, "test-node1", 0);
SearchCluster cluster = new SearchCluster("a", createDispatchConfig(n1), null, null);
LoadBalancer lb = new LoadBalancer(cluster, true);
@@ -39,7 +39,7 @@ public class LoadBalancerTest {
}
@Test
- public void requireThatLoadBalancerServesMultiGroupSetups() {
+ void requireThatLoadBalancerServesMultiGroupSetups() {
Node n1 = new Node(0, "test-node1", 0);
Node n2 = new Node(1, "test-node2", 1);
SearchCluster cluster = new SearchCluster("a", createDispatchConfig(n1, n2), null, null);
@@ -53,7 +53,7 @@ public class LoadBalancerTest {
}
@Test
- public void requireThatLoadBalancerServesClusteredGroups() {
+ void requireThatLoadBalancerServesClusteredGroups() {
Node n1 = new Node(0, "test-node1", 0);
Node n2 = new Node(1, "test-node2", 0);
Node n3 = new Node(0, "test-node3", 1);
@@ -66,10 +66,10 @@ public class LoadBalancerTest {
}
@Test
- public void requireThatLoadBalancerReturnsDifferentGroups() {
+ void requireThatLoadBalancerReturnsDifferentGroups() {
Node n1 = new Node(0, "test-node1", 0);
Node n2 = new Node(1, "test-node2", 1);
- SearchCluster cluster = new SearchCluster("a", createDispatchConfig(n1, n2), null,null);
+ SearchCluster cluster = new SearchCluster("a", createDispatchConfig(n1, n2), null, null);
LoadBalancer lb = new LoadBalancer(cluster, true);
// get first group
@@ -86,7 +86,7 @@ public class LoadBalancerTest {
}
@Test
- public void requireCorrectAverageSearchTimeDecay() {
+ void requireCorrectAverageSearchTimeDecay() {
final double delta = 0.00001;
GroupStatus gs = newGroupStatus(1);
@@ -115,7 +115,7 @@ public class LoadBalancerTest {
}
@Test
- public void requireEqualDistributionInFlatWeightListWithAdaptiveScheduler() {
+ void requireEqualDistributionInFlatWeightListWithAdaptiveScheduler() {
List<GroupStatus> scoreboard = new ArrayList<>();
for (int i = 0; i < 5; i++) {
scoreboard.add(newGroupStatus(i));
@@ -134,7 +134,7 @@ public class LoadBalancerTest {
}
@Test
- public void requireThatAdaptiveSchedulerObeysWeights() {
+ void requireThatAdaptiveSchedulerObeysWeights() {
List<GroupStatus> scoreboard = new ArrayList<>();
for (int i = 0; i < 5; i++) {
GroupStatus gs = newGroupStatus(i);
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java
index 3a1a60df7af..12cbe488485 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java
@@ -3,16 +3,13 @@ package com.yahoo.search.dispatch;
import com.yahoo.search.dispatch.SearchPath.InvalidSearchPathException;
import com.yahoo.search.dispatch.searchcluster.Node;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.Set;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author ollivir
@@ -20,7 +17,7 @@ import static org.junit.Assert.fail;
public class SearchPathTest {
@Test
- public void requreThatSearchPathsAreParsedCorrectly() {
+ void requreThatSearchPathsAreParsedCorrectly() {
assertEquals(SearchPath.fromString("0/0").get().toString(), "0/0");
assertEquals(SearchPath.fromString("1/0").get().toString(), "1/0");
assertEquals(SearchPath.fromString("0/1").get().toString(), "0/1");
@@ -43,7 +40,7 @@ public class SearchPathTest {
}
@Test
- public void requreThatWildcardsAreDetected() {
+ void requreThatWildcardsAreDetected() {
assertFalse(SearchPath.fromString("").isPresent());
assertFalse(SearchPath.fromString("*/*").isPresent());
assertFalse(SearchPath.fromString("/").isPresent());
@@ -52,7 +49,7 @@ public class SearchPathTest {
}
@Test
- public void invalidRangeMustThrowException() {
+ void invalidRangeMustThrowException() {
try {
SearchPath.fromString("[p,0>/0");
fail("Expected exception");
@@ -63,7 +60,7 @@ public class SearchPathTest {
}
@Test
- public void invalidPartMustThrowException() {
+ void invalidPartMustThrowException() {
try {
SearchPath.fromString("p/0");
fail("Expected exception");
@@ -74,7 +71,7 @@ public class SearchPathTest {
}
@Test
- public void invalidRowMustThrowException() {
+ void invalidRowMustThrowException() {
try {
SearchPath.fromString("1,2,3/r");
fail("Expected exception");
@@ -92,8 +89,8 @@ public class SearchPathTest {
}
@Test
- public void searchPathMustFilterNodesBasedOnDefinition() {
- MockSearchCluster cluster = new MockSearchCluster("a",3, 3);
+ void searchPathMustFilterNodesBasedOnDefinition() {
+ MockSearchCluster cluster = new MockSearchCluster("a", 3, 3);
assertEquals(distKeysAsString(SearchPath.selectNodes("1/1", cluster)), "4");
assertEquals(distKeysAsString(SearchPath.selectNodes("/1", cluster)), "3,4,5");
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java
index 5dfcd8901da..283596322e6 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java
@@ -1,15 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.dispatch;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Locale;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class TopKEstimatorTest {
@Test
- public void requireHitsAreEstimatedAccordingToPartitionsAndProbability() {
+ void requireHitsAreEstimatedAccordingToPartitionsAndProbability() {
TopKEstimator estimator = new TopKEstimator(30, 0.999);
assertEquals(91.97368471911312, estimator.estimateExactK(200, 3), 0.0);
assertEquals(92, estimator.estimateK(200, 3));
@@ -27,8 +27,9 @@ public class TopKEstimatorTest {
assertEquals(44.909040374464155, estimator.estimateExactK(200, 10, 0.99999), 0.0);
assertEquals(45, estimator.estimateK(200, 10, 0.99999));
}
+
@Test
- public void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K200() {
+ void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K200() {
TopKEstimator estimator = new TopKEstimator(30, 0.99999);
assertEquals(200, estimator.estimateExactK(200, 1), 0.0);
assertEquals(200, estimator.estimateK(200, 1));
@@ -39,7 +40,7 @@ public class TopKEstimatorTest {
}
@Test
- public void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K20() {
+ void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K20() {
TopKEstimator estimator = new TopKEstimator(30, 0.99999);
assertEquals(20, estimator.estimateExactK(20, 1), 0.0);
assertEquals(20, estimator.estimateK(20, 1));
@@ -50,7 +51,7 @@ public class TopKEstimatorTest {
}
@Test
- public void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K10_Five9() {
+ void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K10_Five9() {
TopKEstimator estimator = new TopKEstimator(30, 0.99999);
assertEquals(10, estimator.estimateExactK(10, 1), 0.0);
assertEquals(10, estimator.estimateK(10, 1));
@@ -61,7 +62,7 @@ public class TopKEstimatorTest {
}
@Test
- public void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K10_Four9() {
+ void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K10_Four9() {
TopKEstimator estimator = new TopKEstimator(30, 0.9999);
assertEquals(10, estimator.estimateExactK(10, 1), 0.0);
assertEquals(10, estimator.estimateK(10, 1));
@@ -72,21 +73,21 @@ public class TopKEstimatorTest {
}
@Test
- public void requireEstimatesAreRoundeUp() {
+ void requireEstimatesAreRoundeUp() {
TopKEstimator estimator = new TopKEstimator(30, 0.9999);
assertEquals(5.794676146031378, estimator.estimateExactK(10, 10), 0.0);
assertEquals(6, estimator.estimateK(10, 10));
}
@Test
- public void requireEstimatesAreCappedAtInputK() {
+ void requireEstimatesAreCappedAtInputK() {
TopKEstimator estimator = new TopKEstimator(30, 0.9999);
assertEquals(12.087323848369289, estimator.estimateExactK(10, 2), 0.0);
assertEquals(10, estimator.estimateK(10, 2));
}
@Test
- public void requireThatLargeKAreSane() {
+ void requireThatLargeKAreSane() {
System.out.println(dumpProbability(10, 0.05));
TopKEstimator idealEstimator = new TopKEstimator(30, 0.9999);
TopKEstimator skewedEstimator = new TopKEstimator(30, 0.9999, 0.05);
@@ -100,23 +101,23 @@ public class TopKEstimatorTest {
String expected =
"Prob/Hits: 1.0000000000 0.9999000000 0.9999900000 0.9999990000 0.9999999000 0.9999999900 0.9999999990 0.9999999999\n" +
- " 10: 10.000 6.000 7.000 8.000 9.000 10.000 10.000 10.000\n" +
- " 20: 10.000 4.500 5.000 5.500 6.500 7.000 7.500 8.000\n" +
- " 40: 10.000 3.500 4.000 4.250 4.750 5.250 5.500 6.000\n" +
- " 80: 10.000 2.750 3.000 3.250 3.625 3.875 4.250 4.500\n" +
- " 100: 10.000 2.600 2.800 3.100 3.300 3.600 3.900 4.200\n" +
- " 200: 10.000 2.100 2.250 2.450 2.650 2.800 3.000 3.200\n" +
- " 400: 10.000 1.775 1.900 2.025 2.150 2.275 2.425 2.575\n" +
- " 800: 10.000 1.538 1.625 1.713 1.813 1.900 2.000 2.100\n" +
- " 1000: 10.000 1.480 1.560 1.640 1.720 1.810 1.890 1.990\n" +
- " 2000: 10.000 1.340 1.395 1.450 1.510 1.570 1.630 1.695\n" +
- " 4000: 10.000 1.240 1.280 1.320 1.360 1.403 1.445 1.493\n" +
- " 8000: 10.000 1.170 1.198 1.225 1.254 1.284 1.315 1.348\n" +
- " 10000: 10.000 1.152 1.177 1.202 1.227 1.254 1.282 1.311\n" +
- " 20000: 10.000 1.108 1.125 1.143 1.161 1.180 1.199 1.220\n" +
- " 40000: 10.000 1.076 1.088 1.101 1.114 1.127 1.141 1.156\n" +
- " 80000: 10.000 1.054 1.062 1.071 1.080 1.090 1.100 1.110\n" +
- " 100000: 10.000 1.048 1.056 1.064 1.072 1.080 1.089 1.098\n";
+ " 10: 10.000 6.000 7.000 8.000 9.000 10.000 10.000 10.000\n" +
+ " 20: 10.000 4.500 5.000 5.500 6.500 7.000 7.500 8.000\n" +
+ " 40: 10.000 3.500 4.000 4.250 4.750 5.250 5.500 6.000\n" +
+ " 80: 10.000 2.750 3.000 3.250 3.625 3.875 4.250 4.500\n" +
+ " 100: 10.000 2.600 2.800 3.100 3.300 3.600 3.900 4.200\n" +
+ " 200: 10.000 2.100 2.250 2.450 2.650 2.800 3.000 3.200\n" +
+ " 400: 10.000 1.775 1.900 2.025 2.150 2.275 2.425 2.575\n" +
+ " 800: 10.000 1.538 1.625 1.713 1.813 1.900 2.000 2.100\n" +
+ " 1000: 10.000 1.480 1.560 1.640 1.720 1.810 1.890 1.990\n" +
+ " 2000: 10.000 1.340 1.395 1.450 1.510 1.570 1.630 1.695\n" +
+ " 4000: 10.000 1.240 1.280 1.320 1.360 1.403 1.445 1.493\n" +
+ " 8000: 10.000 1.170 1.198 1.225 1.254 1.284 1.315 1.348\n" +
+ " 10000: 10.000 1.152 1.177 1.202 1.227 1.254 1.282 1.311\n" +
+ " 20000: 10.000 1.108 1.125 1.143 1.161 1.180 1.199 1.220\n" +
+ " 40000: 10.000 1.076 1.088 1.101 1.114 1.127 1.141 1.156\n" +
+ " 80000: 10.000 1.054 1.062 1.071 1.080 1.090 1.100 1.110\n" +
+ " 100000: 10.000 1.048 1.056 1.064 1.072 1.080 1.089 1.098\n";
assertEquals(expected, dumpProbability(10, 0.0));
String expectedSkew =
"Prob/Hits: 1.0000000000 0.9999000000 0.9999900000 0.9999990000 0.9999999000 0.9999999900 0.9999999990 0.9999999999\n" +
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java
index 6834a5edf9b..861ed4d165d 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java
@@ -6,14 +6,12 @@ import com.yahoo.data.access.ArrayTraverser;
import com.yahoo.data.access.Inspector;
import com.yahoo.data.access.ObjectTraverser;
import com.yahoo.data.access.Type;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author arnej
@@ -21,14 +19,14 @@ import static org.junit.Assert.assertTrue;
public class MatchFeatureDataTest {
@Test
- public void testHitValueAPI() {
+ void testHitValueAPI() {
List<String> names = List.of("foo", "bar", "baz", "qux", "quux");
var mf = new MatchFeatureData(names);
var hit = mf.addHit();
assertEquals(hit.type(), Type.OBJECT);
assertTrue(hit.valid());
hit.set(0, 1.0);
- byte[] somebytes = { 42, 0, 17 };
+ byte[] somebytes = {42, 0, 17};
hit.set(2, somebytes);
hit.set(4, 5.0);
hit.set(1, 2.0);
@@ -64,7 +62,7 @@ public class MatchFeatureDataTest {
var fields = hit.fields().iterator();
assertTrue(fields.hasNext());
- Map.Entry<String,Inspector> entry = fields.next();
+ Map.Entry<String, Inspector> entry = fields.next();
assertEquals("foo", entry.getKey());
assertEquals(f1.type(), entry.getValue().type());
assertEquals(f1.asDouble(), entry.getValue().asDouble(), 0.0);
@@ -94,9 +92,9 @@ public class MatchFeatureDataTest {
assertEquals(f5.asDouble(), entry.getValue().asDouble(), 0.0);
assertFalse(fields.hasNext());
-
+
assertEquals("{\"foo\":1.0,\"bar\":2.0,\"baz\":\"0x2A0011\",\"qux\":4.0,\"quux\":5.0}",
- hit.toString());
+ hit.toString());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java
index 9953d1467e1..72b3095b2f9 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java
@@ -12,14 +12,12 @@ import com.yahoo.search.dispatch.InvokerResult;
import com.yahoo.search.dispatch.LeanHit;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileXMLReader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author ollivir
@@ -29,38 +27,38 @@ public class ProtobufSerializationTest {
static final double DELTA = 0.000000000001;
@Test
- public void testQuerySerialization() {
+ void testQuerySerialization() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/tensortypes").compile();
Query query = new Query.Builder().setQueryProfile(registry.getComponent("profile1"))
- .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
- .build();
+ .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
+ .build();
- SearchProtocol.SearchRequest request1 = ProtobufSerialization.convertFromQuery(query, 9,"serverId", 0.5);
+ SearchProtocol.SearchRequest request1 = ProtobufSerialization.convertFromQuery(query, 9, "serverId", 0.5);
assertEquals(9, request1.getHits());
assertEquals(0, request1.getRankPropertiesCount());
assertEquals(0, request1.getTensorRankPropertiesCount());
assertEquals(0, request1.getFeatureOverridesCount());
assertEquals(2, request1.getTensorFeatureOverridesCount());
assertEquals("\"\\001\\001\\003key\\001\\rpre_key1_post?\\360\\000\\000\\000\\000\\000\\000\"",
- contentsOf(request1.getTensorFeatureOverrides(0).getValue()));
+ contentsOf(request1.getTensorFeatureOverrides(0).getValue()));
assertEquals("\"\\006\\001\\001\\001x\\001?\\231\\231\\232\"",
- contentsOf(request1.getTensorFeatureOverrides(1).getValue()));
+ contentsOf(request1.getTensorFeatureOverrides(1).getValue()));
query.prepare(); // calling prepare() moves "overrides" to "features" - content stays the same
- SearchProtocol.SearchRequest request2 = ProtobufSerialization.convertFromQuery(query, 9,"serverId", 0.5);
+ SearchProtocol.SearchRequest request2 = ProtobufSerialization.convertFromQuery(query, 9, "serverId", 0.5);
assertEquals(9, request2.getHits());
assertEquals(0, request2.getRankPropertiesCount());
assertEquals(2, request2.getTensorRankPropertiesCount());
assertEquals("\"\\001\\001\\003key\\001\\rpre_key1_post?\\360\\000\\000\\000\\000\\000\\000\"",
- contentsOf(request2.getTensorRankProperties(0).getValue()));
+ contentsOf(request2.getTensorRankProperties(0).getValue()));
assertEquals("\"\\006\\001\\001\\001x\\001?\\231\\231\\232\"",
- contentsOf(request2.getTensorRankProperties(1).getValue()));
+ contentsOf(request2.getTensorRankProperties(1).getValue()));
assertEquals(0, request2.getFeatureOverridesCount());
assertEquals(0, request2.getTensorFeatureOverridesCount());
}
@Test
- public void testDocsumSerialization() {
+ void testDocsumSerialization() {
Query q = new Query("search/?query=test&hits=10&offset=3");
var builder = ProtobufSerialization.createDocsumRequestBuilder(q, "server", "summary", true, 0.5);
builder.setTimeout(0);
@@ -95,8 +93,9 @@ public class ProtobufSerializationTest {
}
return reply.build();
}
+
@Test
- public void testSearchReplyDecodingWithRelevance() {
+ void testSearchReplyDecodingWithRelevance() {
Query q = new Query("search/?query=test");
InvokerResult result = ProtobufSerialization.convertToResult(q, createSearchReply(5, false), null, 1, 2);
assertEquals(result.getResult().getTotalHitCount(), 7);
@@ -114,8 +113,9 @@ public class ProtobufSerializationTest {
hitNum++;
}
}
+
@Test
- public void testSearchReplyDecodingWithSortData() {
+ void testSearchReplyDecodingWithSortData() {
Query q = new Query("search/?query=test");
InvokerResult result = ProtobufSerialization.convertToResult(q, createSearchReply(5, true), null, 1, 2);
assertEquals(result.getResult().getTotalHitCount(), 7);
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java
index c26bef05fb6..6789d0347d5 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java
@@ -11,17 +11,14 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.dispatch.searchcluster.Node;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author ollivir
@@ -29,7 +26,7 @@ import static org.junit.Assert.fail;
public class RpcSearchInvokerTest {
@Test
- public void testProtobufSerialization() throws IOException {
+ void testProtobufSerialization() throws IOException {
var compressionTypeHolder = new AtomicReference<CompressionType>();
var payloadHolder = new AtomicReference<byte[]>();
var lengthHolder = new AtomicInteger();
@@ -50,14 +47,14 @@ public class RpcSearchInvokerTest {
assertTrue(request.getQueryTreeBlob().size() > 0);
var invoker2 = new RpcSearchInvoker(mockSearcher(), new Node(8, "eight", 1), mockPool, 1000);
- RpcSearchInvoker.RpcContext context2 = (RpcSearchInvoker.RpcContext)invoker2.sendSearchRequest(q, context);
+ RpcSearchInvoker.RpcContext context2 = (RpcSearchInvoker.RpcContext) invoker2.sendSearchRequest(q, context);
assertSame(context, context2);
assertEquals(lengthHolder.get(), context.compressedPayload.uncompressedSize());
assertSame(context.compressedPayload.data(), payloadHolder.get());
}
@Test
- public void testProtobufSerializationWithMaxHitsSet() throws IOException {
+ void testProtobufSerializationWithMaxHitsSet() throws IOException {
int maxHits = 5;
var compressionTypeHolder = new AtomicReference<CompressionType>();
var payloadHolder = new AtomicReference<byte[]>();
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java
index c21bf623366..3d981c5e45a 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.dispatch.searchcluster;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertTrue;
public class SearchClusterCoverageTest {
@Test
- public void two_groups_equal_docs() {
+ void two_groups_equal_docs() {
var tester = new SearchClusterTester(2, 3);
tester.setDocsPerNode(100, 0);
@@ -23,22 +23,22 @@ public class SearchClusterCoverageTest {
}
@Test
- public void two_groups_one_missing_docs() {
+ void two_groups_one_missing_docs() {
var tester = new SearchClusterTester(2, 3);
tester.setDocsPerNode(100, 0);
- tester.setDocsPerNode( 70, 1);
+ tester.setDocsPerNode(70, 1);
tester.pingIterationCompleted();
assertTrue(tester.group(0).hasSufficientCoverage());
assertFalse(tester.group(1).hasSufficientCoverage());
}
@Test
- public void three_groups_one_missing_docs() {
+ void three_groups_one_missing_docs() {
var tester = new SearchClusterTester(3, 3);
tester.setDocsPerNode(100, 0);
- tester.setDocsPerNode( 87, 1); // min is set to 88 in MockSearchCluster
+ tester.setDocsPerNode(87, 1); // min is set to 88 in MockSearchCluster
tester.setDocsPerNode(100, 2);
tester.pingIterationCompleted();
assertTrue(tester.group(0).hasSufficientCoverage());
@@ -47,11 +47,11 @@ public class SearchClusterCoverageTest {
}
@Test
- public void three_groups_one_missing_docs_but_too_few() {
+ void three_groups_one_missing_docs_but_too_few() {
var tester = new SearchClusterTester(3, 3);
tester.setDocsPerNode(100, 0);
- tester.setDocsPerNode( 89, 1); // min is set to 88 in MockSearchCluster
+ tester.setDocsPerNode(89, 1); // min is set to 88 in MockSearchCluster
tester.setDocsPerNode(100, 2);
tester.pingIterationCompleted();
assertTrue(tester.group(0).hasSufficientCoverage());
@@ -60,7 +60,7 @@ public class SearchClusterCoverageTest {
}
@Test
- public void three_groups_one_has_too_many_docs() {
+ void three_groups_one_has_too_many_docs() {
var tester = new SearchClusterTester(3, 3);
tester.setDocsPerNode(100, 0);
@@ -73,7 +73,7 @@ public class SearchClusterCoverageTest {
}
@Test
- public void three_groups_one_has_a_node_down() {
+ void three_groups_one_has_a_node_down() {
var tester = new SearchClusterTester(3, 3);
tester.setDocsPerNode(100, 0);
@@ -87,7 +87,7 @@ public class SearchClusterCoverageTest {
}
@Test
- public void three_groups_one_has_a_node_down_but_remaining_has_enough_docs() {
+ void three_groups_one_has_a_node_down_but_remaining_has_enough_docs() {
var tester = new SearchClusterTester(3, 3);
tester.setDocsPerNode(100, 0);
@@ -96,12 +96,12 @@ public class SearchClusterCoverageTest {
tester.setWorking(1, 1, false);
tester.pingIterationCompleted();
assertTrue(tester.group(0).hasSufficientCoverage());
- assertTrue("Sufficient documents on remaining two nodes", tester.group(1).hasSufficientCoverage());
+ assertTrue(tester.group(1).hasSufficientCoverage(), "Sufficient documents on remaining two nodes");
assertTrue(tester.group(2).hasSufficientCoverage());
}
@Test
- public void one_group_few_docs_unbalanced() {
+ void one_group_few_docs_unbalanced() {
var tester = new SearchClusterTester(1, 2);
Node node0 = tester.group(0).nodes().get(0);
@@ -120,7 +120,7 @@ public class SearchClusterCoverageTest {
}
@Test
- public void one_group_many_docs_unbalanced() {
+ void one_group_many_docs_unbalanced() {
var tester = new SearchClusterTester(1, 2);
Node node0 = tester.group(0).nodes().get(0);
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
index 94df796b370..473b24af19f 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
@@ -9,7 +9,7 @@ import com.yahoo.prelude.Pong;
import com.yahoo.search.cluster.ClusterMonitor;
import com.yahoo.search.dispatch.MockSearchCluster;
import com.yahoo.search.result.ErrorMessage;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -19,9 +19,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
@@ -151,7 +149,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatVipStatusIsDefaultDownButComesUpAfterPinging() {
+ void requireThatVipStatusIsDefaultDownButComesUpAfterPinging() {
try (State test = new State("cluster.1", 2, "a", "b")) {
assertTrue(test.searchCluster.localCorpusDispatchTarget().isEmpty());
@@ -162,7 +160,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatZeroDocsAreFine() {
+ void requireThatZeroDocsAreFine() {
try (State test = new State("cluster.1", 2, "a", "b")) {
test.waitOneFullPingRound();
@@ -180,7 +178,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatVipStatusIsDefaultDownWithLocalDispatch() {
+ void requireThatVipStatusIsDefaultDownWithLocalDispatch() {
try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "b")) {
assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent());
@@ -191,7 +189,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatVipStatusStaysUpWithLocalDispatchAndClusterSize1() {
+ void requireThatVipStatusStaysUpWithLocalDispatchAndClusterSize1() {
try (State test = new State("cluster.1", 1, HostName.getLocalhost())) {
assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent());
@@ -205,7 +203,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatVipStatusIsDefaultDownWithLocalDispatchAndClusterSize2() {
+ void requireThatVipStatusIsDefaultDownWithLocalDispatchAndClusterSize2() {
try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "otherhost")) {
assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent());
@@ -219,7 +217,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatVipStatusDownWhenLocalIsDown() {
+ void requireThatVipStatusDownWhenLocalIsDown() {
try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "b")) {
test.waitOneFullPingRound();
@@ -276,8 +274,8 @@ public class SearchClusterTest {
}
@Test
- public void requireThatVipStatusDownRequireAllNodesDown() {
- verifyThatVipStatusDownRequireAllNodesDown(1,2);
+ void requireThatVipStatusDownRequireAllNodesDown() {
+ verifyThatVipStatusDownRequireAllNodesDown(1, 2);
verifyThatVipStatusDownRequireAllNodesDown(3, 3);
}
@@ -315,13 +313,13 @@ public class SearchClusterTest {
}
@Test
- public void requireThatVipStatusUpRequireOnlyOneOnlineNode() {
+ void requireThatVipStatusUpRequireOnlyOneOnlineNode() {
verifyThatVipStatusUpRequireOnlyOneOnlineNode(1, 2);
verifyThatVipStatusUpRequireOnlyOneOnlineNode(3, 3);
}
@Test
- public void requireThatPingSequenceIsUpHeld() {
+ void requireThatPingSequenceIsUpHeld() {
Node node = new Node(1, "n", 1);
assertEquals(1, node.createPingSequenceId());
assertEquals(2, node.createPingSequenceId());
@@ -335,7 +333,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatEmptyGroupIsInBalance() {
+ void requireThatEmptyGroupIsInBalance() {
Group group = new Group(0, new ArrayList<>());
assertTrue(group.isBalanced());
group.aggregateNodeValues();
@@ -343,7 +341,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatSingleNodeGroupIsInBalance() {
+ void requireThatSingleNodeGroupIsInBalance() {
Group group = new Group(0, Arrays.asList(new Node(1, "n", 1)));
group.nodes().forEach(node -> node.setWorking(true));
assertTrue(group.isBalanced());
@@ -355,7 +353,7 @@ public class SearchClusterTest {
}
@Test
- public void requireThatMultiNodeGroupDetectsBalance() {
+ void requireThatMultiNodeGroupDetectsBalance() {
Group group = new Group(0, Arrays.asList(new Node(1, "n1", 1), new Node(2, "n2", 1)));
assertTrue(group.isBalanced());
group.nodes().forEach(node -> node.setWorking(true));
diff --git a/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
index da25baacd51..cb0d4ab923f 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
@@ -12,7 +12,7 @@ import com.yahoo.search.Searcher;
import com.yahoo.search.federation.sourceref.SearchChainResolver;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChainRegistry;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashMap;
@@ -20,8 +20,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Tests that sources representing document types which resolve to the same actual source
@@ -32,7 +32,7 @@ import static org.junit.Assert.assertEquals;
public class DuplicateSourceTestCase {
@Test
- public void testDuplicateSource() {
+ void testDuplicateSource() {
// Set up a single cluster and chain (chain1), containing a MockBackendSearcher and having 2 doc types (doc1, doc2)
MockBackendSearcher mockBackendSearcher = new MockBackendSearcher();
SearchChainRegistry searchChains = new SearchChainRegistry();
@@ -41,12 +41,12 @@ public class DuplicateSourceTestCase {
clusters.put("chain1", ImmutableList.of("doc1", "doc2"));
IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, Collections.emptyList()));
SearchChainResolver resolver = new SearchChainResolver.Builder()
- .addSearchChain(new ComponentId("chain1"), ImmutableList.of("doc1", "doc2"))
- .build();
+ .addSearchChain(new ComponentId("chain1"), ImmutableList.of("doc1", "doc2"))
+ .build();
FederationSearcher searcher = new FederationSearcher(new ComponentId("test"), resolver);
Result result = searcher.search(new Query("?query=test&sources=doc1%2cdoc2"),
- new Execution(Execution.Context.createContextStub(searchChains, indexFacts)));
+ new Execution(Execution.Context.createContextStub(searchChains, indexFacts)));
assertNull(result.hits().getError());
assertEquals(1, mockBackendSearcher.getInvocationCount());
diff --git a/container-search/src/test/java/com/yahoo/search/federation/FederationResultTest.java b/container-search/src/test/java/com/yahoo/search/federation/FederationResultTest.java
index a17104f888d..71004f5a98a 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/FederationResultTest.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/FederationResultTest.java
@@ -11,16 +11,14 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.FutureResult;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
import com.yahoo.test.ManualClock;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -34,7 +32,7 @@ public class FederationResultTest {
private final ManualClock clock = new ManualClock();
@Test
- public void testFederationResult() {
+ void testFederationResult() {
assertTimeout(ImmutableSet.of(), 100, 200, 180);
assertTimeout(ImmutableSet.of(), 480, 400, 400);
assertTimeout(ImmutableSet.of("dsp1"), 260, 280, 220);
@@ -56,9 +54,9 @@ public class FederationResultTest {
for (FederationResult.TargetResult targetResult : federationResult.all()) {
Result result = targetResult.getOrTimeoutError();
if (expectedTimeoutNames.contains(targetResult.target.getId().toString()))
- assertTrue(targetResult.target.getId() + " timed out", timedOut(result));
+ assertTrue(timedOut(result), targetResult.target.getId() + " timed out");
else
- assertFalse(targetResult.target.getId() + " did not time out", timedOut(result));
+ assertFalse(timedOut(result), targetResult.target.getId() + " did not time out");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTest.java b/container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTest.java
index 4bb6db40c66..2c83bc8cc00 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTest.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTest.java
@@ -20,17 +20,14 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.Execution.Context;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Tony Vaagenes
@@ -40,19 +37,19 @@ public class FederationSearcherTest {
private static final String hasBeenFilled = "hasBeenFilled";
@Test
- public void require_that_hits_are_not_automatically_filled() {
+ void require_that_hits_are_not_automatically_filled() {
Result result = federationToSingleAddHitSearcher().search();
assertNotFilled(firstHitInFirstGroup(result));
}
@Test
- public void require_that_hits_can_be_filled() {
+ void require_that_hits_can_be_filled() {
Result result = federationToSingleAddHitSearcher().searchAndFill();
assertFilled(firstHitInFirstGroup(result));
}
@Test
- public void require_that_hits_can_be_filled_when_moved() {
+ void require_that_hits_can_be_filled_when_moved() {
FederationTester tester = new FederationTester();
tester.addSearchChain("chain1", new AddHitSearcher());
tester.addSearchChain("chain2", new AddHitSearcher());
@@ -80,7 +77,7 @@ public class FederationSearcherTest {
}
@Test
- public void require_that_hits_can_be_filled_for_multiple_chains_and_queries() {
+ void require_that_hits_can_be_filled_for_multiple_chains_and_queries() {
FederationTester tester = new FederationTester();
tester.addSearchChain("chain1", new AddHitSearcher());
tester.addSearchChain("chain2", new ModifyQueryAndAddHitSearcher("modified1"));
@@ -89,12 +86,12 @@ public class FederationSearcherTest {
Result result = tester.search();
tester.fill(result);
assertEquals(3, result.hits().getConcreteSize());
- for (Iterator<Hit> i = result.hits().deepIterator(); i.hasNext();)
+ for (Iterator<Hit> i = result.hits().deepIterator(); i.hasNext(); )
assertFilled(i.next());
}
@Test
- public void require_that_hits_that_time_out_in_fill_are_removed() {
+ void require_that_hits_that_time_out_in_fill_are_removed() {
FederationTester tester = new FederationTester();
tester.addSearchChain("chain1", new AddHitSearcher());
tester.addSearchChain("chain2", new TimeoutInFillSearcher());
@@ -104,13 +101,13 @@ public class FederationSearcherTest {
Result result = tester.search(query);
tester.fill(result);
assertEquals(1, result.hits().getConcreteSize());
- for (Iterator<Hit> i = result.hits().deepIterator(); i.hasNext();)
+ for (Iterator<Hit> i = result.hits().deepIterator(); i.hasNext(); )
assertFilled(i.next());
assertEquals("Timed out", result.hits().getError().getMessage());
}
@Test
- public void require_that_optional_search_chains_does_not_delay_federation() {
+ void require_that_optional_search_chains_does_not_delay_federation() {
BlockingSearcher blockingSearcher = new BlockingSearcher();
FederationTester tester = new FederationTester();
@@ -121,8 +118,8 @@ public class FederationSearcherTest {
assertEquals(2, result.getHitCount());
assertTrue(result.hits().get(0) instanceof HitGroup);
assertTrue(result.hits().get(1) instanceof HitGroup);
- HitGroup chain1Result = (HitGroup)result.hits().get(0);
- HitGroup chain2Result = (HitGroup)result.hits().get(1);
+ HitGroup chain1Result = (HitGroup) result.hits().get(0);
+ HitGroup chain2Result = (HitGroup) result.hits().get(1);
// Verify chain1 result: One filled hit
assertEquals(1, chain1Result.size());
@@ -141,21 +138,21 @@ public class FederationSearcherTest {
}
@Test
- public void require_that_calling_a_single_slow_source_with_long_timeout_does_not_delay_federation() {
+ void require_that_calling_a_single_slow_source_with_long_timeout_does_not_delay_federation() {
FederationTester tester = new FederationTester();
tester.addSearchChain("chain1",
- new FederationOptions().setUseByDefault(true).setRequestTimeoutInMilliseconds(3600 * 1000),
- new BlockingSearcher() );
+ new FederationOptions().setUseByDefault(true).setRequestTimeoutInMilliseconds(3600 * 1000),
+ new BlockingSearcher());
Query query = new Query();
query.setTimeout(50); // make the test run faster
Result result = tester.search(query);
assertEquals(1, result.hits().size());
assertTrue(result.hits().get(0) instanceof HitGroup);
- HitGroup chain1Result = (HitGroup)result.hits().get(0);
+ HitGroup chain1Result = (HitGroup) result.hits().get(0);
assertEquals(1, chain1Result.size());
assertTrue(chain1Result.asList().get(0) instanceof ErrorHit);
- ErrorHit errorHit = (ErrorHit)chain1Result.get(0);
+ ErrorHit errorHit = (ErrorHit) chain1Result.get(0);
assertEquals(1, errorHit.errors().size());
ErrorMessage error = errorHit.errors().iterator().next();
assertEquals("chain1", error.getSource());
@@ -164,7 +161,7 @@ public class FederationSearcherTest {
}
@Test
- public void custom_federation_target() {
+ void custom_federation_target() {
ComponentId targetSelectorId = ComponentId.fromString("TargetSelector");
ComponentRegistry<TargetSelector> targetSelectors = new ComponentRegistry<>();
targetSelectors.register(targetSelectorId, new TestTargetSelector());
@@ -182,7 +179,7 @@ public class FederationSearcherTest {
}
@Test
- public void target_selectors_can_have_multiple_targets() {
+ void target_selectors_can_have_multiple_targets() {
ComponentId targetSelectorId = ComponentId.fromString("TestMultipleTargetSelector");
ComponentRegistry<TargetSelector> targetSelectors = new ComponentRegistry<>();
targetSelectors.register(targetSelectorId, new TestMultipleTargetSelector());
diff --git a/container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTestCase.java
index c2feb16df04..556cbea023f 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/FederationSearcherTestCase.java
@@ -19,17 +19,13 @@ import com.yahoo.search.test.QueryTestCase;
import com.yahoo.yolean.trace.TraceNode;
import com.yahoo.yolean.trace.TraceVisitor;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test for federation searcher. The searcher is also tested in
@@ -60,13 +56,13 @@ public class FederationSearcherTestCase {
private FederationConfig.Builder builder;
private SearchChainRegistry chainRegistry;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
builder = new FederationConfig.Builder();
chainRegistry = new SearchChainRegistry();
}
- @After
+ @AfterEach
public void tearDown() {
builder = null;
chainRegistry = null;
@@ -93,7 +89,7 @@ public class FederationSearcherTestCase {
}
@Test
- public void testQueryProfileNestedReferencing() {
+ void testQueryProfileNestedReferencing() {
addChained(new MockSearcher(), "mySource1");
addChained(new MockSearcher(), "mySource2");
Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher());
@@ -110,7 +106,7 @@ public class FederationSearcherTestCase {
}
@Test
- public void testTraceTwoSources() {
+ void testTraceTwoSources() {
Chain<Searcher> mainChain = twoTracingSources(false);
Query q = new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?query=test&traceLevel=1"));
@@ -148,7 +144,7 @@ public class FederationSearcherTestCase {
}
@Test
- public void testTraceOneSourceNoCloning() {
+ void testTraceOneSourceNoCloning() {
Chain<Searcher> mainChain = twoTracingSources(true);
Query q = new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?query=test&traceLevel=1&sources=source1"));
@@ -163,7 +159,7 @@ public class FederationSearcherTestCase {
}
@Test
- public void testTraceOneSourceWithCloning() {
+ void testTraceOneSourceWithCloning() {
Chain<Searcher> mainChain = twoTracingSources(false);
Query q = new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?query=test&traceLevel=1&sources=source1"));
@@ -179,7 +175,7 @@ public class FederationSearcherTestCase {
}
@Test
- public void testPropertyPropagation() {
+ void testPropertyPropagation() {
Result result = searchWithPropertyPropagation();
assertEquals("source:mySource1", result.hits().get(0).getId().stringValue());
@@ -210,7 +206,7 @@ public class FederationSearcherTestCase {
}
@Test
- public void testTopLevelHitGroupFieldPropagation() {
+ void testTopLevelHitGroupFieldPropagation() {
addChained(new MockSearcher(), "mySource1");
addChained(new AnotherMockSearcher(), "mySource2");
Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher());
@@ -256,7 +252,7 @@ public class FederationSearcherTestCase {
}
@Test
- public void testProviderSelectionFromQueryProperties() {
+ void testProviderSelectionFromQueryProperties() {
SearchChainRegistry registry = new SearchChainRegistry();
registry.register(new Chain<>("provider1", new MockProvider("provider1")));
registry.register(new Chain<>("provider2", new MockProvider("provider2")));
diff --git a/container-search/src/test/java/com/yahoo/search/federation/HitCountTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/HitCountTestCase.java
index 6f1570b702f..59547ecdd35 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/HitCountTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/HitCountTestCase.java
@@ -5,13 +5,13 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Tony Vaagenes
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertTrue;
public class HitCountTestCase {
@Test
- public void require_that_offset_and_hits_are_adjusted_when_federating() {
+ void require_that_offset_and_hits_are_adjusted_when_federating() {
final int chain1RelevanceMultiplier = 1;
final int chain2RelevanceMultiplier = 10;
@@ -38,7 +38,7 @@ public class HitCountTestCase {
}
@Test
- public void require_that_hit_counts_are_merged() {
+ void require_that_hit_counts_are_merged() {
final long chain1TotalHitCount = 3;
final long chain1DeepHitCount = 5;
@@ -56,7 +56,7 @@ public class HitCountTestCase {
}
@Test
- public void require_that_logging_hit_is_populated_with_result_count() {
+ void require_that_logging_hit_is_populated_with_result_count() {
final long chain1TotalHitCount = 9;
final long chain1DeepHitCount = 14;
diff --git a/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SearchChainResolverTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SearchChainResolverTestCase.java
index 34224721487..5a551fdcdee 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SearchChainResolverTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SearchChainResolverTestCase.java
@@ -10,15 +10,13 @@ import com.yahoo.search.federation.sourceref.SearchChainResolver;
import com.yahoo.search.federation.sourceref.Target;
import com.yahoo.search.federation.sourceref.UnresolvedSearchChainException;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Iterator;
import java.util.SortedSet;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Tony Vaagenes
@@ -53,7 +51,7 @@ public class SearchChainResolverTestCase {
}
@Test
- public void check_default_search_chains() {
+ void check_default_search_chains() {
assertEquals(2, searchChainResolver.defaultTargets().size());
Iterator<Target> iterator = searchChainResolver.defaultTargets().iterator();
@@ -62,7 +60,7 @@ public class SearchChainResolverTestCase {
}
@Test
- public void require_error_message_for_invalid_source() {
+ void require_error_message_for_invalid_source() {
try {
resolve("no-such-source");
fail("Expected exception.");
@@ -72,7 +70,7 @@ public class SearchChainResolverTestCase {
}
@Test
- public void lookup_search_chain() throws Exception {
+ void lookup_search_chain() throws Exception {
SearchChainInvocationSpec res = resolve(searchChainId.getName());
assertEquals(searchChainId, res.searchChainId);
}
@@ -86,13 +84,13 @@ public class SearchChainResolverTestCase {
}
@Test
- public void lookup_source() throws Exception {
+ void lookup_source() throws Exception {
SearchChainInvocationSpec res = resolve(sourceId.getName());
assertIsSourceInProvider(res);
}
@Test
- public void lookup_source_search_chain_directly() throws Exception {
+ void lookup_source_search_chain_directly() throws Exception {
SearchChainInvocationSpec res = resolve(sourceChainInProviderId.stringValue());
assertIsSourceInProvider(res);
}
@@ -104,7 +102,7 @@ public class SearchChainResolverTestCase {
}
@Test
- public void lookup_source_for_provider2() throws Exception {
+ void lookup_source_for_provider2() throws Exception {
SearchChainInvocationSpec res = resolve(sourceId.getName(), provider2Id.getName());
assertEquals(provider2Id, res.provider);
assertEquals(sourceId, res.source);
@@ -112,7 +110,7 @@ public class SearchChainResolverTestCase {
}
@Test
- public void lists_source_ref_description_for_top_level_targets() {
+ void lists_source_ref_description_for_top_level_targets() {
SortedSet<Target> topLevelTargets = searchChainResolver.allTopLevelTargets();
assertEquals(3, topLevelTargets.size());
diff --git a/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java
index acb68175921..97c93ed09ed 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java
@@ -10,7 +10,7 @@ import com.yahoo.search.federation.sourceref.SearchChainResolver;
import com.yahoo.search.federation.sourceref.SourceRefResolver;
import com.yahoo.search.federation.sourceref.UnresolvedSearchChainException;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
@@ -19,9 +19,7 @@ import java.util.Set;
import java.util.TreeMap;
import static com.yahoo.search.federation.sourceref.test.SearchChainResolverTestCase.emptySourceToProviderMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test for SourceRefResolver.
@@ -60,38 +58,38 @@ public class SourceRefResolverTestCase {
}
@Test
- public void check_test_assumptions() {
+ void check_test_assumptions() {
assertTrue(indexFacts.clustersHavingSearchDefinition("document1").containsAll(List.of("cluster1", "cluster2")));
}
@Test
- public void lookup_search_chain() throws Exception {
+ void lookup_search_chain() throws Exception {
Set<SearchChainInvocationSpec> searchChains = resolve(cluster1);
assertEquals(1, searchChains.size());
assertTrue(searchChainIds(searchChains).contains(cluster1));
}
@Test
- public void lookup_search_chains_for_document1() throws Exception {
+ void lookup_search_chains_for_document1() throws Exception {
Set<SearchChainInvocationSpec> searchChains = resolve("document1");
assertEquals(2, searchChains.size());
assertTrue(searchChainIds(searchChains).containsAll(List.of(cluster1, cluster2)));
}
@Test
- public void error_when_document_gives_cluster_without_matching_search_chain() {
+ void error_when_document_gives_cluster_without_matching_search_chain() {
try {
resolve("document3");
fail("Expected exception");
} catch (UnresolvedSearchChainException e) {
assertEquals("Failed to resolve cluster search chain 'cluster3' " +
- "when using source ref 'document3' as a document name.",
- e.getMessage());
+ "when using source ref 'document3' as a document name.",
+ e.getMessage());
}
}
@Test
- public void error_when_no_document_or_search_chain() {
+ void error_when_no_document_or_search_chain() {
try {
resolve("document4");
fail("Expected exception");
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/ContinuationTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/ContinuationTestCase.java
index 217fd4af400..3dcfcb8480a 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/ContinuationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/ContinuationTestCase.java
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author Simon Thoresen Hult
@@ -14,7 +14,7 @@ public class ContinuationTestCase {
private static final String KNOWN_CONTINUATION = "BCBCBCBEBGBCBKCBACBKCCK";
@Test
- public void requireThatToStringCanBeParsedByFromString() {
+ void requireThatToStringCanBeParsedByFromString() {
Continuation cnt = Continuation.fromString(KNOWN_CONTINUATION);
assertNotNull(cnt);
assertEquals(KNOWN_CONTINUATION, cnt.toString());
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/GroupingQueryParserTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/GroupingQueryParserTestCase.java
index bbb461a939c..4911a5b2543 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/GroupingQueryParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/GroupingQueryParserTestCase.java
@@ -7,13 +7,13 @@ import com.yahoo.search.grouping.request.EachOperation;
import com.yahoo.search.grouping.request.GroupingOperation;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
import java.util.TimeZone;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -21,17 +21,17 @@ import static org.junit.Assert.*;
public class GroupingQueryParserTestCase {
@Test
- public void requireThatNoRequestIsSkipped() {
+ void requireThatNoRequestIsSkipped() {
assertEquals(Collections.emptyList(), executeQuery(null, null, null));
}
@Test
- public void requireThatEmptyRequestIsSkipped() {
+ void requireThatEmptyRequestIsSkipped() {
assertEquals(Collections.emptyList(), executeQuery("", null, null));
}
@Test
- public void requireThatRequestIsParsed() {
+ void requireThatRequestIsParsed() {
List<GroupingRequest> lst = executeQuery("all(group(foo) each(output(max(bar))))", null, null);
assertNotNull(lst);
assertEquals(1, lst.size());
@@ -41,7 +41,7 @@ public class GroupingQueryParserTestCase {
}
@Test
- public void requireThatRequestListIsParsed() {
+ void requireThatRequestListIsParsed() {
List<GroupingRequest> lst = executeQuery("all();each()", null, null);
assertNotNull(lst);
assertEquals(2, lst.size());
@@ -50,7 +50,7 @@ public class GroupingQueryParserTestCase {
}
@Test
- public void requireThatEachRightBelowAllParses() {
+ void requireThatEachRightBelowAllParses() {
List<GroupingRequest> lst = executeQuery("all(each(output(summary(bar))))",
null, null);
assertNotNull(lst);
@@ -64,9 +64,9 @@ public class GroupingQueryParserTestCase {
}
@Test
- public void requireThatContinuationListIsParsed() {
+ void requireThatContinuationListIsParsed() {
List<GroupingRequest> lst = executeQuery("all(group(foo) each(output(max(bar))))",
- "BCBCBCBEBGBCBKCBACBKCCK BCBBBBBDBF", null);
+ "BCBCBCBEBGBCBKCBACBKCCK BCBBBBBDBF", null);
assertNotNull(lst);
assertEquals(1, lst.size());
GroupingRequest req = lst.get(0);
@@ -76,7 +76,7 @@ public class GroupingQueryParserTestCase {
}
@Test
- public void requireThatTimeZoneIsParsed() {
+ void requireThatTimeZoneIsParsed() {
List<GroupingRequest> lst = executeQuery("all(group(foo) each(output(max(bar))))", null, "cet");
assertNotNull(lst);
assertEquals(1, lst.size());
@@ -88,7 +88,7 @@ public class GroupingQueryParserTestCase {
}
@Test
- public void requireThatTimeZoneHasUtcDefault() {
+ void requireThatTimeZoneHasUtcDefault() {
List<GroupingRequest> lst = executeQuery("all(group(foo) each(output(max(bar))))", null, null);
assertNotNull(lst);
assertEquals(1, lst.size());
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/GroupingRequestTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/GroupingRequestTestCase.java
index 4bc827dde7a..458039fb872 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/GroupingRequestTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/GroupingRequestTestCase.java
@@ -7,7 +7,7 @@ import com.yahoo.search.Result;
import com.yahoo.search.grouping.result.Group;
import com.yahoo.search.grouping.result.RootGroup;
import com.yahoo.search.result.Hit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -15,7 +15,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -23,7 +23,7 @@ import static org.junit.Assert.*;
public class GroupingRequestTestCase {
@Test
- public void requireThatContinuationListIsMutable() {
+ void requireThatContinuationListIsMutable() {
GroupingRequest req = GroupingRequest.newInstance(new Query());
assertTrue(req.continuations().isEmpty());
@@ -41,7 +41,7 @@ public class GroupingRequestTestCase {
}
@Test
- public void requireThatResultIsFound() {
+ void requireThatResultIsFound() {
Query query = new Query();
GroupingRequest req = GroupingRequest.newInstance(query);
Result res = new Result(query);
@@ -57,7 +57,7 @@ public class GroupingRequestTestCase {
}
@Test
- public void requireThatResultIsFoundAfterCloning() {
+ void requireThatResultIsFoundAfterCloning() {
Query query = new Query();
GroupingRequest req = GroupingRequest.newInstance(query);
Result res = new Result(query.clone());
@@ -73,7 +73,7 @@ public class GroupingRequestTestCase {
}
@Test
- public void requireThatParallelRequestsAreSupported() {
+ void requireThatParallelRequestsAreSupported() {
Query query = new Query();
Result res = new Result(query);
@@ -94,7 +94,7 @@ public class GroupingRequestTestCase {
}
@Test
- public void requireThatRemovedResultIsNull() {
+ void requireThatRemovedResultIsNull() {
Query query = new Query();
GroupingRequest req = GroupingRequest.newInstance(query);
Result res = new Result(query);
@@ -107,7 +107,7 @@ public class GroupingRequestTestCase {
}
@Test
- public void requireThatNonGroupResultIsNull() {
+ void requireThatNonGroupResultIsNull() {
Query query = new Query();
GroupingRequest req = GroupingRequest.newInstance(query);
Result res = new Result(query);
@@ -119,7 +119,7 @@ public class GroupingRequestTestCase {
}
@Test
- public void requireThatGetRequestsReturnsAllRequests() {
+ void requireThatGetRequestsReturnsAllRequests() {
Query query = new Query();
assertEquals(Collections.emptyList(), query.getSelect().getGrouping());
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java
index 4f473b29918..4b5fb53b06a 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java
@@ -7,13 +7,13 @@ import com.yahoo.search.Query;
import com.yahoo.search.config.ClusterConfig;
import com.yahoo.search.grouping.request.GroupingOperation;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -21,13 +21,14 @@ import static org.junit.Assert.fail;
public class GroupingValidatorTestCase {
@Test
- public void requireThatAvailableAttributesDoNotThrow() {
+ void requireThatAvailableAttributesDoNotThrow() {
validateGrouping(List.of("foo", "bar"),
- "all(group(foo) each(output(max(bar))))");;
+ "all(group(foo) each(output(max(bar))))");
+ ;
}
@Test
- public void requireThatUnavailableAttributesThrow() {
+ void requireThatUnavailableAttributesThrow() {
try {
validateGrouping(List.of("foo"), "all(group(foo) each(output(max(bar))))");
fail("Excpected exception");
@@ -38,20 +39,20 @@ public class GroupingValidatorTestCase {
}
@Test
- public void requireThatEnableFlagPreventsThrow() {
+ void requireThatEnableFlagPreventsThrow() {
Query query = createQuery("all(group(foo) each(output(max(bar))))");
query.properties().set(GroupingValidator.PARAM_ENABLED, "false");
validateGrouping(List.of("foo"), query);
}
@Test
- public void available_primitive_map_attribute_does_not_throw() {
+ void available_primitive_map_attribute_does_not_throw() {
validateGrouping(List.of("map.key", "map.value"),
"all(group(map{\"foo\"}) each(output(count())))");
}
@Test
- public void unavailable_primitive_map_key_attribute_throws() {
+ void unavailable_primitive_map_key_attribute_throws() {
try {
validateGrouping(List.of("null"), "all(group(map{\"foo\"}) each(output(count())))");
fail("Expected exception");
@@ -62,7 +63,7 @@ public class GroupingValidatorTestCase {
}
@Test
- public void unavailable_primitive_map_value_attribute_throws() {
+ void unavailable_primitive_map_value_attribute_throws() {
try {
validateGrouping(List.of("map.key"), "all(group(map{\"foo\"}) each(output(count())))");
fail("Expected exception");
@@ -73,13 +74,13 @@ public class GroupingValidatorTestCase {
}
@Test
- public void available_struct_map_attribute_does_not_throw() {
+ void available_struct_map_attribute_does_not_throw() {
validateGrouping(List.of("map.key", "map.value.name"),
"all(group(map{\"foo\"}.name) each(output(count())))");
}
@Test
- public void unavailable_struct_map_key_attribute_throws() {
+ void unavailable_struct_map_key_attribute_throws() {
try {
validateGrouping(List.of("null"), "all(group(map{\"foo\"}.name) each(output(count())))");
fail("Expected exception");
@@ -90,7 +91,7 @@ public class GroupingValidatorTestCase {
}
@Test
- public void unavailable_struct_map_value_attribute_throws() {
+ void unavailable_struct_map_value_attribute_throws() {
try {
validateGrouping(List.of("map.key"), "all(group(map{\"foo\"}.name) each(output(count())))");
fail("Expected exception");
@@ -101,16 +102,16 @@ public class GroupingValidatorTestCase {
}
@Test
- public void available_key_source_attribute_does_not_throw() {
+ void available_key_source_attribute_does_not_throw() {
validateGrouping(List.of("map.key", "map.value", "key_source"),
"all(group(map{attribute(key_source)}) each(output(count())))");
}
@Test
- public void unavailable_key_source_attribute_throws() {
+ void unavailable_key_source_attribute_throws() {
try {
validateGrouping(List.of("map.key", "map.value"),
- "all(group(map{attribute(key_source)}) each(output(count())))");
+ "all(group(map{attribute(key_source)}) each(output(count())))");
fail("Expected exception");
}
catch (UnavailableAttributeException e) {
@@ -119,29 +120,29 @@ public class GroupingValidatorTestCase {
}
@Test
- public void key_source_attribute_with_mismatching_data_type_throws() {
+ void key_source_attribute_with_mismatching_data_type_throws() {
try {
validateGrouping(setupMismatchingKeySourceAttribute(false),
- "all(group(map{attribute(key_source)}) each(output(count())))");
+ "all(group(map{attribute(key_source)}) each(output(count())))");
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertEquals("Grouping request references key source attribute 'key_source' with data type 'INT32' " +
- "that is different than data type 'STRING' of key attribute 'map.key'",
- e.getMessage());
+ "that is different than data type 'STRING' of key attribute 'map.key'",
+ e.getMessage());
}
}
@Test
- public void key_source_attribute_with_multi_value_collection_type_throws() {
+ void key_source_attribute_with_multi_value_collection_type_throws() {
try {
validateGrouping(setupMismatchingKeySourceAttribute(true),
- "all(group(map{attribute(key_source)}) each(output(count())))");
+ "all(group(map{attribute(key_source)}) each(output(count())))");
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertEquals("Grouping request references key source attribute 'key_source' which is not of single value type",
- e.getMessage());
+ e.getMessage());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/UniqueGroupingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/UniqueGroupingSearcherTestCase.java
index cb771ecb678..ffb69267212 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/UniqueGroupingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/UniqueGroupingSearcherTestCase.java
@@ -15,11 +15,9 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.result.Relevance;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.yolean.Exceptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author andreer
@@ -27,21 +25,21 @@ import static org.junit.Assert.fail;
public class UniqueGroupingSearcherTestCase {
@Test
- public void testSkipGroupingBasedDedup() {
+ void testSkipGroupingBasedDedup() {
Result result = search("?query=foo",
- new MockResultProvider(0, false));
+ new MockResultProvider(0, false));
assertEquals(0, result.hits().size());
}
@Test
- public void testSkipGroupingBasedDedupIfMultiLevelSorting() {
+ void testSkipGroupingBasedDedupIfMultiLevelSorting() {
Result result = search("?query=foo&unique=fingerprint&sorting=-pubdate%20-[rank]",
- new MockResultProvider(0, false));
+ new MockResultProvider(0, false));
assertEquals(0, result.hits().size());
}
@Test
- public void testIllegalSortingSpec() {
+ void testIllegalSortingSpec() {
try {
search("?query=foo&unique=fingerprint&sorting=-1",
new MockResultProvider(0, true).addGroupList(new GroupList("fingerprint")));
@@ -49,31 +47,31 @@ public class UniqueGroupingSearcherTestCase {
} catch (IllegalArgumentException e) {
// As expected.
assertTrue(Exceptions.toMessageString(e).contains("Could not set 'ranking.sorting' to '-1': " +
- "Illegal attribute name '1' for sorting. " +
- "Requires '[\\[]*[a-zA-Z_][\\.a-zA-Z0-9_-]*[\\]]*'"));
+ "Illegal attribute name '1' for sorting. " +
+ "Requires '[\\[]*[a-zA-Z_][\\.a-zA-Z0-9_-]*[\\]]*'"));
}
}
@Test
- public void testGroupingBasedDedupNoGroupingHits() {
+ void testGroupingBasedDedupNoGroupingHits() {
Result result = search("?query=foo&unique=fingerprint",
- new MockResultProvider(0, true));
+ new MockResultProvider(0, true));
assertEquals(0, result.hits().size());
}
@Test
- public void testGroupingBasedDedupWithEmptyGroupingHitsList() {
+ void testGroupingBasedDedupWithEmptyGroupingHitsList() {
Result result = search("?query=foo&unique=fingerprint",
- new MockResultProvider(0, true).addGroupList(new GroupList("fingerprint")));
+ new MockResultProvider(0, true).addGroupList(new GroupList("fingerprint")));
assertEquals(0, result.hits().size());
assertEquals(0, result.getTotalHitCount());
}
@Test
- public void testGroupingBasedDedupWithNullGroupingResult() {
+ void testGroupingBasedDedupWithNullGroupingResult() {
try {
search("?query=foo&unique=fingerprint",
- new MockResultProvider(0, false));
+ new MockResultProvider(0, false));
fail();
} catch (IllegalStateException e) {
assertEquals("Failed to produce deduped result set.", e.getMessage());
@@ -81,7 +79,7 @@ public class UniqueGroupingSearcherTestCase {
}
@Test
- public void testGroupingBasedDedupWithGroupingHits() {
+ void testGroupingBasedDedupWithGroupingHits() {
GroupList fingerprint = new GroupList("fingerprint");
fingerprint.add(makeHitGroup("1"));
fingerprint.add(makeHitGroup("2"));
@@ -105,7 +103,7 @@ public class UniqueGroupingSearcherTestCase {
}
@Test
- public void testGroupingBasedDedupWithGroupingHitsAndSorting() {
+ void testGroupingBasedDedupWithGroupingHitsAndSorting() {
GroupList fingerprint = new GroupList("fingerprint");
fingerprint.add(makeSortingHitGroup("1"));
fingerprint.add(makeSortingHitGroup("2"));
@@ -130,29 +128,29 @@ public class UniqueGroupingSearcherTestCase {
}
@Test
- public void testBuildGroupingExpression() {
+ void testBuildGroupingExpression() {
assertEquals("all(group(title) max(11) output(count() as(uniqueCount)) each(max(1) each(output(summary())) " +
- "as(uniqueHits)))",
- UniqueGroupingSearcher
- .buildGroupingExpression("title", 11, null, null)
- .toString());
+ "as(uniqueHits)))",
+ UniqueGroupingSearcher
+ .buildGroupingExpression("title", 11, null, null)
+ .toString());
assertEquals("all(group(fingerprint) max(5) output(count() as(uniqueCount)) each(max(1) " +
- "each(output(summary(attributeprefetch))) as(uniqueHits)))",
- UniqueGroupingSearcher
- .buildGroupingExpression("fingerprint", 5, "attributeprefetch", null)
- .toString());
+ "each(output(summary(attributeprefetch))) as(uniqueHits)))",
+ UniqueGroupingSearcher
+ .buildGroupingExpression("fingerprint", 5, "attributeprefetch", null)
+ .toString());
assertEquals("all(group(fingerprint) max(5) order(neg(max(pubdate))) output(count() as(uniqueCount)) each(" +
- "all(group(neg(pubdate)) max(1) order(neg(max(pubdate))) each(each(output(summary())) " +
- "as(uniqueHits)) as(uniqueGroups))))",
- UniqueGroupingSearcher
- .buildGroupingExpression("fingerprint", 5, null, new Sorting("-pubdate"))
- .toString());
+ "all(group(neg(pubdate)) max(1) order(neg(max(pubdate))) each(each(output(summary())) " +
+ "as(uniqueHits)) as(uniqueGroups))))",
+ UniqueGroupingSearcher
+ .buildGroupingExpression("fingerprint", 5, null, new Sorting("-pubdate"))
+ .toString());
assertEquals("all(group(fingerprint) max(5) order(min(pubdate)) output(count() as(uniqueCount)) each(" +
- "all(group(pubdate) max(1) order(min(pubdate)) each(each(output(summary(attributeprefetch))) " +
- "as(uniqueHits)) as(uniqueGroups))))",
- UniqueGroupingSearcher
- .buildGroupingExpression("fingerprint", 5, "attributeprefetch", new Sorting("+pubdate"))
- .toString());
+ "all(group(pubdate) max(1) order(min(pubdate)) each(each(output(summary(attributeprefetch))) " +
+ "as(uniqueHits)) as(uniqueGroups))))",
+ UniqueGroupingSearcher
+ .buildGroupingExpression("fingerprint", 5, "attributeprefetch", new Sorting("+pubdate"))
+ .toString());
}
private static Group makeHitGroup(String name) {
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/BucketResolverTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/BucketResolverTestCase.java
index 50058f3777f..d7a888792d9 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/BucketResolverTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/BucketResolverTestCase.java
@@ -1,13 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.text.ChoiceFormat;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -22,7 +22,7 @@ public class BucketResolverTestCase {
// --------------------------------------------------------------------------------
@Test
- public void testResolve() {
+ void testResolve() {
BucketResolver resolver = new BucketResolver();
resolver.push(new StringValue("a"), true);
try {
@@ -71,32 +71,32 @@ public class BucketResolverTestCase {
}
@Test
- public void testBucketType() {
- checkPushFail(Arrays.asList((ConstantValue)new StringValue("a"), new LongValue(1L)),
- "Bucket type mismatch, expected 'StringValue' got 'LongValue'.");
- checkPushFail(Arrays.asList((ConstantValue)new StringValue("a"), new DoubleValue(1.0)),
- "Bucket type mismatch, expected 'StringValue' got 'DoubleValue'.");
- checkPushFail(Arrays.asList((ConstantValue)new LongValue(1L), new StringValue("a")),
- "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
- checkPushFail(Arrays.asList((ConstantValue)new LongValue(1L), new DoubleValue(1.0)),
- "Bucket type mismatch, expected 'LongValue' got 'DoubleValue'.");
- checkPushFail(Arrays.asList((ConstantValue)new DoubleValue(1.0), new StringValue("a")),
- "Bucket type mismatch, expected 'DoubleValue' got 'StringValue'.");
- checkPushFail(Arrays.asList((ConstantValue)new DoubleValue(1.0), new LongValue(1L)),
- "Bucket type mismatch, expected 'DoubleValue' got 'LongValue'.");
- checkPushFail(Arrays.asList((ConstantValue)new InfiniteValue(new Infinite(true)), new InfiniteValue(new Infinite(false))),
- "Bucket type mismatch, cannot both be infinity.");
+ void testBucketType() {
+ checkPushFail(Arrays.asList((ConstantValue) new StringValue("a"), new LongValue(1L)),
+ "Bucket type mismatch, expected 'StringValue' got 'LongValue'.");
+ checkPushFail(Arrays.asList((ConstantValue) new StringValue("a"), new DoubleValue(1.0)),
+ "Bucket type mismatch, expected 'StringValue' got 'DoubleValue'.");
+ checkPushFail(Arrays.asList((ConstantValue) new LongValue(1L), new StringValue("a")),
+ "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
+ checkPushFail(Arrays.asList((ConstantValue) new LongValue(1L), new DoubleValue(1.0)),
+ "Bucket type mismatch, expected 'LongValue' got 'DoubleValue'.");
+ checkPushFail(Arrays.asList((ConstantValue) new DoubleValue(1.0), new StringValue("a")),
+ "Bucket type mismatch, expected 'DoubleValue' got 'StringValue'.");
+ checkPushFail(Arrays.asList((ConstantValue) new DoubleValue(1.0), new LongValue(1L)),
+ "Bucket type mismatch, expected 'DoubleValue' got 'LongValue'.");
+ checkPushFail(Arrays.asList((ConstantValue) new InfiniteValue(new Infinite(true)), new InfiniteValue(new Infinite(false))),
+ "Bucket type mismatch, cannot both be infinity.");
}
@Test
- public void testBucketOrder() {
- checkPushFail(Arrays.asList((ConstantValue)new LongValue(2L), new LongValue(1L)),
- "Bucket to-value can not be less than from-value.");
- checkPushFail(Arrays.asList((ConstantValue)new DoubleValue(2.0), new DoubleValue(1.0)),
- "Bucket to-value can not be less than from-value.");
- checkPushFail(Arrays.asList((ConstantValue)new StringValue("b"), new StringValue("a")),
- "Bucket to-value can not be less than from-value.");
+ void testBucketOrder() {
+ checkPushFail(Arrays.asList((ConstantValue) new LongValue(2L), new LongValue(1L)),
+ "Bucket to-value can not be less than from-value.");
+ checkPushFail(Arrays.asList((ConstantValue) new DoubleValue(2.0), new DoubleValue(1.0)),
+ "Bucket to-value can not be less than from-value.");
+ checkPushFail(Arrays.asList((ConstantValue) new StringValue("b"), new StringValue("a")),
+ "Bucket to-value can not be less than from-value.");
}
public void assertBucketRange(BucketValue expected, ConstantValue from, boolean inclusiveFrom, ConstantValue to, boolean inclusiveTo) {
@@ -123,7 +123,7 @@ public class BucketResolverTestCase {
}
@Test
- public void requireThatBucketRangesWork() {
+ void requireThatBucketRangesWork() {
BucketValue expected = new LongBucket(2, 5);
assertBucketRange(expected, new LongValue(1), false, new LongValue(4), true);
assertBucketRange(expected, new LongValue(1), false, new LongValue(5), false);
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/ExpressionVisitorTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/ExpressionVisitorTestCase.java
index 24ce3cfea32..1f800b37ff0 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/ExpressionVisitorTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/ExpressionVisitorTestCase.java
@@ -1,13 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Simon Thoresen Hult
@@ -15,7 +15,7 @@ import static org.junit.Assert.assertTrue;
public class ExpressionVisitorTestCase {
@Test
- public void requireThatExpressionsAreVisited() {
+ void requireThatExpressionsAreVisited() {
GroupingOperation op = new AllOperation();
final List<GroupingExpression> lst = new LinkedList<>();
@@ -38,7 +38,7 @@ public class ExpressionVisitorTestCase {
}
@Test
- public void requireThatChildOperationsAreVisited() {
+ void requireThatChildOperationsAreVisited() {
GroupingOperation root, parentA, childA1, childA2, parentB, childB1;
root = new AllOperation()
.addChild(parentA = new AllOperation()
@@ -69,7 +69,7 @@ public class ExpressionVisitorTestCase {
}
@Test
- public void requireThatExpressionsArgumentsAreVisited() {
+ void requireThatExpressionsArgumentsAreVisited() {
final List<GroupingExpression> lst = new LinkedList<>();
GroupingExpression arg1 = new AttributeValue("arg1");
lst.add(arg1);
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java
index 0e89f348449..d1ab7117677 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java
@@ -3,11 +3,11 @@ package com.yahoo.search.grouping.request;
import com.yahoo.search.grouping.request.parser.ParseException;
import com.yahoo.search.grouping.request.parser.TokenMgrException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -15,7 +15,7 @@ import static org.junit.Assert.*;
public class GroupingOperationTestCase {
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
GroupingOperation op = new AllOperation();
GroupingExpression exp = new AttributeValue("alias");
op.putAlias("alias", exp);
@@ -88,7 +88,7 @@ public class GroupingOperationTestCase {
}
@Test
- public void requireThatFromStringAsListParsesAllOperations() {
+ void requireThatFromStringAsListParsesAllOperations() {
List<GroupingOperation> lst = GroupingOperation.fromStringAsList("");
assertTrue(lst.isEmpty());
@@ -107,7 +107,7 @@ public class GroupingOperationTestCase {
}
@Test
- public void requireThatFromStringAcceptsOnlyOneOperation() {
+ void requireThatFromStringAcceptsOnlyOneOperation() {
try {
GroupingOperation.fromString("");
fail();
@@ -125,7 +125,7 @@ public class GroupingOperationTestCase {
}
@Test
- public void requireThatParseExceptionsAreRethrown() {
+ void requireThatParseExceptionsAreRethrown() {
try {
GroupingOperation.fromString("all(foo)");
fail();
@@ -136,7 +136,7 @@ public class GroupingOperationTestCase {
}
@Test
- public void requireThatTokenErrorsAreRethrown() {
+ void requireThatTokenErrorsAreRethrown() {
try {
GroupingOperation.fromString("all(\\foo)");
fail();
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/MathFunctionsTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/MathFunctionsTestCase.java
index d22c2dee7b6..823993b6bc6 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/MathFunctionsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/MathFunctionsTestCase.java
@@ -1,19 +1,17 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Einar M R Rosenvinge
*/
public class MathFunctionsTestCase {
-
+
@Test
- public void testMathFunctions() {
+ void testMathFunctions() {
//if this fails, update the count AND add a test in each of the two blocks below
assertEquals(21, MathFunctions.Function.values().length);
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/MathResolverTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/MathResolverTestCase.java
index 734e2c6a0cb..39fdc7fc3a6 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/MathResolverTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/MathResolverTestCase.java
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author Simon Thoresen Hult
@@ -18,40 +18,40 @@ public class MathResolverTestCase {
// --------------------------------------------------------------------------------
@Test
- public void testOperators() {
+ void testOperators() {
MathResolver resolver = new MathResolver();
resolver.push(MathResolver.Type.ADD, new LongValue(1));
resolver.push(MathResolver.Type.ADD, new LongValue(2));
assertEquals("add(1, 2)",
- resolver.resolve().toString());
+ resolver.resolve().toString());
resolver = new MathResolver();
resolver.push(MathResolver.Type.ADD, new LongValue(1));
resolver.push(MathResolver.Type.SUB, new LongValue(2));
assertEquals("sub(1, 2)",
- resolver.resolve().toString());
+ resolver.resolve().toString());
resolver = new MathResolver();
resolver.push(MathResolver.Type.ADD, new LongValue(1));
resolver.push(MathResolver.Type.DIV, new LongValue(2));
assertEquals("div(1, 2)",
- resolver.resolve().toString());
+ resolver.resolve().toString());
resolver = new MathResolver();
resolver.push(MathResolver.Type.ADD, new LongValue(1));
resolver.push(MathResolver.Type.MOD, new LongValue(2));
assertEquals("mod(1, 2)",
- resolver.resolve().toString());
+ resolver.resolve().toString());
resolver = new MathResolver();
resolver.push(MathResolver.Type.ADD, new LongValue(1));
resolver.push(MathResolver.Type.MUL, new LongValue(2));
assertEquals("mul(1, 2)",
- resolver.resolve().toString());
+ resolver.resolve().toString());
}
@Test
- public void testOperatorPrecedence() {
+ void testOperatorPrecedence() {
assertResolve("add(add(1, 2), 3)", MathResolver.Type.ADD, MathResolver.Type.ADD);
assertResolve("add(1, sub(2, 3))", MathResolver.Type.ADD, MathResolver.Type.SUB);
assertResolve("add(1, div(2, 3))", MathResolver.Type.ADD, MathResolver.Type.DIV);
@@ -83,21 +83,21 @@ public class MathResolverTestCase {
assertResolve("mul(mul(1, 2), 3)", MathResolver.Type.MUL, MathResolver.Type.MUL);
assertResolve("add(1, sub(div(2, mod(3, mul(4, 5))), 6))",
- MathResolver.Type.ADD, MathResolver.Type.DIV, MathResolver.Type.MOD,
- MathResolver.Type.MUL, MathResolver.Type.SUB);
+ MathResolver.Type.ADD, MathResolver.Type.DIV, MathResolver.Type.MOD,
+ MathResolver.Type.MUL, MathResolver.Type.SUB);
assertResolve("add(sub(1, div(mod(mul(2, 3), 4), 5)), 6)",
- MathResolver.Type.SUB, MathResolver.Type.MUL, MathResolver.Type.MOD,
- MathResolver.Type.DIV, MathResolver.Type.ADD);
+ MathResolver.Type.SUB, MathResolver.Type.MUL, MathResolver.Type.MOD,
+ MathResolver.Type.DIV, MathResolver.Type.ADD);
assertResolve("add(1, sub(2, div(3, mod(4, mul(5, 6)))))",
- MathResolver.Type.ADD, MathResolver.Type.SUB, MathResolver.Type.DIV,
- MathResolver.Type.MOD, MathResolver.Type.MUL);
+ MathResolver.Type.ADD, MathResolver.Type.SUB, MathResolver.Type.DIV,
+ MathResolver.Type.MOD, MathResolver.Type.MUL);
assertResolve("add(sub(div(mod(mul(1, 2), 3), 4), 5), 6)",
- MathResolver.Type.MUL, MathResolver.Type.MOD, MathResolver.Type.DIV,
- MathResolver.Type.SUB, MathResolver.Type.ADD);
+ MathResolver.Type.MUL, MathResolver.Type.MOD, MathResolver.Type.DIV,
+ MathResolver.Type.SUB, MathResolver.Type.ADD);
}
@Test
- public void testOperatorSupport() {
+ void testOperatorSupport() {
MathResolver resolver = new MathResolver();
for (MathResolver.Type type : MathResolver.Type.values()) {
if (type == MathResolver.Type.ADD) {
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java
index dfa297b4fa6..03223f786e8 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java
@@ -1,13 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Ulf Lilleengen
@@ -21,18 +21,18 @@ public class RawBufferTestCase {
// --------------------------------------------------------------------------------
@Test
- public void requireThatCompareWorks() {
+ void requireThatCompareWorks() {
RawBuffer buffer = new RawBuffer();
- buffer.put((byte)'a');
- buffer.put((byte)'b');
+ buffer.put((byte) 'a');
+ buffer.put((byte) 'b');
RawBuffer buffer2 = new RawBuffer();
- buffer2.put((byte)'k');
- buffer2.put((byte)'a');
+ buffer2.put((byte) 'k');
+ buffer2.put((byte) 'a');
ArrayList<Byte> backing = new ArrayList<>();
- backing.add((byte)'a');
- backing.add((byte)'b');
+ backing.add((byte) 'a');
+ backing.add((byte) 'b');
RawBuffer buffer3 = new RawBuffer(backing);
assertEquals(buffer.compareTo(buffer2), -1);
@@ -41,9 +41,9 @@ public class RawBufferTestCase {
}
@Test
- public void requireThatToStringWorks() {
+ void requireThatToStringWorks() {
assertToString(Arrays.asList("a".getBytes()[0], "b".getBytes()[0]), "{97,98}");
- assertToString(Arrays.asList((byte)2, (byte)6), "{2,6}");
+ assertToString(Arrays.asList((byte) 2, (byte) 6), "{2,6}");
}
public void assertToString(List<Byte> data, String expected) {
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/RequestTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/RequestTestCase.java
index c02e46fae98..e2b4dc4f34b 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/RequestTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/RequestTestCase.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -13,7 +13,7 @@ import static org.junit.Assert.*;
public class RequestTestCase {
@Test
- public void requireThatApiWorks() {
+ void requireThatApiWorks() {
GroupingOperation op = new AllOperation()
.setGroupBy(new AttributeValue("foo"))
.addOrderBy(new CountAggregator())
@@ -22,19 +22,19 @@ public class RequestTestCase {
.addOutput(new CountAggregator())
.addOutput(new MinAggregator(new AttributeValue("bar")))
.addChild(new EachOperation()
- .addOutput(new AddFunction(
- new LongValue(69),
- new AttributeValue("baz")))
- .addOutput(new SummaryValue("cox"))));
+ .addOutput(new AddFunction(
+ new LongValue(69),
+ new AttributeValue("baz")))
+ .addOutput(new SummaryValue("cox"))));
assertEquals("all(group(foo) order(count()) all() each() " +
- "each(output(count(), min(bar)) each(output(add(69, baz), summary(cox)))))",
- op.toString());
+ "each(output(count(), min(bar)) each(output(add(69, baz), summary(cox)))))",
+ op.toString());
op.resolveLevel(1);
GroupingExpression exp = op.getGroupBy();
assertNotNull(exp);
assertTrue(exp instanceof AttributeValue);
- assertEquals("foo", ((AttributeValue)exp).getAttributeName());
+ assertEquals("foo", ((AttributeValue) exp).getAttributeName());
assertEquals(1, op.getNumOrderBy());
assertNotNull(exp = op.getOrderBy(0));
assertTrue(exp instanceof CountAggregator);
@@ -49,9 +49,9 @@ public class RequestTestCase {
assertTrue(exp instanceof CountAggregator);
assertNotNull(exp = op.getOutput(1));
assertTrue(exp instanceof MinAggregator);
- assertNotNull(exp = ((MinAggregator)exp).getExpression());
+ assertNotNull(exp = ((MinAggregator) exp).getExpression());
assertTrue(exp instanceof AttributeValue);
- assertEquals("bar", ((AttributeValue)exp).getAttributeName());
+ assertEquals("bar", ((AttributeValue) exp).getAttributeName());
assertEquals(1, op.getNumChildren());
assertNotNull(op = op.getChild(0));
@@ -59,24 +59,24 @@ public class RequestTestCase {
assertEquals(2, op.getNumOutputs());
assertNotNull(exp = op.getOutput(0));
assertTrue(exp instanceof AddFunction);
- assertEquals(2, ((AddFunction)exp).getNumArgs());
- GroupingExpression arg = ((AddFunction)exp).getArg(0);
+ assertEquals(2, ((AddFunction) exp).getNumArgs());
+ GroupingExpression arg = ((AddFunction) exp).getArg(0);
assertNotNull(arg);
assertTrue(arg instanceof LongValue);
- assertEquals(69L, ((LongValue)arg).getValue().longValue());
- assertNotNull(arg = ((AddFunction)exp).getArg(1));
+ assertEquals(69L, ((LongValue) arg).getValue().longValue());
+ assertNotNull(arg = ((AddFunction) exp).getArg(1));
assertTrue(arg instanceof AttributeValue);
- assertEquals("baz", ((AttributeValue)arg).getAttributeName());
+ assertEquals("baz", ((AttributeValue) arg).getAttributeName());
assertNotNull(exp = op.getOutput(1));
assertTrue(exp instanceof SummaryValue);
- assertEquals("cox", ((SummaryValue)exp).getSummaryName());
+ assertEquals("cox", ((SummaryValue) exp).getSummaryName());
}
@Test
- public void requireThatPredefinedApiWorks() {
+ void requireThatPredefinedApiWorks() {
PredefinedFunction fnc = new LongPredefined(new AttributeValue("foo"),
- new LongBucket(1, 2),
- new LongBucket(3, 4));
+ new LongBucket(1, 2),
+ new LongBucket(3, 4));
assertEquals(2, fnc.getNumBuckets());
BucketValue bucket = fnc.getBucket(0);
assertNotNull(bucket);
@@ -91,7 +91,7 @@ public class RequestTestCase {
}
@Test
- public void requireThatBucketIntegrityIsChecked() {
+ void requireThatBucketIntegrityIsChecked() {
try {
new LongBucket(2, 1);
} catch (IllegalArgumentException e) {
@@ -99,37 +99,37 @@ public class RequestTestCase {
}
try {
new LongPredefined(new AttributeValue("foo"),
- new LongBucket(3, 4),
- new LongBucket(1, 2));
+ new LongBucket(3, 4),
+ new LongBucket(1, 2));
} catch (IllegalArgumentException e) {
assertEquals("Buckets must be monotonically increasing, got bucket[3, 4> before bucket[1, 2>.",
- e.getMessage());
+ e.getMessage());
}
}
@Test
- public void requireThatAliasWorks() {
+ void requireThatAliasWorks() {
GroupingOperation all = new AllOperation();
all.putAlias("myalias", new AttributeValue("foo"));
GroupingExpression exp = all.getAlias("myalias");
assertNotNull(exp);
assertTrue(exp instanceof AttributeValue);
- assertEquals("foo", ((AttributeValue)exp).getAttributeName());
+ assertEquals("foo", ((AttributeValue) exp).getAttributeName());
GroupingOperation each = new EachOperation();
all.addChild(each);
assertNotNull(exp = each.getAlias("myalias"));
assertTrue(exp instanceof AttributeValue);
- assertEquals("foo", ((AttributeValue)exp).getAttributeName());
+ assertEquals("foo", ((AttributeValue) exp).getAttributeName());
each.putAlias("myalias", new AttributeValue("bar"));
assertNotNull(exp = each.getAlias("myalias"));
assertTrue(exp instanceof AttributeValue);
- assertEquals("bar", ((AttributeValue)exp).getAttributeName());
+ assertEquals("bar", ((AttributeValue) exp).getAttributeName());
}
@Test
- public void testOrderBy() {
+ void testOrderBy() {
GroupingOperation all = new AllOperation();
all.addOrderBy(new AttributeValue("foo"));
try {
@@ -143,7 +143,7 @@ public class RequestTestCase {
}
@Test
- public void testMax() {
+ void testMax() {
GroupingOperation all = new AllOperation();
all.setMax(69);
try {
@@ -156,10 +156,10 @@ public class RequestTestCase {
}
@Test
- public void testAccuracy() {
+ void testAccuracy() {
GroupingOperation all = new AllOperation();
all.setAccuracy(0.53);
- assertEquals((long)(100.0 * all.getAccuracy()), 53);
+ assertEquals((long) (100.0 * all.getAccuracy()), 53);
try {
all.setAccuracy(1.2);
fail();
@@ -175,7 +175,7 @@ public class RequestTestCase {
}
@Test
- public void testLevelChange() {
+ void testLevelChange() {
GroupingOperation all = new AllOperation();
all.resolveLevel(0);
assertEquals(0, all.getLevel());
@@ -198,7 +198,7 @@ public class RequestTestCase {
}
@Test
- public void testLevelInheritance() {
+ void testLevelInheritance() {
GroupingOperation grandParent, parent, child, grandChild;
grandParent = new AllOperation()
.addChild(parent = new EachOperation()
@@ -213,7 +213,7 @@ public class RequestTestCase {
}
@Test
- public void testLevelPropagation() {
+ void testLevelPropagation() {
GroupingOperation all = new AllOperation()
.setGroupBy(new AttributeValue("foo"))
.addOrderBy(new MaxAggregator(new AttributeValue("bar")))
@@ -224,6 +224,6 @@ public class RequestTestCase {
assertEquals(0, all.getGroupBy().getLevel());
assertEquals(1, all.getOrderBy(0).getLevel());
assertEquals(1, all.getChild(0).getOutput(0).getLevel());
- assertEquals(0, ((AggregatorNode)all.getChild(0).getOutput(0)).getExpression().getLevel());
+ assertEquals(0, ((AggregatorNode) all.getChild(0).getOutput(0)).getExpression().getLevel());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserBenchmarkTest.java b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserBenchmarkTest.java
index 56444a99ed3..c95451e991c 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserBenchmarkTest.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserBenchmarkTest.java
@@ -2,7 +2,7 @@
package com.yahoo.search.grouping.request.parser;
import com.yahoo.search.grouping.request.GroupingOperation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.LinkedHashMap;
@@ -26,7 +26,7 @@ public class GroupingParserBenchmarkTest {
}
@Test
- public void requireThatGroupingParserIsFast() {
+ void requireThatGroupingParserIsFast() {
List<String> inputs = getInputs();
long ignore = 0;
long now = 0;
@@ -39,9 +39,9 @@ public class GroupingParserBenchmarkTest {
}
}
long micros = TimeUnit.NANOSECONDS.toMicros(System.nanoTime() - now);
- System.out.format("%d \u03bcs (avg %.2f)\n", micros, (double)micros / (NUM_RUNS * inputs.size()));
+ System.out.format("%d \u03bcs (avg %.2f)\n", micros, (double) micros / (NUM_RUNS * inputs.size()));
for (Map.Entry<String, Long> entry : PREV_RESULTS.entrySet()) {
- System.out.format("%-20s : %4.2f\n", entry.getKey(), (double)micros / entry.getValue());
+ System.out.format("%-20s : %4.2f\n", entry.getKey(), (double) micros / entry.getValue());
}
System.out.println("\nignore " + ignore);
}
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
index 0dfd4685c0f..dd55dd46e5e 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
@@ -9,17 +9,13 @@ import com.yahoo.search.query.parser.Parsable;
import com.yahoo.search.query.parser.ParserEnvironment;
import com.yahoo.search.yql.VespaGroupingStep;
import com.yahoo.search.yql.YqlParser;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -27,7 +23,7 @@ import static org.junit.Assert.fail;
public class GroupingParserTestCase {
@Test
- public void requireThatMathAllowsWhitespace() {
+ void requireThatMathAllowsWhitespace() {
for (String op : Arrays.asList("+", " +", " + ", "+ ",
"-", " -", " - ", "- ",
"*", " *", " * ", "* ",
@@ -41,7 +37,7 @@ public class GroupingParserTestCase {
}
@Test
- public void testRequestList() {
+ void testRequestList() {
List<GroupingOperation> lst = GroupingOperation.fromStringAsList("all();each();all() where(true);each()");
assertNotNull(lst);
assertEquals(4, lst.size());
@@ -52,113 +48,113 @@ public class GroupingParserTestCase {
}
@Test
- public void testAttributeFunctions() {
+ void testAttributeFunctions() {
assertParse("all(group(foo) each(output(sum(attribute(bar)))))",
- "all(group(foo) each(output(sum(attribute(bar)))))");
+ "all(group(foo) each(output(sum(attribute(bar)))))");
assertParse("all(group(foo) each(output(sum(interpolatedlookup(bar, 0.25)))))",
- "all(group(foo) each(output(sum(interpolatedlookup(bar, 0.25)))))");
+ "all(group(foo) each(output(sum(interpolatedlookup(bar, 0.25)))))");
assertParse("all(group(foo) each(output(sum(array.at(bar, 42.0)))))",
- "all(group(foo) each(output(sum(array.at(bar, 42.0)))))");
+ "all(group(foo) each(output(sum(array.at(bar, 42.0)))))");
}
@Test
- public void requireThatTokenImagesAreNotReservedWords() {
+ void requireThatTokenImagesAreNotReservedWords() {
List<String> images = Arrays.asList("acos",
- "acosh",
- "accuracy",
- "add",
- "alias",
- "all",
- "and",
- "array",
- "as",
- "at",
- "asin",
- "asinh",
- "atan",
- "atanh",
- "attribute",
- "avg",
- "bucket",
- "cat",
- "cbrt",
- "cos",
- "cosh",
- "count",
- "debugwait",
- "div",
- "docidnsspecific",
- "each",
- "exp",
- "fixedwidth",
- "floor",
- "group",
- "hint",
- "hypot",
- "log",
- "log1p",
- "log10",
- "math",
- "max",
- "md5",
- "min",
- "mod",
- "mul",
- "neg",
- "normalizesubject",
- "now",
- "or",
- "order",
- "output",
- "pow",
- "precision",
- "predefined",
- "relevance",
- "reverse",
- "sin",
- "sinh",
- "size",
- "sort",
- "stddev",
- "interpolatedlookup",
- "sqrt",
- "strcat",
- "strlen",
- "sub",
- "sum",
- "summary",
- "tan",
- "tanh",
- "time",
- "date",
- "dayofmonth",
- "dayofweek",
- "dayofyear",
- "hourofday",
- "minuteofhour",
- "monthofyear",
- "secondofminute",
- "year",
- "todouble",
- "tolong",
- "toraw",
- "tostring",
- "true",
- "false",
- "uca",
- "where",
- "x",
- "xor",
- "xorbit",
- "y",
- "zcurve");
+ "acosh",
+ "accuracy",
+ "add",
+ "alias",
+ "all",
+ "and",
+ "array",
+ "as",
+ "at",
+ "asin",
+ "asinh",
+ "atan",
+ "atanh",
+ "attribute",
+ "avg",
+ "bucket",
+ "cat",
+ "cbrt",
+ "cos",
+ "cosh",
+ "count",
+ "debugwait",
+ "div",
+ "docidnsspecific",
+ "each",
+ "exp",
+ "fixedwidth",
+ "floor",
+ "group",
+ "hint",
+ "hypot",
+ "log",
+ "log1p",
+ "log10",
+ "math",
+ "max",
+ "md5",
+ "min",
+ "mod",
+ "mul",
+ "neg",
+ "normalizesubject",
+ "now",
+ "or",
+ "order",
+ "output",
+ "pow",
+ "precision",
+ "predefined",
+ "relevance",
+ "reverse",
+ "sin",
+ "sinh",
+ "size",
+ "sort",
+ "stddev",
+ "interpolatedlookup",
+ "sqrt",
+ "strcat",
+ "strlen",
+ "sub",
+ "sum",
+ "summary",
+ "tan",
+ "tanh",
+ "time",
+ "date",
+ "dayofmonth",
+ "dayofweek",
+ "dayofyear",
+ "hourofday",
+ "minuteofhour",
+ "monthofyear",
+ "secondofminute",
+ "year",
+ "todouble",
+ "tolong",
+ "toraw",
+ "tostring",
+ "true",
+ "false",
+ "uca",
+ "where",
+ "x",
+ "xor",
+ "xorbit",
+ "y",
+ "zcurve");
for (String image : images) {
assertParse("all(group(" + image + "))", "all(group(" + image + "))");
}
}
@Test
- public void testTokenizedWhitespace() {
+ void testTokenizedWhitespace() {
String expected = "all(group(foo) each(output(max(bar))))";
assertParse(" all(group(foo)each(output(max(bar))))", expected);
@@ -182,7 +178,7 @@ public class GroupingParserTestCase {
}
@Test
- public void testOperationTypes() {
+ void testOperationTypes() {
assertParse("all()");
assertParse("each()");
assertParse("all(each())");
@@ -193,21 +189,21 @@ public class GroupingParserTestCase {
assertParse("all(each() each())");
assertParse("each(all() all())");
assertIllegalArgument("each(all() each())",
- "Operation 'each()' can not operate on single hit.");
+ "Operation 'each()' can not operate on single hit.");
assertIllegalArgument("each(group(foo) all() each())",
- "Operation 'each(group(foo) all() each())' can not group single hit.");
+ "Operation 'each(group(foo) all() each())' can not group single hit.");
assertIllegalArgument("each(each() all())",
- "Operation 'each()' can not operate on single hit.");
+ "Operation 'each()' can not operate on single hit.");
assertIllegalArgument("each(group(foo) each() all())",
- "Operation 'each(group(foo) each() all())' can not group single hit.");
+ "Operation 'each(group(foo) each() all())' can not group single hit.");
assertIllegalArgument("each(each() each())",
- "Operation 'each()' can not operate on single hit.");
+ "Operation 'each()' can not operate on single hit.");
assertIllegalArgument("each(group(foo) each() each())",
- "Operation 'each(group(foo) each() each())' can not group single hit.");
+ "Operation 'each(group(foo) each() each())' can not group single hit.");
}
@Test
- public void testOperationParts() {
+ void testOperationParts() {
assertParse("all(group(foo))");
assertParse("all(hint(foo))");
assertParse("all(hint(foo) hint(bar))");
@@ -232,7 +228,7 @@ public class GroupingParserTestCase {
}
@Test
- public void testComplexExpressionTypes() {
+ void testComplexExpressionTypes() {
// fixedwidth
assertParse("all(group(fixedwidth(foo, 1)))");
assertParse("all(group(fixedwidth(foo, 1.2)))");
@@ -315,43 +311,43 @@ public class GroupingParserTestCase {
assertParse("all(group(predefined(foo, bucket({'b', 'a'}, {'k', 'a'}), bucket({'k', 'a'}, {'u', 'b'}))))");
assertIllegalArgument("all(group(predefined(foo, bucket(1, 2.0))))",
- "Bucket type mismatch, expected 'LongValue' got 'DoubleValue'.");
+ "Bucket type mismatch, expected 'LongValue' got 'DoubleValue'.");
assertIllegalArgument("all(group(predefined(foo, bucket(1, '2'))))",
- "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
+ "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
assertIllegalArgument("all(group(predefined(foo, bucket(1, 2), bucket(3.0, 4.0))))",
- "Bucket type mismatch, expected 'LongValue' got 'DoubleValue'.");
+ "Bucket type mismatch, expected 'LongValue' got 'DoubleValue'.");
assertIllegalArgument("all(group(predefined(foo, bucket(1, 2), bucket('3', '4'))))",
- "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
+ "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
assertIllegalArgument("all(group(predefined(foo, bucket(1, 2), bucket(\"3\", \"4\"))))",
- "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
+ "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
assertIllegalArgument("all(group(predefined(foo, bucket(1, 2), bucket(three, four))))",
- "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
+ "Bucket type mismatch, expected 'LongValue' got 'StringValue'.");
assertIllegalArgument("all(group(predefined(foo, bucket<-inf, inf>)))",
- "Bucket type mismatch, cannot both be infinity");
+ "Bucket type mismatch, cannot both be infinity");
assertIllegalArgument("all(group(predefined(foo, bucket<inf, -inf>)))",
- "Encountered \" \"inf\" \"inf\"\" at line 1, column 34.");
+ "Encountered \" \"inf\" \"inf\"\" at line 1, column 34.");
assertIllegalArgument("all(group(predefined(foo, bucket(2, 1))))",
- "Bucket to-value can not be less than from-value.");
+ "Bucket to-value can not be less than from-value.");
assertIllegalArgument("all(group(predefined(foo, bucket(3, 4), bucket(1, 2))))",
- "Buckets must be monotonically increasing, got bucket[3, 4> before bucket[1, 2>.");
+ "Buckets must be monotonically increasing, got bucket[3, 4> before bucket[1, 2>.");
assertIllegalArgument("all(group(predefined(foo, bucket(b, a))))",
- "Bucket to-value can not be less than from-value.");
+ "Bucket to-value can not be less than from-value.");
assertIllegalArgument("all(group(predefined(foo, bucket(b, -inf))))",
- "Encountered \" \"-inf\" \"-inf\"\" at line 1, column 37.");
+ "Encountered \" \"-inf\" \"-inf\"\" at line 1, column 37.");
assertIllegalArgument("all(group(predefined(foo, bucket(c, d), bucket(a, b))))",
- "Buckets must be monotonically increasing, got bucket[\"c\", \"d\"> before bucket[\"a\", \"b\">.");
+ "Buckets must be monotonically increasing, got bucket[\"c\", \"d\"> before bucket[\"a\", \"b\">.");
assertIllegalArgument("all(group(predefined(foo, bucket(c, d), bucket(-inf, e))))",
- "Buckets must be monotonically increasing, got bucket[\"c\", \"d\"> before bucket[-inf, \"e\">.");
+ "Buckets must be monotonically increasing, got bucket[\"c\", \"d\"> before bucket[-inf, \"e\">.");
assertIllegalArgument("all(group(predefined(foo, bucket(u, inf), bucket(e, i))))",
- "Buckets must be monotonically increasing, got bucket[\"u\", inf> before bucket[\"e\", \"i\">.");
+ "Buckets must be monotonically increasing, got bucket[\"u\", inf> before bucket[\"e\", \"i\">.");
// xorbit
assertParse("all(group(xorbit(foo, 1)))");
}
@Test
- public void testInfixArithmetic() {
+ void testInfixArithmetic() {
assertParse("all(group(1))", "all(group(1))");
assertParse("all(group(1+2))", "all(group(add(1, 2)))");
assertParse("all(group(1-2))", "all(group(sub(1, 2)))");
@@ -371,16 +367,16 @@ public class GroupingParserTestCase {
}
@Test
- public void testOperationLabel() {
+ void testOperationLabel() {
assertParse("each() as(foo)",
- "each() as(foo)");
+ "each() as(foo)");
assertParse("all(each() as(foo)" +
- " each() as(bar))",
- "all(each() as(foo) each() as(bar))");
+ " each() as(bar))",
+ "all(each() as(foo) each() as(bar))");
assertParse("all(group(a) each(each() as(foo)" +
- " each() as(bar))" +
- " each() as(baz))",
- "all(group(a) each(each() as(foo) each() as(bar)) each() as(baz))");
+ " each() as(bar))" +
+ " each() as(baz))",
+ "all(group(a) each(each() as(foo) each() as(bar)) each() as(baz))");
assertIllegalArgument("all() as(foo)", "Encountered \" \"as\" \"as\"\" at line 1, column 7.");
assertIllegalArgument("all(all() as(foo))", "Encountered \" \"as\" \"as\"\" at line 1, column 11.");
@@ -388,58 +384,58 @@ public class GroupingParserTestCase {
}
@Test
- public void testAttributeName() {
+ void testAttributeName() {
assertParse("all(group(foo))");
assertIllegalArgument("all(group(foo.))",
- "Encountered \" \")\" \")\"\" at line 1, column 15.");
+ "Encountered \" \")\" \")\"\" at line 1, column 15.");
assertParse("all(group(foo.bar))");
assertIllegalArgument("all(group(foo.bar.))",
- "Encountered \" \")\" \")\"\" at line 1, column 19.");
+ "Encountered \" \")\" \")\"\" at line 1, column 19.");
assertParse("all(group(foo.bar.baz))");
}
@Test
- public void testOutputLabel() {
+ void testOutputLabel() {
assertParse("all(output(min(a) as(foo)))",
- "all(output(min(a) as(foo)))");
+ "all(output(min(a) as(foo)))");
assertParse("all(output(min(a) as(foo), max(b) as(bar)))",
- "all(output(min(a) as(foo), max(b) as(bar)))");
+ "all(output(min(a) as(foo), max(b) as(bar)))");
assertIllegalArgument("all(output(min(a)) as(foo))",
- "Encountered \" \"as\" \"as\"\" at line 1, column 20.");
+ "Encountered \" \"as\" \"as\"\" at line 1, column 20.");
}
@Test
- public void testRootWhere() {
+ void testRootWhere() {
String expected = "all(where(bar) all(group(foo)))";
assertParse("all(where(bar) all(group(foo)))", expected);
assertParse("all(group(foo)) where(bar)", expected);
}
@Test
- public void testParseBadRequest() {
+ void testParseBadRequest() {
assertIllegalArgument("output(count())",
- "Encountered \" \"output\" \"output\"\" at line 1, column 1.");
+ "Encountered \" \"output\" \"output\"\" at line 1, column 1.");
assertIllegalArgument("each(output(count()))",
- "Expression 'count()' not applicable for single hit.");
+ "Expression 'count()' not applicable for single hit.");
assertIllegalArgument("all(output(count())))",
- "Encountered \" \")\" \")\"\" at line 1, column 21.");
+ "Encountered \" \")\" \")\"\" at line 1, column 21.");
}
@Test
- public void testAttributeFunction() {
+ void testAttributeFunction() {
assertParse("all(group(attribute(foo)))");
assertParse("all(group(attribute(foo)) order(sum(attribute(a))))");
}
@Test
- public void testAccuracy() {
+ void testAccuracy() {
assertParse("all(accuracy(0.5))");
assertParse("all(group(foo) accuracy(1.0))");
}
@Test
- public void testMapSyntax() {
+ void testMapSyntax() {
assertParse("all(group(my.little{key}))", "all(group(my.little{\"key\"}))");
assertParse("all(group(my.little{key }))", "all(group(my.little{\"key\"}))");
assertParse("all(group(my.little{\"key\"}))", "all(group(my.little{\"key\"}))");
@@ -458,7 +454,7 @@ public class GroupingParserTestCase {
}
@Test
- public void testMapSyntaxWithKeySourceAttribute() {
+ void testMapSyntaxWithKeySourceAttribute() {
assertAttributeMapLookup("all(group(my_map{attribute(my_attr)}))",
"my_map.key", "my_map.value", "", "my_attr");
assertAttributeMapLookup("all(group(my_map{attribute(my_attr)}.name))",
@@ -487,7 +483,7 @@ public class GroupingParserTestCase {
}
@Test
- public void testMisc() {
+ void testMisc() {
for (String fnc : Arrays.asList("time.date",
"time.dayofmonth",
"time.dayofweek",
@@ -536,39 +532,39 @@ public class GroupingParserTestCase {
// TODO: assertParseRequest("all(group(a) each(output(xor(xorbit(b)) xor(xorbit(b, 64)))))");
assertParse("all(group(artist) each(each(output(summary()))))");
assertParse("all(group(artist) max(13) each(group(fixedwidth(year, 21.34)) max(55) output(count()) " +
- "each(each(output(summary())))))");
+ "each(each(output(summary())))))");
assertParse("all(group(artist) max(13) each(group(predefined(year, bucket(7, 19), bucket(90, 300))) " +
- "max(55) output(count()) each(each(output(summary())))))");
+ "max(55) output(count()) each(each(output(summary())))))");
assertParse("all(group(artist) max(13) each(group(predefined(year, bucket(7.1, 19.0), bucket(90.7, 300.0))) " +
- "max(55) output(count()) each(each(output(summary())))))");
+ "max(55) output(count()) each(each(output(summary())))))");
assertParse("all(group(artist) max(13) each(group(predefined(year, bucket('a', 'b'), bucket('cd'))) " +
- "max(55) output(count()) each(each(output(summary())))))");
+ "max(55) output(count()) each(each(output(summary())))))");
assertParse("all(output(count()))");
assertParse("all(group(album) output(count()))");
assertParse("all(group(album) each(output(count())))");
assertParse("all(group(artist) each(group(album) output(count()))" +
- " each(group(song) output(count())))");
+ " each(group(song) output(count())))");
assertParse("all(group(artist) output(count())" +
- " each(group(album) output(count())" +
- " each(group(song) output(count())" +
- " each(each(output(summary()))))))");
+ " each(group(album) output(count())" +
+ " each(group(song) output(count())" +
+ " each(each(output(summary()))))))");
assertParse("all(group(album) order(-$total=sum(length)) each(output($total)))");
assertParse("all(group(album) max(1) each(output(sum(length))))");
assertParse("all(group(artist) each(max(2) each(output(summary()))))");
assertParse("all(group(artist) max(3)" +
- " each(group(album as(albumsongs)) each(each(output(summary()))))" +
- " each(group(album as(albumlength)) output(sum(sum(length)))))");
+ " each(group(album as(albumsongs)) each(each(output(summary()))))" +
+ " each(group(album as(albumlength)) output(sum(sum(length)))))");
assertParse("all(group(artist) max(15)" +
- " each(group(album) " +
- " each(group(song)" +
- " each(max(2) each(output(summary()))))))");
+ " each(group(album) " +
+ " each(group(song)" +
+ " each(max(2) each(output(summary()))))))");
assertParse("all(group(artist) max(15)" +
- " each(group(album)" +
- " each(group(song)" +
- " each(max(2) each(output(summary())))))" +
- " each(group(song) max(5) order(sum(popularity))" +
- " each(output(sum(sold)) each(output(summary())))))");
+ " each(group(album)" +
+ " each(group(song)" +
+ " each(max(2) each(output(summary())))))" +
+ " each(group(song) max(5) order(sum(popularity))" +
+ " each(output(sum(sold)) each(output(summary())))))");
assertParse("all(group(artist) order(max(relevance) * count()) each(output(count())))");
assertParse("all(group(artist) each(output(sum(popularity) / count())))");
@@ -576,9 +572,9 @@ public class GroupingParserTestCase {
assertParse("all(group(debugwait(artist, 3.3, true)))");
assertParse("all(group(debugwait(artist, 3.3, false)))");
assertIllegalArgument("all(group(debugwait(artist, -3.3, true)))",
- "Encountered \" \"-\" \"-\"\" at line 1, column 29");
+ "Encountered \" \"-\" \"-\"\" at line 1, column 29");
assertIllegalArgument("all(group(debugwait(artist, 3.3, lol)))",
- "Encountered \" <IDENTIFIER> \"lol\"\" at line 1, column 34");
+ "Encountered \" <IDENTIFIER> \"lol\"\" at line 1, column 34");
assertParse("all(group(artist) each(output(stddev(simple))))");
// Test max()
@@ -588,35 +584,35 @@ public class GroupingParserTestCase {
}
@Test
- public void testBucket() {
+ void testBucket() {
List<GroupingOperation> operations = assertParse("all(group(predefined(artist, bucket('a'), bucket('c', 'z'))))");
assertEquals(1, operations.size());
assertEquals("all(group(predefined(artist, bucket[\"a\", \"a \">, bucket[\"c\", \"z\">)))",
- operations.get(0).toString());
+ operations.get(0).toString());
}
@Test
- public void requireThatParseExceptionMessagesContainErrorMarker() {
+ void requireThatParseExceptionMessagesContainErrorMarker() {
assertIllegalArgument("foo",
- "Encountered \" <IDENTIFIER> \"foo\"\" at line 1, column 1.\n\n" +
- "Was expecting one of:\n\n" +
- "<SPACE> ...\n" +
- " \"all\" ...\n" +
- " \"each\" ...\n" +
- " \n" +
- "At position:\n" +
- "foo\n" +
- "^");
+ "Encountered \" <IDENTIFIER> \"foo\"\" at line 1, column 1.\n\n" +
+ "Was expecting one of:\n\n" +
+ "<SPACE> ...\n" +
+ " \"all\" ...\n" +
+ " \"each\" ...\n" +
+ " \n" +
+ "At position:\n" +
+ "foo\n" +
+ "^");
assertIllegalArgument("\n foo",
- "Encountered \" <IDENTIFIER> \"foo\"\" at line 2, column 2.\n\n" +
- "Was expecting one of:\n\n" +
- "<SPACE> ...\n" +
- " \"all\" ...\n" +
- " \"each\" ...\n" +
- " \n" +
- "At position:\n" +
- " foo\n" +
- " ^");
+ "Encountered \" <IDENTIFIER> \"foo\"\" at line 2, column 2.\n\n" +
+ "Was expecting one of:\n\n" +
+ "<SPACE> ...\n" +
+ " \"all\" ...\n" +
+ " \"each\" ...\n" +
+ " \n" +
+ "At position:\n" +
+ " foo\n" +
+ " ^");
}
// --------------------------------------------------------------------------------
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/result/FlatteningSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/result/FlatteningSearcherTestCase.java
index c97bf150645..3e1cff54737 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/result/FlatteningSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/result/FlatteningSearcherTestCase.java
@@ -23,15 +23,15 @@ import com.yahoo.searchlib.aggregation.Grouping;
import com.yahoo.searchlib.aggregation.HitsAggregationResult;
import com.yahoo.searchlib.aggregation.hll.SparseSketch;
import com.yahoo.searchlib.expression.StringResultNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -39,42 +39,42 @@ import static org.junit.Assert.assertTrue;
public class FlatteningSearcherTestCase {
@Test
- public void testFlatteningSearcher() {
+ void testFlatteningSearcher() {
Query query = new Query("?query=test");
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) output(count()) each(each(output(summary(bar)))))"));
Grouping group0 = new Grouping(0);
group0.setRoot(new Group()
- .addAggregationResult(new ExpressionCountAggregationResult(new SparseSketch(), sketch -> 69))
- .addChild(new Group().setId(new StringResultNode("unique1"))
- .addAggregationResult(new HitsAggregationResult(3, "bar")
- )
- )
- .addChild(new Group().setId(new StringResultNode("unique2"))
- .addAggregationResult(new HitsAggregationResult(3, "bar")
- )
- ));
+ .addAggregationResult(new ExpressionCountAggregationResult(new SparseSketch(), sketch -> 69))
+ .addChild(new Group().setId(new StringResultNode("unique1"))
+ .addAggregationResult(new HitsAggregationResult(3, "bar")
+ )
+ )
+ .addChild(new Group().setId(new StringResultNode("unique2"))
+ .addAggregationResult(new HitsAggregationResult(3, "bar")
+ )
+ ));
Grouping group1 = new Grouping(0);
group1.setRoot(new Group()
- .addChild(new Group().setId(new StringResultNode("unique1"))
- .addAggregationResult(new HitsAggregationResult(3, "bar")
- .addHit(fs4Hit(0.7))
- .addHit(fs4Hit(0.6))
- .addHit(fs4Hit(0.3))
- )
- )
- .addChild(new Group().setId(new StringResultNode("unique2"))
- .addAggregationResult(new HitsAggregationResult(3, "bar")
- .addHit(fs4Hit(0.5))
- .addHit(fs4Hit(0.4))
- )
- ));
+ .addChild(new Group().setId(new StringResultNode("unique1"))
+ .addAggregationResult(new HitsAggregationResult(3, "bar")
+ .addHit(fs4Hit(0.7))
+ .addHit(fs4Hit(0.6))
+ .addHit(fs4Hit(0.3))
+ )
+ )
+ .addChild(new Group().setId(new StringResultNode("unique2"))
+ .addAggregationResult(new HitsAggregationResult(3, "bar")
+ .addHit(fs4Hit(0.5))
+ .addHit(fs4Hit(0.4))
+ )
+ ));
Execution execution = newExecution(new FlatteningSearcher(),
- new GroupingExecutor(ComponentId.fromString("grouping")),
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(group0), null),
- new GroupingListHit(List.of(group1), null))));
+ new GroupingExecutor(ComponentId.fromString("grouping")),
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(group0), null),
+ new GroupingListHit(List.of(group1), null))));
Result result = execution.search(query);
assertEquals(5, result.hits().size());
assertFlat(result);
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/result/GroupIdTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/result/GroupIdTestCase.java
index 01eba55924f..7b2f0d52742 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/result/GroupIdTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/result/GroupIdTestCase.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.result;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -11,7 +11,7 @@ import static org.junit.Assert.*;
public class GroupIdTestCase {
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
ValueGroupId valueId = new DoubleId(6.9);
assertEquals(6.9, valueId.getValue());
BucketGroupId rangeId = new DoubleBucketId(6.0, 9.0);
@@ -24,11 +24,11 @@ public class GroupIdTestCase {
assertEquals(6L, rangeId.getFrom());
assertEquals(9L, rangeId.getTo());
- valueId = new RawId(new byte[] { 6, 9 });
- assertArrayEquals(new byte[] { 6, 9 }, (byte[])valueId.getValue());
- rangeId = new RawBucketId(new byte[] { 6, 9 }, new byte[] { 9, 6 });
- assertArrayEquals(new byte[] { 6, 9 }, (byte[])rangeId.getFrom());
- assertArrayEquals(new byte[] { 9, 6 }, (byte[])rangeId.getTo());
+ valueId = new RawId(new byte[]{6, 9});
+ assertArrayEquals(new byte[]{6, 9}, (byte[]) valueId.getValue());
+ rangeId = new RawBucketId(new byte[]{6, 9}, new byte[]{9, 6});
+ assertArrayEquals(new byte[]{6, 9}, (byte[]) rangeId.getFrom());
+ assertArrayEquals(new byte[]{9, 6}, (byte[]) rangeId.getTo());
valueId = new StringId("69");
assertEquals("69", valueId.getValue());
@@ -41,14 +41,14 @@ public class GroupIdTestCase {
}
@Test
- public void requireThatToStringCorrespondsToType() {
+ void requireThatToStringCorrespondsToType() {
assertEquals("group:double:6.9", new DoubleId(6.9).toString());
assertEquals("group:double_bucket:6.0:9.0", new DoubleBucketId(6.0, 9.0).toString());
assertEquals("group:long:69", new LongId(69L).toString());
assertEquals("group:long_bucket:6:9", new LongBucketId(6L, 9L).toString());
assertEquals("group:null", new NullId().toString());
- assertEquals("group:raw:[6, 9]", new RawId(new byte[] { 6, 9 }).toString());
- assertEquals("group:raw_bucket:[6, 9]:[9, 6]", new RawBucketId(new byte[] { 6, 9 }, new byte[] { 9, 6 }).toString());
+ assertEquals("group:raw:[6, 9]", new RawId(new byte[]{6, 9}).toString());
+ assertEquals("group:raw_bucket:[6, 9]:[9, 6]", new RawBucketId(new byte[]{6, 9}, new byte[]{9, 6}).toString());
assertTrue(new RootId(0).toString().startsWith("group:root:"));
assertEquals("group:string:69", new StringId("69").toString());
assertEquals("group:string_bucket:6:9", new StringBucketId("6", "9").toString());
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.java
index 33e8f119ec9..3c583c88d5a 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/result/GroupListTestCase.java
@@ -2,10 +2,10 @@
package com.yahoo.search.grouping.result;
import com.yahoo.search.grouping.Continuation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* @author Simon Thoresen Hult
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertSame;
public class GroupListTestCase {
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
GroupList lst = new GroupList("foo");
assertEquals("foo", lst.getLabel());
assertEquals(0, lst.continuations().size());
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/result/GroupTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/result/GroupTestCase.java
index 47f82205689..4e359531b7a 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/result/GroupTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/result/GroupTestCase.java
@@ -3,10 +3,10 @@ package com.yahoo.search.grouping.result;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.Relevance;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author Simon Thoresen Hult
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertNull;
public class GroupTestCase {
@Test
- public void requireThatListsAreAccessibleByLabel() {
+ void requireThatListsAreAccessibleByLabel() {
Group grp = new Group(new LongId(69L), new Relevance(1));
grp.add(new Hit("hit"));
grp.add(new HitList("hitList"));
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/result/HitListTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/result/HitListTestCase.java
index 2404af09c7a..5f1d2d3f125 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/result/HitListTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/result/HitListTestCase.java
@@ -2,10 +2,10 @@
package com.yahoo.search.grouping.result;
import com.yahoo.search.grouping.Continuation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* @author Simon Thoresen Hult
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertSame;
public class HitListTestCase {
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
HitList lst = new HitList("foo");
assertEquals("foo", lst.getLabel());
assertEquals(0, lst.continuations().size());
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/result/HitRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/result/HitRendererTestCase.java
index 1035c9d9284..8e98f49df48 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/result/HitRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/result/HitRendererTestCase.java
@@ -6,13 +6,13 @@ import com.yahoo.search.result.HitGroup;
import com.yahoo.search.result.Relevance;
import com.yahoo.text.Utf8;
import com.yahoo.text.XMLWriter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -20,7 +20,7 @@ import static org.junit.Assert.fail;
public class HitRendererTestCase {
@Test
- public void requireThatGroupListsRenderAsExpected() {
+ void requireThatGroupListsRenderAsExpected() {
assertRender(new GroupList("foo"), "<grouplist label=\"foo\"></grouplist>\n");
assertRender(new GroupList("b\u00e6z"), "<grouplist label=\"b\u00e6z\"></grouplist>\n");
@@ -28,21 +28,21 @@ public class HitRendererTestCase {
lst.continuations().put("bar.key", new MyContinuation("bar.val"));
lst.continuations().put("baz.key", new MyContinuation("baz.val"));
assertRender(lst, "<grouplist label=\"foo\">\n" +
- "<continuation id=\"bar.key\">bar.val</continuation>\n" +
- "<continuation id=\"baz.key\">baz.val</continuation>\n" +
- "</grouplist>\n");
+ "<continuation id=\"bar.key\">bar.val</continuation>\n" +
+ "<continuation id=\"baz.key\">baz.val</continuation>\n" +
+ "</grouplist>\n");
}
@Test
- public void requireThatGroupIdsRenderAsExpected() {
+ void requireThatGroupIdsRenderAsExpected() {
assertRender(newGroup(new DoubleId(6.9)),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"double\">6.9</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"double\">6.9</id>\n" +
+ "</group>\n");
assertRender(newGroup(new LongId(69L)),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"long\">69</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"long\">69</id>\n" +
+ "</group>\n");
assertRender(newGroup(new BoolId(true)),
"<group relevance=\"1.0\">\n" +
"<id type=\"bool\">true</id>\n" +
@@ -52,89 +52,89 @@ public class HitRendererTestCase {
"<id type=\"bool\">false</id>\n" +
"</group>\n");
assertRender(newGroup(new NullId()),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"null\"/>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"null\"/>\n" +
+ "</group>\n");
assertRender(newGroup(new RawId(Utf8.toBytes("foo"))),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"raw\">[102, 111, 111]</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"raw\">[102, 111, 111]</id>\n" +
+ "</group>\n");
assertRender(newGroup(new StringId("foo")),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"string\">foo</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"string\">foo</id>\n" +
+ "</group>\n");
assertRender(newGroup(new StringId("b\u00e6z")),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"string\">b\u00e6z</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"string\">b\u00e6z</id>\n" +
+ "</group>\n");
assertRender(newGroup(new DoubleBucketId(6.9, 9.6)),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"double_bucket\">\n<from>6.9</from>\n<to>9.6</to>\n</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"double_bucket\">\n<from>6.9</from>\n<to>9.6</to>\n</id>\n" +
+ "</group>\n");
assertRender(newGroup(new LongBucketId(6L, 9L)),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"long_bucket\">\n<from>6</from>\n<to>9</to>\n</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"long_bucket\">\n<from>6</from>\n<to>9</to>\n</id>\n" +
+ "</group>\n");
assertRender(newGroup(new StringBucketId("bar", "baz")),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"string_bucket\">\n<from>bar</from>\n<to>baz</to>\n</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"string_bucket\">\n<from>bar</from>\n<to>baz</to>\n</id>\n" +
+ "</group>\n");
assertRender(newGroup(new StringBucketId("b\u00e6r", "b\u00e6z")),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"string_bucket\">\n<from>b\u00e6r</from>\n<to>b\u00e6z</to>\n</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"string_bucket\">\n<from>b\u00e6r</from>\n<to>b\u00e6z</to>\n</id>\n" +
+ "</group>\n");
assertRender(newGroup(new RawBucketId(Utf8.toBytes("bar"), Utf8.toBytes("baz"))),
- "<group relevance=\"1.0\">\n" +
- "<id type=\"raw_bucket\">\n<from>[98, 97, 114]</from>\n<to>[98, 97, 122]</to>\n</id>\n" +
- "</group>\n");
+ "<group relevance=\"1.0\">\n" +
+ "<id type=\"raw_bucket\">\n<from>[98, 97, 114]</from>\n<to>[98, 97, 122]</to>\n</id>\n" +
+ "</group>\n");
}
@Test
- public void requireThatGroupsRenderAsExpected() {
+ void requireThatGroupsRenderAsExpected() {
Group group = newGroup(new StringId("foo"));
group.setField("foo", "bar");
group.setField("baz", "cox");
assertRender(group, "<group relevance=\"1.0\">\n" +
- "<id type=\"string\">foo</id>\n" +
- "<output label=\"foo\">bar</output>\n" +
- "<output label=\"baz\">cox</output>\n" +
- "</group>\n");
+ "<id type=\"string\">foo</id>\n" +
+ "<output label=\"foo\">bar</output>\n" +
+ "<output label=\"baz\">cox</output>\n" +
+ "</group>\n");
group = newGroup(new StringId("foo"));
group.setField("foo", "b\u00e6r");
group.setField("b\u00e5z", "cox");
assertRender(group, "<group relevance=\"1.0\">\n" +
- "<id type=\"string\">foo</id>\n" +
- "<output label=\"foo\">b\u00e6r</output>\n" +
- "<output label=\"b\u00e5z\">cox</output>\n" +
- "</group>\n");
+ "<id type=\"string\">foo</id>\n" +
+ "<output label=\"foo\">b\u00e6r</output>\n" +
+ "<output label=\"b\u00e5z\">cox</output>\n" +
+ "</group>\n");
}
@Test
- public void requireThatRootGroupsRenderAsExpected() {
+ void requireThatRootGroupsRenderAsExpected() {
RootGroup group = new RootGroup(0, new MyContinuation("69"));
group.setField("foo", "bar");
group.setField("baz", "cox");
assertRender(group, "<group relevance=\"1.0\">\n" +
- "<id type=\"root\"/>\n" +
- "<continuation id=\"this\">69</continuation>\n" +
- "<output label=\"foo\">bar</output>\n" +
- "<output label=\"baz\">cox</output>\n" +
- "</group>\n");
+ "<id type=\"root\"/>\n" +
+ "<continuation id=\"this\">69</continuation>\n" +
+ "<output label=\"foo\">bar</output>\n" +
+ "<output label=\"baz\">cox</output>\n" +
+ "</group>\n");
group = new RootGroup(0, new MyContinuation("96"));
group.setField("foo", "b\u00e6r");
group.setField("b\u00e5z", "cox");
assertRender(group, "<group relevance=\"1.0\">\n" +
- "<id type=\"root\"/>\n" +
- "<continuation id=\"this\">96</continuation>\n" +
- "<output label=\"foo\">b\u00e6r</output>\n" +
- "<output label=\"b\u00e5z\">cox</output>\n" +
- "</group>\n");
+ "<id type=\"root\"/>\n" +
+ "<continuation id=\"this\">96</continuation>\n" +
+ "<output label=\"foo\">b\u00e6r</output>\n" +
+ "<output label=\"b\u00e5z\">cox</output>\n" +
+ "</group>\n");
}
@Test
- public void requireThatHitListsRenderAsExpected() {
+ void requireThatHitListsRenderAsExpected() {
assertRender(new HitList("foo"), "<hitlist label=\"foo\"></hitlist>\n");
assertRender(new HitList("b\u00e6z"), "<hitlist label=\"b\u00e6z\"></hitlist>\n");
@@ -142,10 +142,10 @@ public class HitRendererTestCase {
lst.continuations().put("bar.key", new MyContinuation("bar.val"));
lst.continuations().put("baz.key", new MyContinuation("baz.val"));
assertRender(lst, "<hitlist label=\"foo\">\n" +
- "<continuation id=\"bar.key\">bar.val</continuation>\n" +
- "<continuation id=\"baz.key\">baz.val</continuation>\n" +
- "</hitlist>\n");
-}
+ "<continuation id=\"bar.key\">bar.val</continuation>\n" +
+ "<continuation id=\"baz.key\">baz.val</continuation>\n" +
+ "</hitlist>\n");
+ }
private static Group newGroup(GroupId id) {
return new Group(id, new Relevance(1));
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/CompositeContinuationTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/CompositeContinuationTestCase.java
index a440fcaac7a..ee177709b59 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/CompositeContinuationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/CompositeContinuationTestCase.java
@@ -2,11 +2,11 @@
package com.yahoo.search.grouping.vespa;
import com.yahoo.search.grouping.Continuation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Iterator;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -14,7 +14,7 @@ import static org.junit.Assert.*;
public class CompositeContinuationTestCase {
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
CompositeContinuation cnt = new CompositeContinuation();
Iterator<EncodableContinuation> it = cnt.iterator();
assertFalse(it.hasNext());
@@ -37,51 +37,51 @@ public class CompositeContinuationTestCase {
}
@Test
- public void requireThatCompositeContinuationsAreFlattened() {
+ void requireThatCompositeContinuationsAreFlattened() {
assertEncode("BCBCBCBEBGBCBKCBACBKCCK",
- newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21)));
+ newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21)));
assertEncode("BCBBBBBDBFBCBJBPCBJCCJ",
- newComposite(newComposite(newOffset(-1, -1, -2, -3)), newComposite(newOffset(-5, -8, -13, -21))));
+ newComposite(newComposite(newOffset(-1, -1, -2, -3)), newComposite(newOffset(-5, -8, -13, -21))));
}
@Test
- public void requireThatEmptyStringCanBeDecoded() {
+ void requireThatEmptyStringCanBeDecoded() {
assertDecode("", new CompositeContinuation());
}
@Test
- public void requireThatCompositeContinuationsCanBeDecoded() {
+ void requireThatCompositeContinuationsCanBeDecoded() {
assertDecode("BCBCBCBEBGBCBKCBACBKCCK",
- newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21)));
+ newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21)));
assertDecode("BCBBBBBDBFBCBJBPCBJCCJ",
- newComposite(newOffset(-1, -1, -2, -3), newOffset(-5, -8, -13, -21)));
+ newComposite(newOffset(-1, -1, -2, -3), newOffset(-5, -8, -13, -21)));
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(newComposite().hashCode(), newComposite().hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
CompositeContinuation cnt = newComposite();
- assertFalse(cnt.equals(new Object()));
+ assertNotEquals(cnt, new Object());
assertEquals(cnt, newComposite());
- assertFalse(cnt.equals(newComposite(newOffset(1, 1, 2, 3))));
- assertFalse(cnt.equals(newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21))));
- assertFalse(cnt.equals(newComposite(newOffset(5, 8, 13, 21))));
+ assertNotEquals(cnt, newComposite(newOffset(1, 1, 2, 3)));
+ assertNotEquals(cnt, newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21)));
+ assertNotEquals(cnt, newComposite(newOffset(5, 8, 13, 21)));
cnt = newComposite(newOffset(1, 1, 2, 3));
- assertFalse(cnt.equals(new Object()));
+ assertNotEquals(cnt, new Object());
assertEquals(cnt, newComposite(newOffset(1, 1, 2, 3)));
- assertFalse(cnt.equals(newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21))));
- assertFalse(cnt.equals(newComposite(newOffset(5, 8, 13, 21))));
+ assertNotEquals(cnt, newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21)));
+ assertNotEquals(cnt, newComposite(newOffset(5, 8, 13, 21)));
cnt = newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21));
- assertFalse(cnt.equals(new Object()));
- assertFalse(cnt.equals(newComposite(newOffset(1, 1, 2, 3))));
+ assertNotEquals(cnt, new Object());
+ assertNotEquals(cnt, newComposite(newOffset(1, 1, 2, 3)));
assertEquals(cnt, newComposite(newOffset(1, 1, 2, 3), newOffset(5, 8, 13, 21)));
- assertFalse(cnt.equals(newComposite(newOffset(5, 8, 13, 21))));
+ assertNotEquals(cnt, newComposite(newOffset(5, 8, 13, 21)));
}
private static CompositeContinuation newComposite(EncodableContinuation... children) {
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingExecutorTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingExecutorTestCase.java
index 4a7c6179db7..268a3ceb635 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingExecutorTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingExecutorTestCase.java
@@ -34,7 +34,7 @@ import com.yahoo.searchlib.expression.ConstantNode;
import com.yahoo.searchlib.expression.IntegerResultNode;
import com.yahoo.searchlib.expression.StringResultNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -45,12 +45,7 @@ import java.util.List;
import java.util.Map;
import java.util.Queue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -58,14 +53,14 @@ import static org.junit.Assert.fail;
public class GroupingExecutorTestCase {
@Test
- public void requireThatNullRequestsPass() {
+ void requireThatNullRequestsPass() {
Result res = newExecution(new GroupingExecutor()).search(newQuery());
assertNotNull(res);
assertEquals(0, res.hits().size());
}
@Test
- public void requireThatEmptyRequestsPass() {
+ void requireThatEmptyRequestsPass() {
Query query = newQuery();
GroupingRequest.newInstance(query).setRootOperation(new AllOperation());
Result res = newExecution(new GroupingExecutor()).search(query);
@@ -74,7 +69,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatRequestsAreTransformed() {
+ void requireThatRequestsAreTransformed() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))))"));
@@ -90,7 +85,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatEachBelowAllDoesNotBlowUp() {
+ void requireThatEachBelowAllDoesNotBlowUp() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(each(output(summary(bar))))"));
@@ -100,7 +95,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatSearchIsMultiPass() {
+ void requireThatSearchIsMultiPass() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))))"));
@@ -110,7 +105,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatPassRequestsSingleLevel() {
+ void requireThatPassRequestsSingleLevel() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))))"));
@@ -126,7 +121,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatAggregationPerHitWithoutGroupingDoesNotWorkYet() {
+ void requireThatAggregationPerHitWithoutGroupingDoesNotWorkYet() {
try {
execute("each(output(strlen(customer)))");
fail();
@@ -136,19 +131,19 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatAggregationWithoutGroupingWorks() {
- List<Grouping> groupings=execute("all(output(count()))");
- assertEquals(1,groupings.size());
+ void requireThatAggregationWithoutGroupingWorks() {
+ List<Grouping> groupings = execute("all(output(count()))");
+ assertEquals(1, groupings.size());
assertEquals(0, groupings.get(0).getLevels().size());
assertEquals(ConstantNode.class, groupings.get(0).getRoot().getAggregationResults().get(0).getExpression().getClass());
}
@Test
- public void requireThatGroupingIsParallel() {
+ void requireThatGroupingIsParallel() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))) as(max)" +
- " each(output(min(bar))) as(min))"));
+ " each(output(min(bar))) as(min))"));
GroupingCounter cnt = new GroupingCounter();
newExecution(new GroupingExecutor(), cnt).search(query);
assertEquals(2, cnt.passList.size());
@@ -157,11 +152,11 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatParallelGroupingIsNotRedundant() {
+ void requireThatParallelGroupingIsNotRedundant() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))) as(shallow)" +
- " each(group(baz) each(output(max(cox)))) as(deep))"));
+ " each(group(baz) each(output(max(cox)))) as(deep))"));
GroupingCounter cnt = new GroupingCounter();
newExecution(new GroupingExecutor(), cnt).search(query);
assertEquals(3, cnt.passList.size());
@@ -171,7 +166,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatPassResultsAreMerged() {
+ void requireThatPassResultsAreMerged() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(min(bar), max(bar))))"));
@@ -187,14 +182,14 @@ public class GroupingExecutorTestCase {
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MinAggregationResult().setMin(new IntegerResultNode(6)).setTag(3)))
);
Execution exec = newExecution(new GroupingExecutor(),
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(grpA), null),
- new GroupingListHit(List.of(grpB), null))));
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(grpA), null),
+ new GroupingListHit(List.of(grpB), null))));
Group grp = req.getResultGroup(exec.search(query));
assertEquals(1, grp.size());
Hit hit = grp.get(0);
assertTrue(hit instanceof GroupList);
- GroupList lst = (GroupList)hit;
+ GroupList lst = (GroupList) hit;
assertEquals(3, lst.size());
assertNotNull(hit = lst.get("group:string:uniqueA"));
assertEquals(6L, hit.getField("max(bar)"));
@@ -206,7 +201,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatUnexpectedGroupingResultsAreIgnored() {
+ void requireThatUnexpectedGroupingResultsAreIgnored() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))))"));
@@ -220,14 +215,14 @@ public class GroupingExecutorTestCase {
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("unexpected")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(96)).setTag(3)))
);
Execution exec = newExecution(new GroupingExecutor(),
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(grpExpected), null),
- new GroupingListHit(List.of(grpUnexpected), null))));
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(grpExpected), null),
+ new GroupingListHit(List.of(grpUnexpected), null))));
Group grp = req.getResultGroup(exec.search(query));
assertEquals(1, grp.size());
Hit hit = grp.get(0);
assertTrue(hit instanceof GroupList);
- GroupList lst = (GroupList)hit;
+ GroupList lst = (GroupList) hit;
assertEquals(1, lst.size());
assertNotNull(hit = lst.get("group:string:expected"));
assertEquals(69L, hit.getField("max(bar)"));
@@ -235,7 +230,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatHitsAreFilled() {
+ void requireThatHitsAreFilled() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
@@ -243,20 +238,20 @@ public class GroupingExecutorTestCase {
Grouping grp0 = new Grouping(0);
grp0.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar"))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "bar"))
+ ));
Grouping grp1 = new Grouping(0);
grp1.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))
+ ));
Execution exec = newExecution(new GroupingExecutor(),
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(grp0), null),
- new GroupingListHit(List.of(grp1), null))),
- new FillRequestThrower());
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(grp0), null),
+ new GroupingListHit(List.of(grp1), null))),
+ new FillRequestThrower());
Result res = exec.search(query);
-
+
// Fill with summary specified in grouping
try {
exec.fill(res);
@@ -275,59 +270,59 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatUnfilledHitsRenderError() {
+ void requireThatUnfilledHitsRenderError() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
Grouping grp0 = new Grouping(0);
grp0.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar"))));
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
+ .addAggregationResult(new HitsAggregationResult(1, "bar"))));
Grouping grp1 = new Grouping(0);
grp1.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(
- new HitsAggregationResult(1, "bar")
- .addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
+ .addAggregationResult(
+ new HitsAggregationResult(1, "bar")
+ .addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
Execution exec = newExecution(new GroupingExecutor(),
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(grp0), null),
- new GroupingListHit(List.of(grp1), null))),
- new FillErrorProvider());
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(grp0), null),
+ new GroupingListHit(List.of(grp1), null))),
+ new FillErrorProvider());
Result res = exec.search(query);
exec.fill(res);
assertNotNull(res.hits().getError());
}
@Test
- public void requireThatGroupRelevanceCanBeSynthesized() {
+ void requireThatGroupRelevanceCanBeSynthesized() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) order(count()) each(output(count())))"));
Grouping grp = new Grouping(0);
grp.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group()
- .setId(new StringResultNode("foo"))
- .addAggregationResult(new CountAggregationResult(1))
- .addOrderBy(new AggregationRefNode(0), true))
- .addChild(new com.yahoo.searchlib.aggregation.Group()
- .setId(new StringResultNode("bar"))
- .addAggregationResult(new CountAggregationResult(2))
- .addOrderBy(new AggregationRefNode(0), true)));
+ .addChild(new com.yahoo.searchlib.aggregation.Group()
+ .setId(new StringResultNode("foo"))
+ .addAggregationResult(new CountAggregationResult(1))
+ .addOrderBy(new AggregationRefNode(0), true))
+ .addChild(new com.yahoo.searchlib.aggregation.Group()
+ .setId(new StringResultNode("bar"))
+ .addAggregationResult(new CountAggregationResult(2))
+ .addOrderBy(new AggregationRefNode(0), true)));
Result res = newExecution(new GroupingExecutor(),
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(grp), null),
- new GroupingListHit(List.of(grp), null)))).search(query);
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(grp), null),
+ new GroupingListHit(List.of(grp), null)))).search(query);
- GroupList groupList = (GroupList)req.getResultGroup(res).get(0);
+ GroupList groupList = (GroupList) req.getResultGroup(res).get(0);
assertEquals(1.0, groupList.get(0).getRelevance().getScore(), 1E-6);
assertEquals(0.5, groupList.get(1).getRelevance().getScore(), 1E-6);
}
@Test
- public void requireThatErrorsAreHandled() {
+ void requireThatErrorsAreHandled() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
@@ -335,20 +330,20 @@ public class GroupingExecutorTestCase {
Grouping grp0 = new Grouping(0);
grp0.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar"))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "bar"))
+ ));
Grouping grp1 = new Grouping(0);
grp1.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))
+ ));
ErrorProvider err = new ErrorProvider(1);
Execution exec = newExecution(new GroupingExecutor(),
- err,
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(grp0), null),
- new GroupingListHit(List.of(grp1), null))));
+ err,
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(grp0), null),
+ new GroupingListHit(List.of(grp1), null))));
Result res = exec.search(query);
assertNotNull(res.hits().getError());
assertEquals(Error.TIMEOUT.code, res.hits().getError().getCode());
@@ -356,10 +351,10 @@ public class GroupingExecutorTestCase {
err = new ErrorProvider(0);
exec = newExecution(new GroupingExecutor(),
- err,
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(grp0), null),
- new GroupingListHit(List.of(grp1), null))));
+ err,
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(grp0), null),
+ new GroupingListHit(List.of(grp1), null))));
res = exec.search(query);
assertNotNull(res.hits().getError());
assertEquals(Error.TIMEOUT.code, res.hits().getError().getCode());
@@ -367,39 +362,39 @@ public class GroupingExecutorTestCase {
}
@Test
- public void requireThatHitsAreFilledWithCorrectSummary() {
+ void requireThatHitsAreFilledWithCorrectSummary() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar))) as(bar) " +
- " each(output(summary(baz))) as(baz)))"));
+ " each(output(summary(baz))) as(baz)))"));
Grouping pass0A = new Grouping(0);
pass0A.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar"))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "bar"))
+ ));
Grouping pass0B = new Grouping(1);
pass0B.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "baz"))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "baz"))
+ ));
GlobalId gid1 = new GlobalId((new DocumentId("id:ns:type::1")).getGlobalId());
GlobalId gid2 = new GlobalId((new DocumentId("id:ns:type::2")).getGlobalId());
Grouping pass1A = new Grouping(0);
pass1A.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(1, gid1, 3)))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(1, gid1, 3)))
+ ));
Grouping pass1B = new Grouping(1);
pass1B.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "baz").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(4, gid2, 6)))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "baz").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(4, gid2, 6)))
+ ));
SummaryMapper sm = new SummaryMapper();
Execution exec = newExecution(new GroupingExecutor(),
- new ResultProvider(Arrays.asList(
- new GroupingListHit(Arrays.asList(pass0A, pass0B), null),
- new GroupingListHit(Arrays.asList(pass1A, pass1B), null))),
- sm);
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(Arrays.asList(pass0A, pass0B), null),
+ new GroupingListHit(Arrays.asList(pass1A, pass1B), null))),
+ sm);
exec.fill(exec.search(query), "default");
assertEquals(2, sm.hitsBySummary.size());
@@ -408,51 +403,51 @@ public class GroupingExecutorTestCase {
assertEquals(1, lst.size());
Hit hit = lst.get(0);
assertTrue(hit instanceof FastHit);
- assertEquals(1, ((FastHit)hit).getPartId());
- assertEquals(gid1, ((FastHit)hit).getGlobalId());
+ assertEquals(1, ((FastHit) hit).getPartId());
+ assertEquals(gid1, ((FastHit) hit).getGlobalId());
assertNotNull(lst = sm.hitsBySummary.get("baz"));
assertNotNull(lst);
assertEquals(1, lst.size());
hit = lst.get(0);
assertTrue(hit instanceof FastHit);
- assertEquals(4, ((FastHit)hit).getPartId());
- assertEquals(gid2, ((FastHit)hit).getGlobalId());
+ assertEquals(4, ((FastHit) hit).getPartId());
+ assertEquals(gid2, ((FastHit) hit).getGlobalId());
}
@Test
- public void requireThatDefaultSummaryNameFillsHitsWithNull() {
+ void requireThatDefaultSummaryNameFillsHitsWithNull() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary()))) as(foo))"));
Grouping pass0 = new Grouping(0);
pass0.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group()
- .setId(new StringResultNode("foo"))
- .addAggregationResult(
- new HitsAggregationResult(1, ExpressionConverter.DEFAULT_SUMMARY_NAME))));
+ .addChild(new com.yahoo.searchlib.aggregation.Group()
+ .setId(new StringResultNode("foo"))
+ .addAggregationResult(
+ new HitsAggregationResult(1, ExpressionConverter.DEFAULT_SUMMARY_NAME))));
Grouping pass1 = new Grouping(0);
pass1.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group()
- .setId(new StringResultNode("foo"))
- .addAggregationResult(
- new HitsAggregationResult(1, ExpressionConverter.DEFAULT_SUMMARY_NAME)
- .addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
+ .addChild(new com.yahoo.searchlib.aggregation.Group()
+ .setId(new StringResultNode("foo"))
+ .addAggregationResult(
+ new HitsAggregationResult(1, ExpressionConverter.DEFAULT_SUMMARY_NAME)
+ .addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
Execution exec = newExecution(new GroupingExecutor(),
- new ResultProvider(Arrays.asList(
- new GroupingListHit(List.of(pass0), null),
- new GroupingListHit(List.of(pass1), null))));
+ new ResultProvider(Arrays.asList(
+ new GroupingListHit(List.of(pass0), null),
+ new GroupingListHit(List.of(pass1), null))));
Result res = exec.search(query);
exec.fill(res);
- Hit hit = ((HitList)((Group)((GroupList)req.getResultGroup(res).get(0)).get(0)).get(0)).get(0);
+ Hit hit = ((HitList) ((Group) ((GroupList) req.getResultGroup(res).get(0)).get(0)).get(0)).get(0);
assertTrue(hit instanceof FastHit);
assertTrue(hit.isFilled(null));
}
@Test
- public void requireThatHitsAreAttachedToCorrectQuery() {
+ void requireThatHitsAreAttachedToCorrectQuery() {
Query queryA = newQuery();
GroupingRequest req = GroupingRequest.newInstance(queryA);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
@@ -460,24 +455,24 @@ public class GroupingExecutorTestCase {
Grouping grp = new Grouping(0);
grp.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar"))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "bar"))
+ ));
GroupingListHit pass0 = new GroupingListHit(List.of(grp), null);
GlobalId gid = new GlobalId((new DocumentId("id:ns:type::1")).getGlobalId());
grp = new Grouping(0);
grp.setRoot(new com.yahoo.searchlib.aggregation.Group()
.addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo"))
- .addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(4, gid, 6)))
- ));
+ .addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(4, gid, 6)))
+ ));
GroupingListHit pass1 = new GroupingListHit(List.of(grp), null);
Query queryB = newQuery(); // required by GroupingListHit.getSearchQuery()
pass1.setQuery(queryB);
QueryMapper qm = new QueryMapper();
Execution exec = newExecution(new GroupingExecutor(),
- new ResultProvider(Arrays.asList(pass0, pass1)),
- qm);
+ new ResultProvider(Arrays.asList(pass0, pass1)),
+ qm);
exec.fill(exec.search(queryA));
assertEquals(1, qm.hitsByQuery.size());
assertTrue(qm.hitsByQuery.containsKey(queryB));
@@ -488,7 +483,7 @@ public class GroupingExecutorTestCase {
* (triggered by the exc.search call in the below).
*/
@Test
- public void testRankProperties() {
+ void testRankProperties() {
final double delta = 0.000000001;
Execution exc = newExecution(new GroupingExecutor());
{
@@ -532,7 +527,7 @@ public class GroupingExecutorTestCase {
}
@Test
- public void testIllegalQuery() {
+ void testIllegalQuery() {
Execution exc = newExecution(new GroupingExecutor());
Query query = new Query();
@@ -541,14 +536,14 @@ public class GroupingExecutorTestCase {
Result result = exc.search(query);
com.yahoo.search.result.ErrorMessage message = result.hits().getError();
- assertNotNull("Got error", message);
+ assertNotNull(message, "Got error");
assertEquals("Illegal query", message.getMessage());
assertEquals("No query", message.getDetailedMessage());
assertEquals(3, message.getCode());
}
@Test
- public void testResultsFromMultipleDocumentTypes() {
+ void testResultsFromMultipleDocumentTypes() {
Query query = newQuery();
GroupingRequest request = GroupingRequest.newInstance(query);
request.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(min(bar), max(bar))))"));
@@ -556,38 +551,38 @@ public class GroupingExecutorTestCase {
Map<String, List<GroupingListHit>> resultsByDocumentType = new HashMap<>();
Grouping groupA1 = new Grouping(0);
groupA1.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueA")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(6)).setTag(4)))
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(9)).setTag(4)))
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueA")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(6)).setTag(4)))
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(9)).setTag(4)))
);
Grouping groupA2 = new Grouping(0);
groupA2.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueB")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(9)).setTag(4)))
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MinAggregationResult().setMin(new IntegerResultNode(6)).setTag(3)))
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueB")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(9)).setTag(4)))
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MinAggregationResult().setMin(new IntegerResultNode(6)).setTag(3)))
);
Grouping groupB1 = new Grouping(0);
groupB1.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueA")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(2)).setTag(4)))
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(3)).setTag(4)))
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueA")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(2)).setTag(4)))
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(3)).setTag(4)))
);
Grouping groupB2 = new Grouping(0);
groupB2.setRoot(new com.yahoo.searchlib.aggregation.Group()
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueC")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(7)).setTag(4)))
- .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(11)).setTag(4)))
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueC")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(7)).setTag(4)))
+ .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(11)).setTag(4)))
);
resultsByDocumentType.put("typeA", List.of(new GroupingListHit(List.of(groupA1), null),
- new GroupingListHit(List.of(groupA2), null)));
+ new GroupingListHit(List.of(groupA2), null)));
resultsByDocumentType.put("typeB", List.of(new GroupingListHit(List.of(groupB1), null),
- new GroupingListHit(List.of(groupB2), null)));
+ new GroupingListHit(List.of(groupB2), null)));
Execution execution = newExecution(new GroupingExecutor(),
- new MockClusterSearcher(),
- new MultiDocumentTypeResultProvider(resultsByDocumentType));
+ new MockClusterSearcher(),
+ new MultiDocumentTypeResultProvider(resultsByDocumentType));
Result result = execution.search(query);
Group group = request.getResultGroup(result);
assertEquals(1, group.size());
Hit hit = group.get(0);
assertTrue(hit instanceof GroupList);
- GroupList list = (GroupList)hit;
+ GroupList list = (GroupList) hit;
assertEquals(4, list.size());
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingTransformTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingTransformTestCase.java
index c6503617da5..c41fb03f2f5 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingTransformTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingTransformTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.search.grouping.vespa;
import com.yahoo.search.grouping.Continuation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -14,14 +14,14 @@ public class GroupingTransformTestCase {
private static final int REQUEST_ID = 0;
@Test
- public void requireThatLabelCanBeSet() {
+ void requireThatLabelCanBeSet() {
GroupingTransform transform = newTransform();
transform.putLabel(0, 1, "foo", "my_type");
assertEquals("foo", transform.getLabel(1));
}
@Test
- public void requireThatLabelCanNotBeReplaced() {
+ void requireThatLabelCanNotBeReplaced() {
GroupingTransform transform = newTransform();
transform.putLabel(0, 1, "foo", "my_type");
try {
@@ -29,12 +29,12 @@ public class GroupingTransformTestCase {
fail();
} catch (IllegalStateException e) {
assertEquals("Can not set label of my_type 1 to 'bar' because it is already set to 'foo'.",
- e.getMessage());
+ e.getMessage());
}
}
@Test
- public void requireThatLabelIsUniqueAmongSiblings() {
+ void requireThatLabelIsUniqueAmongSiblings() {
GroupingTransform transform = newTransform();
transform.putLabel(0, 1, "foo", "my_type");
try {
@@ -42,26 +42,26 @@ public class GroupingTransformTestCase {
fail();
} catch (UnsupportedOperationException e) {
assertEquals("Can not use my_type label 'foo' for multiple siblings.",
- e.getMessage());
+ e.getMessage());
}
}
@Test
- public void requireThatMaxDefaultsToZero() {
+ void requireThatMaxDefaultsToZero() {
GroupingTransform transform = newTransform();
assertEquals(0, transform.getMax(6));
assertEquals(0, transform.getMax(9));
}
@Test
- public void requireThatMaxCanBeSet() {
+ void requireThatMaxCanBeSet() {
GroupingTransform transform = newTransform();
transform.putMax(0, 69, "my_type");
assertEquals(69, transform.getMax(0));
}
@Test
- public void requireThatMaxCanNotBeReplaced() {
+ void requireThatMaxCanNotBeReplaced() {
GroupingTransform transform = newTransform();
transform.putMax(0, 6, "my_type");
try {
@@ -69,27 +69,27 @@ public class GroupingTransformTestCase {
fail();
} catch (IllegalStateException e) {
assertEquals("Can not set max of my_type 0 to 9 because it is already set to 6.",
- e.getMessage());
+ e.getMessage());
}
assertEquals(6, transform.getMax(0));
}
@Test
- public void requireThatOffsetDefaultsToZero() {
+ void requireThatOffsetDefaultsToZero() {
GroupingTransform transform = newTransform();
assertEquals(0, transform.getOffset(6));
assertEquals(0, transform.getOffset(9));
}
@Test
- public void requireThatOffsetContinuationsCanBeAdded() {
+ void requireThatOffsetContinuationsCanBeAdded() {
GroupingTransform transform = newTransform();
transform.addContinuation(newStableOffset(newResultId(), 6, 9));
assertEquals(9, transform.getOffset(6));
}
@Test
- public void requireThatOffsetByIdCanBeReplaced() {
+ void requireThatOffsetByIdCanBeReplaced() {
GroupingTransform transform = newTransform();
ResultId id = newResultId(6, 9);
transform.addContinuation(newStableOffset(id, 0, 6));
@@ -103,7 +103,7 @@ public class GroupingTransformTestCase {
}
@Test
- public void requireThatOffsetByTagEqualsHighestSibling() {
+ void requireThatOffsetByTagEqualsHighestSibling() {
GroupingTransform transform = newTransform();
transform.addContinuation(newStableOffset(newResultId(1), 69, 6));
assertEquals(6, transform.getOffset(69));
@@ -116,7 +116,7 @@ public class GroupingTransformTestCase {
}
@Test
- public void requireThatOffsetContinuationsCanBeReplaced() {
+ void requireThatOffsetContinuationsCanBeReplaced() {
GroupingTransform transform = newTransform();
ResultId id = newResultId(6, 9);
transform.addContinuation(newStableOffset(id, 1, 1));
@@ -136,7 +136,7 @@ public class GroupingTransformTestCase {
}
@Test
- public void requireThatUnstableOffsetsAreTracked() {
+ void requireThatUnstableOffsetsAreTracked() {
GroupingTransform transform = newTransform();
ResultId stableId = newResultId(6);
transform.addContinuation(newStableOffset(stableId, 1, 1));
@@ -148,17 +148,17 @@ public class GroupingTransformTestCase {
}
@Test
- public void requireThatCompositeContinuationsAreDecomposed() {
+ void requireThatCompositeContinuationsAreDecomposed() {
GroupingTransform transform = newTransform();
transform.addContinuation(new CompositeContinuation()
- .add(newStableOffset(newResultId(), 6, 9))
- .add(newStableOffset(newResultId(), 9, 6)));
+ .add(newStableOffset(newResultId(), 6, 9))
+ .add(newStableOffset(newResultId(), 9, 6)));
assertEquals(9, transform.getOffset(6));
assertEquals(6, transform.getOffset(9));
}
@Test
- public void requireThatUnsupportedContinuationsCanNotBeAdded() {
+ void requireThatUnsupportedContinuationsCanNotBeAdded() {
GroupingTransform transform = newTransform();
try {
transform.addContinuation(new Continuation() {
@@ -174,7 +174,7 @@ public class GroupingTransformTestCase {
}
@Test
- public void requireThatUnrelatedContinuationsAreIgnored() {
+ void requireThatUnrelatedContinuationsAreIgnored() {
GroupingTransform transform = new GroupingTransform(REQUEST_ID);
ResultId id = ResultId.valueOf(REQUEST_ID + 1, 1);
transform.addContinuation(new OffsetContinuation(id, 2, 3, OffsetContinuation.FLAG_UNSTABLE));
@@ -184,7 +184,7 @@ public class GroupingTransformTestCase {
}
@Test
- public void requireThatToStringIsVerbose() {
+ void requireThatToStringIsVerbose() {
GroupingTransform transform = new GroupingTransform(REQUEST_ID);
transform.putLabel(1, 1, "label1", "type1");
transform.putLabel(2, 2, "label2", "type2");
@@ -193,19 +193,19 @@ public class GroupingTransformTestCase {
transform.putMax(5, 5, "type5");
transform.putMax(6, 6, "type6");
assertEquals("groupingTransform {\n" +
- "\tlabels {\n" +
- "\t\t1 : label1\n" +
- "\t\t2 : label2\n" +
- "\t}\n" +
- "\toffsets {\n" +
- "\t\t3 : 3\n" +
- "\t\t4 : 4\n" +
- "\t}\n" +
- "\tmaxes {\n" +
- "\t\t5 : 5\n" +
- "\t\t6 : 6\n" +
- "\t}\n" +
- "}", transform.toString());
+ "\tlabels {\n" +
+ "\t\t1 : label1\n" +
+ "\t\t2 : label2\n" +
+ "\t}\n" +
+ "\toffsets {\n" +
+ "\t\t3 : 3\n" +
+ "\t\t4 : 4\n" +
+ "\t}\n" +
+ "\tmaxes {\n" +
+ "\t\t5 : 5\n" +
+ "\t\t6 : 6\n" +
+ "\t}\n" +
+ "}", transform.toString());
}
private static GroupingTransform newTransform() {
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
index b3afd8c5f50..5263583f771 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java
@@ -17,11 +17,11 @@ import com.yahoo.search.schema.Schema;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.searchlib.aggregation.FS4Hit;
import com.yahoo.searchlib.aggregation.VdsHit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -33,7 +33,7 @@ public class HitConverterTestCase {
}
@Test
- public void requireThatHitsAreConverted() {
+ void requireThatHitsAreConverted() {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
Hit hit = converter.toSearchHit("default", new FS4Hit(1, createGlobalId(2), 3).setContext(context()));
assertNotNull(hit);
@@ -45,7 +45,7 @@ public class HitConverterTestCase {
}
@Test
- public void requireThatContextDataIsCopied() {
+ void requireThatContextDataIsCopied() {
Hit ctxHit = context();
ctxHit.setSource("69");
Query ctxQuery = new Query();
@@ -55,14 +55,14 @@ public class HitConverterTestCase {
Hit hit = converter.toSearchHit("default", new FS4Hit(1, createGlobalId(2), 3).setContext(ctxHit));
assertNotNull(hit);
assertTrue(hit instanceof FastHit);
- assertEquals(1, ((FastHit)hit).getPartId());
- assertEquals(createGlobalId(2), ((FastHit)hit).getGlobalId());
+ assertEquals(1, ((FastHit) hit).getPartId());
+ assertEquals(createGlobalId(2), ((FastHit) hit).getGlobalId());
assertSame(ctxQuery, hit.getQuery());
assertEquals(ctxHit.getSource(), hit.getSource());
}
@Test
- public void requireThatSummaryClassIsSet() {
+ void requireThatSummaryClassIsSet() {
Searcher searcher = new MySearcher();
HitConverter converter = new HitConverter(searcher, new Query());
Hit hit = converter.toSearchHit("69", new FS4Hit(1, createGlobalId(2), 3).setContext(context()));
@@ -72,7 +72,7 @@ public class HitConverterTestCase {
}
@Test
- public void requireThatHitHasContext() {
+ void requireThatHitHasContext() {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
try {
converter.toSearchHit("69", new FS4Hit(1, createGlobalId(2), 3));
@@ -83,7 +83,7 @@ public class HitConverterTestCase {
}
@Test
- public void requireThatUnsupportedHitClassThrows() {
+ void requireThatUnsupportedHitClassThrows() {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
try {
converter.toSearchHit("69", new com.yahoo.searchlib.aggregation.Hit() {
@@ -107,10 +107,10 @@ public class HitConverterTestCase {
}
@Test
- public void requireThatVdsHitCanBeConverted() {
+ void requireThatVdsHitCanBeConverted() {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
GroupingListHit context = new GroupingListHit(null, sixtynine());
- VdsHit lowHit = new VdsHit("id:ns:type::", new byte[] { 0x55, 0x55, 0x55, 0x55 }, 1);
+ VdsHit lowHit = new VdsHit("id:ns:type::", new byte[]{0x55, 0x55, 0x55, 0x55}, 1);
lowHit.setContext(context);
Hit hit = converter.toSearchHit("69", lowHit);
assertNotNull(hit);
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerDecoderTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerDecoderTestCase.java
index 7d0827f0eb7..c574a99d2c0 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerDecoderTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerDecoderTestCase.java
@@ -1,10 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.vespa;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -12,7 +11,7 @@ import static org.junit.Assert.fail;
public class IntegerDecoderTestCase {
@Test
- public void requireThatIntDecoderWorksAsExpected() {
+ void requireThatIntDecoderWorksAsExpected() {
assertDecode("A", 0);
assertDecode("BC", 1);
assertDecode("CBI", 12);
@@ -29,7 +28,7 @@ public class IntegerDecoderTestCase {
}
@Test
- public void requireThatDecoderThrowsExceptionOnBadInput() {
+ void requireThatDecoderThrowsExceptionOnBadInput() {
try {
new IntegerDecoder("B").next();
fail();
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerEmbedderTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerEmbedderTestCase.java
index e7a4f1572c5..c644607b3ae 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerEmbedderTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerEmbedderTestCase.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.vespa;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Simon Thoresen Hult
@@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals;
public class IntegerEmbedderTestCase {
@Test
- public void requireThatIntEncoderWorksAsExpected() {
+ void requireThatIntEncoderWorksAsExpected() {
assertEncode("A", 0);
assertEncode("BC", 1);
assertEncode("CBI", 12);
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/OffsetContinuationTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/OffsetContinuationTestCase.java
index 7242e5ba054..513f8c89f05 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/OffsetContinuationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/OffsetContinuationTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.search.grouping.vespa;
import com.yahoo.search.grouping.Continuation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -12,7 +12,7 @@ import static org.junit.Assert.*;
public class OffsetContinuationTestCase {
@Test
- public void requireThatNullResultIdThrowsException() {
+ void requireThatNullResultIdThrowsException() {
try {
new OffsetContinuation(null, 0, 0, 0);
fail();
@@ -22,7 +22,7 @@ public class OffsetContinuationTestCase {
}
@Test
- public void requireThatAccessorsWork() {
+ void requireThatAccessorsWork() {
OffsetContinuation cnt = new OffsetContinuation(ResultId.valueOf(1), 2, 3, 4);
assertEquals(ResultId.valueOf(1), cnt.getResultId());
assertEquals(2, cnt.getTag());
@@ -44,7 +44,7 @@ public class OffsetContinuationTestCase {
}
@Test
- public void requireThatOffsetContinuationsCanBeEncoded() {
+ void requireThatOffsetContinuationsCanBeEncoded() {
assertEncode("BCBCBCBEBG", newOffset(1, 1, 2, 3));
assertEncode("BCBKCBACBKCCK", newOffset(5, 8, 13, 21));
assertEncode("BCBBBBBDBF", newOffset(-1, -1, -2, -3));
@@ -52,7 +52,7 @@ public class OffsetContinuationTestCase {
}
@Test
- public void requireThatOffsetContinuationsCanBeDecoded() {
+ void requireThatOffsetContinuationsCanBeDecoded() {
assertDecode("BCBCBCBEBG", newOffset(1, 1, 2, 3));
assertDecode("BCBKCBACBKCCK", newOffset(5, 8, 13, 21));
assertDecode("BCBBBBBDBF", newOffset(-1, -1, -2, -3));
@@ -60,18 +60,18 @@ public class OffsetContinuationTestCase {
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(newOffset(1, 1, 2, 3).hashCode(), newOffset(1, 1, 2, 3).hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
Continuation cnt = newOffset(1, 1, 2, 3);
- assertFalse(cnt.equals(new Object()));
- assertFalse(cnt.equals(newOffset(0, 1, 2, 3)));
- assertFalse(cnt.equals(newOffset(1, 0, 2, 3)));
- assertFalse(cnt.equals(newOffset(1, 1, 0, 3)));
- assertFalse(cnt.equals(newOffset(1, 1, 2, 0)));
+ assertNotEquals(cnt, new Object());
+ assertNotEquals(cnt, newOffset(0, 1, 2, 3));
+ assertNotEquals(cnt, newOffset(1, 0, 2, 3));
+ assertNotEquals(cnt, newOffset(1, 1, 0, 3));
+ assertNotEquals(cnt, newOffset(1, 1, 2, 0));
assertEquals(cnt, newOffset(1, 1, 2, 3));
}
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java
index 5882c56c688..f8e67a10076 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java
@@ -26,7 +26,7 @@ import com.yahoo.searchlib.expression.StringResultNode;
import com.yahoo.searchlib.expression.TimeStampFunctionNode;
import com.yahoo.searchlib.expression.ToStringFunctionNode;
import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
@@ -34,9 +34,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.TimeZone;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -44,19 +42,19 @@ import static org.junit.Assert.fail;
public class RequestBuilderTestCase {
@Test
- public void requireThatAllAggregationResulsAreSupported() {
- assertLayout("all(group(a) each(output(avg(b))))", "[[{ Attribute, result = [Average] }]]");
- assertLayout("all(group(a) each(output(count())))", "[[{ Attribute, result = [Count] }]]");
- assertLayout("all(group(a) each(output(max(b))))", "[[{ Attribute, result = [Max] }]]");
- assertLayout("all(group(a) each(output(min(b))))", "[[{ Attribute, result = [Min] }]]");
- assertLayout("all(group(a) each(output(sum(b))))", "[[{ Attribute, result = [Sum] }]]");
- assertLayout("all(group(a) each(each(output(summary()))))", "[[{ Attribute, result = [Hits] }]]");
- assertLayout("all(group(a) each(output(xor(b))))", "[[{ Attribute, result = [Xor] }]]");
- assertLayout("all(group(a) each(output(stddev(b))))", "[[{ Attribute, result = [StandardDeviation] }]]");
+ void requireThatAllAggregationResulsAreSupported() {
+ assertLayout("all(group(a) each(output(avg(b))))", "[[{ Attribute, result = [Average] }]]");
+ assertLayout("all(group(a) each(output(count())))", "[[{ Attribute, result = [Count] }]]");
+ assertLayout("all(group(a) each(output(max(b))))", "[[{ Attribute, result = [Max] }]]");
+ assertLayout("all(group(a) each(output(min(b))))", "[[{ Attribute, result = [Min] }]]");
+ assertLayout("all(group(a) each(output(sum(b))))", "[[{ Attribute, result = [Sum] }]]");
+ assertLayout("all(group(a) each(each(output(summary()))))", "[[{ Attribute, result = [Hits] }]]");
+ assertLayout("all(group(a) each(output(xor(b))))", "[[{ Attribute, result = [Xor] }]]");
+ assertLayout("all(group(a) each(output(stddev(b))))", "[[{ Attribute, result = [StandardDeviation] }]]");
}
@Test
- public void requireThatExpressionCountAggregationResultIsSupported() {
+ void requireThatExpressionCountAggregationResultIsSupported() {
RequestBuilder builder = new RequestBuilder(0);
builder.setRootOperation(GroupingOperation.fromString("all(group(foo) output(count()))"));
builder.build();
@@ -73,28 +71,28 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatTopNIsHonoured() {
+ void requireThatTopNIsHonoured() {
List<Grouping> gl = getRequestList("all(max(3) all(group(product_id) max(5) each(output(sum(price)))))");
assertEquals(1, gl.size());
assertEquals(3, gl.get(0).getTopN());
}
@Test
- public void requireThatTopNIsHonouredWhenNested() {
+ void requireThatTopNIsHonouredWhenNested() {
List<Grouping> gl = getRequestList("all( all(max(3) all(group(product_id) max(5) each(output(sum(price))))))");
assertEquals(1, gl.size());
assertEquals(3, gl.get(0).getTopN());
}
@Test
- public void requireThatTopNIsInherited() {
+ void requireThatTopNIsInherited() {
List<Grouping> gl = getRequestList("all(max(7) all( all(group(product_id) max(5) each(output(sum(price))))))");
assertEquals(1, gl.size());
assertEquals(7, gl.get(0).getTopN());
}
@Test
- public void requireThatTopNIsMinimum() {
+ void requireThatTopNIsMinimum() {
List<Grouping> gl = getRequestList("all(max(7) all(max(3) all(group(product_id) max(5) each(output(sum(price))))))");
assertEquals(1, gl.size());
assertEquals(3, gl.get(0).getTopN());
@@ -104,7 +102,7 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatTopNIsIndividual() {
+ void requireThatTopNIsIndividual() {
List<Grouping> gl = getRequestList("all( all(max(3) all(group(product_id) max(5) each(output(sum(price))))) all(group(filter_cluster3) order(count()) each(output(count()))))");
assertEquals(2, gl.size());
assertEquals(3, gl.get(0).getTopN());
@@ -117,7 +115,7 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatAllExpressionNodesAreSupported() {
+ void requireThatAllExpressionNodesAreSupported() {
assertLayout("all(group(add(a,b)) each(output(count())))", "[[{ Add, result = [Count] }]]");
assertLayout("all(group(and(a,b)) each(output(count())))", "[[{ And, result = [Count] }]]");
assertLayout("all(group(a) each(output(count())))", "[[{ Attribute, result = [Count] }]]");
@@ -188,22 +186,22 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatForceSinglePassIsSupported() {
+ void requireThatForceSinglePassIsSupported() {
assertForceSinglePass("all(group(foo) each(output(count())))", "[false]");
assertForceSinglePass("all(group(foo) hint(singlepass) each(output(count())))", "[true]");
assertForceSinglePass("all(hint(singlepass) " +
- " all(group(foo) each(output(count())))" +
- " all(group(bar) each(output(count()))))",
- "[true, true]");
+ " all(group(foo) each(output(count())))" +
+ " all(group(bar) each(output(count()))))",
+ "[true, true]");
// it would be really nice if this test returned [true, true], but that is not how the AST is built
assertForceSinglePass("all(all(group(foo) hint(singlepass) each(output(count())))" +
- " all(group(bar) hint(singlepass) each(output(count()))))",
- "[false, false]");
+ " all(group(bar) hint(singlepass) each(output(count()))))",
+ "[false, false]");
}
@Test
- public void requireThatThereCanBeOnlyOneBuildCall() {
+ void requireThatThereCanBeOnlyOneBuildCall() {
RequestBuilder builder = new RequestBuilder(0);
builder.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(count())))"));
builder.build();
@@ -216,148 +214,148 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatNullSummaryClassProvidesDefault() {
+ void requireThatNullSummaryClassProvidesDefault() {
RequestBuilder reqBuilder = new RequestBuilder(0);
reqBuilder.setRootOperation(new AllOperation()
- .setGroupBy(new AttributeValue("foo"))
- .addChild(new EachOperation()
- .addChild(new EachOperation()
- .addOutput(new SummaryValue()))));
+ .setGroupBy(new AttributeValue("foo"))
+ .addChild(new EachOperation()
+ .addChild(new EachOperation()
+ .addOutput(new SummaryValue()))));
reqBuilder.setDefaultSummaryName(null);
reqBuilder.build();
- HitsAggregationResult hits = (HitsAggregationResult)reqBuilder.getRequestList().get(0)
- .getLevels().get(0)
- .getGroupPrototype()
- .getAggregationResults().get(0);
+ HitsAggregationResult hits = (HitsAggregationResult) reqBuilder.getRequestList().get(0)
+ .getLevels().get(0)
+ .getGroupPrototype()
+ .getAggregationResults().get(0);
assertEquals(ExpressionConverter.DEFAULT_SUMMARY_NAME, hits.getSummaryClass());
}
@Test
- public void requireThatGroupOfGroupsAreNotSupported() {
+ void requireThatGroupOfGroupsAreNotSupported() {
// "Can not group list of groups."
assertBuildFail("all(group(a) all(group(avg(b)) each(each(each(output(summary()))))))",
"Can not operate on list of list of groups.");
}
@Test
- public void requireThatAnonymousListsAreNotSupported() {
+ void requireThatAnonymousListsAreNotSupported() {
assertBuildFail("all(group(a) all(each(each(output(summary())))))",
- "Can not create anonymous list of groups.");
+ "Can not create anonymous list of groups.");
}
@Test
- public void requireThatOffsetContinuationCanModifyGroupingLevel() {
+ void requireThatOffsetContinuationCanModifyGroupingLevel() {
assertOffset("all(group(a) max(5) each(output(count())))",
- newOffset(2, 5),
- "[[{ tag = 2, max = [5, 11], hits = [] }]]");
+ newOffset(2, 5),
+ "[[{ tag = 2, max = [5, 11], hits = [] }]]");
assertOffset("all(group(a) max(5) each(output(count())) as(foo)" +
- " each(output(count())) as(bar))",
- newOffset(2, 5),
- "[[{ tag = 2, max = [5, 11], hits = [] }]," +
- " [{ tag = 4, max = [5, 6], hits = [] }]]");
+ " each(output(count())) as(bar))",
+ newOffset(2, 5),
+ "[[{ tag = 2, max = [5, 11], hits = [] }]," +
+ " [{ tag = 4, max = [5, 6], hits = [] }]]");
assertOffset("all(group(a) max(5) each(output(count())) as(foo)" +
- " each(output(count())) as(bar))",
+ " each(output(count())) as(bar))",
newComposite(newOffset(2, 5), newOffset(4, 10)),
"[[{ tag = 2, max = [5, 11], hits = [] }]," +
" [{ tag = 4, max = [5, 16], hits = [] }]]");
}
@Test
- public void requireThatOffsetContinuationCanModifyHitAggregator() {
+ void requireThatOffsetContinuationCanModifyHitAggregator() {
assertOffset("all(group(a) each(max(5) each(output(summary()))))",
- newOffset(3, 5),
- "[[{ tag = 2, max = [0, -1], hits = [{ tag = 3, max = [5, 11] }] }]]");
+ newOffset(3, 5),
+ "[[{ tag = 2, max = [0, -1], hits = [{ tag = 3, max = [5, 11] }] }]]");
assertOffset("all(group(a) each(max(5) each(output(summary()))) as(foo)" +
- " each(max(5) each(output(summary()))) as(bar))",
- newOffset(3, 5),
- "[[{ tag = 2, max = [0, -1], hits = [{ tag = 3, max = [5, 11] }] }]," +
- " [{ tag = 4, max = [0, -1], hits = [{ tag = 5, max = [5, 6] }] }]]");
+ " each(max(5) each(output(summary()))) as(bar))",
+ newOffset(3, 5),
+ "[[{ tag = 2, max = [0, -1], hits = [{ tag = 3, max = [5, 11] }] }]," +
+ " [{ tag = 4, max = [0, -1], hits = [{ tag = 5, max = [5, 6] }] }]]");
assertOffset("all(group(a) each(max(5) each(output(summary()))) as(foo)" +
- " each(max(5) each(output(summary()))) as(bar))",
- newComposite(newOffset(3, 5), newOffset(5, 10)),
- "[[{ tag = 2, max = [0, -1], hits = [{ tag = 3, max = [5, 11] }] }]," +
- " [{ tag = 4, max = [0, -1], hits = [{ tag = 5, max = [5, 16] }] }]]");
+ " each(max(5) each(output(summary()))) as(bar))",
+ newComposite(newOffset(3, 5), newOffset(5, 10)),
+ "[[{ tag = 2, max = [0, -1], hits = [{ tag = 3, max = [5, 11] }] }]," +
+ " [{ tag = 4, max = [0, -1], hits = [{ tag = 5, max = [5, 16] }] }]]");
}
@Test
- public void requireThatOffsetContinuationIsNotAppliedToGroupingLevelWithoutMax() {
+ void requireThatOffsetContinuationIsNotAppliedToGroupingLevelWithoutMax() {
assertOffset("all(group(a) each(output(count())))",
- newOffset(2, 5),
- "[[{ tag = 2, max = [0, -1], hits = [] }]]");
+ newOffset(2, 5),
+ "[[{ tag = 2, max = [0, -1], hits = [] }]]");
}
@Test
- public void requireThatOffsetContinuationIsNotAppliedToHitAggregatorWithoutMax() {
+ void requireThatOffsetContinuationIsNotAppliedToHitAggregatorWithoutMax() {
assertOffset("all(group(a) each(each(output(summary()))))",
- newOffset(3, 5),
- "[[{ tag = 2, max = [0, -1], hits = [{ tag = 3, max = [0, -1] }] }]]");
+ newOffset(3, 5),
+ "[[{ tag = 2, max = [0, -1], hits = [{ tag = 3, max = [0, -1] }] }]]");
}
@Test
- public void requireThatUnstableContinuationsDoNotAffectRequestedGroupLists() {
+ void requireThatUnstableContinuationsDoNotAffectRequestedGroupLists() {
String request = "all(group(a) max(5) each(group(b) max(5) each(output(count())) as(a1_b1)" +
- " each(output(count())) as(a1_b2)) as(a1)" +
- " each(group(b) max(5) each(output(count())) as(a2_b1)" +
- " each(output(count())) as(a2_b2)) as(a2))";
+ " each(output(count())) as(a1_b2)) as(a1)" +
+ " each(group(b) max(5) each(output(count())) as(a2_b1)" +
+ " each(output(count())) as(a2_b2)) as(a2))";
CompositeContinuation session = newComposite(newOffset(2, 5), newOffset(3, 5), newOffset(5, 5),
- newOffset(7, 5), newOffset(8, 5), newOffset(10, 5));
+ newOffset(7, 5), newOffset(8, 5), newOffset(10, 5));
assertOffset(request, newComposite(session),
- "[[{ tag = 2, max = [5, 11], hits = [] }, { tag = 3, max = [5, 11], hits = [] }]," +
- " [{ tag = 2, max = [5, 11], hits = [] }, { tag = 5, max = [5, 11], hits = [] }]," +
- " [{ tag = 7, max = [5, 11], hits = [] }, { tag = 10, max = [5, 11], hits = [] }]," +
- " [{ tag = 7, max = [5, 11], hits = [] }, { tag = 8, max = [5, 11], hits = [] }]]");
+ "[[{ tag = 2, max = [5, 11], hits = [] }, { tag = 3, max = [5, 11], hits = [] }]," +
+ " [{ tag = 2, max = [5, 11], hits = [] }, { tag = 5, max = [5, 11], hits = [] }]," +
+ " [{ tag = 7, max = [5, 11], hits = [] }, { tag = 10, max = [5, 11], hits = [] }]," +
+ " [{ tag = 7, max = [5, 11], hits = [] }, { tag = 8, max = [5, 11], hits = [] }]]");
assertOffset(request, newComposite(session, newUnstableOffset(2, 10)),
- "[[{ tag = 2, max = [5, 16], hits = [] }, { tag = 3, max = [5, 11], hits = [] }]," +
- " [{ tag = 2, max = [5, 16], hits = [] }, { tag = 5, max = [5, 11], hits = [] }]," +
- " [{ tag = 7, max = [5, 11], hits = [] }, { tag = 10, max = [5, 11], hits = [] }]," +
- " [{ tag = 7, max = [5, 11], hits = [] }, { tag = 8, max = [5, 11], hits = [] }]]");
+ "[[{ tag = 2, max = [5, 16], hits = [] }, { tag = 3, max = [5, 11], hits = [] }]," +
+ " [{ tag = 2, max = [5, 16], hits = [] }, { tag = 5, max = [5, 11], hits = [] }]," +
+ " [{ tag = 7, max = [5, 11], hits = [] }, { tag = 10, max = [5, 11], hits = [] }]," +
+ " [{ tag = 7, max = [5, 11], hits = [] }, { tag = 8, max = [5, 11], hits = [] }]]");
assertOffset(request, newComposite(session, newUnstableOffset(7, 10)),
- "[[{ tag = 2, max = [5, 11], hits = [] }, { tag = 3, max = [5, 11], hits = [] }]," +
- " [{ tag = 2, max = [5, 11], hits = [] }, { tag = 5, max = [5, 11], hits = [] }]," +
- " [{ tag = 7, max = [5, 16], hits = [] }, { tag = 10, max = [5, 11], hits = [] }]," +
- " [{ tag = 7, max = [5, 16], hits = [] }, { tag = 8, max = [5, 11], hits = [] }]]");
+ "[[{ tag = 2, max = [5, 11], hits = [] }, { tag = 3, max = [5, 11], hits = [] }]," +
+ " [{ tag = 2, max = [5, 11], hits = [] }, { tag = 5, max = [5, 11], hits = [] }]," +
+ " [{ tag = 7, max = [5, 16], hits = [] }, { tag = 10, max = [5, 11], hits = [] }]," +
+ " [{ tag = 7, max = [5, 16], hits = [] }, { tag = 8, max = [5, 11], hits = [] }]]");
assertOffset(request, newComposite(session, newUnstableOffset(2, 10), newUnstableOffset(7, 10)),
- "[[{ tag = 2, max = [5, 16], hits = [] }, { tag = 3, max = [5, 11], hits = [] }]," +
- " [{ tag = 2, max = [5, 16], hits = [] }, { tag = 5, max = [5, 11], hits = [] }]," +
- " [{ tag = 7, max = [5, 16], hits = [] }, { tag = 10, max = [5, 11], hits = [] }]," +
- " [{ tag = 7, max = [5, 16], hits = [] }, { tag = 8, max = [5, 11], hits = [] }]]");
+ "[[{ tag = 2, max = [5, 16], hits = [] }, { tag = 3, max = [5, 11], hits = [] }]," +
+ " [{ tag = 2, max = [5, 16], hits = [] }, { tag = 5, max = [5, 11], hits = [] }]," +
+ " [{ tag = 7, max = [5, 16], hits = [] }, { tag = 10, max = [5, 11], hits = [] }]," +
+ " [{ tag = 7, max = [5, 16], hits = [] }, { tag = 8, max = [5, 11], hits = [] }]]");
}
@Test
- public void requireThatUnstableContinuationsDoNotAffectRequestedHitLists() {
+ void requireThatUnstableContinuationsDoNotAffectRequestedHitLists() {
String request = "all(group(a) max(5) each(max(5) each(output(summary())) as(a1_h1)" +
- " each(output(summary())) as(a1_h2)) as(a1)" +
- " each(max(5) each(output(summary())) as(a2_h1)" +
- " each(output(summary())) as(a2_h2)) as(a2))";
+ " each(output(summary())) as(a1_h2)) as(a1)" +
+ " each(max(5) each(output(summary())) as(a2_h1)" +
+ " each(output(summary())) as(a2_h2)) as(a2))";
CompositeContinuation session = newComposite(newOffset(2, 5), newOffset(3, 5), newOffset(4, 5),
- newOffset(5, 5), newOffset(6, 5), newOffset(7, 5));
+ newOffset(5, 5), newOffset(6, 5), newOffset(7, 5));
assertOffset(request, newComposite(session),
- "[[{ tag = 2, max = [5, 11], hits = [{ tag = 3, max = [5, 11] }] }]," +
- " [{ tag = 2, max = [5, 11], hits = [{ tag = 4, max = [5, 11] }] }]," +
- " [{ tag = 5, max = [5, 11], hits = [{ tag = 6, max = [5, 11] }] }]," +
- " [{ tag = 5, max = [5, 11], hits = [{ tag = 7, max = [5, 11] }] }]]");
+ "[[{ tag = 2, max = [5, 11], hits = [{ tag = 3, max = [5, 11] }] }]," +
+ " [{ tag = 2, max = [5, 11], hits = [{ tag = 4, max = [5, 11] }] }]," +
+ " [{ tag = 5, max = [5, 11], hits = [{ tag = 6, max = [5, 11] }] }]," +
+ " [{ tag = 5, max = [5, 11], hits = [{ tag = 7, max = [5, 11] }] }]]");
assertOffset(request, newComposite(session, newUnstableOffset(2, 10)),
- "[[{ tag = 2, max = [5, 16], hits = [{ tag = 3, max = [5, 11] }] }]," +
- " [{ tag = 2, max = [5, 16], hits = [{ tag = 4, max = [5, 11] }] }]," +
- " [{ tag = 5, max = [5, 11], hits = [{ tag = 6, max = [5, 11] }] }]," +
- " [{ tag = 5, max = [5, 11], hits = [{ tag = 7, max = [5, 11] }] }]]");
+ "[[{ tag = 2, max = [5, 16], hits = [{ tag = 3, max = [5, 11] }] }]," +
+ " [{ tag = 2, max = [5, 16], hits = [{ tag = 4, max = [5, 11] }] }]," +
+ " [{ tag = 5, max = [5, 11], hits = [{ tag = 6, max = [5, 11] }] }]," +
+ " [{ tag = 5, max = [5, 11], hits = [{ tag = 7, max = [5, 11] }] }]]");
assertOffset(request, newComposite(session, newUnstableOffset(5, 10)),
- "[[{ tag = 2, max = [5, 11], hits = [{ tag = 3, max = [5, 11] }] }]," +
- " [{ tag = 2, max = [5, 11], hits = [{ tag = 4, max = [5, 11] }] }]," +
- " [{ tag = 5, max = [5, 16], hits = [{ tag = 6, max = [5, 11] }] }]," +
- " [{ tag = 5, max = [5, 16], hits = [{ tag = 7, max = [5, 11] }] }]]");
+ "[[{ tag = 2, max = [5, 11], hits = [{ tag = 3, max = [5, 11] }] }]," +
+ " [{ tag = 2, max = [5, 11], hits = [{ tag = 4, max = [5, 11] }] }]," +
+ " [{ tag = 5, max = [5, 16], hits = [{ tag = 6, max = [5, 11] }] }]," +
+ " [{ tag = 5, max = [5, 16], hits = [{ tag = 7, max = [5, 11] }] }]]");
assertOffset(request, newComposite(session, newUnstableOffset(2, 10), newUnstableOffset(5, 10)),
- "[[{ tag = 2, max = [5, 16], hits = [{ tag = 3, max = [5, 11] }] }]," +
- " [{ tag = 2, max = [5, 16], hits = [{ tag = 4, max = [5, 11] }] }]," +
- " [{ tag = 5, max = [5, 16], hits = [{ tag = 6, max = [5, 11] }] }]," +
- " [{ tag = 5, max = [5, 16], hits = [{ tag = 7, max = [5, 11] }] }]]");
+ "[[{ tag = 2, max = [5, 16], hits = [{ tag = 3, max = [5, 11] }] }]," +
+ " [{ tag = 2, max = [5, 16], hits = [{ tag = 4, max = [5, 11] }] }]," +
+ " [{ tag = 5, max = [5, 16], hits = [{ tag = 6, max = [5, 11] }] }]," +
+ " [{ tag = 5, max = [5, 16], hits = [{ tag = 7, max = [5, 11] }] }]]");
}
@Test
- public void requireThatExpressionsCanBeAliased() {
+ void requireThatExpressionsCanBeAliased() {
OutputWriter writer = (groupingList, transform) -> groupingList.get(0).getLevels().get(0).getGroupPrototype().getAggregationResults().get(0)
- .toString();
+ .toString();
RequestTest test = new RequestTest();
test.expectedOutput = new SumAggregationResult().setTag(3).setExpression(new AttributeNode("price")).toString();
@@ -373,89 +371,89 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatGroupingLayoutIsCorrect() {
+ void requireThatGroupingLayoutIsCorrect() {
assertLayout("all(group(artist) each(max(69) output(count()) each(output(summary()))))",
- "[[{ Attribute, result = [Count, Hits] }]]");
+ "[[{ Attribute, result = [Count, Hits] }]]");
assertLayout("all(group(artist) each(output(count()) all(group(album) each(output(count()) all(group(song) each(max(69) output(count()) each(output(summary()))))))))",
- "[[{ Attribute, result = [Count] }, { Attribute, result = [Count] }, { Attribute, result = [Count, Hits] }]]");
+ "[[{ Attribute, result = [Count] }, { Attribute, result = [Count] }, { Attribute, result = [Count, Hits] }]]");
assertLayout("all(group(artist) each(output(count())))",
- "[[{ Attribute, result = [Count] }]]");
+ "[[{ Attribute, result = [Count] }]]");
assertLayout("all(group(artist) order(sum(price)) each(output(count())))",
- "[[{ Attribute, result = [Count, Sum], order = [[1], [AggregationRef]] }]]");
+ "[[{ Attribute, result = [Count, Sum], order = [[1], [AggregationRef]] }]]");
assertLayout("all(group(artist) each(max(69) output(count()) each(output(summary(foo)))))",
- "[[{ Attribute, result = [Count, Hits] }]]");
+ "[[{ Attribute, result = [Count, Hits] }]]");
assertLayout("all(group(artist) each(output(count()) all(group(album) each(output(count())))))",
- "[[{ Attribute, result = [Count] }, { Attribute, result = [Count] }]]");
+ "[[{ Attribute, result = [Count] }, { Attribute, result = [Count] }]]");
assertLayout("all(group(artist) max(5) each(output(count()) all(group(album) max(3) each(output(count())))))",
- "[[{ Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [4, 4], result = [Count] }]]");
+ "[[{ Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [4, 4], result = [Count] }]]");
assertLayout("all(group(artist) max(5) each(output(count()) all(group(album) max(3) each(output(count())))))",
- "[[{ Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [4, 4], result = [Count] }]]");
+ "[[{ Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [4, 4], result = [Count] }]]");
assertLayout("all(group(foo) max(10) each(output(count()) all(group(bar) max(10) each(output(count())))))",
- "[[{ Attribute, max = [11, 11], result = [Count] }, { Attribute, max = [11, 11], result = [Count] }]]");
+ "[[{ Attribute, max = [11, 11], result = [Count] }, { Attribute, max = [11, 11], result = [Count] }]]");
assertLayout("all(group(a) max(5) each(max(69) output(count()) each(output(summary()))))",
- "[[{ Attribute, max = [6, 6], result = [Count, Hits] }]]");
+ "[[{ Attribute, max = [6, 6], result = [Count, Hits] }]]");
assertLayout("all(group(a) max(5) each(output(count()) all(group(b) max(5) each(max(69) output(count()) each(output(summary()))))))",
- "[[{ Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [6, 6], result = [Count, Hits] }]]");
+ "[[{ Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [6, 6], result = [Count, Hits] }]]");
assertLayout("all(group(a) max(5) each(output(count()) all(group(b) max(5) each(output(count()) all(group(c) max(5) each(max(69) output(count()) each(output(summary()))))))))",
- "[[{ Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [6, 6], result = [Count, Hits] }]]");
+ "[[{ Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [6, 6], result = [Count] }, { Attribute, max = [6, 6], result = [Count, Hits] }]]");
assertLayout("all(group(fixedwidth(n,3)) max(5) each(output(count()) all(group(a) max(2) each(output(count())))))",
- "[[{ FixedWidthBucket, max = [6, 6], result = [Count] }, { Attribute, max = [3, 3], result = [Count] }]]");
+ "[[{ FixedWidthBucket, max = [6, 6], result = [Count] }, { Attribute, max = [3, 3], result = [Count] }]]");
assertLayout("all(group(fixedwidth(n,3)) max(5) each(output(count()) all(group(a) max(2) each(output(count())))))",
- "[[{ FixedWidthBucket, max = [6, 6], result = [Count] }, { Attribute, max = [3, 3], result = [Count] }]]");
+ "[[{ FixedWidthBucket, max = [6, 6], result = [Count] }, { Attribute, max = [3, 3], result = [Count] }]]");
assertLayout("all(group(fixedwidth(n,3)) max(5) each(output(count()) all(group(a) max(2) each(max(1) output(count()) each(output(summary()))))))",
- "[[{ FixedWidthBucket, max = [6, 6], result = [Count] }, { Attribute, max = [3, 3], result = [Count, Hits] }]]");
+ "[[{ FixedWidthBucket, max = [6, 6], result = [Count] }, { Attribute, max = [3, 3], result = [Count, Hits] }]]");
assertLayout("all(group(predefined(n,bucket(1,3),bucket(6,9))) each(output(count())))",
- "[[{ RangeBucketPreDef, result = [Count] }]]");
+ "[[{ RangeBucketPreDef, result = [Count] }]]");
assertLayout("all(group(predefined(f,bucket(1.0,3.0),bucket(6.0,9.0))) each(output(count())))",
- "[[{ RangeBucketPreDef, result = [Count] }]]");
+ "[[{ RangeBucketPreDef, result = [Count] }]]");
assertLayout("all(group(predefined(s,bucket(\"ab\",\"cd\"),bucket(\"ef\",\"gh\"))) each(output(count())))",
- "[[{ RangeBucketPreDef, result = [Count] }]]");
+ "[[{ RangeBucketPreDef, result = [Count] }]]");
assertLayout("all(group(a) max(5) each(output(count())))",
- "[[{ Attribute, max = [6, 6], result = [Count] }]]");
+ "[[{ Attribute, max = [6, 6], result = [Count] }]]");
assertLayout("all(group(a) max(5) each(output(count())))",
- "[[{ Attribute, max = [6, 6], result = [Count] }]]");
+ "[[{ Attribute, max = [6, 6], result = [Count] }]]");
assertLayout("all(max(9) all(group(a) each(output(count()))))",
- "[[{ Attribute, result = [Count] }]]");
+ "[[{ Attribute, result = [Count] }]]");
assertLayout("all(where(true) all(group(a) each(output(count()))))",
- "[[{ Attribute, result = [Count] }]]");
+ "[[{ Attribute, result = [Count] }]]");
assertLayout("all(group(a) order(sum(n)) each(output(count())))",
- "[[{ Attribute, result = [Count, Sum], order = [[1], [AggregationRef]] }]]");
+ "[[{ Attribute, result = [Count, Sum], order = [[1], [AggregationRef]] }]]");
assertLayout("all(group(a) max(2) each(output(count())))",
- "[[{ Attribute, max = [3, 3], result = [Count] }]]");
+ "[[{ Attribute, max = [3, 3], result = [Count] }]]");
assertLayout("all(group(a) max(2) precision(10) each(output(count())))",
- "[[{ Attribute, max = [3, 10], result = [Count] }]]");
+ "[[{ Attribute, max = [3, 10], result = [Count] }]]");
assertLayout("all(group(fixedwidth(a,1)) each(output(count())))",
- "[[{ FixedWidthBucket, result = [Count] }]]");
+ "[[{ FixedWidthBucket, result = [Count] }]]");
}
@Test
- public void requireThatAggregatorCanBeUsedAsArgumentToOrderByFunction() {
+ void requireThatAggregatorCanBeUsedAsArgumentToOrderByFunction() {
assertLayout("all(group(a) order(sum(price) * count()) each(output(count())))",
- "[[{ Attribute, result = [Count, Sum], order = [[1], [Multiply]] }]]");
+ "[[{ Attribute, result = [Count, Sum], order = [[1], [Multiply]] }]]");
assertLayout("all(group(a) order(sum(price) + 4) each(output(sum(price))))",
- "[[{ Attribute, result = [Sum], order = [[1], [Add]] }]]");
+ "[[{ Attribute, result = [Sum], order = [[1], [Add]] }]]");
assertLayout("all(group(a) order(sum(price) + 4, count()) each(output(sum(price))))",
- "[[{ Attribute, result = [Sum, Count], order = [[1, 2], [Add, AggregationRef]] }]]");
+ "[[{ Attribute, result = [Sum, Count], order = [[1, 2], [Add, AggregationRef]] }]]");
assertLayout("all(group(a) order(sum(price) + 4, -count()) each(output(sum(price))))",
- "[[{ Attribute, result = [Sum, Count], order = [[1, -2], [Add, AggregationRef]] }]]");
+ "[[{ Attribute, result = [Sum, Count], order = [[1, -2], [Add, AggregationRef]] }]]");
}
@Test
- public void requireThatSameAggregatorCanBeUsedMultipleTimes() {
+ void requireThatSameAggregatorCanBeUsedMultipleTimes() {
assertLayout("all(group(a) each(output(count() as(b),count() as(c))))",
- "[[{ Attribute, result = [Count, Count] }]]");
+ "[[{ Attribute, result = [Count, Count] }]]");
}
@Test
- public void requireThatSiblingAggregatorsCanNotShareSameLabel() {
+ void requireThatSiblingAggregatorsCanNotShareSameLabel() {
assertBuildFail("all(group(a) each(output(count(),count())))",
- "Can not use output label 'count()' for multiple siblings.");
+ "Can not use output label 'count()' for multiple siblings.");
assertBuildFail("all(group(a) each(output(count() as(b),count() as(b))))",
"Can not use output label 'b' for multiple siblings.");
}
@Test
- public void requireThatOrderByReusesOutputResults() {
+ void requireThatOrderByReusesOutputResults() {
assertLayout("all(group(a) order(count()) each(output(count())))",
"[[{ Attribute, result = [Count], order = [[1], [AggregationRef]] }]]");
assertLayout("all(group(a) order(count()) each(output(count() as(b))))",
@@ -463,40 +461,40 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatNoopBranchesArePruned() {
+ void requireThatNoopBranchesArePruned() {
assertLayout("all()", "[]");
assertLayout("all(group(a))", "[]");
assertLayout("all(group(a) each())", "[]");
String expectedA = "[{ Attribute, result = [Count] }]";
assertLayout("all(group(a) each(output(count())))",
- Arrays.asList(expectedA).toString());
+ Arrays.asList(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all()))",
- Arrays.asList(expectedA).toString());
+ Arrays.asList(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b))))",
- Arrays.asList(expectedA).toString());
+ Arrays.asList(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())))",
- Arrays.asList(expectedA).toString());
+ Arrays.asList(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())))",
- Arrays.asList(expectedA).toString());
+ Arrays.asList(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())) as(foo)" +
- " each())",
- Arrays.asList(expectedA).toString());
+ " each())",
+ Arrays.asList(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())) as(foo)" +
- " each(group(b)))",
- Arrays.asList(expectedA).toString());
+ " each(group(b)))",
+ Arrays.asList(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())) as(foo)" +
- " each(group(b) each()))",
- Arrays.asList(expectedA).toString());
+ " each(group(b) each()))",
+ Arrays.asList(expectedA).toString());
String expectedB = "[{ Attribute }, { Attribute, result = [Count] }]";
assertLayout("all(group(a) each(output(count()) all(group(b) each())) as(foo)" +
- " each(group(b) each(output(count()))))",
- Arrays.asList(expectedB, expectedA).toString());
+ " each(group(b) each(output(count()))))",
+ Arrays.asList(expectedB, expectedA).toString());
}
@Test
- public void requireThatAggregationLevelIsValidatedFails() {
+ void requireThatAggregationLevelIsValidatedFails() {
assertBuildFail("all(group(artist) output(sum(length)))",
"Expression 'length' not applicable for single group.");
assertBuild("all(group(artist) each(output(count())))");
@@ -506,46 +504,46 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatCountOnListOfGroupsIsValidated() {
+ void requireThatCountOnListOfGroupsIsValidated() {
assertBuild("all(group(artist) output(count()))");
assertBuild("all(group(artist) each(group(album) output(count())))");
}
@Test
- public void requireThatGroupByIsValidated() {
+ void requireThatGroupByIsValidated() {
assertBuild("all(group(artist) each(output(count())))");
assertBuildFail("all(group(sum(artist)) each(output(count())))",
- "Expression 'sum(artist)' not applicable for single hit.");
+ "Expression 'sum(artist)' not applicable for single hit.");
assertBuild("all(group(artist) each(group(album) each(output(count()))))");
assertBuildFail("all(group(artist) each(group(sum(album)) each(output(count()))))",
- "Expression 'sum(album)' not applicable for single hit.");
+ "Expression 'sum(album)' not applicable for single hit.");
}
@Test
- public void requireThatGroupingLevelIsValidated() {
+ void requireThatGroupingLevelIsValidated() {
assertBuild("all(group(artist))");
assertBuild("all(group(artist) each(group(album)))");
assertBuildFail("all(group(artist) all(group(sum(price))))",
- "Can not operate on list of list of groups.");
+ "Can not operate on list of list of groups.");
assertBuild("all(group(artist) each(group(album) each(group(song))))");
assertBuildFail("all(group(artist) each(group(album) all(group(sum(price)))))",
- "Can not operate on list of list of groups.");
+ "Can not operate on list of list of groups.");
}
@Test
- public void requireThatOrderByIsValidated() {
+ void requireThatOrderByIsValidated() {
assertBuildFail("all(order(length))",
- "Can not order single group content.");
+ "Can not order single group content.");
assertBuild("all(group(artist) order(sum(length)))");
assertBuildFail("all(group(artist) each(order(length)))",
- "Can not order single group content.");
+ "Can not order single group content.");
assertBuild("all(group(artist) each(group(album) order(sum(length))))");
assertBuildFail("all(group(artist) each(group(album) each(order(length))))",
- "Can not order single group content.");
+ "Can not order single group content.");
}
@Test
- public void requireThatOrderByHasCorrectReference() {
+ void requireThatOrderByHasCorrectReference() {
assertOrderBy("all(group(a) order(count()) each(output(count())))", "[[[1]]]");
assertOrderBy("all(group(a) order(-count()) each(output(count())))", "[[[-1]]]");
assertOrderBy("all(group(a) order(count()) each(output(count(),sum(b))))", "[[[1]]]");
@@ -565,23 +563,23 @@ public class RequestBuilderTestCase {
assertOrderBy("all(group(a) order(-count(),-sum(b)) each(output(sum(b), count())))", "[[[-1, -2]]]");
assertOrderBy("all(group(a) order(count()) each(output(count())) as(foo)" +
- " each(output(sum(b))) as(bar))",
- "[[[1]], [[1]]]");
+ " each(output(sum(b))) as(bar))",
+ "[[[1]], [[1]]]");
}
@Test
- public void requireThatWhereIsValidated() {
+ void requireThatWhereIsValidated() {
assertBuild("all(where(true))");
assertBuild("all(where($query))");
assertBuildFail("all(where(foo))",
- "Operation 'where' does not support 'foo'.");
+ "Operation 'where' does not support 'foo'.");
assertBuildFail("all(group(artist) where(true))",
- "Can not apply 'where' to non-root group.");
+ "Can not apply 'where' to non-root group.");
}
@Test
- public void requireThatRootAggregationCanBeTransformed() {
+ void requireThatRootAggregationCanBeTransformed() {
RequestTest test = new RequestTest();
test.expectedOutput = CountAggregationResult.class.getName();
test.request = "all(output(count()))";
@@ -590,68 +588,68 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatExpressionsCanBeLabeled() {
+ void requireThatExpressionsCanBeLabeled() {
assertLabel("all(group(a) each(output(count())))",
- "[[{ label = 'a', results = [count()] }]]");
+ "[[{ label = 'a', results = [count()] }]]");
assertLabel("all(group(a) each(output(count())) as(b))",
- "[[{ label = 'b', results = [count()] }]]");
+ "[[{ label = 'b', results = [count()] }]]");
assertLabel("all(group(a) each(group(b) each(output(count()))))",
- "[[{ label = 'a', results = [] }, { label = 'b', results = [count()] }]]");
+ "[[{ label = 'a', results = [] }, { label = 'b', results = [count()] }]]");
assertLabel("all(group(a) each(group(b) each(group(c) each(output(count())))))",
- "[[{ label = 'a', results = [] }, { label = 'b', results = [] }, { label = 'c', results = [count()] }]]");
+ "[[{ label = 'a', results = [] }, { label = 'b', results = [] }, { label = 'c', results = [count()] }]]");
assertBuildFail("all(group(a) each(output(count())) each(output(count())))",
- "Can not use group list label 'a' for multiple siblings.");
+ "Can not use group list label 'a' for multiple siblings.");
assertBuildFail("all(all(group(a) each(output(count())))" +
- " all(group(a) each(output(count()))))",
- "Can not use group list label 'a' for multiple siblings.");
+ " all(group(a) each(output(count()))))",
+ "Can not use group list label 'a' for multiple siblings.");
assertLabel("all(group(a) each(output(count())) as(a1)" +
- " each(output(count())) as(a2))",
- "[[{ label = 'a1', results = [count()] }], [{ label = 'a2', results = [count()] }]]");
+ " each(output(count())) as(a2))",
+ "[[{ label = 'a1', results = [count()] }], [{ label = 'a2', results = [count()] }]]");
assertLabel("all(group(a) each(all(group(b) each(output(count())))" +
- " all(group(c) each(output(count())))))",
- "[[{ label = 'a', results = [] }, { label = 'b', results = [count()] }], [{ label = 'a', results = [] }, { label = 'c', results = [count()] }]]");
+ " all(group(c) each(output(count())))))",
+ "[[{ label = 'a', results = [] }, { label = 'b', results = [count()] }], [{ label = 'a', results = [] }, { label = 'c', results = [count()] }]]");
assertLabel("all(group(a) each(group(b) each(output(count()))) as(a1)" +
- " each(group(b) each(output(count()))) as(a2))",
- "[[{ label = 'a1', results = [] }, { label = 'b', results = [count()] }], [{ label = 'a2', results = [] }, { label = 'b', results = [count()] }]]");
+ " each(group(b) each(output(count()))) as(a2))",
+ "[[{ label = 'a1', results = [] }, { label = 'b', results = [count()] }], [{ label = 'a2', results = [] }, { label = 'b', results = [count()] }]]");
assertLabel("all(group(a) each(group(b) each(group(c) each(output(count())))) as(a1)" +
- " each(group(b) each(group(e) each(output(count())))) as(a2))",
- "[[{ label = 'a1', results = [] }, { label = 'b', results = [] }, { label = 'c', results = [count()] }]," +
- " [{ label = 'a2', results = [] }, { label = 'b', results = [] }, { label = 'e', results = [count()] }]]");
+ " each(group(b) each(group(e) each(output(count())))) as(a2))",
+ "[[{ label = 'a1', results = [] }, { label = 'b', results = [] }, { label = 'c', results = [count()] }]," +
+ " [{ label = 'a2', results = [] }, { label = 'b', results = [] }, { label = 'e', results = [count()] }]]");
assertLabel("all(group(a) each(group(b) each(output(count())) as(b1)" +
- " each(output(count())) as(b2)))",
- "[[{ label = 'a', results = [] }, { label = 'b1', results = [count()] }]," +
- " [{ label = 'a', results = [] }, { label = 'b2', results = [count()] }]]");
+ " each(output(count())) as(b2)))",
+ "[[{ label = 'a', results = [] }, { label = 'b1', results = [count()] }]," +
+ " [{ label = 'a', results = [] }, { label = 'b2', results = [count()] }]]");
assertBuildFail("all(group(a) each(each(output(summary() as(foo)))))",
- "Can not label expression 'summary()'.");
+ "Can not label expression 'summary()'.");
assertLabel("all(group(foo) each(each(output(summary()))))",
- "[[{ label = 'foo', results = [hits] }]]");
+ "[[{ label = 'foo', results = [hits] }]]");
assertLabel("all(group(foo) each(each(output(summary())) as(bar)))",
- "[[{ label = 'foo', results = [bar] }]]");
+ "[[{ label = 'foo', results = [bar] }]]");
assertLabel("all(group(foo) each(each(output(summary())) as(bar)) as(baz))",
- "[[{ label = 'baz', results = [bar] }]]");
+ "[[{ label = 'baz', results = [bar] }]]");
assertLabel("all(group(foo) each(each(output(summary())) as(bar)" +
- " each(output(summary())) as(baz)))",
- "[[{ label = 'foo', results = [bar] }]," +
- " [{ label = 'foo', results = [baz] }]]");
+ " each(output(summary())) as(baz)))",
+ "[[{ label = 'foo', results = [bar] }]," +
+ " [{ label = 'foo', results = [baz] }]]");
assertLabel("all(group(foo) each(each(output(summary())))" +
- " each(each(output(summary()))) as(bar))",
- "[[{ label = 'bar', results = [hits] }]," +
- " [{ label = 'foo', results = [hits] }]]");
+ " each(each(output(summary()))) as(bar))",
+ "[[{ label = 'bar', results = [hits] }]," +
+ " [{ label = 'foo', results = [hits] }]]");
}
@Test
- public void requireThatOrderByResultsAreNotLabeled() {
+ void requireThatOrderByResultsAreNotLabeled() {
assertLabel("all(group(a) each(output(min(b), max(b), avg(b))))",
- "[[{ label = 'a', results = [min(b), max(b), avg(b)] }]]");
+ "[[{ label = 'a', results = [min(b), max(b), avg(b)] }]]");
assertLabel("all(group(a) order(min(b)) each(output(max(b), avg(b))))",
- "[[{ label = 'a', results = [max(b), avg(b), null] }]]");
+ "[[{ label = 'a', results = [max(b), avg(b), null] }]]");
assertLabel("all(group(a) order(min(b), max(b)) each(output(avg(b))))",
- "[[{ label = 'a', results = [avg(b), null, null] }]]");
+ "[[{ label = 'a', results = [avg(b), null, null] }]]");
}
@Test
- public void requireThatTimeZoneIsAppliedToTimeFunctions() {
+ void requireThatTimeZoneIsAppliedToTimeFunctions() {
for (String timePart : Arrays.asList("dayofmonth", "dayofweek", "dayofyear", "hourofday",
"minuteofhour", "monthofyear", "secondofminute", "year"))
{
@@ -665,17 +663,17 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatTimeDateIsExpanded() {
+ void requireThatTimeDateIsExpanded() {
RequestTest test = new RequestTest();
test.expectedOutput = new StrCatFunctionNode()
.addArg(new ToStringFunctionNode(new TimeStampFunctionNode(new AttributeNode("foo"),
- TimeStampFunctionNode.TimePart.Year, true)))
+ TimeStampFunctionNode.TimePart.Year, true)))
.addArg(new ConstantNode(new StringResultNode("-")))
.addArg(new ToStringFunctionNode(new TimeStampFunctionNode(new AttributeNode("foo"),
- TimeStampFunctionNode.TimePart.Month, true)))
+ TimeStampFunctionNode.TimePart.Month, true)))
.addArg(new ConstantNode(new StringResultNode("-")))
.addArg(new ToStringFunctionNode(new TimeStampFunctionNode(new AttributeNode("foo"),
- TimeStampFunctionNode.TimePart.MonthDay, true)))
+ TimeStampFunctionNode.TimePart.MonthDay, true)))
.toString();
test.request = "all(output(avg(time.date(foo))))";
test.outputWriter = (groupingList, transform) -> groupingList.get(0).getRoot().getAggregationResults().get(0).getExpression().toString();
@@ -683,7 +681,7 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatNowIsResolvedToCurrentTime() {
+ void requireThatNowIsResolvedToCurrentTime() {
RequestTest test = new RequestTest();
test.expectedOutput = Boolean.toString(true);
test.request = "all(output(avg(now() - foo)))";
@@ -693,8 +691,8 @@ public class RequestBuilderTestCase {
@Override
public String write(List<Grouping> groupingList, GroupingTransform transform) {
AddFunctionNode add =
- (AddFunctionNode)groupingList.get(0).getRoot().getAggregationResults().get(0).getExpression();
- long nowValue = ((ConstantNode)add.getArg(0)).getValue().getInteger();
+ (AddFunctionNode) groupingList.get(0).getRoot().getAggregationResults().get(0).getExpression();
+ long nowValue = ((ConstantNode) add.getArg(0)).getValue().getInteger();
boolean preCond = nowValue >= (before / 1000);
long after = System.currentTimeMillis();
boolean postCond = nowValue <= (after / 1000);
@@ -706,7 +704,7 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatAttributeMapLookupNodeIsCreatedFromKey() {
+ void requireThatAttributeMapLookupNodeIsCreatedFromKey() {
RequestTest test = new RequestTest();
test.expectedOutput = AttributeMapLookupNode.fromKey("map{\"my_key\"}", "map.key", "map.value", "my_key").toString();
test.request = "all(group(map{\"my_key\"}) each(output(count())))";
@@ -715,7 +713,7 @@ public class RequestBuilderTestCase {
}
@Test
- public void requireThatAttributeMapLookupNodeIsCreatedFromKeySourceAttribute() {
+ void requireThatAttributeMapLookupNodeIsCreatedFromKeySourceAttribute() {
RequestTest test = new RequestTest();
test.expectedOutput = AttributeMapLookupNode.fromKeySourceAttribute("map{attribute(key_source)}", "map.key", "map.value", "key_source").toString();
test.request = "all(group(map{attribute(key_source)}) each(output(count())))";
@@ -724,7 +722,7 @@ public class RequestBuilderTestCase {
}
@Test
- public void require_that_default_max_values_from_request_builder_restricts_max_groups_and_hits() {
+ void require_that_default_max_values_from_request_builder_restricts_max_groups_and_hits() {
int defaultMaxHits = 19;
int defaultMaxGroups = 7;
RequestBuilder builder = new RequestBuilder(0)
@@ -735,12 +733,12 @@ public class RequestBuilderTestCase {
List<Grouping> requests = builder.getRequestList();
assertEquals(defaultMaxGroups + 1, requests.get(0).getLevels().get(0).getMaxGroups());
HitsAggregationResult hitsAggregation =
- (HitsAggregationResult)requests.get(0).getLevels().get(0).getGroupPrototype().getAggregationResults().get(0);
+ (HitsAggregationResult) requests.get(0).getLevels().get(0).getGroupPrototype().getAggregationResults().get(0);
assertEquals(defaultMaxHits + 1, hitsAggregation.getMaxHits());
}
@Test
- public void require_that_default_max_values_from_request_builder_respects_explicit_max() {
+ void require_that_default_max_values_from_request_builder_respects_explicit_max() {
{
RequestBuilder builder = new RequestBuilder(0)
.setDefaultMaxGroups(7)
@@ -750,7 +748,7 @@ public class RequestBuilderTestCase {
List<Grouping> requests = builder.getRequestList();
assertEquals(12, requests.get(0).getLevels().get(0).getMaxGroups());
HitsAggregationResult hitsAggregation =
- (HitsAggregationResult)requests.get(0).getLevels().get(0).getGroupPrototype().getAggregationResults().get(0);
+ (HitsAggregationResult) requests.get(0).getLevels().get(0).getGroupPrototype().getAggregationResults().get(0);
assertEquals(22, hitsAggregation.getMaxHits());
}
{
@@ -762,21 +760,21 @@ public class RequestBuilderTestCase {
List<Grouping> requests = builder.getRequestList();
assertEquals(-1, requests.get(0).getLevels().get(0).getMaxGroups());
HitsAggregationResult hitsAggregation =
- (HitsAggregationResult)requests.get(0).getLevels().get(0).getGroupPrototype().getAggregationResults().get(0);
+ (HitsAggregationResult) requests.get(0).getLevels().get(0).getGroupPrototype().getAggregationResults().get(0);
assertEquals(-1, hitsAggregation.getMaxHits());
}
}
@Test
- public void require_that_total_groups_and_summaries_calculation_is_correct() {
+ void require_that_total_groups_and_summaries_calculation_is_correct() {
assertTotalGroupsAndSummaries(5, "all(group(a) max(5) each(output(count())))");
- assertTotalGroupsAndSummaries(5+5*7, "all(group(a) max(5) each(max(7) each(output(summary()))))");
- assertTotalGroupsAndSummaries(3+3*5+3*5*7+3*5*7*11,
+ assertTotalGroupsAndSummaries(5 + 5 * 7, "all(group(a) max(5) each(max(7) each(output(summary()))))");
+ assertTotalGroupsAndSummaries(3 + 3 * 5 + 3 * 5 * 7 + 3 * 5 * 7 * 11,
"all( group(a) max(3) each(output(count())" +
- " all(group(b) max(5) each(output(count())" +
- " all(group(c) max(7) each(max(11) output(count())" +
- " each(output(summary()))))))))");
- assertTotalGroupsAndSummaries(2*(3+3*5),
+ " all(group(b) max(5) each(output(count())" +
+ " all(group(c) max(7) each(max(11) output(count())" +
+ " each(output(summary()))))))))");
+ assertTotalGroupsAndSummaries(2 * (3 + 3 * 5),
"all(" +
" all(group(a) max(3) each(output(count()) max(5) each(output(summary())))) " +
" all(group(b) max(3) each(output(count()) max(5) each(output(summary())))))");
@@ -784,24 +782,24 @@ public class RequestBuilderTestCase {
}
@Test
- public void require_that_total_groups_restriction_can_be_disabled() {
- assertTotalGroupsAndSummaries(3+3*5+3*5*7+3*5*7*100,
- -1, // disable
- "all( group(a) max(3) each(output(count())" +
- " all(group(b) max(5) each(output(count())" +
- " all(group(c) max(7) each(max(100) output(count())" +
- " each(output(summary()))))))))");
+ void require_that_total_groups_restriction_can_be_disabled() {
+ assertTotalGroupsAndSummaries(3 + 3 * 5 + 3 * 5 * 7 + 3 * 5 * 7 * 100,
+ -1, // disable
+ "all( group(a) max(3) each(output(count())" +
+ " all(group(b) max(5) each(output(count())" +
+ " all(group(c) max(7) each(max(100) output(count())" +
+ " each(output(summary()))))))))");
}
@Test
- public void require_that_unbounded_queries_fails_when_global_max_is_enabled() {
+ void require_that_unbounded_queries_fails_when_global_max_is_enabled() {
assertQueryFailsOnGlobalMax(4, "all(group(a) max(5) each(output(count())))", "5 > 4");
assertQueryFailsOnGlobalMax(Long.MAX_VALUE, "all(group(a) each(output(count())))", "unbounded number of groups");
assertQueryFailsOnGlobalMax(Long.MAX_VALUE, "all(group(a) max(5) each(each(output(summary()))))", "unbounded number of summaries");
}
@Test
- public void require_that_default_precision_factor_overrides_implicit_precision() {
+ void require_that_default_precision_factor_overrides_implicit_precision() {
int factor = 3;
RequestBuilder builder = new RequestBuilder(0)
.setDefaultPrecisionFactor(factor)
@@ -811,7 +809,7 @@ public class RequestBuilderTestCase {
}
@Test
- public void require_that_explicit_precision_has_precedence() {
+ void require_that_explicit_precision_has_precedence() {
RequestBuilder builder = new RequestBuilder(0)
.setDefaultPrecisionFactor(3)
.setRootOperation(GroupingOperation.fromString("all(group(foo)max(5)precision(10)each(output(count())))"));
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultBuilderTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultBuilderTestCase.java
index 3bc5a7c245c..019a022b7e6 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultBuilderTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultBuilderTestCase.java
@@ -13,12 +13,12 @@ import com.yahoo.search.result.Relevance;
import com.yahoo.searchlib.aggregation.*;
import com.yahoo.searchlib.aggregation.hll.SparseSketch;
import com.yahoo.searchlib.expression.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -29,28 +29,28 @@ public class ResultBuilderTestCase {
private static final int ROOT_IDX = 0;
@Test
- public void requireThatAllGroupIdsCanBeConverted() {
+ void requireThatAllGroupIdsCanBeConverted() {
assertGroupId("group:6.9", new FloatResultNode(6.9));
assertGroupId("group:69", new IntegerResultNode(69));
assertGroupId("group:null", new NullResultNode());
- assertGroupId("group:[6, 9]", new RawResultNode(new byte[] { 6, 9 }));
+ assertGroupId("group:[6, 9]", new RawResultNode(new byte[]{6, 9}));
assertGroupId("group:a", new StringResultNode("a"));
assertGroupId("group:6.9:9.6", new FloatBucketResultNode(6.9, 9.6));
assertGroupId("group:6:9", new IntegerBucketResultNode(6, 9));
assertGroupId("group:a:b", new StringBucketResultNode("a", "b"));
- assertGroupId("group:[6, 9]:[9, 6]", new RawBucketResultNode(new RawResultNode(new byte[] { 6, 9 }),
- new RawResultNode(new byte[] { 9, 6 })));
+ assertGroupId("group:[6, 9]:[9, 6]", new RawBucketResultNode(new RawResultNode(new byte[]{6, 9}),
+ new RawResultNode(new byte[]{9, 6})));
}
@Test
- public void requireThatUnknownGroupIdThrows() {
+ void requireThatUnknownGroupIdThrows() {
assertBuildFail("all(group(a) each(output(count())))",
- Arrays.asList(newGrouping(new Group().setTag(2).setId(new MyResultNode()))),
- "com.yahoo.search.grouping.vespa.ResultBuilderTestCase$MyResultNode");
+ Arrays.asList(newGrouping(new Group().setTag(2).setId(new MyResultNode()))),
+ "com.yahoo.search.grouping.vespa.ResultBuilderTestCase$MyResultNode");
}
@Test
- public void requireThatAllExpressionNodesCanBeConverted() {
+ void requireThatAllExpressionNodesCanBeConverted() {
assertResult("0", new AverageAggregationResult(new IntegerResultNode(6), 9));
assertResult("69", new CountAggregationResult(69));
assertResult("69", new MaxAggregationResult(new IntegerResultNode(69)));
@@ -61,89 +61,89 @@ public class ResultBuilderTestCase {
}
@Test
- public void requireThatUnknownExpressionNodeThrows() {
+ void requireThatUnknownExpressionNodeThrows() {
assertBuildFail("all(group(a) each(output(count())))",
- Arrays.asList(newGrouping(newGroup(2, 2, new MyAggregationResult().setTag(3)))),
- "com.yahoo.search.grouping.vespa.ResultBuilderTestCase$MyAggregationResult");
+ Arrays.asList(newGrouping(newGroup(2, 2, new MyAggregationResult().setTag(3)))),
+ "com.yahoo.search.grouping.vespa.ResultBuilderTestCase$MyAggregationResult");
}
@Test
- public void requireThatRootResultsAreIncluded() {
+ void requireThatRootResultsAreIncluded() {
assertLayout("all(output(count()))",
- new Grouping().setRoot(newGroup(1, new CountAggregationResult(69).setTag(2))),
- "RootGroup{id=group:root, count()=69}[]");
+ new Grouping().setRoot(newGroup(1, new CountAggregationResult(69).setTag(2))),
+ "RootGroup{id=group:root, count()=69}[]");
}
@Test
- public void requireThatRootResultsAreIncludedUsingExpressionCountAggregationResult() {
+ void requireThatRootResultsAreIncludedUsingExpressionCountAggregationResult() {
assertLayout("all(group(a) output(count()))",
new Grouping().setRoot(newGroup(1, new ExpressionCountAggregationResult(new SparseSketch(), sketch -> 69).setTag(2))),
"RootGroup{id=group:root, count()=69}[]");
}
@Test
- public void requireThatNestedGroupingResultsCanBeTransformed() {
+ void requireThatNestedGroupingResultsCanBeTransformed() {
Grouping grouping = new Grouping()
.setRoot(new Group()
- .setTag(1)
- .addChild(new Group()
- .setTag(2)
- .setId(new StringResultNode("foo"))
- .addAggregationResult(new CountAggregationResult(10).setTag(3))
- .addChild(new Group()
- .setTag(4)
- .setId(new StringResultNode("foo_a"))
- .addAggregationResult(new CountAggregationResult(15)
- .setTag(5)))
- .addChild(new Group()
- .setTag(4)
- .setId(new StringResultNode("foo_b"))
- .addAggregationResult(new CountAggregationResult(16)
- .setTag(5))))
- .addChild(new Group()
- .setTag(2)
- .setId(new StringResultNode("bar"))
- .addAggregationResult(new CountAggregationResult(20).setTag(3))
- .addChild(new Group()
- .setTag(4)
- .setId(new StringResultNode("bar_a"))
- .addAggregationResult(
- new CountAggregationResult(25)
- .setTag(5)))
- .addChild(new Group()
- .setTag(4)
- .setId(new StringResultNode("bar_b"))
- .addAggregationResult(
- new CountAggregationResult(26)
- .setTag(5)))));
+ .setTag(1)
+ .addChild(new Group()
+ .setTag(2)
+ .setId(new StringResultNode("foo"))
+ .addAggregationResult(new CountAggregationResult(10).setTag(3))
+ .addChild(new Group()
+ .setTag(4)
+ .setId(new StringResultNode("foo_a"))
+ .addAggregationResult(new CountAggregationResult(15)
+ .setTag(5)))
+ .addChild(new Group()
+ .setTag(4)
+ .setId(new StringResultNode("foo_b"))
+ .addAggregationResult(new CountAggregationResult(16)
+ .setTag(5))))
+ .addChild(new Group()
+ .setTag(2)
+ .setId(new StringResultNode("bar"))
+ .addAggregationResult(new CountAggregationResult(20).setTag(3))
+ .addChild(new Group()
+ .setTag(4)
+ .setId(new StringResultNode("bar_a"))
+ .addAggregationResult(
+ new CountAggregationResult(25)
+ .setTag(5)))
+ .addChild(new Group()
+ .setTag(4)
+ .setId(new StringResultNode("bar_b"))
+ .addAggregationResult(
+ new CountAggregationResult(26)
+ .setTag(5)))));
assertLayout("all(group(artist) max(5) each(output(count() as(baz)) all(group(album) " +
- "max(5) each(output(count() as(cox))) as(group_album))) as(group_artist))",
- grouping,
- "RootGroup{id=group:root}[GroupList{label=group_artist}[" +
- "Group{id=group:foo, baz=10}[GroupList{label=group_album}[Group{id=group:foo_a, cox=15}[], Group{id=group:foo_b, cox=16}[]]], " +
- "Group{id=group:bar, baz=20}[GroupList{label=group_album}[Group{id=group:bar_a, cox=25}[], Group{id=group:bar_b, cox=26}[]]]]]");
+ "max(5) each(output(count() as(cox))) as(group_album))) as(group_artist))",
+ grouping,
+ "RootGroup{id=group:root}[GroupList{label=group_artist}[" +
+ "Group{id=group:foo, baz=10}[GroupList{label=group_album}[Group{id=group:foo_a, cox=15}[], Group{id=group:foo_b, cox=16}[]]], " +
+ "Group{id=group:bar, baz=20}[GroupList{label=group_album}[Group{id=group:bar_a, cox=25}[], Group{id=group:bar_b, cox=26}[]]]]]");
}
@Test
- public void requireThatParallelResultsAreTransformed() {
+ void requireThatParallelResultsAreTransformed() {
assertBuild("all(group(foo) each(output(count())) as(bar) each(output(count())) as(baz))",
- Arrays.asList(new Grouping().setRoot(newGroup(1, 0)),
- new Grouping().setRoot(newGroup(1, 0))));
+ Arrays.asList(new Grouping().setRoot(newGroup(1, 0)),
+ new Grouping().setRoot(newGroup(1, 0))));
assertBuildFail("all(group(foo) each(output(count())) as(bar) each(output(count())) as(baz))",
- Arrays.asList(new Grouping().setRoot(newGroup(2)),
- new Grouping().setRoot(newGroup(3))),
- "Expected 1 group, got 2.");
+ Arrays.asList(new Grouping().setRoot(newGroup(2)),
+ new Grouping().setRoot(newGroup(3))),
+ "Expected 1 group, got 2.");
}
@Test
- public void requireThatTagsAreHandledCorrectly() {
+ void requireThatTagsAreHandledCorrectly() {
assertBuild("all(group(a) each(output(count())))",
Arrays.asList(newGrouping(
newGroup(7, new CountAggregationResult(0)))));
}
@Test
- public void requireThatEmptyBranchesArePruned() {
+ void requireThatEmptyBranchesArePruned() {
assertBuildFail("all()", Collections.<Grouping>emptyList(), "Expected 1 group, got 0.");
assertBuildFail("all(group(a))", Collections.<Grouping>emptyList(), "Expected 1 group, got 0.");
assertBuildFail("all(group(a) each())", Collections.<Grouping>emptyList(), "Expected 1 group, got 0.");
@@ -156,71 +156,71 @@ public class ResultBuilderTestCase {
assertLayout("all(group(a) each(output(count()) all(group(b) each())))", grouping, expectedOutput);
assertLayout("all(group(a) each(output(count()) all(group(b) each())))", grouping, expectedOutput);
assertLayout("all(group(a) each(output(count()) all(group(b) each()))" +
- " each() as(foo))", grouping, expectedOutput);
+ " each() as(foo))", grouping, expectedOutput);
assertLayout("all(group(a) each(output(count()) all(group(b) each()))" +
- " each(group(b)) as(foo))", grouping, expectedOutput);
+ " each(group(b)) as(foo))", grouping, expectedOutput);
assertLayout("all(group(a) each(output(count()) all(group(b) each()))" +
- " each(group(b) each()) as(foo))", grouping, expectedOutput);
+ " each(group(b) each()) as(foo))", grouping, expectedOutput);
}
@Test
- public void requireThatGroupListsAreLabeled() {
+ void requireThatGroupListsAreLabeled() {
assertLayout("all(group(a) each(output(count())))",
- newGrouping(newGroup(2, new CountAggregationResult(69).setTag(3))),
- "RootGroup{id=group:root}[GroupList{label=a}[Group{id=group:2, count()=69}[]]]");
+ newGrouping(newGroup(2, new CountAggregationResult(69).setTag(3))),
+ "RootGroup{id=group:root}[GroupList{label=a}[Group{id=group:2, count()=69}[]]]");
assertLayout("all(group(a) each(output(count())) as(bar))",
- newGrouping(newGroup(2, new CountAggregationResult(69).setTag(3))),
- "RootGroup{id=group:root}[GroupList{label=bar}[Group{id=group:2, count()=69}[]]]");
+ newGrouping(newGroup(2, new CountAggregationResult(69).setTag(3))),
+ "RootGroup{id=group:root}[GroupList{label=bar}[Group{id=group:2, count()=69}[]]]");
}
@Test
- public void requireThatHitListsAreLabeled() {
+ void requireThatHitListsAreLabeled() {
assertLayout("all(group(foo) each(each(output(summary()))))",
- newGrouping(newGroup(2, newHitList(3, 2))),
- "RootGroup{id=group:root}[GroupList{label=foo}[Group{id=group:2}[" +
- "HitList{label=hits}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
+ newGrouping(newGroup(2, newHitList(3, 2))),
+ "RootGroup{id=group:root}[GroupList{label=foo}[Group{id=group:2}[" +
+ "HitList{label=hits}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
assertLayout("all(group(foo) each(each(output(summary())) as(bar)))",
- newGrouping(newGroup(2, newHitList(3, 2))),
- "RootGroup{id=group:root}[GroupList{label=foo}[Group{id=group:2}[" +
- "HitList{label=bar}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
+ newGrouping(newGroup(2, newHitList(3, 2))),
+ "RootGroup{id=group:root}[GroupList{label=foo}[Group{id=group:2}[" +
+ "HitList{label=bar}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
assertLayout("all(group(foo) each(each(output(summary())) as(bar)) as(baz))",
- newGrouping(newGroup(2, newHitList(3, 2))),
- "RootGroup{id=group:root}[GroupList{label=baz}[Group{id=group:2}[" +
- "HitList{label=bar}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
+ newGrouping(newGroup(2, newHitList(3, 2))),
+ "RootGroup{id=group:root}[GroupList{label=baz}[Group{id=group:2}[" +
+ "HitList{label=bar}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
assertLayout("all(group(foo) each(each(output(summary())) as(bar)" +
- " each(output(summary())) as(baz)))",
- Arrays.asList(newGrouping(newGroup(2, newHitList(3, 2))),
- newGrouping(newGroup(2, newHitList(4, 2)))),
- "RootGroup{id=group:root}[GroupList{label=foo}[Group{id=group:2}[" +
- "HitList{label=bar}[Hit{id=hit:1}, Hit{id=hit:2}], " +
- "HitList{label=baz}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
+ " each(output(summary())) as(baz)))",
+ Arrays.asList(newGrouping(newGroup(2, newHitList(3, 2))),
+ newGrouping(newGroup(2, newHitList(4, 2)))),
+ "RootGroup{id=group:root}[GroupList{label=foo}[Group{id=group:2}[" +
+ "HitList{label=bar}[Hit{id=hit:1}, Hit{id=hit:2}], " +
+ "HitList{label=baz}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
assertLayout("all(group(foo) each(each(output(summary())))" +
- " each(each(output(summary()))) as(bar))",
- Arrays.asList(newGrouping(newGroup(2, newHitList(3, 2))),
- newGrouping(newGroup(4, newHitList(5, 2)))),
- "RootGroup{id=group:root}[" +
- "GroupList{label=foo}[Group{id=group:2}[HitList{label=hits}[Hit{id=hit:1}, Hit{id=hit:2}]]], " +
- "GroupList{label=bar}[Group{id=group:4}[HitList{label=hits}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
+ " each(each(output(summary()))) as(bar))",
+ Arrays.asList(newGrouping(newGroup(2, newHitList(3, 2))),
+ newGrouping(newGroup(4, newHitList(5, 2)))),
+ "RootGroup{id=group:root}[" +
+ "GroupList{label=foo}[Group{id=group:2}[HitList{label=hits}[Hit{id=hit:1}, Hit{id=hit:2}]]], " +
+ "GroupList{label=bar}[Group{id=group:4}[HitList{label=hits}[Hit{id=hit:1}, Hit{id=hit:2}]]]]");
}
@Test
- public void requireThatOutputsAreLabeled() {
+ void requireThatOutputsAreLabeled() {
assertLayout("all(output(count()))",
- new Grouping().setRoot(newGroup(1, new CountAggregationResult(69).setTag(2))),
- "RootGroup{id=group:root, count()=69}[]");
+ new Grouping().setRoot(newGroup(1, new CountAggregationResult(69).setTag(2))),
+ "RootGroup{id=group:root, count()=69}[]");
assertLayout("all(output(count() as(foo)))",
- new Grouping().setRoot(newGroup(1, new CountAggregationResult(69).setTag(2))),
- "RootGroup{id=group:root, foo=69}[]");
+ new Grouping().setRoot(newGroup(1, new CountAggregationResult(69).setTag(2))),
+ "RootGroup{id=group:root, foo=69}[]");
assertLayout("all(group(a) each(output(count())))",
- newGrouping(newGroup(2, new CountAggregationResult(69).setTag(3))),
- "RootGroup{id=group:root}[GroupList{label=a}[Group{id=group:2, count()=69}[]]]");
+ newGrouping(newGroup(2, new CountAggregationResult(69).setTag(3))),
+ "RootGroup{id=group:root}[GroupList{label=a}[Group{id=group:2, count()=69}[]]]");
assertLayout("all(group(a) each(output(count() as(foo))))",
- newGrouping(newGroup(2, new CountAggregationResult(69).setTag(3))),
- "RootGroup{id=group:root}[GroupList{label=a}[Group{id=group:2, foo=69}[]]]");
+ newGrouping(newGroup(2, new CountAggregationResult(69).setTag(3))),
+ "RootGroup{id=group:root}[GroupList{label=a}[Group{id=group:2, foo=69}[]]]");
}
@Test
- public void requireThatExpressionCountCanUseExactGroupCount() {
+ void requireThatExpressionCountCanUseExactGroupCount() {
Group root1 = newGroup(1, new ExpressionCountAggregationResult(new SparseSketch(), sketch -> 42).setTag(2));
Grouping grouping1 = new Grouping().setRoot(root1);
@@ -260,35 +260,35 @@ public class ResultBuilderTestCase {
@Test
- public void requireThatResultContinuationContainsCurrentPages() {
+ void requireThatResultContinuationContainsCurrentPages() {
String request = "all(group(a) max(2) each(output(count())))";
Grouping result = newGrouping(newGroup(2, 1, new CountAggregationResult(1)),
- newGroup(2, 2, new CountAggregationResult(2)),
- newGroup(2, 3, new CountAggregationResult(3)),
- newGroup(2, 4, new CountAggregationResult(4)));
+ newGroup(2, 2, new CountAggregationResult(2)),
+ newGroup(2, 3, new CountAggregationResult(3)),
+ newGroup(2, 4, new CountAggregationResult(4)));
assertResultCont(request, result, newOffset(newResultId(0), 2, 0), "[]");
assertResultCont(request, result, newOffset(newResultId(0), 2, 1), "[0=1]");
assertResultCont(request, result, newOffset(newResultId(0), 2, 2), "[0=2]");
assertResultCont(request, result, newOffset(newResultId(0), 2, 3), "[0=3]");
assertResultCont("all(group(a) max(2) each(output(count())) as(foo)" +
- " each(output(count())) as(bar))",
- Arrays.asList(newGrouping(newGroup(2, 1, new CountAggregationResult(1))),
- newGrouping(newGroup(4, 2, new CountAggregationResult(4)))),
- "[]");
+ " each(output(count())) as(bar))",
+ Arrays.asList(newGrouping(newGroup(2, 1, new CountAggregationResult(1))),
+ newGrouping(newGroup(4, 2, new CountAggregationResult(4)))),
+ "[]");
assertResultCont("all(group(a) max(2) each(output(count())) as(foo)" +
- " each(output(count())) as(bar))",
- Arrays.asList(newGrouping(newGroup(2, 1, new CountAggregationResult(1))),
- newGrouping(newGroup(4, 2, new CountAggregationResult(4)))),
- newOffset(newResultId(0), 2, 1),
- "[0=1]");
+ " each(output(count())) as(bar))",
+ Arrays.asList(newGrouping(newGroup(2, 1, new CountAggregationResult(1))),
+ newGrouping(newGroup(4, 2, new CountAggregationResult(4)))),
+ newOffset(newResultId(0), 2, 1),
+ "[0=1]");
assertResultCont("all(group(a) max(2) each(output(count())) as(foo)" +
- " each(output(count())) as(bar))",
- Arrays.asList(newGrouping(newGroup(2, 1, new CountAggregationResult(1))),
- newGrouping(newGroup(4, 2, new CountAggregationResult(4)))),
- newComposite(newOffset(newResultId(0), 2, 2),
- newOffset(newResultId(1), 4, 1)),
- "[0=2, 1=1]");
+ " each(output(count())) as(bar))",
+ Arrays.asList(newGrouping(newGroup(2, 1, new CountAggregationResult(1))),
+ newGrouping(newGroup(4, 2, new CountAggregationResult(4)))),
+ newComposite(newOffset(newResultId(0), 2, 2),
+ newOffset(newResultId(1), 4, 1)),
+ "[0=2, 1=1]");
request = "all(group(a) each(max(2) each(output(summary()))))";
result = newGrouping(newGroup(2, newHitList(3, 4)));
@@ -298,436 +298,436 @@ public class ResultBuilderTestCase {
assertResultCont(request, result, newOffset(newResultId(0, 0, 0), 3, 3), "[0.0.0=3]");
assertResultCont("all(group(a) each(max(2) each(output(summary()))) as(foo)" +
- " each(max(2) each(output(summary()))) as(bar))",
- Arrays.asList(newGrouping(newGroup(2, newHitList(3, 4))),
- newGrouping(newGroup(4, newHitList(5, 4)))),
- "[]");
+ " each(max(2) each(output(summary()))) as(bar))",
+ Arrays.asList(newGrouping(newGroup(2, newHitList(3, 4))),
+ newGrouping(newGroup(4, newHitList(5, 4)))),
+ "[]");
assertResultCont("all(group(a) each(max(2) each(output(summary()))) as(foo)" +
- " each(max(2) each(output(summary()))) as(bar))",
- Arrays.asList(newGrouping(newGroup(2, newHitList(3, 4))),
- newGrouping(newGroup(4, newHitList(5, 4)))),
- newOffset(newResultId(0, 0, 0), 3, 1),
- "[0.0.0=1]");
+ " each(max(2) each(output(summary()))) as(bar))",
+ Arrays.asList(newGrouping(newGroup(2, newHitList(3, 4))),
+ newGrouping(newGroup(4, newHitList(5, 4)))),
+ newOffset(newResultId(0, 0, 0), 3, 1),
+ "[0.0.0=1]");
assertResultCont("all(group(a) each(max(2) each(output(summary()))) as(foo)" +
- " each(max(2) each(output(summary()))) as(bar))",
- Arrays.asList(newGrouping(newGroup(2, newHitList(3, 4))),
- newGrouping(newGroup(4, newHitList(5, 4)))),
- newComposite(newOffset(newResultId(0, 0, 0), 3, 2),
- newOffset(newResultId(1, 0, 0), 5, 1)),
- "[0.0.0=2, 1.0.0=1]");
+ " each(max(2) each(output(summary()))) as(bar))",
+ Arrays.asList(newGrouping(newGroup(2, newHitList(3, 4))),
+ newGrouping(newGroup(4, newHitList(5, 4)))),
+ newComposite(newOffset(newResultId(0, 0, 0), 3, 2),
+ newOffset(newResultId(1, 0, 0), 5, 1)),
+ "[0.0.0=2, 1.0.0=1]");
}
@Test
- public void requireThatGroupListContinuationsAreNotCreatedWhenUnlessMaxIsSet() {
+ void requireThatGroupListContinuationsAreNotCreatedWhenUnlessMaxIsSet() {
assertContinuation("all(group(a) each(output(count())))",
- newGrouping(newGroup(2, 1, new CountAggregationResult(1)),
- newGroup(2, 2, new CountAggregationResult(2)),
- newGroup(2, 3, new CountAggregationResult(3)),
- newGroup(2, 4, new CountAggregationResult(4))),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:1', {}, [] }, { 'group:2', {}, [] }, { 'group:3', {}, [] }, { 'group:4', {}, [] }] }] }");
+ newGrouping(newGroup(2, 1, new CountAggregationResult(1)),
+ newGroup(2, 2, new CountAggregationResult(2)),
+ newGroup(2, 3, new CountAggregationResult(3)),
+ newGroup(2, 4, new CountAggregationResult(4))),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:1', {}, [] }, { 'group:2', {}, [] }, { 'group:3', {}, [] }, { 'group:4', {}, [] }] }] }");
}
@Test
- public void requireThatGroupListContinuationsCanBeSet() {
+ void requireThatGroupListContinuationsCanBeSet() {
String request = "all(group(a) max(2) each(output(count())))";
Grouping result = newGrouping(newGroup(2, 1, new CountAggregationResult(1)),
- newGroup(2, 2, new CountAggregationResult(2)),
- newGroup(2, 3, new CountAggregationResult(3)),
- newGroup(2, 4, new CountAggregationResult(4)));
+ newGroup(2, 2, new CountAggregationResult(2)),
+ newGroup(2, 3, new CountAggregationResult(3)),
+ newGroup(2, 4, new CountAggregationResult(4)));
assertContinuation(request, result, newOffset(newResultId(0), 2, 0),
- "{ 'group:root', {}, [{ 'grouplist:a', {next=2}, [" +
- "{ 'group:1', {}, [] }, { 'group:2', {}, [] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {next=2}, [" +
+ "{ 'group:1', {}, [] }, { 'group:2', {}, [] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0), 2, 1),
- "{ 'group:root', {}, [{ 'grouplist:a', {next=3, prev=0}, [" +
- "{ 'group:2', {}, [] }, { 'group:3', {}, [] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {next=3, prev=0}, [" +
+ "{ 'group:2', {}, [] }, { 'group:3', {}, [] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0), 2, 2),
- "{ 'group:root', {}, [{ 'grouplist:a', {prev=0}, [" +
- "{ 'group:3', {}, [] }, { 'group:4', {}, [] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {prev=0}, [" +
+ "{ 'group:3', {}, [] }, { 'group:4', {}, [] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0), 2, 3),
- "{ 'group:root', {}, [{ 'grouplist:a', {prev=1}, [" +
- "{ 'group:4', {}, [] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {prev=1}, [" +
+ "{ 'group:4', {}, [] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0), 2, 4),
- "{ 'group:root', {}, [{ 'grouplist:a', {prev=2}, [" +
- "] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {prev=2}, [" +
+ "] }] }");
assertContinuation(request, result, newOffset(newResultId(0), 2, 5),
- "{ 'group:root', {}, [{ 'grouplist:a', {prev=2}, [" +
- "] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {prev=2}, [" +
+ "] }] }");
}
@Test
- public void requireThatGroupListContinuationsCanBeSetInSiblingGroups() {
+ void requireThatGroupListContinuationsCanBeSetInSiblingGroups() {
String request = "all(group(a) each(group(b) max(2) each(output(count()))))";
Grouping result = newGrouping(newGroup(2, 201,
- newGroup(3, 301, new CountAggregationResult(1)),
- newGroup(3, 302, new CountAggregationResult(2)),
- newGroup(3, 303, new CountAggregationResult(3)),
- newGroup(3, 304, new CountAggregationResult(4))),
- newGroup(2, 202,
- newGroup(3, 305, new CountAggregationResult(5)),
- newGroup(3, 306, new CountAggregationResult(6)),
- newGroup(3, 307, new CountAggregationResult(7)),
- newGroup(3, 308, new CountAggregationResult(8))));
+ newGroup(3, 301, new CountAggregationResult(1)),
+ newGroup(3, 302, new CountAggregationResult(2)),
+ newGroup(3, 303, new CountAggregationResult(3)),
+ newGroup(3, 304, new CountAggregationResult(4))),
+ newGroup(2, 202,
+ newGroup(3, 305, new CountAggregationResult(5)),
+ newGroup(3, 306, new CountAggregationResult(6)),
+ newGroup(3, 307, new CountAggregationResult(7)),
+ newGroup(3, 308, new CountAggregationResult(8))));
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 2, 0),
- newOffset(newResultId(0, 1, 0), 2, 5)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [{ 'group:301', {}, [] }, { 'group:302', {}, [] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {prev=2}, [] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 2, 5)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [{ 'group:301', {}, [] }, { 'group:302', {}, [] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {prev=2}, [] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 2, 1),
- newOffset(newResultId(0, 1, 0), 2, 4)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=3, prev=0}, [{ 'group:302', {}, [] }, { 'group:303', {}, [] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {prev=2}, [] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 2, 4)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=3, prev=0}, [{ 'group:302', {}, [] }, { 'group:303', {}, [] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {prev=2}, [] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 2, 2),
- newOffset(newResultId(0, 1, 0), 2, 3)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [{ 'group:303', {}, [] }, { 'group:304', {}, [] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {prev=1}, [{ 'group:308', {}, [] }] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 2, 3)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [{ 'group:303', {}, [] }, { 'group:304', {}, [] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {prev=1}, [{ 'group:308', {}, [] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 2, 3),
- newOffset(newResultId(0, 1, 0), 2, 2)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=1}, [{ 'group:304', {}, [] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {prev=0}, [{ 'group:307', {}, [] }, { 'group:308', {}, [] }] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 2, 2)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=1}, [{ 'group:304', {}, [] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {prev=0}, [{ 'group:307', {}, [] }, { 'group:308', {}, [] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 2, 4),
- newOffset(newResultId(0, 1, 0), 2, 1)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=2}, [] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=3, prev=0}, [{ 'group:306', {}, [] }, { 'group:307', {}, [] }] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 2, 1)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=2}, [] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=3, prev=0}, [{ 'group:306', {}, [] }, { 'group:307', {}, [] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 2, 5),
- newOffset(newResultId(0, 1, 0), 2, 0)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=2}, [] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [{ 'group:305', {}, [] }, { 'group:306', {}, [] }] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 2, 0)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=2}, [] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [{ 'group:305', {}, [] }, { 'group:306', {}, [] }] }] }] }] }");
}
@Test
- public void requireThatGroupListContinuationsCanBeSetInSiblingGroupLists() {
+ void requireThatGroupListContinuationsCanBeSetInSiblingGroupLists() {
String request = "all(group(a) max(2) each(output(count())) as(foo)" +
- " each(output(count())) as(bar))";
+ " each(output(count())) as(bar))";
List<Grouping> result = Arrays.asList(newGrouping(newGroup(2, 1, new CountAggregationResult(1)),
- newGroup(2, 2, new CountAggregationResult(2)),
- newGroup(2, 3, new CountAggregationResult(3)),
- newGroup(2, 4, new CountAggregationResult(4))),
- newGrouping(newGroup(4, 1, new CountAggregationResult(1)),
- newGroup(4, 2, new CountAggregationResult(2)),
- newGroup(4, 3, new CountAggregationResult(3)),
- newGroup(4, 4, new CountAggregationResult(4))));
+ newGroup(2, 2, new CountAggregationResult(2)),
+ newGroup(2, 3, new CountAggregationResult(3)),
+ newGroup(2, 4, new CountAggregationResult(4))),
+ newGrouping(newGroup(4, 1, new CountAggregationResult(1)),
+ newGroup(4, 2, new CountAggregationResult(2)),
+ newGroup(4, 3, new CountAggregationResult(3)),
+ newGroup(4, 4, new CountAggregationResult(4))));
assertContinuation(request, result, newComposite(newOffset(newResultId(0), 2, 0),
- newOffset(newResultId(1), 4, 5)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {next=2}, [{ 'group:1', {}, [] }, { 'group:2', {}, [] }] }, " +
- "{ 'grouplist:bar', {prev=2}, [] }] }");
+ newOffset(newResultId(1), 4, 5)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {next=2}, [{ 'group:1', {}, [] }, { 'group:2', {}, [] }] }, " +
+ "{ 'grouplist:bar', {prev=2}, [] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0), 2, 1),
- newOffset(newResultId(1), 4, 4)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {next=3, prev=0}, [{ 'group:2', {}, [] }, { 'group:3', {}, [] }] }, " +
- "{ 'grouplist:bar', {prev=2}, [] }] }");
+ newOffset(newResultId(1), 4, 4)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {next=3, prev=0}, [{ 'group:2', {}, [] }, { 'group:3', {}, [] }] }, " +
+ "{ 'grouplist:bar', {prev=2}, [] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0), 2, 2),
- newOffset(newResultId(1), 4, 3)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {prev=0}, [{ 'group:3', {}, [] }, { 'group:4', {}, [] }] }, " +
- "{ 'grouplist:bar', {prev=1}, [{ 'group:4', {}, [] }] }] }");
+ newOffset(newResultId(1), 4, 3)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {prev=0}, [{ 'group:3', {}, [] }, { 'group:4', {}, [] }] }, " +
+ "{ 'grouplist:bar', {prev=1}, [{ 'group:4', {}, [] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0), 2, 3),
- newOffset(newResultId(1), 4, 2)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {prev=1}, [{ 'group:4', {}, [] }] }, " +
- "{ 'grouplist:bar', {prev=0}, [{ 'group:3', {}, [] }, { 'group:4', {}, [] }] }] }");
+ newOffset(newResultId(1), 4, 2)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {prev=1}, [{ 'group:4', {}, [] }] }, " +
+ "{ 'grouplist:bar', {prev=0}, [{ 'group:3', {}, [] }, { 'group:4', {}, [] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0), 2, 4),
- newOffset(newResultId(1), 4, 1)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {prev=2}, [] }, " +
- "{ 'grouplist:bar', {next=3, prev=0}, [{ 'group:2', {}, [] }, { 'group:3', {}, [] }] }] }");
+ newOffset(newResultId(1), 4, 1)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {prev=2}, [] }, " +
+ "{ 'grouplist:bar', {next=3, prev=0}, [{ 'group:2', {}, [] }, { 'group:3', {}, [] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0), 2, 5),
- newOffset(newResultId(1), 4, 0)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {prev=2}, [] }, " +
- "{ 'grouplist:bar', {next=2}, [{ 'group:1', {}, [] }, { 'group:2', {}, [] }] }] }");
+ newOffset(newResultId(1), 4, 0)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {prev=2}, [] }, " +
+ "{ 'grouplist:bar', {next=2}, [{ 'group:1', {}, [] }, { 'group:2', {}, [] }] }] }");
}
@Test
- public void requireThatUnstableContinuationsDoNotAffectSiblingGroupLists() {
+ void requireThatUnstableContinuationsDoNotAffectSiblingGroupLists() {
String request = "all(group(a) each(group(b) max(2) each(group(c) max(2) each(output(count())))))";
Grouping result = newGrouping(newGroup(2, 201,
- newGroup(3, 301,
- newGroup(4, 401, new CountAggregationResult(1)),
- newGroup(4, 402, new CountAggregationResult(1)),
- newGroup(4, 403, new CountAggregationResult(1)),
- newGroup(4, 404, new CountAggregationResult(1))),
- newGroup(3, 302,
- newGroup(4, 405, new CountAggregationResult(1)),
- newGroup(4, 406, new CountAggregationResult(1)),
- newGroup(4, 407, new CountAggregationResult(1)),
- newGroup(4, 408, new CountAggregationResult(1))),
- newGroup(3, 303,
- newGroup(4, 409, new CountAggregationResult(1)),
- newGroup(4, 410, new CountAggregationResult(1)),
- newGroup(4, 411, new CountAggregationResult(1)),
- newGroup(4, 412, new CountAggregationResult(1))),
- newGroup(3, 304,
- newGroup(4, 413, new CountAggregationResult(1)),
- newGroup(4, 414, new CountAggregationResult(1)),
- newGroup(4, 415, new CountAggregationResult(1)),
- newGroup(4, 416, new CountAggregationResult(1)))),
- newGroup(2, 202,
- newGroup(3, 305,
- newGroup(4, 417, new CountAggregationResult(1)),
- newGroup(4, 418, new CountAggregationResult(1)),
- newGroup(4, 419, new CountAggregationResult(1)),
- newGroup(4, 420, new CountAggregationResult(1))),
- newGroup(3, 306,
- newGroup(4, 421, new CountAggregationResult(1)),
- newGroup(4, 422, new CountAggregationResult(1)),
- newGroup(4, 423, new CountAggregationResult(1)),
- newGroup(4, 424, new CountAggregationResult(1))),
- newGroup(3, 307,
- newGroup(4, 425, new CountAggregationResult(1)),
- newGroup(4, 426, new CountAggregationResult(1)),
- newGroup(4, 427, new CountAggregationResult(1)),
- newGroup(4, 428, new CountAggregationResult(1))),
- newGroup(3, 308,
- newGroup(4, 429, new CountAggregationResult(1)),
- newGroup(4, 430, new CountAggregationResult(1)),
- newGroup(4, 431, new CountAggregationResult(1)),
- newGroup(4, 432, new CountAggregationResult(1)))));
+ newGroup(3, 301,
+ newGroup(4, 401, new CountAggregationResult(1)),
+ newGroup(4, 402, new CountAggregationResult(1)),
+ newGroup(4, 403, new CountAggregationResult(1)),
+ newGroup(4, 404, new CountAggregationResult(1))),
+ newGroup(3, 302,
+ newGroup(4, 405, new CountAggregationResult(1)),
+ newGroup(4, 406, new CountAggregationResult(1)),
+ newGroup(4, 407, new CountAggregationResult(1)),
+ newGroup(4, 408, new CountAggregationResult(1))),
+ newGroup(3, 303,
+ newGroup(4, 409, new CountAggregationResult(1)),
+ newGroup(4, 410, new CountAggregationResult(1)),
+ newGroup(4, 411, new CountAggregationResult(1)),
+ newGroup(4, 412, new CountAggregationResult(1))),
+ newGroup(3, 304,
+ newGroup(4, 413, new CountAggregationResult(1)),
+ newGroup(4, 414, new CountAggregationResult(1)),
+ newGroup(4, 415, new CountAggregationResult(1)),
+ newGroup(4, 416, new CountAggregationResult(1)))),
+ newGroup(2, 202,
+ newGroup(3, 305,
+ newGroup(4, 417, new CountAggregationResult(1)),
+ newGroup(4, 418, new CountAggregationResult(1)),
+ newGroup(4, 419, new CountAggregationResult(1)),
+ newGroup(4, 420, new CountAggregationResult(1))),
+ newGroup(3, 306,
+ newGroup(4, 421, new CountAggregationResult(1)),
+ newGroup(4, 422, new CountAggregationResult(1)),
+ newGroup(4, 423, new CountAggregationResult(1)),
+ newGroup(4, 424, new CountAggregationResult(1))),
+ newGroup(3, 307,
+ newGroup(4, 425, new CountAggregationResult(1)),
+ newGroup(4, 426, new CountAggregationResult(1)),
+ newGroup(4, 427, new CountAggregationResult(1)),
+ newGroup(4, 428, new CountAggregationResult(1))),
+ newGroup(3, 308,
+ newGroup(4, 429, new CountAggregationResult(1)),
+ newGroup(4, 430, new CountAggregationResult(1)),
+ newGroup(4, 431, new CountAggregationResult(1)),
+ newGroup(4, 432, new CountAggregationResult(1)))));
assertContinuation(request, result, newComposite(),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:301', {}, [{ 'grouplist:c', {next=2}, [{ 'group:401', {}, [] }, { 'group:402', {}, [] }] }] }, " +
- "{ 'group:302', {}, [{ 'grouplist:c', {next=2}, [{ 'group:405', {}, [] }, { 'group:406', {}, [] }] }] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:305', {}, [{ 'grouplist:c', {next=2}, [{ 'group:417', {}, [] }, { 'group:418', {}, [] }] }] }, " +
- "{ 'group:306', {}, [{ 'grouplist:c', {next=2}, [{ 'group:421', {}, [] }, { 'group:422', {}, [] }] }] }] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:301', {}, [{ 'grouplist:c', {next=2}, [{ 'group:401', {}, [] }, { 'group:402', {}, [] }] }] }, " +
+ "{ 'group:302', {}, [{ 'grouplist:c', {next=2}, [{ 'group:405', {}, [] }, { 'group:406', {}, [] }] }] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:305', {}, [{ 'grouplist:c', {next=2}, [{ 'group:417', {}, [] }, { 'group:418', {}, [] }] }] }, " +
+ "{ 'group:306', {}, [{ 'grouplist:c', {next=2}, [{ 'group:421', {}, [] }, { 'group:422', {}, [] }] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 1, 0, 1, 0), 4, 2)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:301', {}, [{ 'grouplist:c', {next=2}, [{ 'group:401', {}, [] }, { 'group:402', {}, [] }] }] }, " +
- "{ 'group:302', {}, [{ 'grouplist:c', {next=2}, [{ 'group:405', {}, [] }, { 'group:406', {}, [] }] }] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:305', {}, [{ 'grouplist:c', {next=2}, [{ 'group:417', {}, [] }, { 'group:418', {}, [] }] }] }, " +
- "{ 'group:306', {}, [{ 'grouplist:c', {prev=0}, [{ 'group:423', {}, [] }, { 'group:424', {}, [] }] }] }] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:301', {}, [{ 'grouplist:c', {next=2}, [{ 'group:401', {}, [] }, { 'group:402', {}, [] }] }] }, " +
+ "{ 'group:302', {}, [{ 'grouplist:c', {next=2}, [{ 'group:405', {}, [] }, { 'group:406', {}, [] }] }] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:305', {}, [{ 'grouplist:c', {next=2}, [{ 'group:417', {}, [] }, { 'group:418', {}, [] }] }] }, " +
+ "{ 'group:306', {}, [{ 'grouplist:c', {prev=0}, [{ 'group:423', {}, [] }, { 'group:424', {}, [] }] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 1, 0, 1, 0), 4, 2),
- newOffset(newResultId(0, 0, 0), 2, 2)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
- "{ 'group:303', {}, [{ 'grouplist:c', {next=2}, [{ 'group:409', {}, [] }, { 'group:410', {}, [] }] }] }, " +
- "{ 'group:304', {}, [{ 'grouplist:c', {next=2}, [{ 'group:413', {}, [] }, { 'group:414', {}, [] }] }] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:305', {}, [{ 'grouplist:c', {next=2}, [{ 'group:417', {}, [] }, { 'group:418', {}, [] }] }] }, " +
- "{ 'group:306', {}, [{ 'grouplist:c', {prev=0}, [{ 'group:423', {}, [] }, { 'group:424', {}, [] }] }] }] }] }] }] }");
+ newOffset(newResultId(0, 0, 0), 2, 2)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
+ "{ 'group:303', {}, [{ 'grouplist:c', {next=2}, [{ 'group:409', {}, [] }, { 'group:410', {}, [] }] }] }, " +
+ "{ 'group:304', {}, [{ 'grouplist:c', {next=2}, [{ 'group:413', {}, [] }, { 'group:414', {}, [] }] }] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:305', {}, [{ 'grouplist:c', {next=2}, [{ 'group:417', {}, [] }, { 'group:418', {}, [] }] }] }, " +
+ "{ 'group:306', {}, [{ 'grouplist:c', {prev=0}, [{ 'group:423', {}, [] }, { 'group:424', {}, [] }] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 1, 0, 1, 0), 4, 2),
- newOffset(newResultId(0, 0, 0), 2, 2),
- newUnstableOffset(newResultId(0, 1, 0), 2, 1)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
- "{ 'group:303', {}, [{ 'grouplist:c', {next=2}, [{ 'group:409', {}, [] }, { 'group:410', {}, [] }] }] }, " +
- "{ 'group:304', {}, [{ 'grouplist:c', {next=2}, [{ 'group:413', {}, [] }, { 'group:414', {}, [] }] }] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=3, prev=0}, [" +
- "{ 'group:306', {}, [{ 'grouplist:c', {next=2}, [{ 'group:421', {}, [] }, { 'group:422', {}, [] }] }] }, " +
- "{ 'group:307', {}, [{ 'grouplist:c', {next=2}, [{ 'group:425', {}, [] }, { 'group:426', {}, [] }] }] }] }] }] }] }");
+ newOffset(newResultId(0, 0, 0), 2, 2),
+ newUnstableOffset(newResultId(0, 1, 0), 2, 1)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
+ "{ 'group:303', {}, [{ 'grouplist:c', {next=2}, [{ 'group:409', {}, [] }, { 'group:410', {}, [] }] }] }, " +
+ "{ 'group:304', {}, [{ 'grouplist:c', {next=2}, [{ 'group:413', {}, [] }, { 'group:414', {}, [] }] }] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=3, prev=0}, [" +
+ "{ 'group:306', {}, [{ 'grouplist:c', {next=2}, [{ 'group:421', {}, [] }, { 'group:422', {}, [] }] }] }, " +
+ "{ 'group:307', {}, [{ 'grouplist:c', {next=2}, [{ 'group:425', {}, [] }, { 'group:426', {}, [] }] }] }] }] }] }] }");
}
@Test
- public void requireThatUnstableContinuationsAffectAllDecendants() {
+ void requireThatUnstableContinuationsAffectAllDecendants() {
String request = "all(group(a) each(group(b) max(1) each(group(c) max(1) each(group(d) max(1) each(output(count()))))))";
Grouping result = newGrouping(newGroup(2, 201,
- newGroup(3, 301,
- newGroup(4, 401,
- newGroup(5, 501, new CountAggregationResult(1)),
- newGroup(5, 502, new CountAggregationResult(1))),
- newGroup(4, 402,
- newGroup(5, 503, new CountAggregationResult(1)),
- newGroup(5, 504, new CountAggregationResult(1)))),
- newGroup(3, 302,
- newGroup(4, 403,
- newGroup(5, 505, new CountAggregationResult(1)),
- newGroup(5, 506, new CountAggregationResult(1))),
- newGroup(4, 404,
- newGroup(5, 507, new CountAggregationResult(1)),
- newGroup(5, 508, new CountAggregationResult(1))))));
+ newGroup(3, 301,
+ newGroup(4, 401,
+ newGroup(5, 501, new CountAggregationResult(1)),
+ newGroup(5, 502, new CountAggregationResult(1))),
+ newGroup(4, 402,
+ newGroup(5, 503, new CountAggregationResult(1)),
+ newGroup(5, 504, new CountAggregationResult(1)))),
+ newGroup(3, 302,
+ newGroup(4, 403,
+ newGroup(5, 505, new CountAggregationResult(1)),
+ newGroup(5, 506, new CountAggregationResult(1))),
+ newGroup(4, 404,
+ newGroup(5, 507, new CountAggregationResult(1)),
+ newGroup(5, 508, new CountAggregationResult(1))))));
assertContinuation(request, result, newComposite(),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=1}, [" +
- "{ 'group:301', {}, [{ 'grouplist:c', {next=1}, [" +
- "{ 'group:401', {}, [{ 'grouplist:d', {next=1}, [" +
- "{ 'group:501', {}, [] }] }] }] }] }] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=1}, [" +
+ "{ 'group:301', {}, [{ 'grouplist:c', {next=1}, [" +
+ "{ 'group:401', {}, [{ 'grouplist:d', {next=1}, [" +
+ "{ 'group:501', {}, [] }] }] }] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0, 0, 0, 0, 0), 5, 1)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=1}, [" +
- "{ 'group:301', {}, [{ 'grouplist:c', {next=1}, [" +
- "{ 'group:401', {}, [{ 'grouplist:d', {prev=0}, [" +
- "{ 'group:502', {}, [] }] }] }] }] }] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=1}, [" +
+ "{ 'group:301', {}, [{ 'grouplist:c', {next=1}, [" +
+ "{ 'group:401', {}, [{ 'grouplist:d', {prev=0}, [" +
+ "{ 'group:502', {}, [] }] }] }] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0, 0, 0, 0, 0), 5, 1),
- newUnstableOffset(newResultId(0, 0, 0, 0, 0), 4, 1)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=1}, [" +
- "{ 'group:301', {}, [{ 'grouplist:c', {prev=0}, [" +
- "{ 'group:402', {}, [{ 'grouplist:d', {next=1}, [" +
- "{ 'group:503', {}, [] }] }] }] }] }] }] }] }] }");
+ newUnstableOffset(newResultId(0, 0, 0, 0, 0), 4, 1)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=1}, [" +
+ "{ 'group:301', {}, [{ 'grouplist:c', {prev=0}, [" +
+ "{ 'group:402', {}, [{ 'grouplist:d', {next=1}, [" +
+ "{ 'group:503', {}, [] }] }] }] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0, 0, 0, 0, 0), 5, 1),
- newUnstableOffset(newResultId(0, 0, 0, 0, 0), 4, 1),
- newUnstableOffset(newResultId(0, 0, 0), 3, 1)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
- "{ 'group:302', {}, [{ 'grouplist:c', {next=1}, [" +
- "{ 'group:403', {}, [{ 'grouplist:d', {next=1}, [" +
- "{ 'group:505', {}, [] }] }] }] }] }] }] }] }] }");
+ newUnstableOffset(newResultId(0, 0, 0, 0, 0), 4, 1),
+ newUnstableOffset(newResultId(0, 0, 0), 3, 1)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
+ "{ 'group:302', {}, [{ 'grouplist:c', {next=1}, [" +
+ "{ 'group:403', {}, [{ 'grouplist:d', {next=1}, [" +
+ "{ 'group:505', {}, [] }] }] }] }] }] }] }] }] }");
}
@Test
- public void requireThatHitListContinuationsAreNotCreatedUnlessMaxIsSet() {
+ void requireThatHitListContinuationsAreNotCreatedUnlessMaxIsSet() {
assertContinuation("all(group(a) each(each(output(summary()))))",
- newGrouping(newGroup(2, newHitList(3, 4))),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:2', {}, [{ 'hitlist:hits', {}, [hit:1, hit:2, hit:3, hit:4] }] }] }] }");
+ newGrouping(newGroup(2, newHitList(3, 4))),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:2', {}, [{ 'hitlist:hits', {}, [hit:1, hit:2, hit:3, hit:4] }] }] }] }");
}
@Test
- public void requireThatHitListContinuationsCanBeSet() {
+ void requireThatHitListContinuationsCanBeSet() {
String request = "all(group(a) each(max(2) each(output(summary()))))";
Grouping result = newGrouping(newGroup(2, newHitList(3, 4)));
assertContinuation(request, result, newOffset(newResultId(0, 0, 0), 3, 0),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:2', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:2', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0, 0, 0), 3, 1),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:2', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:2', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0, 0, 0), 3, 2),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:2', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:2', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0, 0, 0), 3, 3),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:2', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:2', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0, 0, 0), 3, 4),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:2', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:2', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
assertContinuation(request, result, newOffset(newResultId(0, 0, 0), 3, 5),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:2', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:2', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
}
@Test
- public void requireThatHitListContinuationsCanBeSetInSiblingGroups() {
+ void requireThatHitListContinuationsCanBeSetInSiblingGroups() {
String request = "all(group(a) each(max(2) each(output(summary()))))";
Grouping result = newGrouping(newGroup(2, 201, newHitList(3, 4)),
- newGroup(2, 202, newHitList(3, 4)));
+ newGroup(2, 202, newHitList(3, 4)));
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 0),
- newOffset(newResultId(0, 1, 0), 3, 5)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:202', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 3, 5)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:202', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 1),
- newOffset(newResultId(0, 1, 0), 3, 4)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }, " +
- "{ 'group:202', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 3, 4)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }, " +
+ "{ 'group:202', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 2),
- newOffset(newResultId(0, 1, 0), 3, 3)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }, " +
- "{ 'group:202', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 3, 3)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }, " +
+ "{ 'group:202', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 3),
- newOffset(newResultId(0, 1, 0), 3, 2)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }, " +
- "{ 'group:202', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 3, 2)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }, " +
+ "{ 'group:202', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 4),
- newOffset(newResultId(0, 1, 0), 3, 1)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'hitlist:hits', {prev=2}, [] }] }, " +
- "{ 'group:202', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 3, 1)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'hitlist:hits', {prev=2}, [] }] }, " +
+ "{ 'group:202', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 5),
- newOffset(newResultId(0, 1, 0), 3, 0)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'hitlist:hits', {prev=2}, [] }] }, " +
- "{ 'group:202', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }");
+ newOffset(newResultId(0, 1, 0), 3, 0)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'hitlist:hits', {prev=2}, [] }] }, " +
+ "{ 'group:202', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }");
}
@Test
- public void requireThatHitListContinuationsCanBeSetInSiblingHitLists() {
+ void requireThatHitListContinuationsCanBeSetInSiblingHitLists() {
String request = "all(group(a) each(max(2) each(output(summary()))) as(foo)" +
- " each(max(2) each(output(summary()))) as(bar))";
+ " each(max(2) each(output(summary()))) as(bar))";
List<Grouping> result = Arrays.asList(newGrouping(newGroup(2, newHitList(3, 4))),
- newGrouping(newGroup(4, newHitList(5, 4))));
+ newGrouping(newGroup(4, newHitList(5, 4))));
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 0),
- newOffset(newResultId(1, 0, 0), 5, 5)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }, " +
- "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
+ newOffset(newResultId(1, 0, 0), 5, 5)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }, " +
+ "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 1),
- newOffset(newResultId(1, 0, 0), 5, 4)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }] }, " +
- "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
+ newOffset(newResultId(1, 0, 0), 5, 4)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }] }, " +
+ "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 2),
- newOffset(newResultId(1, 0, 0), 5, 3)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }, " +
- "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }] }] }");
+ newOffset(newResultId(1, 0, 0), 5, 3)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }, " +
+ "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 3),
- newOffset(newResultId(1, 0, 0), 5, 2)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }] }, " +
- "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }");
+ newOffset(newResultId(1, 0, 0), 5, 2)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {prev=1}, [hit:4] }] }] }, " +
+ "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 4),
- newOffset(newResultId(1, 0, 0), 5, 1)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }, " +
- "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }] }] }");
+ newOffset(newResultId(1, 0, 0), 5, 1)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }, " +
+ "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {next=3, prev=0}, [hit:2, hit:3] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 0, 0), 3, 5),
- newOffset(newResultId(1, 0, 0), 5, 0)),
- "{ 'group:root', {}, [" +
- "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }, " +
- "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }");
+ newOffset(newResultId(1, 0, 0), 5, 0)),
+ "{ 'group:root', {}, [" +
+ "{ 'grouplist:foo', {}, [{ 'group:2', {}, [{ 'hitlist:hits', {prev=2}, [] }] }] }, " +
+ "{ 'grouplist:bar', {}, [{ 'group:4', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }");
}
@Test
- public void requireThatUnstableContinuationsDoNotAffectSiblingHitLists() {
+ void requireThatUnstableContinuationsDoNotAffectSiblingHitLists() {
String request = "all(group(a) each(group(b) max(2) each(max(2) each(output(summary())))))";
Grouping result = newGrouping(newGroup(2, 201,
- newGroup(3, 301, newHitList(4, 4)),
- newGroup(3, 302, newHitList(4, 4)),
- newGroup(3, 303, newHitList(4, 4)),
- newGroup(3, 304, newHitList(4, 4))),
- newGroup(2, 202,
- newGroup(3, 305, newHitList(4, 4)),
- newGroup(3, 306, newHitList(4, 4)),
- newGroup(3, 307, newHitList(4, 4)),
- newGroup(3, 308, newHitList(4, 4))));
+ newGroup(3, 301, newHitList(4, 4)),
+ newGroup(3, 302, newHitList(4, 4)),
+ newGroup(3, 303, newHitList(4, 4)),
+ newGroup(3, 304, newHitList(4, 4))),
+ newGroup(2, 202,
+ newGroup(3, 305, newHitList(4, 4)),
+ newGroup(3, 306, newHitList(4, 4)),
+ newGroup(3, 307, newHitList(4, 4)),
+ newGroup(3, 308, newHitList(4, 4))));
assertContinuation(request, result, newComposite(),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:301', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:302', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:305', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:306', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:301', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:302', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:305', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:306', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 1, 0, 1, 0), 4, 2)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:301', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:302', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:305', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:306', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }] }] }");
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:301', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:302', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:305', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:306', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 1, 0, 1, 0), 4, 2),
- newOffset(newResultId(0, 0, 0), 2, 2)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
- "{ 'group:303', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:304', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
- "{ 'group:305', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:306', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }] }] }");
+ newOffset(newResultId(0, 0, 0), 2, 2)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
+ "{ 'group:303', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:304', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=2}, [" +
+ "{ 'group:305', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:306', {}, [{ 'hitlist:hits', {prev=0}, [hit:3, hit:4] }] }] }] }] }] }");
assertContinuation(request, result, newComposite(newOffset(newResultId(0, 1, 0, 1, 0), 4, 2),
- newOffset(newResultId(0, 0, 0), 2, 2),
- newUnstableOffset(newResultId(0, 1, 0), 2, 1)),
- "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
- "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
- "{ 'group:303', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:304', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }, " +
- "{ 'group:202', {}, [{ 'grouplist:b', {next=3, prev=0}, [" +
- "{ 'group:306', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
- "{ 'group:307', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }] }] }");
+ newOffset(newResultId(0, 0, 0), 2, 2),
+ newUnstableOffset(newResultId(0, 1, 0), 2, 1)),
+ "{ 'group:root', {}, [{ 'grouplist:a', {}, [" +
+ "{ 'group:201', {}, [{ 'grouplist:b', {prev=0}, [" +
+ "{ 'group:303', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:304', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }, " +
+ "{ 'group:202', {}, [{ 'grouplist:b', {next=3, prev=0}, [" +
+ "{ 'group:306', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }, " +
+ "{ 'group:307', {}, [{ 'hitlist:hits', {next=2}, [hit:1, hit:2] }] }] }] }] }] }");
}
// --------------------------------------------------------------------------------
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultIdTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultIdTestCase.java
index 8afaa4922ec..0e38e688258 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultIdTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/ResultIdTestCase.java
@@ -1,11 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.vespa;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -13,7 +11,7 @@ import static org.junit.Assert.assertTrue;
public class ResultIdTestCase {
@Test
- public void requireThatStartsWithWorks() {
+ void requireThatStartsWithWorks() {
assertFalse(ResultId.valueOf().startsWith(1, 1, 2, 3));
assertFalse(ResultId.valueOf(1).startsWith(1, 1, 2, 3));
assertFalse(ResultId.valueOf(1, 1).startsWith(1, 1, 2, 3));
@@ -26,32 +24,32 @@ public class ResultIdTestCase {
}
@Test
- public void requireThatChildIdStartsWithParentId() {
+ void requireThatChildIdStartsWithParentId() {
ResultId parentId = ResultId.valueOf(1, 1, 2);
ResultId childId = parentId.newChildId(3);
assertTrue(childId.startsWith(1, 1, 2));
}
@Test
- public void requireThatHashCodeIsImplemented() {
+ void requireThatHashCodeIsImplemented() {
assertEquals(ResultId.valueOf(1, 1, 2, 3).hashCode(), ResultId.valueOf(1, 1, 2, 3).hashCode());
- assertFalse(ResultId.valueOf(1, 1, 2, 3).hashCode() == ResultId.valueOf(5, 8, 13, 21).hashCode());
+ assertNotNull(ResultId.valueOf(5, 8, 13, 21).hashCode());
}
@Test
- public void requireThatEqualsIsImplemented() {
+ void requireThatEqualsIsImplemented() {
assertEquals(ResultId.valueOf(1, 1, 2, 3), ResultId.valueOf(1, 1, 2, 3));
- assertFalse(ResultId.valueOf(1, 1, 2, 3).equals(ResultId.valueOf(5, 8, 13, 21)));
+ assertNotEquals(ResultId.valueOf(1, 1, 2, 3), ResultId.valueOf(5, 8, 13, 21));
}
@Test
- public void requireThatResultIdCanBeEncoded() {
+ void requireThatResultIdCanBeEncoded() {
assertEncode("BIBCBCBEBG", ResultId.valueOf(1, 1, 2, 3));
assertEncode("BIBKCBACBKCCK", ResultId.valueOf(5, 8, 13, 21));
}
@Test
- public void requireThatResultIdCanBeDecoded() {
+ void requireThatResultIdCanBeDecoded() {
assertDecode(ResultId.valueOf(1, 1, 2, 3), "BIBCBCBEBG");
assertDecode(ResultId.valueOf(5, 8, 13, 21), "BIBKCBACBKCCK");
}
diff --git a/container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java b/container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java
index b0b88bf8190..83022ccf3ff 100644
--- a/container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java
@@ -17,12 +17,11 @@ import com.yahoo.slime.Inspector;
import com.yahoo.slime.SlimeUtils;
import com.yahoo.test.json.JsonTestHelper;
import org.assertj.core.api.Assertions;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -32,12 +31,12 @@ import java.util.Map;
import java.util.Random;
import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests submitting the query as JSON.
@@ -56,16 +55,16 @@ public class JSONSearchHandlerTestCase {
private static final String uri = "http://localhost?";
private static final String JSON_CONTENT_TYPE = "application/json";
- @Rule
- public TemporaryFolder tempfolder = new TemporaryFolder();
+ @TempDir
+ public File tempfolder;
private RequestHandlerTestDriver driver = null;
private HandlersConfigurerTestWrapper configurer = null;
private SearchHandler searchHandler;
- @Before
+ @BeforeEach
public void startUp() throws IOException {
- File cfgDir = tempfolder.newFolder("SearchHandlerTestCase");
+ File cfgDir = newFolder(tempfolder, "SearchHandlerTestCase");
tempDir = cfgDir.getAbsolutePath();
String configId = "dir:" + tempDir;
@@ -77,7 +76,7 @@ public class JSONSearchHandlerTestCase {
driver = new RequestHandlerTestDriver(searchHandler);
}
- @After
+ @AfterEach
public void shutDown() {
if (configurer != null) configurer.shutdown();
if (driver != null) driver.close();
@@ -96,7 +95,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testBadJSON() {
+ void testBadJSON() {
String json = "Not a valid JSON-string";
RequestHandlerTestDriver.MockResponseHandler responseHandler = driver.sendRequest(uri, com.yahoo.jdisc.http.HttpRequest.Method.POST, json, JSON_CONTENT_TYPE);
String response = responseHandler.readAll();
@@ -106,7 +105,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testFailing() {
+ void testFailing() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "test");
json.put("searchChain", "classLoadingError");
@@ -115,7 +114,7 @@ public class JSONSearchHandlerTestCase {
@Test
- public synchronized void testPluginError() {
+ synchronized void testPluginError() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "test");
json.put("searchChain", "exceptionInPlugin");
@@ -123,7 +122,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public synchronized void testWorkingReconfiguration() throws IOException {
+ synchronized void testWorkingReconfiguration() throws IOException {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "abc");
assertJsonResult(json, driver);
@@ -135,22 +134,22 @@ public class JSONSearchHandlerTestCase {
// ...and check the resulting config
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
- assertNotSame("Have a new instance of the search handler", searchHandler, newSearchHandler);
- assertNotNull("Have the new search chain", fetchSearchHandler(configurer).getSearchChainRegistry().getChain("hello"));
- assertNull("Don't have the new search chain", fetchSearchHandler(configurer).getSearchChainRegistry().getChain("classLoadingError"));
+ assertNotSame(searchHandler, newSearchHandler, "Have a new instance of the search handler");
+ assertNotNull(fetchSearchHandler(configurer).getSearchChainRegistry().getChain("hello"), "Have the new search chain");
+ assertNull(fetchSearchHandler(configurer).getSearchChainRegistry().getChain("classLoadingError"), "Don't have the new search chain");
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) {
assertJsonResult(json, newDriver);
}
}
@Test
- public void testInvalidYqlQuery() throws IOException {
+ void testInvalidYqlQuery() throws IOException {
IOUtils.copyDirectory(new File(testDir, "config_yql"), new File(tempDir), 1);
generateComponentsConfigForActive();
configurer.reloadConfig();
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
- assertTrue("Do I have a new instance of the search handler?", searchHandler != newSearchHandler);
+ assertTrue(searchHandler != newSearchHandler, "Do I have a new instance of the search handler?");
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) {
ObjectNode json = jsonMapper.createObjectNode();
json.put("yql", "selectz * from foo where bar > 1453501295");
@@ -162,7 +161,7 @@ public class JSONSearchHandlerTestCase {
// Query handling takes a different code path when a query profile is active, so we test both paths.
@Test
- public void testInvalidQueryParamWithQueryProfile() throws IOException {
+ void testInvalidQueryParamWithQueryProfile() throws IOException {
try (RequestHandlerTestDriver newDriver = driverWithConfig("config_invalid_param")) {
testInvalidQueryParam(newDriver);
}
@@ -182,7 +181,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testNormalResultJsonAliasRendering() {
+ void testNormalResultJsonAliasRendering() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("format", "json");
json.put("query", "abc");
@@ -190,7 +189,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testNullQuery() {
+ void testNullQuery() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("format", "xml");
@@ -204,7 +203,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testWebServiceStatus() {
+ void testWebServiceStatus() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "web_service_status_code");
RequestHandlerTestDriver.MockResponseHandler responseHandler =
@@ -215,14 +214,14 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testNormalResultImplicitDefaultRendering() {
+ void testNormalResultImplicitDefaultRendering() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "abc");
assertJsonResult(json, driver);
}
@Test
- public void testNormalResultExplicitDefaultRendering() {
+ void testNormalResultExplicitDefaultRendering() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "abc");
json.put("format", "default");
@@ -230,7 +229,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testNormalResultXmlAliasRendering() {
+ void testNormalResultXmlAliasRendering() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "abc");
json.put("format", "xml");
@@ -238,7 +237,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testNormalResultExplicitDefaultRenderingFullRendererName1() {
+ void testNormalResultExplicitDefaultRenderingFullRendererName1() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "abc");
json.put("format", "XmlRenderer");
@@ -246,7 +245,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testNormalResultExplicitDefaultRenderingFullRendererName2() {
+ void testNormalResultExplicitDefaultRenderingFullRendererName2() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "abc");
json.put("format", "JsonRenderer");
@@ -303,12 +302,12 @@ public class JSONSearchHandlerTestCase {
configurer.reloadConfig();
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
- assertTrue("Do I have a new instance of the search handler?", searchHandler != newSearchHandler);
+ assertTrue(searchHandler != newSearchHandler, "Do I have a new instance of the search handler?");
return new RequestHandlerTestDriver(newSearchHandler);
}
@Test
- public void testSelectParameters() throws IOException {
+ void testSelectParameters() throws IOException {
ObjectNode json = jsonMapper.createObjectNode();
ObjectNode select = jsonMapper.createObjectNode();
@@ -335,7 +334,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testJsonQueryWithSelectWhere() {
+ void testJsonQueryWithSelectWhere() {
ObjectNode root = jsonMapper.createObjectNode();
ObjectNode select = jsonMapper.createObjectNode();
ObjectNode where = jsonMapper.createObjectNode();
@@ -349,28 +348,28 @@ public class JSONSearchHandlerTestCase {
// Run query
String result = driver.sendRequest(uri + "searchChain=echoingQuery", com.yahoo.jdisc.http.HttpRequest.Method.POST, root.toString(), JSON_CONTENT_TYPE).readAll();
assertEquals("{\"root\":{\"id\":\"toplevel\",\"relevance\":1.0,\"fields\":{\"totalCount\":0},\"children\":[{\"id\":\"Query\",\"relevance\":1.0,\"fields\":{\"query\":\"select * from sources * where default contains \\\"bad\\\"\"}}]}}",
- result);
+ result);
}
@Test
- public void testJsonWithWhereAndGroupingUnderSelect() {
+ void testJsonWithWhereAndGroupingUnderSelect() {
String query = "{\n" +
- " \"select\": {\n" +
- " \"where\": {\n" +
- " \"contains\": [\n" +
- " \"field\",\n" +
- " \"term\"\n" +
- " ]\n" +
- " },\n" +
- " \"grouping\":[\n" +
- " {\n" +
- " \"all\": {\n" +
- " \"output\": \"count()\"\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- "}\n";
+ " \"select\": {\n" +
+ " \"where\": {\n" +
+ " \"contains\": [\n" +
+ " \"field\",\n" +
+ " \"term\"\n" +
+ " ]\n" +
+ " },\n" +
+ " \"grouping\":[\n" +
+ " {\n" +
+ " \"all\": {\n" +
+ " \"output\": \"count()\"\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ "}\n";
String result = driver.sendRequest(uri + "searchChain=echoingQuery", com.yahoo.jdisc.http.HttpRequest.Method.POST, query, JSON_CONTENT_TYPE).readAll();
String expected = "{\"root\":{\"id\":\"toplevel\",\"relevance\":1.0,\"fields\":{\"totalCount\":0},\"children\":[{\"id\":\"Query\",\"relevance\":1.0,\"fields\":{\"query\":\"select * from sources * where field contains \\\"term\\\" | all(output(count()))\"}}]}}";
@@ -378,22 +377,22 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testJsonWithWhereAndGroupingSeparate() {
+ void testJsonWithWhereAndGroupingSeparate() {
String query = "{\n" +
- " \"select.where\": {\n" +
- " \"contains\": [\n" +
- " \"field\",\n" +
- " \"term\"\n" +
- " ]\n" +
- " },\n" +
- " \"select.grouping\":[\n" +
- " {\n" +
- " \"all\": {\n" +
- " \"output\": \"count()\"\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- "}\n";
+ " \"select.where\": {\n" +
+ " \"contains\": [\n" +
+ " \"field\",\n" +
+ " \"term\"\n" +
+ " ]\n" +
+ " },\n" +
+ " \"select.grouping\":[\n" +
+ " {\n" +
+ " \"all\": {\n" +
+ " \"output\": \"count()\"\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ "}\n";
String result = driver.sendRequest(uri + "searchChain=echoingQuery", com.yahoo.jdisc.http.HttpRequest.Method.POST, query, JSON_CONTENT_TYPE).readAll();
String expected = "{\"root\":{\"id\":\"toplevel\",\"relevance\":1.0,\"fields\":{\"totalCount\":0},\"children\":[{\"id\":\"Query\",\"relevance\":1.0,\"fields\":{\"query\":\"select * from sources * where field contains \\\"term\\\" | all(output(count()))\"}}]}}";
@@ -401,18 +400,18 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testJsonQueryWithYQL() {
+ void testJsonQueryWithYQL() {
ObjectNode root = jsonMapper.createObjectNode();
root.put("yql", "select * from sources * where default contains 'bad';");
// Run query
String result = driver.sendRequest(uri + "searchChain=echoingQuery", com.yahoo.jdisc.http.HttpRequest.Method.POST, root.toString(), JSON_CONTENT_TYPE).readAll();
assertEquals("{\"root\":{\"id\":\"toplevel\",\"relevance\":1.0,\"fields\":{\"totalCount\":0},\"children\":[{\"id\":\"Query\",\"relevance\":1.0,\"fields\":{\"query\":\"select * from sources * where default contains \\\"bad\\\"\"}}]}}",
- result);
+ result);
}
@Test
- public void testRequestMapping() {
+ void testRequestMapping() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("yql", "select * from sources * where sddocname contains \"blog_post\" limit 0 | all(group(date) max(3) order(-count())each(output(count())))");
json.put("hits", 10);
@@ -529,7 +528,7 @@ public class JSONSearchHandlerTestCase {
}
@Test
- public void testContentTypeParsing() {
+ void testContentTypeParsing() {
ObjectNode json = jsonMapper.createObjectNode();
json.put("query", "abc");
assertOkResult(driver.sendRequest(uri, com.yahoo.jdisc.http.HttpRequest.Method.POST, json.toString(), "Application/JSON; charset=utf-8"), jsonResult);
@@ -546,7 +545,7 @@ public class JSONSearchHandlerTestCase {
sb.append("]}");
return sb.toString();
}
- @Ignore
+ @Disabled
public void benchmarkJsonParsing() {
String request = createBenchmarkRequest(768);
for (int i=0; i < 10000; i++) {
@@ -558,4 +557,13 @@ public class JSONSearchHandlerTestCase {
}
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
diff --git a/container-search/src/test/java/com/yahoo/search/handler/Json2SinglelevelMapTestCase.java b/container-search/src/test/java/com/yahoo/search/handler/Json2SinglelevelMapTestCase.java
index c50b063ff44..e421365b541 100644
--- a/container-search/src/test/java/com/yahoo/search/handler/Json2SinglelevelMapTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/handler/Json2SinglelevelMapTestCase.java
@@ -1,17 +1,17 @@
package com.yahoo.search.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class Json2SinglelevelMapTestCase {
@Test
- public void testDecodeString() {
+ void testDecodeString() {
Map<String, String> m = new Json2SingleLevelMap(new ByteArrayInputStream("{\"yql\":\"text\", \"f1\":7.3, \"i1\":7, \"t\":true, \"f\":false, \"n\":null, \"a\":[0.786, 0.193]}".getBytes(StandardCharsets.UTF_8))).parse();
assertEquals(7, m.size());
assertTrue(m.containsKey("yql"));
@@ -29,8 +29,9 @@ public class Json2SinglelevelMapTestCase {
assertEquals("null", m.get("n"));
assertEquals("[0.786, 0.193]", m.get("a"));
}
+
@Test
- public void testThatWeAllowSingleQuotes() {
+ void testThatWeAllowSingleQuotes() {
Map<String, String> m = new Json2SingleLevelMap(new ByteArrayInputStream("{'yql':'text'}".getBytes(StandardCharsets.UTF_8))).parse();
assertTrue(m.containsKey("yql"));
assertEquals("text", m.get("yql"));
diff --git a/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java b/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java
index a0374570b69..eb461d6211f 100644
--- a/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java
@@ -23,12 +23,11 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.result.Relevance;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.config.test.SearchChainConfigurerTestCase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -37,13 +36,7 @@ import java.net.URI;
import java.util.concurrent.Executors;
import static com.yahoo.yolean.Exceptions.uncheckInterrupted;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -56,17 +49,17 @@ public class SearchHandlerTest {
private static String tempDir = "";
- @Rule
- public TemporaryFolder tempfolder = new TemporaryFolder();
+ @TempDir
+ public File tempfolder;
private RequestHandlerTestDriver driver = null;
private HandlersConfigurerTestWrapper configurer = null;
private MockMetric metric;
private SearchHandler searchHandler;
- @Before
+ @BeforeEach
public void startUp() throws IOException {
- File cfgDir = tempfolder.newFolder("SearchHandlerTestCase");
+ File cfgDir = newFolder(tempfolder, "SearchHandlerTestCase");
tempDir = cfgDir.getAbsolutePath();
String configId = "dir:" + tempDir;
@@ -79,7 +72,7 @@ public class SearchHandlerTest {
driver = new RequestHandlerTestDriver(searchHandler);
}
- @After
+ @AfterEach
public void shutDown() {
if (configurer != null) configurer.shutdown();
if (driver != null) driver.close();
@@ -98,30 +91,30 @@ public class SearchHandlerTest {
}
@Test
- public void testNullQuery() {
+ void testNullQuery() {
assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
- "<result total-hit-count=\"0\">\n" +
- " <hit relevancy=\"1.0\">\n" +
- " <field name=\"relevancy\">1.0</field>\n" +
- " <field name=\"uri\">testHit</field>\n" +
- " </hit>\n" +
- "</result>\n",
- driver.sendRequest("http://localhost?format=xml").readAll()
- );
+ "<result total-hit-count=\"0\">\n" +
+ " <hit relevancy=\"1.0\">\n" +
+ " <field name=\"relevancy\">1.0</field>\n" +
+ " <field name=\"uri\">testHit</field>\n" +
+ " </hit>\n" +
+ "</result>\n",
+ driver.sendRequest("http://localhost?format=xml").readAll()
+ );
}
@Test
- public void testFailing() {
- assertTrue(driver.sendRequest("http://localhost?query=test&searchChain=classLoadingError").readAll().contains("NoClassDefFoundError"));
+ void testFailing() {
+ assertTrue(driver.sendRequest("http://localhost?query=test&searchChain=classLoadingError").readAll().contains("NoClassDefFoundError"));
}
@Test
- public synchronized void testPluginError() {
+ synchronized void testPluginError() {
assertTrue(driver.sendRequest("http://localhost?query=test&searchChain=exceptionInPlugin").readAll().contains("NullPointerException"));
}
@Test
- public synchronized void testWorkingReconfiguration() throws Exception {
+ synchronized void testWorkingReconfiguration() throws Exception {
assertJsonResult("http://localhost?query=abc", driver);
// reconfiguration
@@ -131,17 +124,17 @@ public class SearchHandlerTest {
// ...and check the resulting config
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
- assertNotSame("Have a new instance of the search handler", searchHandler, newSearchHandler);
- assertNotNull("Have the new search chain", fetchSearchHandler(configurer).getSearchChainRegistry().getChain("hello"));
- assertNull("Don't have the new search chain", fetchSearchHandler(configurer).getSearchChainRegistry().getChain("classLoadingError"));
+ assertNotSame(searchHandler, newSearchHandler, "Have a new instance of the search handler");
+ assertNotNull(fetchSearchHandler(configurer).getSearchChainRegistry().getChain("hello"), "Have the new search chain");
+ assertNull(fetchSearchHandler(configurer).getSearchChainRegistry().getChain("classLoadingError"), "Don't have the new search chain");
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) {
assertJsonResult("http://localhost?query=abc", newDriver);
}
}
@Test
- @Ignore //TODO: Must be done at the ConfiguredApplication level, not handlers configurer? Also, this must be rewritten as the above
- public synchronized void testFailedReconfiguration() throws Exception {
+ @Disabled //TODO: Must be done at the ConfiguredApplication level, not handlers configurer? Also, this must be rewritten as the above
+ synchronized void testFailedReconfiguration() throws Exception {
assertXmlResult(driver);
// attempt reconfiguration
@@ -150,15 +143,15 @@ public class SearchHandlerTest {
configurer.reloadConfig();
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
RequestHandler newMockHandler = configurer.getRequestHandlerRegistry().getComponent("com.yahoo.search.handler.test.MockHandler");
- assertSame("Reconfiguration failed: Kept the existing instance of the search handler", searchHandler, newSearchHandler);
- assertNull("Reconfiguration failed: No mock handler", newMockHandler);
+ assertSame(searchHandler, newSearchHandler, "Reconfiguration failed: Kept the existing instance of the search handler");
+ assertNull(newMockHandler, "Reconfiguration failed: No mock handler");
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(searchHandler)) {
assertXmlResult(newDriver);
}
}
@Test
- public void testResponseBasics() {
+ void testResponseBasics() {
Query q = new Query("?query=dummy&tracelevel=3");
q.trace("nalle", 1);
Result r = new Result(q);
@@ -172,13 +165,13 @@ public class SearchHandlerTest {
}
@Test
- public void testInvalidYqlQuery() throws Exception {
+ void testInvalidYqlQuery() throws Exception {
IOUtils.copyDirectory(new File(testDir, "config_yql"), new File(tempDir), 1);
generateComponentsConfigForActive();
configurer.reloadConfig();
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
- assertNotSame("Have a new instance of the search handler", searchHandler, newSearchHandler);
+ assertNotSame(searchHandler, newSearchHandler, "Have a new instance of the search handler");
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) {
RequestHandlerTestDriver.MockResponseHandler responseHandler = newDriver.sendRequest(
"http://localhost/search/?yql=select%20*%20from%20foo%20where%20bar%20%3E%201453501295%27%3B");
@@ -189,7 +182,7 @@ public class SearchHandlerTest {
}
@Test
- public void testRequestType() throws Exception {
+ void testRequestType() throws Exception {
IOUtils.copyDirectory(new File(testDir, "config_yql"), new File(tempDir), 1);
generateComponentsConfigForActive();
configurer.reloadConfig();
@@ -205,14 +198,14 @@ public class SearchHandlerTest {
// Query handling takes a different code path when a query profile is active, so we test both paths.
@Test
- public void testInvalidQueryParamWithQueryProfile() throws Exception {
+ void testInvalidQueryParamWithQueryProfile() throws Exception {
try (RequestHandlerTestDriver newDriver = driverWithConfig("config_invalid_param")) {
testInvalidQueryParam(newDriver);
}
}
@Test
- public void testInvalidQueryParamWithoutQueryProfile() {
+ void testInvalidQueryParamWithoutQueryProfile() {
testInvalidQueryParam(driver);
}
private void testInvalidQueryParam(final RequestHandlerTestDriver testDriver) {
@@ -225,7 +218,7 @@ public class SearchHandlerTest {
}
@Test
- public void testResultStatus() {
+ void testResultStatus() {
assertEquals(200, httpStatus(result().build()));
assertEquals(200, httpStatus(result().withHit().build()));
assertEquals(200, httpStatus(result().withGroups().build()));
@@ -238,7 +231,7 @@ public class SearchHandlerTest {
}
@Test
- public void testWebServiceStatus() {
+ void testWebServiceStatus() {
RequestHandlerTestDriver.MockResponseHandler responseHandler =
driver.sendRequest("http://localhost/search/?query=web_service_status_code");
String response = responseHandler.readAll();
@@ -247,32 +240,32 @@ public class SearchHandlerTest {
}
@Test
- public void testNormalResultImplicitDefaultRendering() {
+ void testNormalResultImplicitDefaultRendering() {
assertJsonResult("http://localhost?query=abc", driver);
}
@Test
- public void testNormalResultExplicitDefaultRendering() {
+ void testNormalResultExplicitDefaultRendering() {
assertJsonResult("http://localhost?query=abc&format=default", driver);
}
@Test
- public void testNormalResultXmlAliasRendering() {
+ void testNormalResultXmlAliasRendering() {
assertXmlResult("http://localhost?query=abc&format=xml", driver);
}
@Test
- public void testNormalResultJsonAliasRendering() {
+ void testNormalResultJsonAliasRendering() {
assertJsonResult("http://localhost?query=abc&format=json", driver);
}
@Test
- public void testNormalResultExplicitDefaultRenderingFullRendererName1() {
+ void testNormalResultExplicitDefaultRenderingFullRendererName1() {
assertXmlResult("http://localhost?query=abc&format=XmlRenderer", driver);
}
@Test
- public void testNormalResultExplicitDefaultRenderingFullRendererName2() {
+ void testNormalResultExplicitDefaultRenderingFullRendererName2() {
assertJsonResult("http://localhost?query=abc&format=JsonRenderer", driver);
}
@@ -319,7 +312,7 @@ public class SearchHandlerTest {
}
@Test
- public void testFaultyHandlers() throws Exception {
+ void testFaultyHandlers() throws Exception {
assertHandlerResponse(500, null, "NullReturning");
assertHandlerResponse(500, null, "NullReturningAsync");
assertHandlerResponse(500, null, "Throwing");
@@ -327,7 +320,7 @@ public class SearchHandlerTest {
}
@Test
- public void testForwardingHandlers() throws Exception {
+ void testForwardingHandlers() throws Exception {
assertHandlerResponse(200, jsonResult, "ForwardingAsync");
// Fails because we are forwarding from a sync to an async handler -
@@ -341,9 +334,9 @@ public class SearchHandlerTest {
try (RequestHandlerTestDriver forwardingDriver = new RequestHandlerTestDriver(forwardingHandler)) {
RequestHandlerTestDriver.MockResponseHandler response = forwardingDriver.sendRequest("http://localhost/" + handlerName + "?query=test");
response.awaitResponse();
- assertEquals("Expected HTTP status", status, response.getStatus());
+ assertEquals(status, response.getStatus(), "Expected HTTP status");
if (responseData == null)
- assertNull("Connection closed with no data", response.read());
+ assertNull(response.read(), "Connection closed with no data");
else
assertEquals(responseData, response.readAll());
}
@@ -355,7 +348,7 @@ public class SearchHandlerTest {
configurer.reloadConfig();
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
- assertNotSame("Should have a new instance of the search handler", searchHandler, newSearchHandler);
+ assertNotSame(searchHandler, newSearchHandler, "Should have a new instance of the search handler");
return new RequestHandlerTestDriver(newSearchHandler);
}
@@ -387,6 +380,15 @@ public class SearchHandlerTest {
return result;
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
}
/** Referenced from config */
@@ -396,6 +398,15 @@ public class SearchHandlerTest {
public Result search(Query query, Execution execution) {
throw new NoClassDefFoundError(); // Simulate typical OSGi problem
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
}
/** Referenced from config */
@@ -411,6 +422,15 @@ public class SearchHandlerTest {
}
return result;
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
}
/** Referenced from config */
@@ -422,6 +442,15 @@ public class SearchHandlerTest {
result.hits().add(new Hit("HelloWorld"));
return result;
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
}
/** Referenced from config */
@@ -435,6 +464,15 @@ public class SearchHandlerTest {
result.hits().add(hit);
return result;
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
}
/** Referenced from config */
@@ -459,6 +497,15 @@ public class SearchHandlerTest {
}
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
/** Referenced from config */
@@ -483,6 +530,15 @@ public class SearchHandlerTest {
}
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
/** Referenced from config */
@@ -497,6 +553,15 @@ public class SearchHandlerTest {
return null;
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
/** Referenced from config */
@@ -511,6 +576,15 @@ public class SearchHandlerTest {
return null;
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
/** Referenced from config */
@@ -525,6 +599,15 @@ public class SearchHandlerTest {
throw new RuntimeException();
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
/** Referenced from config */
@@ -539,6 +622,15 @@ public class SearchHandlerTest {
throw new RuntimeException();
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
private ResultBuilder result() { return new ResultBuilder(); }
@@ -564,6 +656,24 @@ public class SearchHandlerTest {
public Result build() { return result; }
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
+ }
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/match/test/DocumentDbTest.java b/container-search/src/test/java/com/yahoo/search/match/test/DocumentDbTest.java
index eff9c2f558f..4df45b26191 100644
--- a/container-search/src/test/java/com/yahoo/search/match/test/DocumentDbTest.java
+++ b/container-search/src/test/java/com/yahoo/search/match/test/DocumentDbTest.java
@@ -6,17 +6,16 @@ import com.yahoo.document.datatypes.WeightedSet;
import com.yahoo.search.Result;
import com.yahoo.search.match.DocumentDb;
import com.yahoo.text.MapParser;
-import org.junit.Ignore;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
public class DocumentDbTest {
@Test
- @Ignore
- public void testWand() {
+ @Disabled
+ void testWand() {
DocumentDb db = new DocumentDb();
- db.put(createFeatureDocument("1","[a:7, b:5, c:3]"));
+ db.put(createFeatureDocument("1", "[a:7, b:5, c:3]"));
db.put(createFeatureDocument("2", "[a:2, b:1, c:4]"));
//Result r = execute(createWandQuery("[a:1, b:3, c:5]"));
//assertEquals(67,r.hits().get(0).getRelevance());
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/MapPageTemplateXMLReadingTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/MapPageTemplateXMLReadingTestCase.java
index b8457344944..5b4f4e82221 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/MapPageTemplateXMLReadingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/MapPageTemplateXMLReadingTestCase.java
@@ -8,13 +8,11 @@ import com.yahoo.search.pagetemplates.model.MapChoice;
import com.yahoo.search.pagetemplates.model.Placeholder;
import com.yahoo.search.pagetemplates.model.Section;
import com.yahoo.search.pagetemplates.model.Source;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -24,13 +22,13 @@ public class MapPageTemplateXMLReadingTestCase {
private String root="src/test/java/com/yahoo/search/pagetemplates/config/test/examples/mapexamples/";
@Test
- public void testMap1() {
- PageTemplateRegistry registry=new PageTemplateXMLReader().read(root);
+ void testMap1() {
+ PageTemplateRegistry registry = new PageTemplateXMLReader().read(root);
assertCorrectMap1(registry.getComponent("map1"));
}
private void assertCorrectMap1(PageTemplate page) {
- assertNotNull("map1 was read",page);
+ assertNotNull(page,"map1 was read");
Section root=page.getSection();
assertTrue(((Section)((Section)root.elements(Section.class).get(0)).elements(Section.class).get(0)).elements().get(0) instanceof Placeholder);
assertTrue(((Section)((Section)root.elements(Section.class).get(0)).elements(Section.class).get(1)).elements().get(0) instanceof Placeholder);
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/PageTemplateXMLReadingTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/PageTemplateXMLReadingTestCase.java
index 1b845802ec3..5994cad468d 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/PageTemplateXMLReadingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/config/test/PageTemplateXMLReadingTestCase.java
@@ -13,15 +13,12 @@ import com.yahoo.search.pagetemplates.model.Choice;
import com.yahoo.search.pagetemplates.model.Renderer;
import com.yahoo.search.pagetemplates.model.Section;
import com.yahoo.search.pagetemplates.model.Source;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -31,8 +28,8 @@ public class PageTemplateXMLReadingTestCase {
private String root="src/test/java/com/yahoo/search/pagetemplates/config/test/";
@Test
- public void testExamples() {
- PageTemplateRegistry registry=new PageTemplateXMLReader().read(root + "examples");
+ void testExamples() {
+ PageTemplateRegistry registry = new PageTemplateXMLReader().read(root + "examples");
assertCorrectSerp(registry.getComponent("serp"));
assertCorrectSlottingSerp(registry.getComponent("slottingSerp"));
assertCorrectRichSerp(registry.getComponent("richSerp"));
@@ -42,7 +39,7 @@ public class PageTemplateXMLReadingTestCase {
}
@Test
- public void testConfigReading() {
+ void testConfigReading() {
PageTemplatesConfig config = new PageTemplatesConfig(new PageTemplatesConfig.Builder()
.page("<page id=\"slottingSerp\" layout=\"mainAndRight\">\n <section layout=\"column\" region=\"main\" source=\"*\" order=\"-[rank]\"/>\n <section layout=\"column\" region=\"right\" source=\"ads\"/>\n</page>\n")
.page("<page id=\"richSerp\" layout=\"mainAndRight\">\n <section layout=\"row\" region=\"main\">\n <section layout=\"column\" description=\"left main pane\">\n <section layout=\"row\" max=\"5\" description=\"Bar of images, from one of two possible sources\">\n <choice method=\"annealing\">\n <source name=\"images\"/>\n <source name=\"flickr\"/>\n </choice>\n </section>\n <section max=\"1\" source=\"local map video ticker weather\" description=\"A single relevant graphically rich element\"/>\n <section order=\"-[rank]\" max=\"10\" source=\"web news\" description=\"Various kinds of traditional search results\"/>\n </section>\n <section layout=\"column\" order=\"[source]\" source=\"answers blogs twitter\" description=\"right main pane, ugc stuff, grouped by source\"/>\n </section>\n <section layout=\"column\" source=\"ads\" region=\"right\"/>\n</page>\n")
@@ -57,19 +54,19 @@ public class PageTemplateXMLReadingTestCase {
}
@Test
- public void testInvalidFilename() {
+ void testInvalidFilename() {
try {
- PageTemplateRegistry registry=new PageTemplateXMLReader().read(root + "examples/invalidfilename");
- assertEquals(0,registry.allComponents().size());
+ PageTemplateRegistry registry = new PageTemplateXMLReader().read(root + "examples/invalidfilename");
+ assertEquals(0, registry.allComponents().size());
fail("Should have caused an exception");
}
catch (IllegalArgumentException e) {
- assertEquals("The file name of page template 'notinvalid' must be 'notinvalid.xml' but was 'invalid.xml'",e.getMessage());
+ assertEquals("The file name of page template 'notinvalid' must be 'notinvalid.xml' but was 'invalid.xml'", e.getMessage());
}
}
protected void assertCorrectSerp(PageTemplate page) {
- assertNotNull("'serp' was read",page);
+ assertNotNull(page,"'serp' was read");
Section rootSection=page.getSection();
assertNotNull(rootSection);
assertEquals("mainAndRight",rootSection.getLayout().getName());
@@ -84,7 +81,7 @@ public class PageTemplateXMLReadingTestCase {
}
protected void assertCorrectSlottingSerp(PageTemplate page) {
- assertNotNull("'slotting serp' was read",page);
+ assertNotNull(page,"'slotting serp' was read");
Section rootSection=page.getSection();
Section main=(Section)rootSection.elements(Section.class).get(0);
assertEquals("-[rank]",main.getOrder().toString());
@@ -94,7 +91,7 @@ public class PageTemplateXMLReadingTestCase {
}
protected void assertCorrectRichSerp(PageTemplate page) {
- assertNotNull("'rich serp' was read",page);
+ assertNotNull(page,"'rich serp' was read");
Section rootSection=page.getSection();
assertNotNull(rootSection);
assertEquals("mainAndRight",rootSection.getLayout().getName());
@@ -129,7 +126,7 @@ public class PageTemplateXMLReadingTestCase {
}
protected void assertCorrectRicherSerp(PageTemplate page) {
- assertNotNull("'richer serp' was read",page);
+ assertNotNull(page,"'richer serp' was read");
// Check resolution as we go
Resolver resolver=new DeterministicResolver();
@@ -139,7 +136,7 @@ public class PageTemplateXMLReadingTestCase {
assertNotNull(root);
assertEquals("column",root.getLayout().getName());
- assertEquals("Sections was correctly imported and combined with the section in this",4,root.elements(Section.class).size());
+ assertEquals(4,root.elements(Section.class).size(),"Sections was correctly imported and combined with the section in this");
assertCorrectHeader((Section)root.elements(Section.class).get(0));
@@ -218,14 +215,13 @@ public class PageTemplateXMLReadingTestCase {
Set<String> sourceNames=new HashSet<>();
for (Source source : page.getSources())
sourceNames.add(source.getName());
- assertEquals("Expected " + expectedSourceNames.length + " elements in " + sourceNames,
- expectedSourceNames.length,sourceNames.size());
+ assertEquals(expectedSourceNames.length,sourceNames.size(),"Expected " + expectedSourceNames.length + " elements in " + sourceNames);
for (String expectedSourceName : expectedSourceNames)
- assertTrue("Sources did not include '" + expectedSourceName+ "'",sourceNames.contains(expectedSourceName));
+ assertTrue(sourceNames.contains(expectedSourceName),"Sources did not include '" + expectedSourceName+ "'");
}
protected void assertCorrectIncluder(PageTemplate page) {
- assertNotNull("'includer' was read",page);
+ assertNotNull(page,"'includer' was read");
Resolution resolution=new DeterministicResolver().resolve(Choice.createSingleton(page),null,null);
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceTestCase.java
index 4ee07db691b..7e72a57b1dc 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/AnySourceTestCase.java
@@ -9,9 +9,9 @@ import com.yahoo.search.pagetemplates.engine.Resolver;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -19,41 +19,41 @@ import static org.junit.Assert.assertEquals;
public class AnySourceTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("AnySource.xml"));
+ Choice page = Choice.createSingleton(importPage("AnySource.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source2",3));
- result.hits().add(createHits("source3",3));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source2", 3));
+ result.hits().add(createHits("source3", 3));
// Resolve (noop here)
- Resolver resolver=new DeterministicResolver();
- Resolution resolution=resolver.resolve(page,query,result);
+ Resolver resolver = new DeterministicResolver();
+ Resolution resolution = resolver.resolve(page, query, result);
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check execution:
// all three sources, ordered by relevance, source 3 first in each relevance group
- HitGroup hits=result.hits();
- assertEquals(9,hits.size());
- assertEquals("source3-1",hits.get(0).getId().stringValue());
- assertEquals("source1-1",hits.get(1).getId().stringValue());
- assertEquals("source2-1",hits.get(2).getId().stringValue());
- assertEquals("source3-2",hits.get(3).getId().stringValue());
- assertEquals("source1-2",hits.get(4).getId().stringValue());
- assertEquals("source2-2",hits.get(5).getId().stringValue());
- assertEquals("source3-3",hits.get(6).getId().stringValue());
- assertEquals("source1-3",hits.get(7).getId().stringValue());
- assertEquals("source2-3",hits.get(8).getId().stringValue());
+ HitGroup hits = result.hits();
+ assertEquals(9, hits.size());
+ assertEquals("source3-1", hits.get(0).getId().stringValue());
+ assertEquals("source1-1", hits.get(1).getId().stringValue());
+ assertEquals("source2-1", hits.get(2).getId().stringValue());
+ assertEquals("source3-2", hits.get(3).getId().stringValue());
+ assertEquals("source1-2", hits.get(4).getId().stringValue());
+ assertEquals("source2-2", hits.get(5).getId().stringValue());
+ assertEquals("source3-3", hits.get(6).getId().stringValue());
+ assertEquals("source1-3", hits.get(7).getId().stringValue());
+ assertEquals("source2-3", hits.get(8).getId().stringValue());
// Check rendering
- assertRendered(result,"AnySourceResult.xml");
+ assertRendered(result, "AnySourceResult.xml");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersTestCase.java
index b495f68464e..227afbce9dc 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfRenderersTestCase.java
@@ -10,9 +10,9 @@ import com.yahoo.search.pagetemplates.engine.Resolver;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
import com.yahoo.search.pagetemplates.model.Renderer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -21,31 +21,31 @@ public class ChoiceOfRenderersTestCase extends ExecutionAbstractTestCase {
//This test is order dependent. Fix this!!
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("ChoiceOfRenderers.xml"));
+ Choice page = Choice.createSingleton(importPage("ChoiceOfRenderers.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source2",3));
- result.hits().add(createHits("source3",3));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source2", 3));
+ result.hits().add(createHits("source3", 3));
// Resolve
- Resolver resolver=new DeterministicResolver();
- Resolution resolution=resolver.resolve(page,query,result);
- assertEquals(1,resolution.getResolution((Choice)((PageTemplate)page.get(0).get(0)).getSection().elements(Renderer.class).get(0)));
- assertEquals(2,resolution.getResolution((Choice)((PageTemplate)page.get(0).get(0)).getSection().elements(Renderer.class).get(1)));
+ Resolver resolver = new DeterministicResolver();
+ Resolution resolution = resolver.resolve(page, query, result);
+ assertEquals(1, resolution.getResolution((Choice) ((PageTemplate) page.get(0).get(0)).getSection().elements(Renderer.class).get(0)));
+ assertEquals(2, resolution.getResolution((Choice) ((PageTemplate) page.get(0).get(0)).getSection().elements(Renderer.class).get(1)));
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
- assertEquals(6,result.getConcreteHitCount());
- assertEquals(6,result.getHitCount());
+ assertEquals(6, result.getConcreteHitCount());
+ assertEquals(6, result.getHitCount());
// Check rendering
- assertRendered(result,"ChoiceOfRenderersResult.xml");
+ assertRendered(result, "ChoiceOfRenderersResult.xml");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java
index 332d8612954..50db2810630 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfSubsectionsTestCase.java
@@ -8,12 +8,12 @@ import com.yahoo.search.pagetemplates.engine.Resolution;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
public class ChoiceOfSubsectionsTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("ChoiceOfSubsections.xml"));
@@ -38,8 +38,8 @@ public class ChoiceOfSubsectionsTestCase extends ExecutionAbstractTestCase {
// Check execution:
// Two subsections with one source each
assertEquals(2, result.hits().size());
- HitGroup section1 = (HitGroup)result.hits().get(0);
- HitGroup section2 = (HitGroup)result.hits().get(1);
+ HitGroup section1 = (HitGroup) result.hits().get(0);
+ HitGroup section2 = (HitGroup) result.hits().get(1);
assertEquals("section", section1.types().stream().collect(Collectors.joining(", ")));
assertEquals("section", section2.types().stream().collect(Collectors.joining(", ")));
assertEqualHitGroups(createHits("source2", 3), section1);
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesTestCase.java
index b7fb22713f2..8849f73cfb6 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoiceOfTwoSourcesTestCase.java
@@ -10,9 +10,9 @@ import com.yahoo.search.pagetemplates.engine.Resolver;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
import com.yahoo.search.pagetemplates.model.Source;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -20,32 +20,32 @@ import static org.junit.Assert.assertEquals;
public class ChoiceOfTwoSourcesTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("ChoiceOfTwoSources.xml"));
+ Choice page = Choice.createSingleton(importPage("ChoiceOfTwoSources.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source2",3));
- result.hits().add(createHits("source3",3));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source2", 3));
+ result.hits().add(createHits("source3", 3));
// Resolve
- Resolver resolver=new DeterministicResolver();
- Resolution resolution=resolver.resolve(page,query,result);
- assertEquals(1,resolution.getResolution((Choice)((PageTemplate)page.get(0).get(0)).getSection().elements(Source.class).get(0)));
+ Resolver resolver = new DeterministicResolver();
+ Resolution resolution = resolver.resolve(page, query, result);
+ assertEquals(1, resolution.getResolution((Choice) ((PageTemplate) page.get(0).get(0)).getSection().elements(Source.class).get(0)));
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check execution:
// No subsections: Last choice (source2) used
- assertEqualHitGroups(createHits("source2",3),result.hits());
+ assertEqualHitGroups(createHits("source2", 3), result.hits());
// Check rendering
- assertRendered(result,"ChoiceOfTwoSourcesResult.xml");
+ assertRendered(result, "ChoiceOfTwoSourcesResult.xml");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesTestCase.java
index 629d690fda2..17d59b3e22f 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ChoicesTestCase.java
@@ -9,7 +9,7 @@ import com.yahoo.search.pagetemplates.engine.Resolver;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
import com.yahoo.search.pagetemplates.model.PageElement;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -20,31 +20,31 @@ import java.util.List;
public class ChoicesTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template (second alternative will be chosen)
- List<PageElement> pages=new ArrayList<>();
+ List<PageElement> pages = new ArrayList<>();
pages.add(importPage("AnySource.xml"));
pages.add(importPage("Choices.xml"));
- Choice page=Choice.createSingletons(pages);
+ Choice page = Choice.createSingletons(pages);
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("news",3));
- result.hits().add(createHits("web",3));
- result.hits().add(createHits("blog",3));
- result.hits().add(createHits("images",3));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("news", 3));
+ result.hits().add(createHits("web", 3));
+ result.hits().add(createHits("blog", 3));
+ result.hits().add(createHits("images", 3));
// Resolve
- Resolver resolver=new DeterministicResolver();
- Resolution resolution=resolver.resolve(page,query,result);
+ Resolver resolver = new DeterministicResolver();
+ Resolution resolution = resolver.resolve(page, query, result);
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check rendering
- assertRendered(result,"ChoicesResult.xml");
+ assertRendered(result, "ChoicesResult.xml");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java
index 5a8a4dfa9d2..3645b0efe37 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/ExecutionAbstractTestCase.java
@@ -14,7 +14,7 @@ import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.concurrent.CompletableFuture;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -25,7 +25,7 @@ public class ExecutionAbstractTestCase {
protected PageTemplate importPage(String name) {
PageTemplate template=new PageTemplateXMLReader().readFile(root + name);
- assertNotNull("Could look up page template '" + name + "'",template);
+ assertNotNull(template,"Could look up page template '" + name + "'");
return template;
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsTestCase.java
index 770e7f524e8..284c719b05e 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSectionsToSectionsTestCase.java
@@ -13,13 +13,13 @@ import com.yahoo.search.pagetemplates.model.MapChoice;
import com.yahoo.search.pagetemplates.model.PageElement;
import com.yahoo.search.pagetemplates.model.Section;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author bratseth
@@ -27,52 +27,52 @@ import static org.junit.Assert.assertNotNull;
public class MapSectionsToSectionsTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("MapSectionsToSections.xml"));
+ Choice page = Choice.createSingleton(importPage("MapSectionsToSections.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source2",4));
- result.hits().add(createHits("source3",5));
- result.hits().add(createHits("source4",6));
- result.hits().add(createHits("source5",7));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source2", 4));
+ result.hits().add(createHits("source3", 5));
+ result.hits().add(createHits("source4", 6));
+ result.hits().add(createHits("source5", 7));
// Resolve
- Resolver resolver=new DeterministicResolverAssertingMethod();
- Resolution resolution=resolver.resolve(page,query,result);
- Map<String, List<PageElement>> mapping=
- resolution.getResolution((MapChoice)((PageTemplate)page.get(0).get(0)).getSection().elements().get(2));
+ Resolver resolver = new DeterministicResolverAssertingMethod();
+ Resolution resolution = resolver.resolve(page, query, result);
+ Map<String, List<PageElement>> mapping =
+ resolution.getResolution((MapChoice) ((PageTemplate) page.get(0).get(0)).getSection().elements().get(2));
assertNotNull(mapping);
- assertEquals("box1",((Section)mapping.get("box1holder").get(0)).getId());
- assertEquals("box2",((Section)mapping.get("box2holder").get(0)).getId());
- assertEquals("box3",((Section)mapping.get("box3holder").get(0)).getId());
- assertEquals("box4",((Section)mapping.get("box4holder").get(0)).getId());
+ assertEquals("box1", ((Section) mapping.get("box1holder").get(0)).getId());
+ assertEquals("box2", ((Section) mapping.get("box2holder").get(0)).getId());
+ assertEquals("box3", ((Section) mapping.get("box3holder").get(0)).getId());
+ assertEquals("box4", ((Section) mapping.get("box4holder").get(0)).getId());
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check execution:
// Two subsections, each containing two sub-subsections with one source each
- assertEquals(2,result.hits().size());
- HitGroup row1=(HitGroup)result.hits().get(0);
- HitGroup column11=(HitGroup)row1.get(0);
- HitGroup column12=(HitGroup)row1.get(1);
- HitGroup row2=(HitGroup)result.hits().get(1);
- HitGroup column21a=(HitGroup)row2.get(0);
- HitGroup column21b=(HitGroup)row2.get(1);
- HitGroup column22=(HitGroup)row2.get(2);
- assertEqualHitGroups(createHits("source1",3),column11);
- assertEqualHitGroups(createHits("source2",4),column12);
- assertEqualHitGroups(createHits("source3",5),column21a);
- assertEqualHitGroups(createHits("source5",7),column21b);
- assertEqualHitGroups(createHits("source4",6),column22);
+ assertEquals(2, result.hits().size());
+ HitGroup row1 = (HitGroup) result.hits().get(0);
+ HitGroup column11 = (HitGroup) row1.get(0);
+ HitGroup column12 = (HitGroup) row1.get(1);
+ HitGroup row2 = (HitGroup) result.hits().get(1);
+ HitGroup column21a = (HitGroup) row2.get(0);
+ HitGroup column21b = (HitGroup) row2.get(1);
+ HitGroup column22 = (HitGroup) row2.get(2);
+ assertEqualHitGroups(createHits("source1", 3), column11);
+ assertEqualHitGroups(createHits("source2", 4), column12);
+ assertEqualHitGroups(createHits("source3", 5), column21a);
+ assertEqualHitGroups(createHits("source5", 7), column21b);
+ assertEqualHitGroups(createHits("source4", 6), column22);
// Check rendering
- assertRendered(result,"MapSectionsToSectionsResult.xml");
+ assertRendered(result, "MapSectionsToSectionsResult.xml");
}
/** Same as deterministic resolver, but asserts that it received the correct method names for each map choice */
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsTestCase.java
index 8d8e39bd934..4d844c50cc9 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/MapSourcesToSectionsTestCase.java
@@ -13,13 +13,13 @@ import com.yahoo.search.pagetemplates.model.MapChoice;
import com.yahoo.search.pagetemplates.model.PageElement;
import com.yahoo.search.pagetemplates.model.Source;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author bratseth
@@ -27,50 +27,50 @@ import static org.junit.Assert.assertNotNull;
public class MapSourcesToSectionsTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("MapSourcesToSections.xml"));
+ Choice page = Choice.createSingleton(importPage("MapSourcesToSections.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source2",4));
- result.hits().add(createHits("source3",5));
- result.hits().add(createHits("source4",6));
- result.hits().add(createHits("source5",7));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source2", 4));
+ result.hits().add(createHits("source3", 5));
+ result.hits().add(createHits("source4", 6));
+ result.hits().add(createHits("source5", 7));
// Resolve
- Resolver resolver=new DeterministicResolverAssertingMethod();
- Resolution resolution=resolver.resolve(page,query,result);
- Map<String, List<PageElement>> mapping=
- resolution.getResolution((MapChoice)((PageTemplate)page.get(0).get(0)).getSection().elements().get(2));
+ Resolver resolver = new DeterministicResolverAssertingMethod();
+ Resolution resolution = resolver.resolve(page, query, result);
+ Map<String, List<PageElement>> mapping =
+ resolution.getResolution((MapChoice) ((PageTemplate) page.get(0).get(0)).getSection().elements().get(2));
assertNotNull(mapping);
- assertEquals("source1",((Source)mapping.get("box1source").get(0)).getName());
- assertEquals("source2",((Source)mapping.get("box2source").get(0)).getName());
- assertEquals("source3",((Source)mapping.get("box3source").get(0)).getName());
- assertEquals("source4",((Source)mapping.get("box4source").get(0)).getName());
+ assertEquals("source1", ((Source) mapping.get("box1source").get(0)).getName());
+ assertEquals("source2", ((Source) mapping.get("box2source").get(0)).getName());
+ assertEquals("source3", ((Source) mapping.get("box3source").get(0)).getName());
+ assertEquals("source4", ((Source) mapping.get("box4source").get(0)).getName());
// Execute
- Organizer organizer =new Organizer();
- organizer.organize(page,resolution,result);
+ Organizer organizer = new Organizer();
+ organizer.organize(page, resolution, result);
// Check execution:
// Two subsections, each containing two sub-subsections with one source each
- assertEquals(2,result.hits().size());
- HitGroup row1=(HitGroup)result.hits().get(0);
- HitGroup column11=(HitGroup)row1.get(0);
- HitGroup column12=(HitGroup)row1.get(1);
- HitGroup row2=(HitGroup)result.hits().get(1);
- HitGroup column21=(HitGroup)row2.get(0);
- HitGroup column22=(HitGroup)row2.get(1);
- assertEqualHitGroups(createHits("source1",3),column11);
- assertEqualHitGroups(createHits("source2",4),column12);
- assertEqualHitGroups(createHits("source3",5),column21);
- assertEqualHitGroups(createHits("source4",6),column22);
+ assertEquals(2, result.hits().size());
+ HitGroup row1 = (HitGroup) result.hits().get(0);
+ HitGroup column11 = (HitGroup) row1.get(0);
+ HitGroup column12 = (HitGroup) row1.get(1);
+ HitGroup row2 = (HitGroup) result.hits().get(1);
+ HitGroup column21 = (HitGroup) row2.get(0);
+ HitGroup column22 = (HitGroup) row2.get(1);
+ assertEqualHitGroups(createHits("source1", 3), column11);
+ assertEqualHitGroups(createHits("source2", 4), column12);
+ assertEqualHitGroups(createHits("source3", 5), column21);
+ assertEqualHitGroups(createHits("source4", 6), column22);
// Check rendering
- assertRendered(result,"MapSourcesToSectionsResult.xml");
+ assertRendered(result, "MapSourcesToSectionsResult.xml");
}
/** Same as deterministic resolver, but asserts that it received the correct method names for each map choice */
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java
index 6a86f4f81aa..a985c7435d8 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageTestCase.java
@@ -8,7 +8,7 @@ import com.yahoo.search.pagetemplates.engine.Resolution;
import com.yahoo.search.pagetemplates.engine.Resolver;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests an example page.
@@ -18,7 +18,7 @@ import org.junit.Test;
public class PageTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("Page.xml"));
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java
index 69d35eb2b69..a4166b6d90f 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithBlendingTestCase.java
@@ -8,7 +8,7 @@ import com.yahoo.search.pagetemplates.engine.Resolution;
import com.yahoo.search.pagetemplates.engine.Resolver;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests an expanded example.
@@ -18,7 +18,7 @@ import org.junit.Test;
public class PageWithBlendingTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("PageWithBlending.xml"));
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java
index 8cb35bf5e4f..7becf7f1895 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/PageWithSourceRendererTestCase.java
@@ -8,7 +8,7 @@ import com.yahoo.search.pagetemplates.engine.Resolution;
import com.yahoo.search.pagetemplates.engine.Resolver;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests an example with two data sources with a renderer each.
@@ -18,7 +18,7 @@ import org.junit.Test;
public class PageWithSourceRendererTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("PageWithSourceRenderer.xml"));
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java
index bcd6a462a62..349c39514ba 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/SourceChoiceTestCase.java
@@ -8,7 +8,7 @@ import com.yahoo.search.pagetemplates.engine.Resolution;
import com.yahoo.search.pagetemplates.engine.Resolver;
import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -16,7 +16,7 @@ import org.junit.Test;
public class SourceChoiceTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("SourceChoice.xml"));
@@ -29,14 +29,14 @@ public class SourceChoiceTestCase extends ExecutionAbstractTestCase {
// Resolve (noop here)
Resolver resolver = new DeterministicResolver();
- Resolution resolution = resolver.resolve(page,query,result);
+ Resolution resolution = resolver.resolve(page, query, result);
// Execute
Organizer organizer = new Organizer();
organizer.organize(page, resolution, result);
// Check rendering
- assertRendered(result,"SourceChoiceResult.xml", false);
+ assertRendered(result, "SourceChoiceResult.xml", false);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesTestCase.java
index 8413b43e662..43bb16f8b14 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/engine/test/TwoSectionsFourSourcesTestCase.java
@@ -8,11 +8,11 @@ import com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver;
import com.yahoo.search.pagetemplates.model.Choice;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -20,95 +20,95 @@ import static org.junit.Assert.assertEquals;
public class TwoSectionsFourSourcesTestCase extends ExecutionAbstractTestCase {
@Test
- public void testExecution() {
+ void testExecution() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
+ Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source2",4));
- result.hits().add(createHits("source3",12));
- result.hits().add(createHits("source4",13));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source2", 4));
+ result.hits().add(createHits("source3", 12));
+ result.hits().add(createHits("source4", 13));
- new Organizer().organize(page,new DeterministicResolver().resolve(page,query,result),result);
+ new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
// Check execution:
// Two subsections with two sources each, the first grouped the second blended
- assertEquals(2,result.hits().size());
- HitGroup section1=(HitGroup)result.hits().get(0);
- HitGroup section2=(HitGroup)result.hits().get(1);
+ assertEquals(2, result.hits().size());
+ HitGroup section1 = (HitGroup) result.hits().get(0);
+ HitGroup section2 = (HitGroup) result.hits().get(1);
assertGroupedSource3Source1(section1.asList());
assertBlendedSource4Source2(section2.asList());
// Check rendering
- assertRendered(result,"TwoSectionsFourSourcesResult.xml");
+ assertRendered(result, "TwoSectionsFourSourcesResult.xml");
}
@Test
- public void testExecutionMissingOneSource() {
+ void testExecutionMissingOneSource() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
+ Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source3",12));
- result.hits().add(createHits("source4",13));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source3", 12));
+ result.hits().add(createHits("source4", 13));
- new Organizer().organize(page,new DeterministicResolver().resolve(page,query,result),result);
+ new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
// Check execution:
// Two subsections with two sources each, the first grouped the second blended
- assertEquals(2,result.hits().size());
- HitGroup section1=(HitGroup)result.hits().get(0);
- HitGroup section2=(HitGroup)result.hits().get(1);
+ assertEquals(2, result.hits().size());
+ HitGroup section1 = (HitGroup) result.hits().get(0);
+ HitGroup section2 = (HitGroup) result.hits().get(1);
assertGroupedSource3Source1(section1.asList());
- assertEqualHitGroups(createHits("source4",10),section2);
+ assertEqualHitGroups(createHits("source4", 10), section2);
}
@Test
- public void testExecutionMissingTwoSources() {
+ void testExecutionMissingTwoSources() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
+ Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
- result.hits().add(createHits("source1",3));
- result.hits().add(createHits("source3",12));
+ Query query = new Query();
+ Result result = new Result(query);
+ result.hits().add(createHits("source1", 3));
+ result.hits().add(createHits("source3", 12));
- new Organizer().organize(page,new DeterministicResolver().resolve(page,query,result),result);
+ new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
// Check execution:
// Two subsections with two sources each, the first grouped the second blended
- assertEquals(2,result.hits().size());
- HitGroup section1=(HitGroup)result.hits().get(0);
- HitGroup section2=(HitGroup)result.hits().get(1);
+ assertEquals(2, result.hits().size());
+ HitGroup section1 = (HitGroup) result.hits().get(0);
+ HitGroup section2 = (HitGroup) result.hits().get(1);
assertGroupedSource3Source1(section1.asList());
- assertEquals(0,section2.size());
+ assertEquals(0, section2.size());
}
@Test
- public void testExecutionMissingAllSources() {
+ void testExecutionMissingAllSources() {
// Create the page template
- Choice page=Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
+ Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
// Create a federated result
- Query query=new Query();
- Result result=new Result(query);
+ Query query = new Query();
+ Result result = new Result(query);
- new Organizer().organize(page,new DeterministicResolver().resolve(page,query,result),result);
+ new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
// Check execution:
// Two subsections with two sources each, the first grouped the second blended
- assertEquals(2,result.hits().size());
- HitGroup section1=(HitGroup)result.hits().get(0);
- HitGroup section2=(HitGroup)result.hits().get(1);
- assertEquals(0,section1.size());
- assertEquals(0,section2.size());
+ assertEquals(2, result.hits().size());
+ HitGroup section1 = (HitGroup) result.hits().get(0);
+ HitGroup section2 = (HitGroup) result.hits().get(1);
+ assertEquals(0, section1.size());
+ assertEquals(0, section2.size());
}
private void assertGroupedSource3Source1(List<Hit> hits) {
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/test/PageTemplateSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/test/PageTemplateSearcherTestCase.java
index 7b10966a675..a38c3f164b9 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/test/PageTemplateSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/test/PageTemplateSearcherTestCase.java
@@ -18,15 +18,11 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.text.interpretation.Interpretation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -34,50 +30,50 @@ import static org.junit.Assert.fail;
public class PageTemplateSearcherTestCase {
@Test
- public void testSearcher() {
+ void testSearcher() {
PageTemplateSearcher s = new PageTemplateSearcher(createPageTemplateRegistry(), new FirstChoiceResolver());
- Chain<Searcher> chain = new Chain<>(s,new MockFederator());
+ Chain<Searcher> chain = new Chain<>(s, new MockFederator());
{
// No template specified, should use default
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.resolver=native.deterministic"));
- assertSources("source1 source2",result);
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.resolver=native.deterministic"));
+ assertSources("source1 source2", result);
}
{
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.id=oneSource&page.resolver=native.deterministic"));
- assertSources("source1",result);
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.id=oneSource&page.resolver=native.deterministic"));
+ assertSources("source1", result);
}
{
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.id=twoSources&model.sources=source1&page.resolver=native.deterministic"));
- assertSources("source1",result);
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=foo&page.id=twoSources&model.sources=source1&page.resolver=native.deterministic"));
+ assertSources("source1", result);
}
{
- Query query=new Query("?query=foo&page.resolver=native.deterministic");
+ Query query = new Query("?query=foo&page.resolver=native.deterministic");
addIntentModelSpecifyingSource3(query);
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(query);
- assertSources("source1 source2",result);
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
+ assertSources("source1 source2", result);
}
{
- Query query=new Query("?query=foo&page.id=twoSourcesAndAny&page.resolver=native.deterministic");
+ Query query = new Query("?query=foo&page.id=twoSourcesAndAny&page.resolver=native.deterministic");
addIntentModelSpecifyingSource3(query);
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(query);
- assertSources("source1 source2 source3",result);
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
+ assertSources("source1 source2 source3", result);
}
{
- Query query=new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
+ Query query = new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
addIntentModelSpecifyingSource3(query);
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(query);
- assertSources("source3",result);
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
+ assertSources("source3", result);
}
{
- Query query=new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(query);
+ Query query = new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
assertTrue(query.getModel().getSources().isEmpty());
assertNotNull(result.hits().get("source1"));
assertNotNull(result.hits().get("source2"));
@@ -85,38 +81,38 @@ public class PageTemplateSearcherTestCase {
}
{
- Query query=new Query("?query=foo&page.id=choiceOfSources&page.resolver=native.deterministic");
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(query);
- assertSources("source1 source2","source2",result);
+ Query query = new Query("?query=foo&page.id=choiceOfSources&page.resolver=native.deterministic");
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
+ assertSources("source1 source2", "source2", result);
}
{
- Query query=new Query("?query=foo&page.id=choiceOfSources&page.resolver=test.firstChoice");
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(query);
- assertSources("source1 source2","source1",result);
+ Query query = new Query("?query=foo&page.id=choiceOfSources&page.resolver=test.firstChoice");
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
+ assertSources("source1 source2", "source1", result);
}
{ // Specifying two templates, should pick the last
- Query query=new Query("?query=foo&page.id=threeSources+oneSource&page.resolver=native.deterministic");
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(query);
- assertSources("source1 source2 source3","source1",result);
+ Query query = new Query("?query=foo&page.id=threeSources+oneSource&page.resolver=native.deterministic");
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
+ assertSources("source1 source2 source3", "source1", result);
}
{ // Specifying two templates as a list, should override the page.id setting
- Query query=new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
- query.properties().set("page.idList",Arrays.asList("oneSource","threeSources"));
- Result result=new Execution(chain, Execution.Context.createContextStub()).search(query);
- assertSources("source1 source2 source3","source1 source2 source3",result);
+ Query query = new Query("?query=foo&page.id=anySource&page.resolver=native.deterministic");
+ query.properties().set("page.idList", Arrays.asList("oneSource", "threeSources"));
+ Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
+ assertSources("source1 source2 source3", "source1 source2 source3", result);
}
{
try {
- Query query=new Query("?query=foo&page.id=oneSource+choiceOfSources&page.resolver=noneSuch");
+ Query query = new Query("?query=foo&page.id=oneSource+choiceOfSources&page.resolver=noneSuch");
new Execution(chain, Execution.Context.createContextStub()).search(query);
fail("Expected exception");
}
catch (IllegalArgumentException e) {
- assertEquals("No page template resolver 'noneSuch'",e.getMessage());
+ assertEquals("No page template resolver 'noneSuch'", e.getMessage());
}
}
@@ -182,9 +178,9 @@ public class PageTemplateSearcherTestCase {
Set<String> expectedResultSources=new HashSet<>(Arrays.asList(expectedResultSourceString.split(" ")));
for (String sourceName : Arrays.asList("source1 source2 source3".split(" "))) {
if (expectedResultSources.contains(sourceName))
- assertNotNull("Result contains '" + sourceName + "'",result.hits().get(sourceName));
+ assertNotNull(result.hits().get(sourceName),"Result contains '" + sourceName + "'");
else
- assertNull("Result does not contain '" + sourceName + "'",result.hits().get(sourceName));
+ assertNull(result.hits().get(sourceName),"Result does not contain '" + sourceName + "'");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/pagetemplates/test/SourceParametersTestCase.java b/container-search/src/test/java/com/yahoo/search/pagetemplates/test/SourceParametersTestCase.java
index 0606636d0cb..50a19753e0c 100644
--- a/container-search/src/test/java/com/yahoo/search/pagetemplates/test/SourceParametersTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/pagetemplates/test/SourceParametersTestCase.java
@@ -7,10 +7,10 @@ import com.yahoo.search.pagetemplates.PageTemplateRegistry;
import com.yahoo.search.pagetemplates.PageTemplateSearcher;
import com.yahoo.search.pagetemplates.config.PageTemplateXMLReader;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author bratseth
@@ -20,40 +20,40 @@ public class SourceParametersTestCase {
private static final String root="src/test/java/com/yahoo/search/pagetemplates/test/";
@Test
- public void testSourceParametersWithSourcesDeterminedByTemplate() {
+ void testSourceParametersWithSourcesDeterminedByTemplate() {
// Create the page template
- PageTemplateRegistry pageTemplateRegistry=new PageTemplateRegistry();
- PageTemplate page=importPage("SourceParameters.xml");
+ PageTemplateRegistry pageTemplateRegistry = new PageTemplateRegistry();
+ PageTemplate page = importPage("SourceParameters.xml");
pageTemplateRegistry.register(page);
- PageTemplateSearcher s=new PageTemplateSearcher(pageTemplateRegistry);
- Query query=new Query("?query=foo&page.id=SourceParameters&page.resolver=native.deterministic");
+ PageTemplateSearcher s = new PageTemplateSearcher(pageTemplateRegistry);
+ Query query = new Query("?query=foo&page.id=SourceParameters&page.resolver=native.deterministic");
new Execution(s, Execution.Context.createContextStub()).search(query);
- assertEquals("source1p1Value",query.properties().get("source.source1.p1"));
- assertEquals("source1p1Value",query.properties().get("source.source1.p1"));
- assertEquals("source2p1Value",query.properties().get("source.source2.p1"));
- assertEquals("source2p3Value",query.properties().get("source.source2.p3"));
- assertEquals("source3p1Value",query.properties().get("source.source3.p1"));
- assertEquals("We get the correct number of parameters",5,query.properties().listProperties("source").size());
+ assertEquals("source1p1Value", query.properties().get("source.source1.p1"));
+ assertEquals("source1p1Value", query.properties().get("source.source1.p1"));
+ assertEquals("source2p1Value", query.properties().get("source.source2.p1"));
+ assertEquals("source2p3Value", query.properties().get("source.source2.p3"));
+ assertEquals("source3p1Value", query.properties().get("source.source3.p1"));
+ assertEquals(5, query.properties().listProperties("source").size(), "We get the correct number of parameters");
}
@Test
- public void testSourceParametersWithSourcesDeterminedByParameter() {
+ void testSourceParametersWithSourcesDeterminedByParameter() {
// Create the page template
- PageTemplateRegistry pageTemplateRegistry=new PageTemplateRegistry();
- PageTemplate page=importPage("SourceParameters.xml");
+ PageTemplateRegistry pageTemplateRegistry = new PageTemplateRegistry();
+ PageTemplate page = importPage("SourceParameters.xml");
pageTemplateRegistry.register(page);
- PageTemplateSearcher s=new PageTemplateSearcher(pageTemplateRegistry);
- Query query=new Query("?query=foo&page.id=SourceParameters&model.sources=source1,source3&page.resolver=native.deterministic");
+ PageTemplateSearcher s = new PageTemplateSearcher(pageTemplateRegistry);
+ Query query = new Query("?query=foo&page.id=SourceParameters&model.sources=source1,source3&page.resolver=native.deterministic");
new Execution(s, Execution.Context.createContextStub()).search(query);
- assertEquals("source1p1Value",query.properties().get("source.source1.p1"));
- assertEquals("source1p1Value",query.properties().get("source.source1.p1"));
- assertEquals("source3p1Value",query.properties().get("source.source3.p1"));
- assertEquals("We get the correct number of parameters",3,query.properties().listProperties("source").size());
+ assertEquals("source1p1Value", query.properties().get("source.source1.p1"));
+ assertEquals("source1p1Value", query.properties().get("source.source1.p1"));
+ assertEquals("source3p1Value", query.properties().get("source.source3.p1"));
+ assertEquals(3, query.properties().listProperties("source").size(), "We get the correct number of parameters");
}
protected PageTemplate importPage(String name) {
PageTemplate template=new PageTemplateXMLReader().readFile(root + name);
- assertNotNull("Could look up read template '" + name + "'",template);
+ assertNotNull(template,"Could look up read template '" + name + "'");
return template;
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
index 9eb44eb0dc4..e3a1eb18a33 100644
--- a/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
@@ -2,10 +2,9 @@
package com.yahoo.search.query;
import com.yahoo.search.Query;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
@@ -13,7 +12,7 @@ import static org.junit.Assert.assertEquals;
public class MatchingTestCase {
@Test
- public void testDefaultsInQuery() {
+ void testDefaultsInQuery() {
Query query = new Query("?query=test");
assertNull(query.getRanking().getMatching().getTermwiseLimit());
assertNull(query.getRanking().getMatching().getNumThreadsPerSearch());
@@ -24,7 +23,7 @@ public class MatchingTestCase {
}
@Test
- public void testQueryOverrides() {
+ void testQueryOverrides() {
Query query = new Query("?query=test" +
"&ranking.matching.termwiseLimit=0.7" +
"&ranking.matching.numThreadsPerSearch=17" +
@@ -49,7 +48,7 @@ public class MatchingTestCase {
}
@Test
- public void testBackwardsCompatibleQueryOverrides() {
+ void testBackwardsCompatibleQueryOverrides() {
// The lowercase aliases are supported to provide backwards compatibility of the properties that was wrongly named in the first place.
Query query = new Query("?query=test" +
"&ranking.matching.termwiselimit=0.7" +
@@ -73,7 +72,7 @@ public class MatchingTestCase {
}
@Test
- public void testLimits() {
+ void testLimits() {
verifyException("termwiselimit", "-0.1");
verifyException("termwiselimit", "1.1");
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java b/container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java
index 6c73937f4fa..4badb16f20c 100644
--- a/container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java
+++ b/container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java
@@ -4,9 +4,9 @@ package com.yahoo.search.query;
import com.yahoo.prelude.query.NotItem;
import com.yahoo.prelude.query.NullItem;
import com.yahoo.prelude.query.WordItem;
-import org.junit.Assert;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -14,53 +14,53 @@ import static org.junit.Assert.assertEquals;
public class QueryTreeTest {
@Test
- public void testAddQueryItemWithRoot() {
- Assert.assertEquals("AND a b",
- new QueryTree(new WordItem("a")).and(new WordItem("b")).toString());
+ void testAddQueryItemWithRoot() {
+ assertEquals("AND a b",
+ new QueryTree(new WordItem("a")).and(new WordItem("b")).toString());
NotItem not = new NotItem();
not.addNegativeItem(new WordItem("b"));
assertEquals("+a -b",
- new QueryTree(new WordItem("a")).and(not).toString());
- }
+ new QueryTree(new WordItem("a")).and(not).toString());
+ }
- @Test
- public void addNotToNot() {
- NotItem not1 = new NotItem();
- not1.addPositiveItem(new WordItem("p1"));
- not1.addNegativeItem(new WordItem("n1.1"));
- not1.addNegativeItem(new WordItem("n1.2"));
+ @Test
+ void addNotToNot() {
+ NotItem not1 = new NotItem();
+ not1.addPositiveItem(new WordItem("p1"));
+ not1.addNegativeItem(new WordItem("n1.1"));
+ not1.addNegativeItem(new WordItem("n1.2"));
- NotItem not2 = new NotItem();
- not2.addPositiveItem(new WordItem("p2"));
- not2.addNegativeItem(new WordItem("n2.1"));
- not2.addNegativeItem(new WordItem("n2.2"));
+ NotItem not2 = new NotItem();
+ not2.addPositiveItem(new WordItem("p2"));
+ not2.addNegativeItem(new WordItem("n2.1"));
+ not2.addNegativeItem(new WordItem("n2.2"));
- QueryTree tree = new QueryTree(not1);
- tree.and(not2);
+ QueryTree tree = new QueryTree(not1);
+ tree.and(not2);
- assertEquals("+(AND p1 p2) -n1.1 -n1.2 -n2.1 -n2.2", tree.toString());
- }
+ assertEquals("+(AND p1 p2) -n1.1 -n1.2 -n2.1 -n2.2", tree.toString());
+ }
- @Test
- public void getCorrectTreeSize() {
+ @Test
+ void getCorrectTreeSize() {
QueryTree nullTree = new QueryTree(new NullItem());
assertEquals(0, nullTree.treeSize());
- NotItem not1 = new NotItem();
- not1.addPositiveItem(new WordItem("p1"));
- not1.addNegativeItem(new WordItem("n1.1"));
- not1.addNegativeItem(new WordItem("n1.2"));
+ NotItem not1 = new NotItem();
+ not1.addPositiveItem(new WordItem("p1"));
+ not1.addNegativeItem(new WordItem("n1.1"));
+ not1.addNegativeItem(new WordItem("n1.2"));
- NotItem not2 = new NotItem();
- not2.addPositiveItem(new WordItem("p2"));
- not2.addNegativeItem(new WordItem("n2.1"));
- not2.addNegativeItem(new WordItem("n2.2"));
+ NotItem not2 = new NotItem();
+ not2.addPositiveItem(new WordItem("p2"));
+ not2.addNegativeItem(new WordItem("n2.1"));
+ not2.addNegativeItem(new WordItem("n2.2"));
- QueryTree tree = new QueryTree(not1);
- tree.and(not2);
+ QueryTree tree = new QueryTree(not1);
+ tree.and(not2);
- assertEquals(8, tree.treeSize());
- }
+ assertEquals(8, tree.treeSize());
+ }
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java b/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
index e30e8bf119a..da1d09fec1e 100644
--- a/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
+++ b/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
@@ -14,7 +14,7 @@ import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.yolean.Exceptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@@ -23,9 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests queries towards rank profiles using input declarations.
@@ -35,7 +33,7 @@ import static org.junit.Assert.fail;
public class RankProfileInputTest {
@Test
- public void testTensorRankFeatureInRequest() {
+ void testTensorRankFeatureInRequest() {
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
{
@@ -55,13 +53,12 @@ public class RankProfileInputTest {
{ // Resolution is limited to the correct sources
Query query = createTensor1Query(tensorString, "bOnly", "sources=a");
assertEquals(0, query.errors().size());
- assertEquals("Not converted to tensor",
- tensorString, query.properties().get("ranking.features.query(myTensor1)"));
+ assertEquals(tensorString, query.properties().get("ranking.features.query(myTensor1)"), "Not converted to tensor");
}
}
@Test
- public void testTensorRankFeatureInRequestInconsistentInput() {
+ void testTensorRankFeatureInRequestInconsistentInput() {
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
try {
createTensor1Query(tensorString, "inconsistent", "");
@@ -69,14 +66,14 @@ public class RankProfileInputTest {
}
catch (IllegalArgumentException e) {
assertEquals("Conflicting input type declarations for 'query(myTensor1)': " +
- "Declared as tensor(a{},b{}) in rank profile 'inconsistent' in schema 'a', " +
- "and as tensor(x[10]) in rank profile 'inconsistent' in schema 'b'",
- Exceptions.toMessageString(e));
+ "Declared as tensor(a{},b{}) in rank profile 'inconsistent' in schema 'a', " +
+ "and as tensor(x[10]) in rank profile 'inconsistent' in schema 'b'",
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testTensorRankFeatureWithSourceResolution() {
+ void testTensorRankFeatureWithSourceResolution() {
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
{
@@ -99,14 +96,14 @@ public class RankProfileInputTest {
}
@Test
- public void testTensorRankFeatureSetProgrammatically() {
+ void testTensorRankFeatureSetProgrammatically() {
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query.Builder()
.setSchemaInfo(createSchemaInfo())
.setQueryProfile(createQueryProfile()) // Use the instantiation path with query profiles
.setRequest(HttpRequest.createTestRequest("?" +
- "&ranking=commonProfile",
- com.yahoo.jdisc.http.HttpRequest.Method.GET))
+ "&ranking=commonProfile",
+ com.yahoo.jdisc.http.HttpRequest.Method.GET))
.build();
query.properties().set("ranking.features.query(myTensor1)", Tensor.from(tensorString));
@@ -114,24 +111,24 @@ public class RankProfileInputTest {
}
@Test
- public void testTensorRankFeatureSetProgrammaticallyWithWrongType() {
+ void testTensorRankFeatureSetProgrammaticallyWithWrongType() {
Query query = new Query.Builder()
.setSchemaInfo(createSchemaInfo())
.setQueryProfile(createQueryProfile()) // Use the instantiation path with query profiles
.setRequest(HttpRequest.createTestRequest("?" +
- "&ranking=commonProfile",
- com.yahoo.jdisc.http.HttpRequest.Method.GET))
+ "&ranking=commonProfile",
+ com.yahoo.jdisc.http.HttpRequest.Method.GET))
.build();
String tensorString = "tensor(x[3]):[0.1, 0.2, 0.3]";
try {
- query.getRanking().getFeatures().put("query(myTensor1)",Tensor.from(tensorString));
+ query.getRanking().getFeatures().put("query(myTensor1)", Tensor.from(tensorString));
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'ranking.features.query(myTensor1)' to 'tensor(x[3]):[0.1, 0.2, 0.3]': " +
- "This input is declared in rank profile 'commonProfile' as tensor(a{},b{})",
- Exceptions.toMessageString(e));
+ "This input is declared in rank profile 'commonProfile' as tensor(a{},b{})",
+ Exceptions.toMessageString(e));
}
try {
query.properties().set("ranking.features.query(myTensor1)", Tensor.from(tensorString));
@@ -139,13 +136,13 @@ public class RankProfileInputTest {
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'ranking.features.query(myTensor1)' to 'tensor(x[3]):[0.1, 0.2, 0.3]': " +
- "Require a tensor of type tensor(a{},b{})",
- Exceptions.toMessageString(e));
+ "Require a tensor of type tensor(a{},b{})",
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testUnembeddedTensorRankFeatureInRequest() {
+ void testUnembeddedTensorRankFeatureInRequest() {
String text = "text to embed into a tensor";
Tensor embedding1 = Tensor.from("tensor<float>(x[5]):[3,7,4,0,0]]");
Tensor embedding2 = Tensor.from("tensor<float>(x[5]):[1,2,3,4,0]]");
@@ -159,7 +156,7 @@ public class RankProfileInputTest {
assertEmbedQuery("embed(emb1, '" + text + "')", embedding1, embedders);
assertEmbedQuery("embed(emb1, \"" + text + "\")", embedding1, embedders);
assertEmbedQueryFails("embed(emb2, \"" + text + "\")", embedding1, embedders,
- "Can't find embedder 'emb2'. Valid embedders are emb1");
+ "Can't find embedder 'emb2'. Valid embedders are emb1");
embedders = Map.of(
"emb1", new MockEmbedder(text, Language.UNKNOWN, embedding1),
@@ -168,7 +165,7 @@ public class RankProfileInputTest {
assertEmbedQuery("embed(emb1, '" + text + "')", embedding1, embedders);
assertEmbedQuery("embed(emb2, '" + text + "')", embedding2, embedders);
assertEmbedQueryFails("embed(emb3, \"" + text + "\")", embedding1, embedders,
- "Can't find embedder 'emb3'. Valid embedders are emb1,emb2");
+ "Can't find embedder 'emb3'. Valid embedders are emb1,emb2");
// And with specified language
embedders = Map.of(
diff --git a/container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java b/container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java
index f8874040cb2..2decb3fb26a 100644
--- a/container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java
@@ -2,8 +2,9 @@
package com.yahoo.search.query;
import com.yahoo.search.Query;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
@@ -11,7 +12,7 @@ import static org.junit.Assert.*;
public class SoftTimeoutTestCase {
@Test
- public void testDefaultsInQuery() {
+ void testDefaultsInQuery() {
Query query = new Query("?query=test");
assertTrue(query.getRanking().getSoftTimeout().getEnable());
assertNull(query.getRanking().getSoftTimeout().getFactor());
@@ -19,7 +20,7 @@ public class SoftTimeoutTestCase {
}
@Test
- public void testQueryOverride() {
+ void testQueryOverride() {
Query query = new Query("?query=test&ranking.softtimeout.factor=0.7&ranking.softtimeout.tailcost=0.3");
assertTrue(query.getRanking().getSoftTimeout().getEnable());
assertEquals(Double.valueOf(0.7), query.getRanking().getSoftTimeout().getFactor());
@@ -31,16 +32,16 @@ public class SoftTimeoutTestCase {
}
@Test
- public void testDisable() {
- Query query=new Query("?query=test&ranking.softtimeout.enable=false");
+ void testDisable() {
+ Query query = new Query("?query=test&ranking.softtimeout.enable=false");
assertFalse(query.getRanking().getSoftTimeout().getEnable());
query.prepare();
assertEquals("false", query.getRanking().getProperties().get("vespa.softtimeout.enable").get(0));
}
@Test
- public void testEnable() {
- Query query=new Query("?query=test&ranking.softtimeout.enable=true");
+ void testEnable() {
+ Query query = new Query("?query=test&ranking.softtimeout.enable=true");
assertTrue(query.getRanking().getSoftTimeout().getEnable());
query.prepare();
assertEquals("true", query.getRanking().getProperties().get("vespa.softtimeout.enable").get(0));
@@ -57,7 +58,7 @@ public class SoftTimeoutTestCase {
}
@Test
- public void testLimits() {
+ void testLimits() {
verifyException("factor", "-0.1");
verifyException("factor", "1.1");
verifyException("tailcost", "-0.1");
diff --git a/container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java
index 4f14ae066cb..facb620b63b 100644
--- a/container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java
@@ -5,20 +5,19 @@ import com.ibm.icu.lang.UScript;
import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RuleBasedCollator;
import com.ibm.icu.util.ULocale;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
*/
public class SortingTestCase {
@Test
- public void validAttributeName() {
+ void validAttributeName() {
assertNotNull(Sorting.fromString("a"));
assertNotNull(Sorting.fromString("_a"));
assertNotNull(Sorting.fromString("+a"));
@@ -33,8 +32,9 @@ public class SortingTestCase {
fail("I only expect 'IllegalArgumentException', not: + " + e.toString());
}
}
+
@Test
- public void requireThatChineseSortCorrect() {
+ void requireThatChineseSortCorrect() {
requireThatChineseHasCorrectRules(Collator.getInstance(new ULocale("zh")));
Sorting ch = Sorting.fromString("uca(a,zh)");
assertEquals(1, ch.fieldOrders().size());
@@ -69,9 +69,10 @@ public class SortingTestCase {
assertNotEquals("", ((RuleBasedCollator) col).getRules());
}
+
@Test
- @Ignore
- public void requireThatArabicSortCorrect() {
+ @Disabled
+ void requireThatArabicSortCorrect() {
requireThatArabicHasCorrectRules(Collator.getInstance(new ULocale("ar")));
Sorting ar = Sorting.fromString("uca(a,ar)");
assertEquals(1, ar.fieldOrders().size());
diff --git a/container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java
index 0152367915a..d4f1e814980 100644
--- a/container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java
@@ -8,10 +8,10 @@ import java.util.Set;
import com.yahoo.processing.execution.Execution;
import com.yahoo.search.Query;
import com.yahoo.search.query.context.QueryContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -19,34 +19,34 @@ import static org.junit.Assert.assertTrue;
public class LoggingTestCase {
@Test
- public void testLogging() {
- Query query=new Query();
+ void testLogging() {
+ Query query = new Query();
QueryContext queryContext = query.getContext(true);
- queryContext.logValue("a","a1");
+ queryContext.logValue("a", "a1");
queryContext.trace("first message", 2);
- queryContext.logValue("a","a2");
- queryContext.logValue("b","b1");
+ queryContext.logValue("a", "a2");
+ queryContext.logValue("b", "b1");
QueryContext h2 = query.clone().getContext(true);
- h2.logValue("b","b2");
+ h2.logValue("b", "b2");
h2.trace("second message", 2);
- h2.logValue("b","b3");
- queryContext.logValue("b","b4");
+ h2.logValue("b", "b3");
+ queryContext.logValue("b", "b4");
QueryContext h3 = query.clone().getContext(true);
- h3.logValue("b","b5");
- h3.logValue("c","c1");
+ h3.logValue("b", "b5");
+ h3.logValue("c", "c1");
h3.trace("third message", 2);
- h2.logValue("c","c2");
+ h2.logValue("c", "c2");
queryContext.trace("fourth message", 2);
- queryContext.logValue("d","d1");
+ queryContext.logValue("d", "d1");
h2.trace("fifth message", 2);
- h2.logValue("c","c3");
- queryContext.logValue("c","c4");
+ h2.logValue("c", "c3");
+ queryContext.logValue("c", "c4");
// Assert that all of the above is in the log, in some undefined order
- Set<String> logValues=new HashSet<>();
- for (Iterator<Execution.Trace.LogValue> logValueIterator=queryContext.logValueIterator(); logValueIterator.hasNext(); )
+ Set<String> logValues = new HashSet<>();
+ for (Iterator<Execution.Trace.LogValue> logValueIterator = queryContext.logValueIterator(); logValueIterator.hasNext(); )
logValues.add(logValueIterator.next().toString());
- assertEquals(12,logValues.size());
+ assertEquals(12, logValues.size());
assertTrue(logValues.contains("a=a1"));
assertTrue(logValues.contains("a=a2"));
assertTrue(logValues.contains("b=b1"));
diff --git a/container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java
index 61e1f06ed28..8505da0e814 100644
--- a/container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java
@@ -3,10 +3,10 @@ package com.yahoo.search.query.context.test;
import com.yahoo.search.Query;
import com.yahoo.search.query.context.QueryContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author bratseth
@@ -14,34 +14,34 @@ import static org.junit.Assert.assertNull;
public class PropertiesTestCase {
@Test
- public void testProperties() {
- Query query=new Query();
+ void testProperties() {
+ Query query = new Query();
QueryContext h = query.getContext(true);
- h.setProperty("a","a1");
+ h.setProperty("a", "a1");
h.trace("first message", 2);
- h.setProperty("a","a2");
- h.setProperty("b","b1");
+ h.setProperty("a", "a2");
+ h.setProperty("b", "b1");
query.clone();
QueryContext h2 = query.clone().getContext(true);
- h2.setProperty("b","b2");
+ h2.setProperty("b", "b2");
h2.trace("second message", 2);
- h2.setProperty("b","b3");
- h.setProperty("b","b4");
+ h2.setProperty("b", "b3");
+ h.setProperty("b", "b4");
QueryContext h3 = query.clone().getContext(true);
- h3.setProperty("b","b5");
- h3.setProperty("c","c1");
+ h3.setProperty("b", "b5");
+ h3.setProperty("c", "c1");
h3.trace("third message", 2);
- h2.setProperty("c","c2");
+ h2.setProperty("c", "c2");
h.trace("fourth message", 2);
- h.setProperty("d","d1");
+ h.setProperty("d", "d1");
h2.trace("fifth message", 2);
- h2.setProperty("c","c3");
- h.setProperty("c","c4");
+ h2.setProperty("c", "c3");
+ h.setProperty("c", "c4");
- assertEquals("a2",h.getProperty("a"));
- assertEquals("b5",h.getProperty("b"));
- assertEquals("c4",h.getProperty("c"));
- assertEquals("d1",h.getProperty("d"));
+ assertEquals("a2", h.getProperty("a"));
+ assertEquals("b5", h.getProperty("b"));
+ assertEquals("c4", h.getProperty("c"));
+ assertEquals("d1", h.getProperty("d"));
assertNull(h.getProperty("e"));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java b/container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java
index 76f243e4592..a340e83a77c 100644
--- a/container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java
@@ -3,15 +3,15 @@ package com.yahoo.search.query.context.test;
import com.yahoo.search.Query;
import com.yahoo.search.query.context.QueryContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Iterator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Steinar Knutsen
@@ -19,8 +19,8 @@ import static org.junit.Assert.assertTrue;
public class TraceTestCase {
@Test
- public void testBasicTracing() {
- Query query=new Query();
+ void testBasicTracing() {
+ Query query = new Query();
QueryContext h = query.getContext(true);
h.trace("first message", 0);
h.trace("second message", 0);
@@ -28,8 +28,8 @@ public class TraceTestCase {
}
@Test
- public void testCloning() throws IOException {
- Query query=new Query();
+ void testCloning() throws IOException {
+ Query query = new Query();
QueryContext h = query.getContext(true);
h.trace("first message", 0);
QueryContext h2 = query.clone().getContext(true);
@@ -49,19 +49,19 @@ public class TraceTestCase {
assertEquals(toplevel, finishedBelow);
// basic sanity test
assertEquals("trace: [ [ " +
- "first message second message third message " +
- "fourth message fifth message ] ]",h.toString());
+ "first message second message third message " +
+ "fourth message fifth message ] ]", h.toString());
Iterator<String> i = h.getTrace().traceNode().root().descendants(String.class).iterator();
- assertEquals("first message",i.next());
- assertEquals("second message",i.next());
- assertEquals("third message",i.next());
- assertEquals("fourth message",i.next());
- assertEquals("fifth message",i.next());
+ assertEquals("first message", i.next());
+ assertEquals("second message", i.next());
+ assertEquals("third message", i.next());
+ assertEquals("fourth message", i.next());
+ assertEquals("fifth message", i.next());
}
@Test
- public void testEmpty() throws IOException {
- Query query=new Query();
+ void testEmpty() throws IOException {
+ Query query = new Query();
QueryContext h = query.getContext(true);
Writer w = new StringWriter();
h.render(w);
@@ -69,20 +69,20 @@ public class TraceTestCase {
}
@Test
- public void testEmptySubSequence() {
- Query query=new Query();
+ void testEmptySubSequence() {
+ Query query = new Query();
QueryContext h = query.getContext(true);
query.clone().getContext(true);
Writer w = new StringWriter();
try {
h.render(w);
} catch (IOException e) {
- assertTrue("rendering empty subsequence crashed", false);
+ assertTrue(false, "rendering empty subsequence crashed");
}
}
@Test
- public void testAttachedTraces() throws IOException {
+ void testAttachedTraces() throws IOException {
String needle0 = "nalle";
String needle1 = "tralle";
String needle2 = "trolle";
@@ -101,10 +101,10 @@ public class TraceTestCase {
int tralle = trace.indexOf(needle1);
int trolle = trace.indexOf(needle2);
int bamse = trace.indexOf(needle3);
- assertTrue("Could not find first manual context to main query.", nalle > 0);
- assertTrue("Could not find second manual context to main query.", bamse > 0);
- assertTrue("Could not find first manual context to attached query.", tralle > 0);
- assertTrue("Could not find second manual context to attached query.", trolle > 0);
+ assertTrue(nalle > 0, "Could not find first manual context to main query.");
+ assertTrue(bamse > 0, "Could not find second manual context to main query.");
+ assertTrue(tralle > 0, "Could not find first manual context to attached query.");
+ assertTrue(trolle > 0, "Could not find second manual context to attached query.");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java
index 22847772ff3..a73d12a5a4e 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java
@@ -1,28 +1,27 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
*/
public class ChainedMapTestCase {
@Test
- public void testIsEmpty() {
+ void testIsEmpty() {
assertTrue(new ChainedMap<String, String>(Map.of(), Map.of()).isEmpty());
assertFalse(new ChainedMap<>(Map.of("k", "v"), Map.of()).isEmpty());
assertFalse(new ChainedMap<>(Map.of(), Map.of("k", "v")).isEmpty());
assertFalse(new ChainedMap<>(Map.of("k", "v"), Map.of("k", "v")).isEmpty());
}
+
@Test
- public void testSize() {
+ void testSize() {
assertEquals(0, new ChainedMap<String, String>(Map.of(), Map.of()).size());
assertEquals(1, new ChainedMap<>(Map.of("k", "v"), Map.of()).size());
assertEquals(1, new ChainedMap<>(Map.of(), Map.of("k", "v")).size());
@@ -30,8 +29,9 @@ public class ChainedMapTestCase {
assertEquals(2, new ChainedMap<>(Map.of("k", "v"), Map.of("K", "v")).size());
assertEquals(2, new ChainedMap<>(Map.of("k", "v"), Map.of("K", "v", "k", "v")).size());
}
+
@Test
- public void testGetUsesBoth() {
+ void testGetUsesBoth() {
Map<String, String> a = Map.of("a", "a_1");
Map<String, String> b = Map.of("b", "b_1");
Map<String, String> ab = Map.of("a", "a_2", "b", "b_2");
@@ -53,7 +53,7 @@ public class ChainedMapTestCase {
}
@Test
- public void testKeySet() {
+ void testKeySet() {
assertTrue(new ChainedMap<String, String>(Map.of(), Map.of()).keySet().isEmpty());
Map<String, String> a = Map.of("a", "a_1");
Map<String, String> b = Map.of("b", "b_1");
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java
index bebdda15983..013de292cb7 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java
@@ -2,13 +2,13 @@
package com.yahoo.search.query.profile.compiled;
import com.yahoo.search.query.profile.DimensionBinding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -16,7 +16,7 @@ import static org.junit.Assert.assertTrue;
public class BindingTestCase {
@Test
- public void testGeneralizes() {
+ void testGeneralizes() {
Map<String, String> m1 = new HashMap<>();
m1.put("a", "a1");
m1.put("b", "b1");
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java b/container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java
index 511921ac047..c2faeb899c9 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java
@@ -2,12 +2,12 @@
package com.yahoo.search.query.profile.compiled;
import com.yahoo.search.query.profile.config.QueryProfilesConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.Executors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author gjoranv
@@ -15,13 +15,13 @@ import static org.junit.Assert.assertTrue;
public class CompiledQueryProfileRegistryTest {
@Test
- public void registry_can_be_created_from_config() {
+ void registry_can_be_created_from_config() {
var config = new QueryProfilesConfig.Builder()
.queryprofile(new QueryProfilesConfig.Queryprofile.Builder()
- .id("profile1")
- .property(new QueryProfilesConfig.Queryprofile.Property.Builder()
- .name("hits")
- .value("5")))
+ .id("profile1")
+ .property(new QueryProfilesConfig.Queryprofile.Property.Builder()
+ .name("hits")
+ .value("5")))
.build();
var executor = Executors.newCachedThreadPool();
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java
index 21f20e70ddb..ebe9c9d3c04 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java
@@ -7,10 +7,10 @@ import java.util.Map;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileXMLReader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author bratseth
@@ -18,31 +18,31 @@ import static org.junit.Assert.assertNotNull;
public class MultiProfileTestCase {
@Test
- public void testValid() {
- QueryProfileRegistry registry=
+ void testValid() {
+ QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/multiprofile");
- QueryProfile multiprofile1=registry.getComponent("multiprofile1");
+ QueryProfile multiprofile1 = registry.getComponent("multiprofile1");
assertNotNull(multiprofile1);
- assertGet("general-a","a",new String[] {null,null,null},multiprofile1);
- assertGet("us-nokia-test1-a","a",new String[] {"us","nok ia","test1"},multiprofile1);
- assertGet("us-nokia-b","b",new String[] {"us","nok ia","test1"},multiprofile1);
- assertGet("us-a","a",new String[] {"us",null,null},multiprofile1);
- assertGet("us-b","b",new String[] {"us",null,null},multiprofile1);
- assertGet("us-nokia-a","a",new String[] {"us","nok ia",null},multiprofile1);
- assertGet("us-test1-a","a",new String[] {"us",null,"test1"},multiprofile1);
- assertGet("us-test1-b","b",new String[] {"us",null,"test1"},multiprofile1);
+ assertGet("general-a", "a", new String[]{null, null, null}, multiprofile1);
+ assertGet("us-nokia-test1-a", "a", new String[]{"us", "nok ia", "test1"}, multiprofile1);
+ assertGet("us-nokia-b", "b", new String[]{"us", "nok ia", "test1"}, multiprofile1);
+ assertGet("us-a", "a", new String[]{"us", null, null}, multiprofile1);
+ assertGet("us-b", "b", new String[]{"us", null, null}, multiprofile1);
+ assertGet("us-nokia-a", "a", new String[]{"us", "nok ia", null}, multiprofile1);
+ assertGet("us-test1-a", "a", new String[]{"us", null, "test1"}, multiprofile1);
+ assertGet("us-test1-b", "b", new String[]{"us", null, "test1"}, multiprofile1);
- assertGet("us-a","a",new String[] {"us","unspecified","unspecified"},multiprofile1);
- assertGet("us-nokia-a","a",new String[] {"us","nok ia","unspecified"},multiprofile1);
- assertGet("us-test1-a","a",new String[] {"us","unspecified","test1"},multiprofile1);
- assertGet("us-nokia-b","b",new String[] {"us","nok ia","test1"},multiprofile1);
+ assertGet("us-a", "a", new String[]{"us", "unspecified", "unspecified"}, multiprofile1);
+ assertGet("us-nokia-a", "a", new String[]{"us", "nok ia", "unspecified"}, multiprofile1);
+ assertGet("us-test1-a", "a", new String[]{"us", "unspecified", "test1"}, multiprofile1);
+ assertGet("us-nokia-b", "b", new String[]{"us", "nok ia", "test1"}, multiprofile1);
// ...inherited
- assertGet("parent1-value","parent1",new String[] { "us","nok ia","-" }, multiprofile1);
- assertGet("parent2-value","parent2",new String[] { "us","nok ia","-" }, multiprofile1);
- assertGet(null,"parent1",new String[] { "us","-","-" }, multiprofile1);
- assertGet(null,"parent2",new String[] { "us","-","-" }, multiprofile1);
+ assertGet("parent1-value", "parent1", new String[]{"us", "nok ia", "-"}, multiprofile1);
+ assertGet("parent2-value", "parent2", new String[]{"us", "nok ia", "-"}, multiprofile1);
+ assertGet(null, "parent1", new String[]{"us", "-", "-"}, multiprofile1);
+ assertGet(null, "parent2", new String[]{"us", "-", "-"}, multiprofile1);
}
private void assertGet(String expectedValue,String parameter,String[] dimensionValues,QueryProfile profile) {
@@ -50,7 +50,7 @@ public class MultiProfileTestCase {
context.put("region",dimensionValues[0]);
context.put("model",dimensionValues[1]);
context.put("bucket",dimensionValues[2]);
- assertEquals("Looking up '" + parameter + "' for '" + toString(dimensionValues) + "'",expectedValue,profile.get(parameter,context,null));
+ assertEquals(expectedValue,profile.get(parameter,context,null),"Looking up '" + parameter + "' for '" + toString(dimensionValues) + "'");
}
private String toString(String[] array) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java
index 29a8969233b..bf3afecc115 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java
@@ -7,15 +7,13 @@ import com.yahoo.search.query.profile.QueryProfileProperties;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.search.query.profile.config.QueryProfileConfigurer;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -25,9 +23,9 @@ public class QueryProfileConfigurationTestCase {
public final String CONFIG_DIR ="src/test/java/com/yahoo/search/query/profile/config/test/";
@Test
- public void testConfiguration() {
+ void testConfiguration() {
var profile = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "query-profiles-configuration.cfg")
- .getComponent("default");
+ .getComponent("default");
assertEquals("a-value", profile.get("a"));
assertEquals("b-value", profile.get("b"));
@@ -43,9 +41,9 @@ public class QueryProfileConfigurationTestCase {
}
@Test
- public void testBug3197426() {
+ void testBug3197426() {
var profile = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "bug3197426.cfg")
- .getComponent("default").compile(null);
+ .getComponent("default").compile(null);
Map<String, Object> properties = new QueryProfileProperties(profile).listProperties("source.image");
assertEquals("yes", properties.get("mlr"));
@@ -63,42 +61,42 @@ public class QueryProfileConfigurationTestCase {
}
@Test
- public void testVariantConfiguration() {
+ void testVariantConfiguration() {
var registry = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "query-profile-variants-configuration.cfg");
// Variant 1
QueryProfile variants1 = registry.getComponent("variants1");
- assertGet("x1.y1.a", "a", new String[] { "x1","y1" }, variants1);
- assertGet("x1.y1.b", "b", new String[] { "x1","y1" }, variants1);
- assertGet("x1.y?.a", "a", new String[] { "x1","zz" }, variants1);
- assertGet("x?.y1.a", "a", new String[] { "zz","y1" }, variants1);
- assertGet("a-deflt", "a", new String[] { "z1","z2" }, variants1);
+ assertGet("x1.y1.a", "a", new String[]{"x1", "y1"}, variants1);
+ assertGet("x1.y1.b", "b", new String[]{"x1", "y1"}, variants1);
+ assertGet("x1.y?.a", "a", new String[]{"x1", "zz"}, variants1);
+ assertGet("x?.y1.a", "a", new String[]{"zz", "y1"}, variants1);
+ assertGet("a-deflt", "a", new String[]{"z1", "z2"}, variants1);
// ...inherited
- assertGet("parent1-value", "parent1", new String[] { "x1","y1" }, variants1);
- assertGet("parent2-value", "parent2", new String[] { "x1","y1" }, variants1);
- assertGet(null, "parent1", new String[] { "x1","y2" }, variants1);
- assertGet(null, "parent2", new String[] { "x1","y2" }, variants1);
+ assertGet("parent1-value", "parent1", new String[]{"x1", "y1"}, variants1);
+ assertGet("parent2-value", "parent2", new String[]{"x1", "y1"}, variants1);
+ assertGet(null, "parent1", new String[]{"x1", "y2"}, variants1);
+ assertGet(null, "parent2", new String[]{"x1", "y2"}, variants1);
// Variant 2
QueryProfile variants2 = registry.getComponent("variants2");
- assertGet("variant2:y1.c", "c", new String[] { "*","y1" }, variants2);
- assertGet("variant2:y2.c", "c", new String[] { "*","y2" }, variants2);
- assertGet("variant2:c-df", "c", new String[] { "*","z1" }, variants2);
- assertGet("variant2:c-df", "c", new String[] { }, variants2);
- assertGet("variant2:c-df", "c", new String[] { "*" }, variants2);
- assertGet(null, "d", new String[] { "*","y1" }, variants2);
+ assertGet("variant2:y1.c", "c", new String[]{"*", "y1"}, variants2);
+ assertGet("variant2:y2.c", "c", new String[]{"*", "y2"}, variants2);
+ assertGet("variant2:c-df", "c", new String[]{"*", "z1"}, variants2);
+ assertGet("variant2:c-df", "c", new String[]{ }, variants2);
+ assertGet("variant2:c-df", "c", new String[]{"*" }, variants2);
+ assertGet(null, "d", new String[]{"*", "y1"}, variants2);
// Reference following from variant 1
- assertGet("variant2:y1.c", "toVariants.c", new String[] { "**", "y1" } , variants1);
- assertGet("variant3:c-df", "toVariants.c", new String[] { "x1", "**" } , variants1);
- assertGet("variant3:y1.c", "toVariants.c", new String[] { "x1", "y1" } , variants1); // variant3 by order priority
- assertGet("variant3:y2.c", "toVariants.c", new String[] { "x1", "y2" } , variants1);
+ assertGet("variant2:y1.c", "toVariants.c", new String[]{"**", "y1"}, variants1);
+ assertGet("variant3:c-df", "toVariants.c", new String[]{"x1", "**"}, variants1);
+ assertGet("variant3:y1.c", "toVariants.c", new String[]{"x1", "y1"}, variants1); // variant3 by order priority
+ assertGet("variant3:y2.c", "toVariants.c", new String[]{"x1", "y2"}, variants1);
}
@Test
- public void testVariantConfigurationThroughQueryLookup() {
+ void testVariantConfigurationThroughQueryLookup() {
var registry = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "query-profile-variants-configuration.cfg")
- .compile();
+ .compile();
CompiledQueryProfile variants1 = registry.getComponent("variants1");
@@ -107,7 +105,7 @@ public class QueryProfileConfigurationTestCase {
assertEquals("x1.y1.b", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=y1"), variants1).properties().get("b"));
assertEquals("x1.y1.defaultIndex", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=y1"), variants1).getModel().getDefaultIndex());
assertEquals("x1.y?.a", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=zz"), variants1).properties().get("a"));
- assertEquals("x1.y?.defaultIndex", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=zz"),variants1).getModel().getDefaultIndex());
+ assertEquals("x1.y?.defaultIndex", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=zz"), variants1).getModel().getDefaultIndex());
assertEquals("x?.y1.a", new Query(QueryTestCase.httpEncode("?query=foo&x=zz&y=y1"), variants1).properties().get("a"));
assertEquals("x?.y1.defaultIndex", new Query(QueryTestCase.httpEncode("?query=foo&x=zz&y=y1"), variants1).getModel().getDefaultIndex());
assertEquals("x?.y1.filter", new Query(QueryTestCase.httpEncode("?query=foo&x=zz&y=y1"), variants1).getModel().getFilter());
@@ -130,14 +128,14 @@ public class QueryProfileConfigurationTestCase {
}
@Test
- public void testVariant2ConfigurationThroughQueryLookup() {
+ void testVariant2ConfigurationThroughQueryLookup() {
final double delta = 0.0000001;
var registry = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "query-profile-variants2.cfg")
- .compile();
+ .compile();
Query query = new Query(QueryTestCase.httpEncode("?query=heh&queryProfile=multi&myindex=default&myquery=lo ve&tracelevel=5"),
- registry.findQueryProfile("multi"));
+ registry.findQueryProfile("multi"));
assertEquals("love", query.properties().get("model.queryString"));
assertEquals("default", query.properties().get("model.defaultIndex"));
@@ -152,8 +150,7 @@ public class QueryProfileConfigurationTestCase {
Map<String, String> context = new HashMap<>();
for (int i = 0; i<dimensionValues.length; i++)
context.put(profile.getVariants().getDimensions().get(i), dimensionValues[i]); // Lookup dim. names to ease test...
- assertEquals("Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'",
- expectedValue, profile.get(parameter, context, null));
+ assertEquals(expectedValue, profile.get(parameter, context, null), "Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java
index c64d5df64f9..ce6f6264623 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java
@@ -14,10 +14,10 @@ import com.yahoo.search.handler.HttpSearchResponse;
import com.yahoo.search.handler.SearchHandler;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Tests using query profiles in searches
@@ -26,13 +26,13 @@ import static org.junit.Assert.assertNotNull;
*/
public class QueryProfileIntegrationTestCase {
- @org.junit.After
+ @org.junit.jupiter.api.AfterEach
public void tearDown() {
System.getProperties().remove("config.id");
}
@Test
- public void testUntyped() {
+ void testUntyped() {
String configId = "dir:src/test/java/com/yahoo/search/query/profile/config/test/untyped";
System.setProperty("config.id", configId);
Container container = new Container();
@@ -41,79 +41,79 @@ public class QueryProfileIntegrationTestCase {
// Should get "default" query profile containing the "test" search chain containing the "test" searcher
HttpRequest request = HttpRequest.createTestRequest("search", Method.GET);
- HttpSearchResponse response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ HttpSearchResponse response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:test"));
// Should get the "test' query profile containing the "default" search chain containing the "default" searcher
request = HttpRequest.createTestRequest("search?queryProfile=test", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:default"));
// Should get "default" query profile, but override the search chain to default
request = HttpRequest.createTestRequest("search?searchChain=default", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:default"));
// Tests a profile setting hits and offset
request = HttpRequest.createTestRequest("search?queryProfile=hitsoffset", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertEquals(20, response.getQuery().getHits());
assertEquals(80, response.getQuery().getOffset());
// Tests a non-resolved profile request
request = HttpRequest.createTestRequest("search?queryProfile=none", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertNotNull("Got an error", response.getResult().hits().getError());
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertNotNull(response.getResult().hits().getError(), "Got an error");
assertEquals("Could not resolve query profile 'none'", response.getResult().hits().getError().getDetailedMessage());
// Tests that properties in objects owned by query is handled correctly
request = HttpRequest.createTestRequest("search?query=word&queryProfile=test", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertEquals("index" ,response.getQuery().getModel().getDefaultIndex());
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertEquals("index", response.getQuery().getModel().getDefaultIndex());
assertEquals("WEAKAND(100) index:word", response.getQuery().getModel().getQueryTree().toString());
configurer.shutdown();
}
@Test
- public void testTyped() {
+ void testTyped() {
String configId = "dir:src/test/java/com/yahoo/search/query/profile/config/test/typed";
System.setProperty("config.id", configId);
Container container = new Container();
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper(container, configId);
- SearchHandler searchHandler = (SearchHandler)configurer.getRequestHandlerRegistry().getComponent(SearchHandler.class.getName());
+ SearchHandler searchHandler = (SearchHandler) configurer.getRequestHandlerRegistry().getComponent(SearchHandler.class.getName());
// Should get "default" query profile containing the "test" search chain containing the "test" searcher
HttpRequest request = HttpRequest.createTestRequest("search", Method.GET);
- HttpSearchResponse response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ HttpSearchResponse response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:test"));
// Should get the "test' query profile containing the "default" search chain containing the "default" searcher
request = HttpRequest.createTestRequest("search?queryProfile=test", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:default"));
// Should get "default" query profile, but override the search chain to default
request = HttpRequest.createTestRequest("search?searchChain=default", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:default"));
// Tests a profile setting hits and offset
request = HttpRequest.createTestRequest("search?queryProfile=hitsoffset", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertEquals(22,response.getQuery().getHits());
- assertEquals(80,response.getQuery().getOffset());
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertEquals(22, response.getQuery().getHits());
+ assertEquals(80, response.getQuery().getOffset());
// Tests a non-resolved profile request
request = HttpRequest.createTestRequest("search?queryProfile=none", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertNotNull("Got an error",response.getResult().hits().getError());
- assertEquals("Could not resolve query profile 'none'",response.getResult().hits().getError().getDetailedMessage());
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertNotNull(response.getResult().hits().getError(), "Got an error");
+ assertEquals("Could not resolve query profile 'none'", response.getResult().hits().getError().getDetailedMessage());
// Test overriding a sub-profile in the request
request = HttpRequest.createTestRequest("search?queryProfile=root&sub=newsub", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertEquals("newsubvalue1",response.getQuery().properties().get("sub.value1"));
- assertEquals("newsubvalue2",response.getQuery().properties().get("sub.value2"));
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertEquals("newsubvalue1", response.getQuery().properties().get("sub.value1"));
+ assertEquals("newsubvalue2", response.getQuery().properties().get("sub.value2"));
configurer.shutdown();
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java
index 944ee6d79ef..de46e6ee77c 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java
@@ -4,11 +4,9 @@ package com.yahoo.search.query.profile.config.test;
import com.yahoo.search.query.profile.config.QueryProfileConfigurer;
import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -17,7 +15,7 @@ public class TypedProfilesConfigurationTestCase {
/** Asserts that everything is read correctly from this configuration */
@Test
- public void testIt() {
+ void testIt() {
var registry = QueryProfileConfigurer.createFromConfigId("file:src/test/java/com/yahoo/search/query/profile/config/test/typed-profiles.cfg");
var types = registry.getTypeRegistry();
@@ -33,19 +31,19 @@ public class TypedProfilesConfigurationTestCase {
assertTrue(testType.getField("myString").isOverridable());
assertFalse(testType.getField("myInteger").isMandatory());
assertFalse(testType.getField("myInteger").isOverridable());
- FieldDescription field= testType.getField("myUserQueryProfile");
+ FieldDescription field = testType.getField("myUserQueryProfile");
assertEquals("reference to a query profile of type 'user'", field.getType().toInstanceDescription());
assertTrue(field.getAliases().contains("myqp"));
assertTrue(field.getAliases().contains("user-profile"));
- QueryProfileType testTypeStrict=types.getComponent("testtypestrict");
+ QueryProfileType testTypeStrict = types.getComponent("testtypestrict");
assertTrue(testTypeStrict.isStrict());
assertTrue(testTypeStrict.getMatchAsPath());
assertEquals(7, testTypeStrict.fields().size());
assertEquals("reference to a query profile of type 'userstrict'",
- testTypeStrict.getField("myUserQueryProfile").getType().toInstanceDescription());
+ testTypeStrict.getField("myUserQueryProfile").getType().toInstanceDescription());
- QueryProfileType user=types.getComponent("user");
+ QueryProfileType user = types.getComponent("user");
assertFalse(user.isStrict());
assertFalse(user.getMatchAsPath());
assertEquals(2, user.fields().size());
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java
index 62bc89c8453..dcb41dc5e31 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java
@@ -19,17 +19,13 @@ import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileXMLReader;
import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -37,7 +33,7 @@ import static org.junit.Assert.fail;
public class XmlReadingTestCase {
@Test
- public void testInheritance() {
+ void testInheritance() {
QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/inheritance");
@@ -48,7 +44,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testValid() {
+ void testValid() {
QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/validxml");
CompiledQueryProfileRegistry cRegistry = registry.compile();
@@ -106,8 +102,8 @@ public class XmlReadingTestCase {
assertEquals(3, query.getTrace().getLevel());
QueryProfile someUser = registry.getComponent("someUser");
- assertEquals("5",someUser.get("sub.test"));
- assertEquals(18,someUser.get("age"));
+ assertEquals("5", someUser.get("sub.test"));
+ assertEquals(18, someUser.get("age"));
// aliases
assertEquals(18, someUser.get("alder"));
@@ -129,19 +125,19 @@ public class XmlReadingTestCase {
}
@Test
- public void testBasicsNoProfile() {
- Query q=new Query(HttpRequest.createTestRequest("?query=test", Method.GET));
- assertEquals("test",q.properties().get("query"));
- assertEquals("test",q.properties().get("QueRY"));
- assertEquals("test",q.properties().get("model.queryString"));
- assertEquals("test",q.getModel().getQueryString());
+ void testBasicsNoProfile() {
+ Query q = new Query(HttpRequest.createTestRequest("?query=test", Method.GET));
+ assertEquals("test", q.properties().get("query"));
+ assertEquals("test", q.properties().get("QueRY"));
+ assertEquals("test", q.properties().get("model.queryString"));
+ assertEquals("test", q.getModel().getQueryString());
}
@Test
- public void testBasicsWithProfile() {
+ void testBasicsWithProfile() {
QueryProfile p = new QueryProfile("default");
p.set("a", "foo", null);
- Query q=new Query(HttpRequest.createTestRequest("?query=test", Method.GET), p.compile(null));
+ Query q = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), p.compile(null));
assertEquals("test", q.properties().get("query"));
assertEquals("test", q.properties().get("QueRY"));
assertEquals("test", q.properties().get("model.queryString"));
@@ -150,7 +146,7 @@ public class XmlReadingTestCase {
/** Tests a subset of the configuration in the system test of this */
@Test
- public void testSystemtest() {
+ void testSystemtest() {
String queryString = "?query=test";
QueryProfileXMLReader reader = new QueryProfileXMLReader();
@@ -170,7 +166,7 @@ public class XmlReadingTestCase {
assertEquals("le", p.get("subst.end"));
assertEquals("title", p.get("model.defaultIndex"));
- Map<String,Object> ps = p.listProperties();
+ Map<String, Object> ps = p.listProperties();
assertEquals("bar", ps.get("foo"));
assertEquals(5, ps.get("hits"));
assertEquals("tit", ps.get("subst"));
@@ -180,7 +176,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testInvalid1() {
+ void testInvalid1() {
try {
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml1");
fail("Should have failed");
@@ -191,7 +187,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testInvalid2() {
+ void testInvalid2() {
try {
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml2");
fail("Should have failed");
@@ -202,7 +198,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testInvalid3() {
+ void testInvalid3() {
try {
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml3");
fail("Should have failed");
@@ -213,7 +209,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testQueryProfileVariants() {
+ void testQueryProfileVariants() {
String query = "?query=test&dim1=yahoo&dim2=uk&dim3=test";
QueryProfileXMLReader reader = new QueryProfileXMLReader();
@@ -227,7 +223,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testQueryProfileVariantsWithOverridableFalse() {
+ void testQueryProfileVariantsWithOverridableFalse() {
QueryProfileXMLReader reader = new QueryProfileXMLReader();
CompiledQueryProfileRegistry registry = reader.read("src/test/java/com/yahoo/search/query/profile/config/test/variants/").compile();
CompiledQueryProfile profile = registry.findQueryProfile("default");
@@ -240,156 +236,156 @@ public class XmlReadingTestCase {
}
@Test
- public void testNewsFE1() {
- CompiledQueryProfileRegistry registry=new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe").compile();
+ void testNewsFE1() {
+ CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe").compile();
- String queryString="tiled?vertical=news&query=barack&intl=us&resulttypes=article&testid=&clientintl=us&SpellState=&rss=0&tracelevel=5";
+ String queryString = "tiled?vertical=news&query=barack&intl=us&resulttypes=article&testid=&clientintl=us&SpellState=&rss=0&tracelevel=5";
- Query query=new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
- assertEquals("13",query.properties().listProperties().get("source.news.discovery.sources.count"));
- assertEquals("13",query.properties().get("source.news.discovery.sources.count"));
- assertEquals("sources",query.properties().listProperties().get("source.news.discovery"));
- assertEquals("sources",query.properties().get("source.news.discovery"));
+ Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
+ assertEquals("13", query.properties().listProperties().get("source.news.discovery.sources.count"));
+ assertEquals("13", query.properties().get("source.news.discovery.sources.count"));
+ assertEquals("sources", query.properties().listProperties().get("source.news.discovery"));
+ assertEquals("sources", query.properties().get("source.news.discovery"));
}
@Test
- public void testQueryProfileVariants2() {
+ void testQueryProfileVariants2() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/queryprofilevariants2").compile();
CompiledQueryProfile multi = registry.getComponent("multi");
{
- Query query=new Query(HttpRequest.createTestRequest("?queryProfile=multi", Method.GET), multi);
+ Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi", Method.GET), multi);
query.validate();
- assertEquals("best",query.properties().get("model.queryString"));
- assertEquals("best",query.getModel().getQueryString());
+ assertEquals("best", query.properties().get("model.queryString"));
+ assertEquals("best", query.getModel().getQueryString());
}
{
- Query query=new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default", Method.GET), multi);
+ Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default", Method.GET), multi);
query.validate();
assertEquals("best", query.properties().get("model.queryString"));
assertEquals("best", query.getModel().getQueryString());
assertEquals("default", query.getModel().getDefaultIndex());
}
{
- Query query=new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default&myquery=love", Method.GET), multi);
+ Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default&myquery=love", Method.GET), multi);
query.validate();
assertEquals("love", query.properties().get("model.queryString"));
assertEquals("love", query.getModel().getQueryString());
assertEquals("default", query.getModel().getDefaultIndex());
}
{
- Query query=new Query(HttpRequest.createTestRequest("?model=querybest", Method.GET), multi);
+ Query query = new Query(HttpRequest.createTestRequest("?model=querybest", Method.GET), multi);
query.validate();
- assertEquals("best",query.getModel().getQueryString());
- assertEquals("title",query.properties().get("model.defaultIndex"));
- assertEquals("title",query.getModel().getDefaultIndex());
+ assertEquals("best", query.getModel().getQueryString());
+ assertEquals("title", query.properties().get("model.defaultIndex"));
+ assertEquals("title", query.getModel().getDefaultIndex());
}
}
@Test
- public void testKlee() {
- QueryProfileRegistry registry=
+ void testKlee() {
+ QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/klee");
- QueryProfile pv=registry.getComponent("twitter_dd-us:0.2.4");
- assertEquals("0.2.4",pv.getId().getVersion().toString());
- assertEquals("[query profile 'production']",pv.inherited().toString());
+ QueryProfile pv = registry.getComponent("twitter_dd-us:0.2.4");
+ assertEquals("0.2.4", pv.getId().getVersion().toString());
+ assertEquals("[query profile 'production']", pv.inherited().toString());
- QueryProfile p=registry.getComponent("twitter_dd-us:0.0.0");
- assertEquals("",p.getId().getVersion().toString()); // that is 0.0.0
- assertEquals("[query profile 'twitter_dd']",p.inherited().toString());
+ QueryProfile p = registry.getComponent("twitter_dd-us:0.0.0");
+ assertEquals("", p.getId().getVersion().toString()); // that is 0.0.0
+ assertEquals("[query profile 'twitter_dd']", p.inherited().toString());
}
@Test
- public void testVersions() {
- QueryProfileRegistry registry=
+ void testVersions() {
+ QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/versions");
registry.freeze();
- assertEquals("1.20.100",registry.findQueryProfile("testprofile:1.20.100").getId().getVersion().toString());
- assertEquals("1.20.100",registry.findQueryProfile("testprofile:1.20").getId().getVersion().toString());
- assertEquals("1.20.100",registry.findQueryProfile("testprofile:1").getId().getVersion().toString());
- assertEquals("1.20.100",registry.findQueryProfile("testprofile").getId().getVersion().toString());
+ assertEquals("1.20.100", registry.findQueryProfile("testprofile:1.20.100").getId().getVersion().toString());
+ assertEquals("1.20.100", registry.findQueryProfile("testprofile:1.20").getId().getVersion().toString());
+ assertEquals("1.20.100", registry.findQueryProfile("testprofile:1").getId().getVersion().toString());
+ assertEquals("1.20.100", registry.findQueryProfile("testprofile").getId().getVersion().toString());
}
@Test
- public void testNewsFE2() {
- CompiledQueryProfileRegistry registry=new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe2").compile();
+ void testNewsFE2() {
+ CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe2").compile();
- String queryString="tiled?query=a&intl=tw&mode=adv&mode=adv";
+ String queryString = "tiled?query=a&intl=tw&mode=adv&mode=adv";
- Query query=new Query(HttpRequest.createTestRequest(queryString, Method.GET),registry.getComponent("default"));
- assertEquals("news_adv",query.properties().listProperties().get("provider"));
- assertEquals("news_adv",query.properties().get("provider"));
+ Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
+ assertEquals("news_adv", query.properties().listProperties().get("provider"));
+ assertEquals("news_adv", query.properties().get("provider"));
}
@Test
- public void testSourceProvider() {
- CompiledQueryProfileRegistry registry=new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/sourceprovider").compile();
+ void testSourceProvider() {
+ CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/sourceprovider").compile();
- String queryString="tiled?query=india&queryProfile=myprofile&source.common.intl=tw&source.common.mode=adv";
+ String queryString = "tiled?query=india&queryProfile=myprofile&source.common.intl=tw&source.common.mode=adv";
- Query query=new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("myprofile"));
- assertEquals("news",query.properties().listProperties().get("source.common.provider"));
- assertEquals("news",query.properties().get("source.common.provider"));
+ Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("myprofile"));
+ assertEquals("news", query.properties().listProperties().get("source.common.provider"));
+ assertEquals("news", query.properties().get("source.common.provider"));
}
@Test
- public void testNewsCase1() {
+ void testNewsCase1() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase1").compile();
Query query;
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals(0.0, query.properties().get("ranking.features.b"));
assertEquals("0.0", query.properties().listProperties().get("ranking.features.b"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals(0.1, query.properties().get("ranking.features.b"));
assertEquals("0.1", query.properties().listProperties().get("ranking.features.b"));
}
@Test
- public void testNewsCase2() {
+ void testNewsCase2() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase2").compile();
Query query;
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals("0.0", query.properties().get("a.features.b"));
assertEquals("0.0", query.properties().listProperties().get("a.features.b"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals("0.1", query.properties().get("a.features.b"));
assertEquals("0.1", query.properties().listProperties().get("a.features.b"));
}
@Test
- public void testNewsCase3() {
+ void testNewsCase3() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase3").compile();
Query query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET),
- registry.getComponent("default"));
- assertEquals("0.0",query.properties().get("a.features"));
+ registry.getComponent("default"));
+ assertEquals("0.0", query.properties().get("a.features"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET),
- registry.getComponent("default"));
- assertEquals("0.1",query.properties().get("a.features"));
+ registry.getComponent("default"));
+ assertEquals("0.1", query.properties().get("a.features"));
}
@Test
- public void testNewsCase4() {
+ void testNewsCase4() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase4").compile();
Query query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals(0.0, query.properties().get("ranking.features.foo"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals(0.1, query.properties().get("ranking.features.foo"));
}
@Test
- public void testVersionRefs() {
+ void testVersionRefs() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/versionrefs").compile();
Query query = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), registry.getComponent("default"));
@@ -397,14 +393,14 @@ public class XmlReadingTestCase {
}
@Test
- public void testRefOverride() {
+ void testRefOverride() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/refoverride").compile();
{
// Original reference
Query query = new Query(HttpRequest.createTestRequest("?query=test", Method.GET),
- registry.getComponent("default"));
- assertEquals(null, query.properties().get("profileRef"));
+ registry.getComponent("default"));
+ assertNull(query.properties().get("profileRef"));
assertEquals("MyProfile1", query.properties().get("profileRef.name"));
assertEquals("myProfile1Only", query.properties().get("profileRef.myProfile1Only"));
assertNull(query.properties().get("profileRef.myProfile2Only"));
@@ -412,8 +408,8 @@ public class XmlReadingTestCase {
{
// Overridden reference
- Query query = new Query(HttpRequest.createTestRequest("?query=test&profileRef=ref:MyProfile2", Method.GET),registry.getComponent("default"));
- assertEquals(null,query.properties().get("profileRef"));
+ Query query = new Query(HttpRequest.createTestRequest("?query=test&profileRef=ref:MyProfile2", Method.GET), registry.getComponent("default"));
+ assertNull(query.properties().get("profileRef"));
assertEquals("MyProfile2", query.properties().get("profileRef.name"));
assertEquals("myProfile2Only", query.properties().get("profileRef.myProfile2Only"));
assertNull(query.properties().get("profileRef.myProfile1Only"));
@@ -423,20 +419,20 @@ public class XmlReadingTestCase {
assertEquals("newName", query.properties().get("profileRef.name"));
// ...will not impact others
query = new Query(HttpRequest.createTestRequest("?query=test&profileRef=ref:MyProfile2", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals("MyProfile2", query.properties().get("profileRef.name"));
}
}
@Test
- public void testRefOverrideTyped() {
+ void testRefOverrideTyped() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/refoverridetyped").compile();
{
// Original reference
Query query = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), registry.getComponent("default"));
- assertEquals(null, query.properties().get("profileRef"));
+ assertNull(query.properties().get("profileRef"));
assertEquals("MyProfile1", query.properties().get("profileRef.name"));
assertEquals("myProfile1Only", query.properties().get("profileRef.myProfile1Only"));
assertNull(query.properties().get("profileRef.myProfile2Only"));
@@ -445,7 +441,7 @@ public class XmlReadingTestCase {
{
// Overridden reference
Query query = new Query(HttpRequest.createTestRequest("?query=test&profileRef=MyProfile2", Method.GET), registry.getComponent("default"));
- assertEquals(null, query.properties().get("profileRef"));
+ assertNull(query.properties().get("profileRef"));
assertEquals("MyProfile2", query.properties().get("profileRef.name"));
assertEquals("myProfile2Only", query.properties().get("profileRef.myProfile2Only"));
assertNull(query.properties().get("profileRef.myProfile1Only"));
@@ -461,7 +457,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testAnonymousIdsAreStableBetweenImports() {
+ void testAnonymousIdsAreStableBetweenImports() {
QueryProfileRegistry registry1 = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/typedinheritance");
var childIn1 = registry1.findQueryProfile("child");
var childTypeIn1 = registry1.getType("childType");
@@ -470,50 +466,50 @@ public class XmlReadingTestCase {
var childIn2 = registry2.findQueryProfile("child");
var childTypeIn2 = registry2.getType("childType");
- assertEquals(((QueryProfile)childIn1.lookup("a", Map.of())).getId().stringValue(),
- ((QueryProfile)childIn2.lookup("a", Map.of())).getId().stringValue());
+ assertEquals(((QueryProfile) childIn1.lookup("a", Map.of())).getId().stringValue(),
+ ((QueryProfile) childIn2.lookup("a", Map.of())).getId().stringValue());
assertEquals(childTypeIn1.getType("a").getId().stringValue(),
- childTypeIn2.getType("a").getId().stringValue());
+ childTypeIn2.getType("a").getId().stringValue());
}
@Test
- public void testTensorTypes() {
+ void testTensorTypes() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/tensortypes").compile();
QueryProfileType type1 = registry.getTypeRegistry().getComponent("type1");
assertEquals(TensorType.fromSpec("tensor<float>(x[1])"),
- type1.getFieldType(new CompoundName("ranking.features.query(tensor_1)")).asTensorType());
+ type1.getFieldType(new CompoundName("ranking.features.query(tensor_1)")).asTensorType());
assertNull(type1.getFieldType(new CompoundName("ranking.features.query(tensor_2)")));
assertNull(type1.getFieldType(new CompoundName("ranking.features.query(tensor_3)")));
assertEquals(TensorType.fromSpec("tensor(key{})"),
- type1.getFieldType(new CompoundName("ranking.features.query(tensor_4)")).asTensorType());
+ type1.getFieldType(new CompoundName("ranking.features.query(tensor_4)")).asTensorType());
QueryProfileType type2 = registry.getTypeRegistry().getComponent("type2");
assertNull(type2.getFieldType(new CompoundName("ranking.features.query(tensor_1)")));
assertEquals(TensorType.fromSpec("tensor<float>(x[2])"),
- type2.getFieldType(new CompoundName("ranking.features.query(tensor_2)")).asTensorType());
+ type2.getFieldType(new CompoundName("ranking.features.query(tensor_2)")).asTensorType());
assertEquals(TensorType.fromSpec("tensor<float>(x[3])"),
- type2.getFieldType(new CompoundName("ranking.features.query(tensor_3)")).asTensorType());
+ type2.getFieldType(new CompoundName("ranking.features.query(tensor_3)")).asTensorType());
Query queryProfile1 = new Query.Builder().setQueryProfile(registry.getComponent("profile1"))
- .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
- .build();
- assertEquals("tensor_1 received as a tensor tensor",
- Tensor.from("tensor<float>(x[1]):[1.2]"),
- queryProfile1.properties().get("ranking.features.query(tensor_1)"));
- assertEquals("tensor_4 contained in the profile is a tensor",
- Tensor.from("tensor(key{}):{pre_key1_post:1.0}"),
- queryProfile1.properties().get("ranking.features.query(tensor_4)"));
+ .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
+ .build();
+ assertEquals(Tensor.from("tensor<float>(x[1]):[1.2]"),
+ queryProfile1.properties().get("ranking.features.query(tensor_1)"),
+ "tensor_1 received as a tensor tensor");
+ assertEquals(Tensor.from("tensor(key{}):{pre_key1_post:1.0}"),
+ queryProfile1.properties().get("ranking.features.query(tensor_4)"),
+ "tensor_4 contained in the profile is a tensor");
Query queryProfile2 = new Query.Builder().setQueryProfile(registry.getComponent("profile2"))
- .setEmbedder(new MockEmbedder("text-to-embed",
- Tensor.from("tensor(x[3]):[1, 2, 3]")))
- .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
- .build();
- assertEquals("tensor_1 received as a string as it is not in type2",
- "[1.200]",
- queryProfile2.properties().get("ranking.features.query(tensor_1)"));
+ .setEmbedder(new MockEmbedder("text-to-embed",
+ Tensor.from("tensor(x[3]):[1, 2, 3]")))
+ .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
+ .build();
+ assertEquals("[1.200]",
+ queryProfile2.properties().get("ranking.features.query(tensor_1)"),
+ "tensor_1 received as a string as it is not in type2");
//assertEquals(Tensor.from("tensor(x[3]):[1, 2, 3]"),
// queryProfile2.properties().get("ranking.features.query(tensor_3)"));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java
index 433b87363b3..437d5e3b943 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java
@@ -6,9 +6,9 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.jdisc.http.HttpRequest.Method;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -16,185 +16,185 @@ import static org.junit.Assert.assertEquals;
public class CloningTestCase {
@Test
- public void testCloningWithVariants() {
+ void testCloningWithVariants() {
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] {"x"} );
+ test.setDimensions(new String[]{"x"});
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
- q1.properties().set("a","a1");
+ q1.properties().set("a", "a1");
Query q2 = q1.clone();
- q2.properties().set("a","a2");
- assertEquals("a1",q1.properties().get("a"));
- assertEquals("a2",q2.properties().get("a"));
+ q2.properties().set("a", "a2");
+ assertEquals("a1", q1.properties().get("a"));
+ assertEquals("a2", q2.properties().get("a"));
}
@Test
- public void testShallowCloning() {
+ void testShallowCloning() {
QueryProfile test = new QueryProfile("test");
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- q1.properties().set("a",new MutableString("a1"));
+ q1.properties().set("a", new MutableString("a1"));
Query q2 = q1.clone();
- ((MutableString)q2.properties().get("a")).set("a2");
- assertEquals("a2",q1.properties().get("a").toString());
- assertEquals("a2",q2.properties().get("a").toString());
+ ((MutableString) q2.properties().get("a")).set("a2");
+ assertEquals("a2", q1.properties().get("a").toString());
+ assertEquals("a2", q2.properties().get("a").toString());
}
@Test
- public void testShallowCloningWithVariants() {
+ void testShallowCloningWithVariants() {
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] {"x"} );
+ test.setDimensions(new String[]{"x"});
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
- q1.properties().set("a",new MutableString("a1"));
+ q1.properties().set("a", new MutableString("a1"));
Query q2 = q1.clone();
- ((MutableString)q2.properties().get("a")).set("a2");
- assertEquals("a2",q1.properties().get("a").toString());
- assertEquals("a2",q2.properties().get("a").toString());
+ ((MutableString) q2.properties().get("a")).set("a2");
+ assertEquals("a2", q1.properties().get("a").toString());
+ assertEquals("a2", q2.properties().get("a").toString());
}
@Test
- public void testDeepCloning() {
- QueryProfile test=new QueryProfile("test");
+ void testDeepCloning() {
+ QueryProfile test = new QueryProfile("test");
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- q1.properties().set("a",new CloneableMutableString("a1"));
- Query q2=q1.clone();
- ((MutableString)q2.properties().get("a")).set("a2");
- assertEquals("a1",q1.properties().get("a").toString());
- assertEquals("a2",q2.properties().get("a").toString());
+ q1.properties().set("a", new CloneableMutableString("a1"));
+ Query q2 = q1.clone();
+ ((MutableString) q2.properties().get("a")).set("a2");
+ assertEquals("a1", q1.properties().get("a").toString());
+ assertEquals("a2", q2.properties().get("a").toString());
}
@Test
- public void testDeepCloningWithVariants() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"} );
+ void testDeepCloningWithVariants() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
- q1.properties().set("a",new CloneableMutableString("a1"));
- Query q2=q1.clone();
- ((MutableString)q2.properties().get("a")).set("a2");
- assertEquals("a1",q1.properties().get("a").toString());
- assertEquals("a2",q2.properties().get("a").toString());
+ q1.properties().set("a", new CloneableMutableString("a1"));
+ Query q2 = q1.clone();
+ ((MutableString) q2.properties().get("a")).set("a2");
+ assertEquals("a1", q1.properties().get("a").toString());
+ assertEquals("a2", q2.properties().get("a").toString());
}
@Test
- public void testReAssignment() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"} );
+ void testReAssignment() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
- q1.properties().set("a","a1");
- q1.properties().set("a","a2");
- assertEquals("a2",q1.properties().get("a"));
+ q1.properties().set("a", "a1");
+ q1.properties().set("a", "a2");
+ assertEquals("a2", q1.properties().get("a"));
}
@Test
- public void testThreeLevelsOfCloning() {
+ void testThreeLevelsOfCloning() {
QueryProfile test = new QueryProfile("test");
- test.set("a", "config-a", (QueryProfileRegistry)null);
+ test.set("a", "config-a", (QueryProfileRegistry) null);
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- q1.properties().set("a","q1-a");
- Query q2=q1.clone();
- q2.properties().set("a","q2-a");
- Query q31=q2.clone();
- q31.properties().set("a","q31-a");
- Query q32=q2.clone();
- q32.properties().set("a","q32-a");
-
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
- q2.properties().set("a","q2-a-2");
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a-2",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
+ q1.properties().set("a", "q1-a");
+ Query q2 = q1.clone();
+ q2.properties().set("a", "q2-a");
+ Query q31 = q2.clone();
+ q31.properties().set("a", "q31-a");
+ Query q32 = q2.clone();
+ q32.properties().set("a", "q32-a");
+
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
+ q2.properties().set("a", "q2-a-2");
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a-2", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
}
@Test
- public void testThreeLevelsOfCloningReverseSetOrder() {
+ void testThreeLevelsOfCloningReverseSetOrder() {
QueryProfile test = new QueryProfile("test");
- test.set("a", "config-a", (QueryProfileRegistry)null);
+ test.set("a", "config-a", (QueryProfileRegistry) null);
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- Query q2=q1.clone();
- Query q31=q2.clone();
- Query q32=q2.clone();
- q32.properties().set("a","q32-a");
- q31.properties().set("a","q31-a");
- q2.properties().set("a","q2-a");
- q1.properties().set("a","q1-a");
-
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
- q2.properties().set("a","q2-a-2");
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a-2",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
+ Query q2 = q1.clone();
+ Query q31 = q2.clone();
+ Query q32 = q2.clone();
+ q32.properties().set("a", "q32-a");
+ q31.properties().set("a", "q31-a");
+ q2.properties().set("a", "q2-a");
+ q1.properties().set("a", "q1-a");
+
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
+ q2.properties().set("a", "q2-a-2");
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a-2", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
}
@Test
- public void testThreeLevelsOfCloningMiddleFirstSetOrder1() {
+ void testThreeLevelsOfCloningMiddleFirstSetOrder1() {
QueryProfile test = new QueryProfile("test");
- test.set("a", "config-a", (QueryProfileRegistry)null);
+ test.set("a", "config-a", (QueryProfileRegistry) null);
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- Query q2=q1.clone();
- Query q31=q2.clone();
- Query q32=q2.clone();
- q2.properties().set("a","q2-a");
- q32.properties().set("a","q32-a");
- q31.properties().set("a","q31-a");
- q1.properties().set("a","q1-a");
-
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
- q2.properties().set("a","q2-a-2");
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a-2",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
+ Query q2 = q1.clone();
+ Query q31 = q2.clone();
+ Query q32 = q2.clone();
+ q2.properties().set("a", "q2-a");
+ q32.properties().set("a", "q32-a");
+ q31.properties().set("a", "q31-a");
+ q1.properties().set("a", "q1-a");
+
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
+ q2.properties().set("a", "q2-a-2");
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a-2", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
}
@Test
- public void testThreeLevelsOfCloningMiddleFirstSetOrder2() {
+ void testThreeLevelsOfCloningMiddleFirstSetOrder2() {
QueryProfile test = new QueryProfile("test");
- test.set("a", "config-a", (QueryProfileRegistry)null);
+ test.set("a", "config-a", (QueryProfileRegistry) null);
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- Query q2=q1.clone();
- Query q31=q2.clone();
- Query q32=q2.clone();
- q2.properties().set("a","q2-a");
- q31.properties().set("a","q31-a");
- q1.properties().set("a","q1-a");
-
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("config-a",q32.properties().get("a").toString());
- q1.properties().set("a","q1-a-2");
- assertEquals("q1-a-2",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("config-a",q32.properties().get("a").toString());
- q2.properties().set("a","q2-a-2");
- assertEquals("q1-a-2",q1.properties().get("a").toString());
- assertEquals("q2-a-2",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("config-a",q32.properties().get("a").toString());
+ Query q2 = q1.clone();
+ Query q31 = q2.clone();
+ Query q32 = q2.clone();
+ q2.properties().set("a", "q2-a");
+ q31.properties().set("a", "q31-a");
+ q1.properties().set("a", "q1-a");
+
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("config-a", q32.properties().get("a").toString());
+ q1.properties().set("a", "q1-a-2");
+ assertEquals("q1-a-2", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("config-a", q32.properties().get("a").toString());
+ q2.properties().set("a", "q2-a-2");
+ assertEquals("q1-a-2", q1.properties().get("a").toString());
+ assertEquals("q2-a-2", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("config-a", q32.properties().get("a").toString());
}
public static class MutableString {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java
index 0fca7a566e2..62ed8413d92 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java
@@ -2,14 +2,14 @@
package com.yahoo.search.query.profile.test;
import com.yahoo.search.query.profile.DimensionBinding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -17,47 +17,47 @@ import static org.junit.Assert.*;
public class DimensionBindingTestCase {
@Test
- public void testCombining() {
+ void testCombining() {
assertEquals(binding("a, b, c", "a=1", "b=1", "c=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("c", "c=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("c", "c=1")));
assertEquals(binding("a, b, c", "a=1", "b=1", "c=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("a, c", "a=1", "c=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("a, c", "a=1", "c=1")));
assertEquals(binding("c, a, b", "c=1", "a=1", "b=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("c, a", "a=1", "c=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("c, a", "a=1", "c=1")));
assertEquals(binding("a, b", "a=1", "b=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("a, b", "a=1", "b=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("a, b", "a=1", "b=1")));
assertEquals(DimensionBinding.invalidBinding,
- binding("a, b", "a=1", "b=1").combineWith(binding("b, a", "a=1", "b=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("b, a", "a=1", "b=1")));
assertEquals(binding("a, b", "a=1", "b=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("b", "b=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("b", "b=1")));
assertEquals(binding("a, b, c", "a=1", "b=1", "c=1"),
- binding("a, b, c", "a=1", "c=1").combineWith(binding("a, b, c", "a=1", "b=1", "c=1")));
+ binding("a, b, c", "a=1", "c=1").combineWith(binding("a, b, c", "a=1", "b=1", "c=1")));
assertEquals(binding("a, b, c", "a=1", "b=1", "c=1"),
- binding("a, c", "a=1", "c=1").combineWith(binding("a, b, c", "a=1", "b=1", "c=1")));
+ binding("a, c", "a=1", "c=1").combineWith(binding("a, b, c", "a=1", "b=1", "c=1")));
}
// found DimensionBinding [custid_1=yahoo, custid_2=ca, custid_3=sc, custid_4=null, custid_5=null, custid_6=null], combined with DimensionBinding [custid_1=yahoo, custid_2=null, custid_3=sc, custid_4=null, custid_5=null, custid_6=null] to Invalid DimensionBinding
@Test
- public void testCombiningBindingsWithNull() {
+ void testCombiningBindingsWithNull() {
List<String> dimensions = list("a,b");
Map<String, String> map1 = new HashMap<>();
- map1.put("a","a1");
- map1.put("b","b1");
+ map1.put("a", "a1");
+ map1.put("b", "b1");
Map<String, String> map2 = new HashMap<>();
- map2.put("a","a1");
- map2.put("b",null);
+ map2.put("a", "a1");
+ map2.put("b", null);
assertEquals(DimensionBinding.createFrom(dimensions, map1),
- DimensionBinding.createFrom(dimensions, map1).combineWith(DimensionBinding.createFrom(dimensions, map2)));
+ DimensionBinding.createFrom(dimensions, map1).combineWith(DimensionBinding.createFrom(dimensions, map2)));
}
private DimensionBinding binding(String dimensions, String ... dimensionPoints) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java
index 3ed044601f0..00e48a639c1 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.search.query.profile.test;
import com.yahoo.search.query.profile.DumpTool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -14,28 +14,28 @@ public class DumpToolTestCase {
private final String profileDir = "src/test/java/com/yahoo/search/query/profile/config/test/multiprofile";
@Test
- public void testNoParameters() {
+ void testNoParameters() {
assertTrue(new DumpTool().resolveAndDump().startsWith("Dumps all resolved"));
}
@Test
- public void testHelpParameter() {
+ void testHelpParameter() {
assertTrue(new DumpTool().resolveAndDump("-help").startsWith("Dumps all resolved"));
}
@Test
- public void testNoDimensionValues() {
+ void testNoDimensionValues() {
System.out.println(new DumpTool().resolveAndDump("multiprofile1", profileDir));
assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir).contains("a=general-a\n"));
}
@Test
- public void testAllParametersSet() {
+ void testAllParametersSet() {
assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir, "").contains("a=general-a\n"));
}
@Test
- public void testVariant() {
+ void testVariant() {
String result = new DumpTool().resolveAndDump("multiprofile1", profileDir, "region=us");
assertTrue(result.contains("a=us-a"));
assertTrue(result.contains("b=us-b"));
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java
index 7a92aa8081b..6a9896188f9 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java
@@ -8,9 +8,9 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test using the profile to set the query to execute
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
public class QueryFromProfileTestCase {
@Test
- public void testQueryFromProfile1() {
+ void testQueryFromProfile1() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile topLevel = new QueryProfile("topLevel");
topLevel.setType(registry.getTypeRegistry().getComponent("native"));
@@ -39,7 +39,7 @@ public class QueryFromProfileTestCase {
}
@Test
- public void testQueryFromProfile2() {
+ void testQueryFromProfile2() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType rootType = new QueryProfileType("root");
rootType.inherited().add(registry.getTypeRegistry().getComponent("native"));
@@ -49,7 +49,7 @@ public class QueryFromProfileTestCase {
root.setType(rootType);
registry.register(root);
- QueryProfile queryBest=new QueryProfile("querybest");
+ QueryProfile queryBest = new QueryProfile("querybest");
queryBest.setType(registry.getTypeRegistry().getComponent("model"));
queryBest.set("queryString", "best", registry);
registry.register(queryBest);
@@ -62,7 +62,7 @@ public class QueryFromProfileTestCase {
}
@Test
- public void testQueryFromProfile3() {
+ void testQueryFromProfile3() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType rootType = new QueryProfileType("root");
rootType.inherited().add(registry.getTypeRegistry().getComponent("native"));
@@ -72,7 +72,7 @@ public class QueryFromProfileTestCase {
root.setType(rootType);
registry.register(root);
- QueryProfile queryBest=new QueryProfile("querybest");
+ QueryProfile queryBest = new QueryProfile("querybest");
queryBest.setType(registry.getTypeRegistry().getComponent("model"));
queryBest.set("queryString", "best", registry);
registry.register(queryBest);
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java
index 2173d72cab9..9c162df02bf 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java
@@ -6,10 +6,10 @@ import com.yahoo.yolean.Exceptions;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileProperties;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author bratseth
@@ -17,17 +17,17 @@ import static org.junit.Assert.fail;
public class QueryProfileSubstitutionTestCase {
@Test
- public void testSubstitutionOnly() {
+ void testSubstitutionOnly() {
QueryProfile p = new QueryProfile("test");
- p.set("message","%{world}", null);
+ p.set("message", "%{world}", null);
p.set("world", "world", null);
assertEquals("world", p.compile(null).get("message"));
}
@Test
- public void testSingleSubstitution() {
+ void testSingleSubstitution() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{world}!", null);
+ p.set("message", "Hello %{world}!", null);
p.set("world", "world", null);
assertEquals("Hello world!", p.compile(null).get("message"));
@@ -38,15 +38,15 @@ public class QueryProfileSubstitutionTestCase {
}
@Test
- public void testRelativeSubstitution() {
+ void testRelativeSubstitution() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{.world}!", null);
+ p.set("message", "Hello %{.world}!", null);
p.set("world", "world", null);
assertEquals("Hello world!", p.compile(null).get("message"));
}
@Test
- public void testRelativeSubstitutionNotFound() {
+ void testRelativeSubstitutionNotFound() {
try {
QueryProfile p = new QueryProfile("test");
p.set("message", "Hello %{.world}!", null);
@@ -55,80 +55,80 @@ public class QueryProfileSubstitutionTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("Invalid query profile 'test': Could not resolve local substitution 'world' in variant []",
- Exceptions.toMessageString(e));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testMultipleSubstitutions() {
+ void testMultipleSubstitutions() {
QueryProfile p = new QueryProfile("test");
- p.set("message","%{greeting} %{entity}%{exclamation}", null);
- p.set("greeting","Hola", null);
- p.set("entity","local group", null);
- p.set("exclamation","?", null);
+ p.set("message", "%{greeting} %{entity}%{exclamation}", null);
+ p.set("greeting", "Hola", null);
+ p.set("entity", "local group", null);
+ p.set("exclamation", "?", null);
assertEquals("Hola local group?", p.compile(null).get("message"));
QueryProfile p2 = new QueryProfile("test2");
p2.addInherited(p);
- p2.set("entity","milky way", null);
+ p2.set("entity", "milky way", null);
assertEquals("Hola milky way?", p2.compile(null).get("message"));
}
@Test
- public void testUnclosedSubstitution1() {
+ void testUnclosedSubstitution1() {
try {
QueryProfile p = new QueryProfile("test");
- p.set("message1","%{greeting} %{entity}%{exclamation", null);
+ p.set("message1", "%{greeting} %{entity}%{exclamation", null);
fail("Should have produced an exception");
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'message1' to '%{greeting} %{entity}%{exclamation': Unterminated value substitution '%{exclamation'",
- Exceptions.toMessageString(e));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testUnclosedSubstitution2() {
+ void testUnclosedSubstitution2() {
try {
QueryProfile p = new QueryProfile("test");
- p.set("message1","%{greeting} %{entity%{exclamation}", null);
+ p.set("message1", "%{greeting} %{entity%{exclamation}", null);
fail("Should have produced an exception");
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'message1' to '%{greeting} %{entity%{exclamation}': Unterminated value substitution '%{entity%{exclamation}'",
- Exceptions.toMessageString(e));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testNullSubstitution() {
+ void testNullSubstitution() {
QueryProfile p = new QueryProfile("test");
- p.set("message","%{greeting} %{entity}%{exclamation}", null);
- p.set("greeting","Hola", null);
+ p.set("message", "%{greeting} %{entity}%{exclamation}", null);
+ p.set("greeting", "Hola", null);
assertEquals("Hola ", p.compile(null).get("message"));
QueryProfile p2 = new QueryProfile("test2");
p2.addInherited(p);
- p2.set("greeting","Hola", null);
+ p2.set("greeting", "Hola", null);
p2.set("exclamation", "?", null);
assertEquals("Hola ?", p2.compile(null).get("message"));
}
@Test
- public void testNoOverridingOfPropertiesSetAtRuntime() {
+ void testNoOverridingOfPropertiesSetAtRuntime() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{world}!", null);
- p.set("world","world", null);
+ p.set("message", "Hello %{world}!", null);
+ p.set("world", "world", null);
p.freeze();
Properties runtime = new QueryProfileProperties(p.compile(null));
- runtime.set("runtimeMessage","Hello %{world}!");
+ runtime.set("runtimeMessage", "Hello %{world}!");
assertEquals("Hello world!", runtime.get("message"));
- assertEquals("Hello %{world}!",runtime.get("runtimeMessage"));
+ assertEquals("Hello %{world}!", runtime.get("runtimeMessage"));
}
@Test
- public void testButPropertiesSetAtRuntimeAreUsedInSubstitutions() {
+ void testButPropertiesSetAtRuntimeAreUsedInSubstitutions() {
QueryProfile p = new QueryProfile("test");
p.set("message", "Hello %{world}!", null);
p.set("world", "world", null);
@@ -139,21 +139,22 @@ public class QueryProfileSubstitutionTestCase {
}
@Test
- public void testInspection() {
+ void testInspection() {
QueryProfile p = new QueryProfile("test");
p.set("message", "%{greeting} %{entity}%{exclamation}", null);
- assertEquals("message","%{greeting} %{entity}%{exclamation}",
- p.declaredContent().entrySet().iterator().next().getValue().toString());
+ assertEquals("%{greeting} %{entity}%{exclamation}",
+ p.declaredContent().entrySet().iterator().next().getValue().toString(),
+ "message");
}
@Test
- public void testVariants() {
+ void testVariants() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{world}!", null);
- p.set("world","world", null);
- p.setDimensions(new String[] {"x"});
- p.set("message","Halo %{world}!",new String[] {"x1"}, null);
- p.set("world","Europe",new String[] {"x2"}, null);
+ p.set("message", "Hello %{world}!", null);
+ p.set("world", "world", null);
+ p.setDimensions(new String[]{"x"});
+ p.set("message", "Halo %{world}!", new String[]{"x1"}, null);
+ p.set("world", "Europe", new String[]{"x2"}, null);
CompiledQueryProfile cp = p.compile(null);
assertEquals("Hello world!", cp.get("message", QueryProfileVariantsTestCase.toMap("x=x?")));
@@ -162,12 +163,12 @@ public class QueryProfileSubstitutionTestCase {
}
@Test
- public void testRecursion() {
+ void testRecursion() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{world}!", null);
- p.set("world","sol planet number %{number}", null);
- p.set("number",3, null);
- assertEquals("Hello sol planet number 3!",p.compile(null).get("message"));
+ p.set("message", "Hello %{world}!", null);
+ p.set("world", "sol planet number %{number}", null);
+ p.set("number", 3, null);
+ assertEquals("Hello sol planet number 3!", p.compile(null).get("message"));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java
index 39ed9b829d2..7a4247f2584 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java
@@ -13,7 +13,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.search.query.profile.compiled.ValueWithSource;
import com.yahoo.yolean.trace.TraceNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -21,11 +21,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests untyped query profiles
@@ -35,60 +31,60 @@ import static org.junit.Assert.fail;
public class QueryProfileTestCase {
@Test
- public void testBasics() {
+ void testBasics() {
QueryProfile profile = new QueryProfile("test");
- profile.set("a","a-value", null);
- profile.set("b.c","b.c-value", null);
- profile.set("d.e.f","d.e.f-value", null);
+ profile.set("a", "a-value", null);
+ profile.set("b.c", "b.c-value", null);
+ profile.set("d.e.f", "d.e.f-value", null);
CompiledQueryProfile cprofile = profile.compile(null);
- assertEquals("a-value",cprofile.get("a"));
- assertEquals("b.c-value",cprofile.get("b.c"));
- assertEquals("d.e.f-value",cprofile.get("d.e.f"));
+ assertEquals("a-value", cprofile.get("a"));
+ assertEquals("b.c-value", cprofile.get("b.c"));
+ assertEquals("d.e.f-value", cprofile.get("d.e.f"));
assertNull(cprofile.get("nonexistent"));
assertNull(cprofile.get("nested.nonexistent"));
- assertTrue(profile.lookup("b",null).getClass()==QueryProfile.class);
- assertTrue(profile.lookup("b",null).getClass()==QueryProfile.class);
+ assertEquals(profile.lookup("b", null).getClass(), QueryProfile.class);
+ assertEquals(profile.lookup("b", null).getClass(), QueryProfile.class);
}
/** Tests cloning, with wrappers used in production in place */
@Test
- public void testCloning() {
+ void testCloning() {
QueryProfile classProfile = new QueryProfile("test");
- classProfile.set("a","aValue", null);
- classProfile.set("b",3, null);
+ classProfile.set("a", "aValue", null);
+ classProfile.set("b", 3, null);
Properties properties = new QueryProfileProperties(classProfile.compile(null));
- Properties propertiesClone=properties.clone();
- assertEquals("aValue",propertiesClone.get("a"));
- assertEquals(3,propertiesClone.get("b"));
- properties.set("a","aNewValue");
- assertEquals("aNewValue",properties.get("a"));
- assertEquals("aValue",propertiesClone.get("a"));
+ Properties propertiesClone = properties.clone();
+ assertEquals("aValue", propertiesClone.get("a"));
+ assertEquals(3, propertiesClone.get("b"));
+ properties.set("a", "aNewValue");
+ assertEquals("aNewValue", properties.get("a"));
+ assertEquals("aValue", propertiesClone.get("a"));
}
@Test
- public void testFreezing() {
+ void testFreezing() {
QueryProfile profile = new QueryProfile("test");
- profile.set("a","a-value", null);
- profile.set("b.c","b.c-value", null);
- profile.set("d.e.f","d.e.f-value", null);
+ profile.set("a", "a-value", null);
+ profile.set("b.c", "b.c-value", null);
+ profile.set("d.e.f", "d.e.f-value", null);
assertFalse(profile.isFrozen());
- assertEquals("a-value",profile.get("a"));
+ assertEquals("a-value", profile.get("a"));
profile.freeze();
assertTrue(profile.isFrozen());
- assertTrue(((QueryProfile)profile.lookup("b",null)).isFrozen());
- assertTrue(((QueryProfile)profile.lookup("d.e",null)).isFrozen());
+ assertTrue(((QueryProfile) profile.lookup("b", null)).isFrozen());
+ assertTrue(((QueryProfile) profile.lookup("d.e", null)).isFrozen());
try {
- profile.set("a","value", null);
+ profile.set("a", "value", null);
fail("Expected exception");
}
catch (IllegalStateException e) {
@@ -97,15 +93,15 @@ public class QueryProfileTestCase {
private void assertSameObjects(CompiledQueryProfile profile, String path, List<String> expectedKeys) {
Map<String, Object> subObjects = profile.listValues(path);
- assertEquals("Sub-objects list equal for path " + path, new HashSet<>(expectedKeys), subObjects.keySet());
+ assertEquals(new HashSet<>(expectedKeys), subObjects.keySet(), "Sub-objects list equal for path " + path);
for(String key : expectedKeys) {
- assertEquals("Equal for key " + key, profile.get(key),subObjects.get(path + "." + key));
+ assertEquals(profile.get(key),subObjects.get(path + "." + key),"Equal for key " + key);
}
}
@Test
- public void testGetSubObjects() {
+ void testGetSubObjects() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -117,21 +113,21 @@ public class QueryProfileTestCase {
far.addInherited(farfar);
barn.addInherited(mor);
barn.addInherited(far);
- mormor.set("a.mormor","a.mormor", null);
- barn.set("a.barn","a.barn", null);
+ mormor.set("a.mormor", "a.mormor", null);
+ barn.set("a.barn", "a.barn", null);
mor.set("b.mor", "b.mor", null);
far.set("b.far", "b.far", null);
- far.set("a.far","a.far", null);
+ far.set("a.far", "a.far", null);
CompiledQueryProfile cbarn = barn.compile(null);
- assertSameObjects(cbarn, "a", Arrays.asList("mormor","far","barn"));
+ assertSameObjects(cbarn, "a", Arrays.asList("mormor", "far", "barn"));
assertEquals("b.mor", cbarn.get("b.mor"));
assertEquals("b.far", cbarn.get("b.far"));
}
@Test
- public void testInheritance() {
+ void testInheritance() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -144,24 +140,24 @@ public class QueryProfileTestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- morfar.set("a","morfar-a", null);
- mormor.set("a","mormor-a", null);
- farfar.set("a","farfar-a", null);
- mor.set("a","mor-a", null);
- far.set("a","far-a", null);
- barn.set("a","barn-a", null);
+ morfar.set("a", "morfar-a", null);
+ mormor.set("a", "mormor-a", null);
+ farfar.set("a", "farfar-a", null);
+ mor.set("a", "mor-a", null);
+ far.set("a", "far-a", null);
+ barn.set("a", "barn-a", null);
- mormor.set("b","mormor-b", null);
- far.set("b","far-b", null);
+ mormor.set("b", "mormor-b", null);
+ far.set("b", "far-b", null);
- mor.set("c","mor-c", null);
- far.set("c","far-c", null);
+ mor.set("c", "mor-c", null);
+ far.set("c", "far-c", null);
- mor.set("d.a","mor-d.a", null);
- barn.set("d.b","barn-d.b", null);
+ mor.set("d.a", "mor-d.a", null);
+ barn.set("d.b", "barn-d.b", null);
- QueryProfile annetBarn=new QueryProfile("annetBarn");
- annetBarn.set("venn",barn, null);
+ QueryProfile annetBarn = new QueryProfile("annetBarn");
+ annetBarn.set("venn", barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -179,7 +175,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testInheritance2Level() {
+ void testInheritance2Level() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -192,24 +188,24 @@ public class QueryProfileTestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- morfar.set("a.x","morfar-a", null);
- mormor.set("a.x","mormor-a", null);
- farfar.set("a.x","farfar-a", null);
- mor.set("a.x","mor-a", null);
- far.set("a.x","far-a", null);
- barn.set("a.x","barn-a", null);
+ morfar.set("a.x", "morfar-a", null);
+ mormor.set("a.x", "mormor-a", null);
+ farfar.set("a.x", "farfar-a", null);
+ mor.set("a.x", "mor-a", null);
+ far.set("a.x", "far-a", null);
+ barn.set("a.x", "barn-a", null);
- mormor.set("b.x","mormor-b", null);
- far.set("b.x","far-b", null);
+ mormor.set("b.x", "mormor-b", null);
+ far.set("b.x", "far-b", null);
- mor.set("c.x","mor-c", null);
- far.set("c.x","far-c", null);
+ mor.set("c.x", "mor-c", null);
+ far.set("c.x", "far-c", null);
- mor.set("d.a.x","mor-d.a", null);
- barn.set("d.b.x","barn-d.b", null);
+ mor.set("d.a.x", "mor-d.a", null);
+ barn.set("d.b.x", "barn-d.b", null);
- QueryProfile annetBarn=new QueryProfile("annetBarn");
- annetBarn.set("venn",barn, null);
+ QueryProfile annetBarn = new QueryProfile("annetBarn");
+ annetBarn.set("venn", barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -227,7 +223,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testInheritance3Level() {
+ void testInheritance3Level() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -240,24 +236,24 @@ public class QueryProfileTestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- morfar.set("y.a.x","morfar-a", null);
- mormor.set("y.a.x","mormor-a", null);
- farfar.set("y.a.x","farfar-a", null);
- mor.set("y.a.x","mor-a", null);
- far.set("y.a.x","far-a", null);
- barn.set("y.a.x","barn-a", null);
+ morfar.set("y.a.x", "morfar-a", null);
+ mormor.set("y.a.x", "mormor-a", null);
+ farfar.set("y.a.x", "farfar-a", null);
+ mor.set("y.a.x", "mor-a", null);
+ far.set("y.a.x", "far-a", null);
+ barn.set("y.a.x", "barn-a", null);
- mormor.set("y.b.x","mormor-b", null);
- far.set("y.b.x","far-b", null);
+ mormor.set("y.b.x", "mormor-b", null);
+ far.set("y.b.x", "far-b", null);
- mor.set("y.c.x","mor-c", null);
- far.set("y.c.x","far-c", null);
+ mor.set("y.c.x", "mor-c", null);
+ far.set("y.c.x", "far-c", null);
- mor.set("y.d.a.x","mor-d.a", null);
- barn.set("y.d.b.x","barn-d.b", null);
+ mor.set("y.d.a.x", "mor-d.a", null);
+ barn.set("y.d.b.x", "barn-d.b", null);
- QueryProfile annetBarn=new QueryProfile("annetBarn");
- annetBarn.set("venn",barn, null);
+ QueryProfile annetBarn = new QueryProfile("annetBarn");
+ annetBarn.set("venn", barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -275,7 +271,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testListProperties() {
+ void testListProperties() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -288,18 +284,18 @@ public class QueryProfileTestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- morfar.set("a","morfar-a", null);
- morfar.set("model.b","morfar-model.b", null);
- mormor.set("a","mormor-a", null);
- mormor.set("model.b","mormor-model.b", null);
- farfar.set("a","farfar-a", null);
- mor.set("a","mor-a", null);
- far.set("a","far-a", null);
- barn.set("a","barn-a", null);
- mormor.set("b","mormor-b", null);
- far.set("b","far-b", null);
- mor.set("c","mor-c", null);
- far.set("c","far-c", null);
+ morfar.set("a", "morfar-a", null);
+ morfar.set("model.b", "morfar-model.b", null);
+ mormor.set("a", "mormor-a", null);
+ mormor.set("model.b", "mormor-model.b", null);
+ farfar.set("a", "farfar-a", null);
+ mor.set("a", "mor-a", null);
+ far.set("a", "far-a", null);
+ barn.set("a", "barn-a", null);
+ mormor.set("b", "mormor-b", null);
+ far.set("b", "far-b", null);
+ mor.set("c", "mor-c", null);
+ far.set("c", "far-c", null);
CompiledQueryProfile cbarn = barn.compile(null);
@@ -316,8 +312,8 @@ public class QueryProfileTestCase {
Map<String, Object> modelMap = properties.listProperties("model");
assertEquals("mormor-model.b", modelMap.get("b"));
- QueryProfile annetBarn=new QueryProfile("annetBarn");
- annetBarn.set("venn", barn, (QueryProfileRegistry)null);
+ QueryProfile annetBarn = new QueryProfile("annetBarn");
+ annetBarn.set("venn", barn, (QueryProfileRegistry) null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
Map<String, Object> annetBarnMap = new QueryProfileProperties(cannetBarn).listProperties();
@@ -329,12 +325,12 @@ public class QueryProfileTestCase {
/** Dots are followed when setting overridability */
@Test
- public void testInstanceOverridable() {
+ void testInstanceOverridable() {
QueryProfile profile = new QueryProfile("root/unoverridableIndex");
- profile.set("model.defaultIndex","default", null);
+ profile.set("model.defaultIndex", "default", null);
profile.setOverridable("model.defaultIndex", false, DimensionValues.empty);
- assertFalse(profile.isDeclaredOverridable("model.defaultIndex",null));
+ assertFalse(profile.isDeclaredOverridable("model.defaultIndex", null));
// Parameters should be ignored
Query query = new Query(HttpRequest.createTestRequest("?model.defaultIndex=title", Method.GET), profile.compile(null));
@@ -348,13 +344,13 @@ public class QueryProfileTestCase {
/** Dots are followed when setting overridability, also with variants */
@Test
- public void testInstanceOverridableWithVariants() {
+ void testInstanceOverridableWithVariants() {
QueryProfile profile = new QueryProfile("root/unoverridableIndex");
- profile.setDimensions(new String[] {"x"});
- profile.set("model.defaultIndex","default", null);
+ profile.setDimensions(new String[]{"x"});
+ profile.set("model.defaultIndex", "default", null);
profile.setOverridable("model.defaultIndex", false, DimensionValues.empty);
- assertFalse(profile.isDeclaredOverridable("model.defaultIndex",null));
+ assertFalse(profile.isDeclaredOverridable("model.defaultIndex", null));
// Parameters should be ignored
Query query = new Query(HttpRequest.createTestRequest("?x=x1&model.defaultIndex=title", Method.GET), profile.compile(null));
@@ -367,47 +363,47 @@ public class QueryProfileTestCase {
}
@Test
- public void testSimpleInstanceOverridableWithVariants1() {
- QueryProfile profile=new QueryProfile("test");
- profile.setDimensions(new String[] {"x"});
- profile.set("a","original", null);
+ void testSimpleInstanceOverridableWithVariants1() {
+ QueryProfile profile = new QueryProfile("test");
+ profile.setDimensions(new String[]{"x"});
+ profile.set("a", "original", null);
profile.setOverridable("a", false, DimensionValues.empty);
- assertFalse(profile.isDeclaredOverridable("a",null));
+ assertFalse(profile.isDeclaredOverridable("a", null));
Query query = new Query(HttpRequest.createTestRequest("?x=x1&a=overridden", Method.GET), profile.compile(null));
assertEquals("original", query.properties().get("a"));
}
@Test
- public void testSimpleInstanceOverridableWithVariants2() {
+ void testSimpleInstanceOverridableWithVariants2() {
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"x"});
- profile.set("a", "original", new String[] {"x1"}, null);
+ profile.setDimensions(new String[]{"x"});
+ profile.set("a", "original", new String[]{"x1"}, null);
profile.setOverridable("a", false, DimensionValues.empty);
assertFalse(profile.isDeclaredOverridable("a", null));
Query query = new Query(HttpRequest.createTestRequest("?x=x1&a=overridden", Method.GET), profile.compile(null));
- assertEquals("original",query.properties().get("a"));
+ assertEquals("original", query.properties().get("a"));
}
/** Tests having both an explicit reference and an override */
@Test
- public void testExplicitReferenceOverride() {
+ void testExplicitReferenceOverride() {
QueryProfile a1 = new QueryProfile("a1");
- a1.set("b","a1.b", null);
+ a1.set("b", "a1.b", null);
QueryProfile profile = new QueryProfile("test");
- profile.set("a",a1, null);
- profile.set("a.b","a.b", null);
+ profile.set("a", a1, null);
+ profile.set("a.b", "a.b", null);
assertEquals("a.b", profile.compile(null).get("a.b"));
}
@Test
- public void testSettingNonLeaf1() {
- QueryProfile p=new QueryProfile("test");
- p.set("a","a-value", null);
- p.set("a.b","a.b-value", null);
+ void testSettingNonLeaf1() {
+ QueryProfile p = new QueryProfile("test");
+ p.set("a", "a-value", null);
+ p.set("a.b", "a.b-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertEquals("a-value", cp.get("a"));
@@ -415,10 +411,10 @@ public class QueryProfileTestCase {
}
@Test
- public void testSettingNonLeaf2() {
+ void testSettingNonLeaf2() {
QueryProfile p = new QueryProfile("test");
- p.set("a.b","a.b-value", null);
- p.set("a","a-value", null);
+ p.set("a.b", "a.b-value", null);
+ p.set("a", "a-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertEquals("a-value", cp.get("a"));
@@ -426,48 +422,48 @@ public class QueryProfileTestCase {
}
@Test
- public void testSettingNonLeaf3a() {
+ void testSettingNonLeaf3a() {
QueryProfile p = new QueryProfile("test");
- p.setDimensions(new String[] {"x"});
- p.set("a.b","a.b-value", null);
- p.set("a","a-value",new String[] {"x1"}, null);
+ p.setDimensions(new String[]{"x"});
+ p.set("a.b", "a.b-value", null);
+ p.set("a", "a-value", new String[]{"x1"}, null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertNull(p.get("a"));
assertEquals("a.b-value", cp.get("a.b"));
- assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
- assertEquals("a.b-value", cp.get("a.b", new String[] {"x1"}));
+ assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
+ assertEquals("a.b-value", cp.get("a.b", new String[]{"x1"}));
}
@Test
- public void testSettingNonLeaf3b() {
+ void testSettingNonLeaf3b() {
QueryProfile p = new QueryProfile("test");
- p.setDimensions(new String[] {"x"});
- p.set("a","a-value",new String[] {"x1"}, null);
- p.set("a.b","a.b-value", null);
+ p.setDimensions(new String[]{"x"});
+ p.set("a", "a-value", new String[]{"x1"}, null);
+ p.set("a.b", "a.b-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertNull(cp.get("a"));
assertEquals("a.b-value", cp.get("a.b"));
- assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
- assertEquals("a.b-value", cp.get("a.b",new String[] {"x1"}));
+ assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
+ assertEquals("a.b-value", cp.get("a.b", new String[]{"x1"}));
}
@Test
- public void testSettingNonLeaf4a() {
+ void testSettingNonLeaf4a() {
QueryProfile p = new QueryProfile("test");
- p.setDimensions(new String[] {"x"});
- p.set("a.b","a.b-value",new String[] {"x1"}, null);
- p.set("a","a-value", null);
+ p.setDimensions(new String[]{"x"});
+ p.set("a.b", "a.b-value", new String[]{"x1"}, null);
+ p.set("a", "a-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertEquals("a-value", cp.get("a"));
assertNull(cp.get("a.b"));
- assertEquals("a-value", cp.get("a",new String[] {"x1"}));
- assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
+ assertEquals("a-value", cp.get("a", new String[]{"x1"}));
+ assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
}
public void testSettingNonLeaf4b() {
@@ -485,36 +481,36 @@ public class QueryProfileTestCase {
}
@Test
- public void testSettingNonLeaf5() {
+ void testSettingNonLeaf5() {
QueryProfile p = new QueryProfile("test");
- p.setDimensions(new String[] {"x"});
- p.set("a.b","a.b-value",new String[] {"x1"}, null);
- p.set("a","a-value",new String[] {"x1"}, null);
+ p.setDimensions(new String[]{"x"});
+ p.set("a.b", "a.b-value", new String[]{"x1"}, null);
+ p.set("a", "a-value", new String[]{"x1"}, null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertNull(cp.get("a"));
assertNull(cp.get("a.b"));
- assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
- assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
+ assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
+ assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
}
@Test
- public void testListingWithNonLeafs() {
+ void testListingWithNonLeafs() {
QueryProfile p = new QueryProfile("test");
- p.set("a","a-value", null);
- p.set("a.b","a.b-value", null);
+ p.set("a", "a-value", null);
+ p.set("a.b", "a.b-value", null);
Map<String, Object> values = p.compile(null).listValues("a");
assertEquals(2, values.size());
- p.set("a","a-value", null);
+ p.set("a", "a-value", null);
assertEquals("a.b-value", values.get("b"));
}
@Test
- public void testListingSources() {
+ void testListingSources() {
QueryProfile p = new QueryProfile("test");
- p.set("a","a-value", null);
- p.set("a.b","a.b-value", null);
+ p.set("a", "a-value", null);
+ p.set("a.b", "a.b-value", null);
{
Map<String, ValueWithSource> values = p.compile(null).listValuesWithSources(new CompoundName(""), new HashMap<>(), null);
@@ -534,30 +530,30 @@ public class QueryProfileTestCase {
}
@Test
- public void testRankTypeNames() {
- QueryProfile p = new QueryProfile("test");
- p.set("a.$b","foo", null);
- p.set("a.query(b)", "bar", null);
- p.set("a.b.default-index", "fuu", null);
- CompiledQueryProfile cp = p.compile(null);
-
- assertEquals("foo", cp.get("a.$b"));
- assertEquals("bar", cp.get("a.query(b)"));
- assertEquals("fuu", cp.get("a.b.default-index"));
-
- Map<String,Object> p1 = cp.listValues("");
- assertEquals("foo", p1.get("a.$b"));
- assertEquals("bar", p1.get("a.query(b)"));
- assertEquals("fuu", p1.get("a.b.default-index"));
-
- Map<String,Object> p2 = cp.listValues("a");
- assertEquals("foo", p2.get("$b"));
- assertEquals("bar", p2.get("query(b)"));
- assertEquals("fuu", p2.get("b.default-index"));
+ void testRankTypeNames() {
+ QueryProfile p = new QueryProfile("test");
+ p.set("a.$b", "foo", null);
+ p.set("a.query(b)", "bar", null);
+ p.set("a.b.default-index", "fuu", null);
+ CompiledQueryProfile cp = p.compile(null);
+
+ assertEquals("foo", cp.get("a.$b"));
+ assertEquals("bar", cp.get("a.query(b)"));
+ assertEquals("fuu", cp.get("a.b.default-index"));
+
+ Map<String, Object> p1 = cp.listValues("");
+ assertEquals("foo", p1.get("a.$b"));
+ assertEquals("bar", p1.get("a.query(b)"));
+ assertEquals("fuu", p1.get("a.b.default-index"));
+
+ Map<String, Object> p2 = cp.listValues("a");
+ assertEquals("foo", p2.get("$b"));
+ assertEquals("bar", p2.get("query(b)"));
+ assertEquals("fuu", p2.get("b.default-index"));
}
@Test
- public void testQueryProfileInlineValueReassignment() {
+ void testQueryProfileInlineValueReassignment() {
QueryProfile p = new QueryProfile("test");
p.set("source.rel.params.query", "%{model.queryString}", null);
p.freeze();
@@ -570,9 +566,9 @@ public class QueryProfileTestCase {
}
@Test
- public void testQueryProfileInlineValueReassignmentSimpleName() {
+ void testQueryProfileInlineValueReassignmentSimpleName() {
QueryProfile p = new QueryProfile("test");
- p.set("key","%{model.queryString}", null);
+ p.set("key", "%{model.queryString}", null);
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?query=foo", Method.GET), p.compile(null));
assertEquals("foo", q.properties().get("key"));
@@ -583,7 +579,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testQueryProfileInlineValueReassignmentSimpleNameGenericProperty() {
+ void testQueryProfileInlineValueReassignmentSimpleNameGenericProperty() {
QueryProfile p = new QueryProfile("test");
p.set("key", "%{value}", null);
p.freeze();
@@ -596,7 +592,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testQueryProfileModelValueListing() {
+ void testQueryProfileModelValueListing() {
QueryProfile p = new QueryProfile("test");
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?query=bar", Method.GET), p.compile(null));
@@ -608,21 +604,21 @@ public class QueryProfileTestCase {
}
@Test
- public void testEmptyBoolean() {
+ void testEmptyBoolean() {
QueryProfile p = new QueryProfile("test");
- p.setDimensions(new String[] {"x","y"});
- p.set("clustering.something","bar", null);
- p.set("clustering.something","bar", new String[] {"x1","y1"}, null);
+ p.setDimensions(new String[]{"x", "y"});
+ p.set("clustering.something", "bar", null);
+ p.set("clustering.something", "bar", new String[]{"x1", "y1"}, null);
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?x=x1&y=y1&query=bar&clustering.timeline.kano=tur&" +
- "clustering.enable=true&clustering.timeline.bucketspec=-" +
- "7d/3h&clustering.timeline.tophit=false&clustering.timeli" +
- "ne=true", Method.GET), p.compile(null));
+ "clustering.enable=true&clustering.timeline.bucketspec=-" +
+ "7d/3h&clustering.timeline.tophit=false&clustering.timeli" +
+ "ne=true", Method.GET), p.compile(null));
assertTrue(q.properties().getBoolean("clustering.timeline", false));
}
@Test
- public void testSubstitutionInTrace() {
+ void testSubstitutionInTrace() {
QueryProfile profile = new QueryProfile("test");
profile.set("property", "%{foo}", null);
CompiledQueryProfile cProfile = profile.compile(null);
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java
index 3e1a101628c..43078db66d0 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java
@@ -5,13 +5,13 @@ package com.yahoo.search.query.profile.test;
import com.yahoo.search.query.profile.DimensionValues;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Tony Vaagenes
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals;
public class QueryProfileVariantsCloneTestCase {
@Test
- public void test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning() {
+ void test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning() {
Map<String, String> dimensionBinding = createDimensionBinding("location", "norway");
QueryProfile profile = new QueryProfile("profile");
@@ -32,10 +32,10 @@ public class QueryProfileVariantsCloneTestCase {
CompiledQueryProfile clone = profile.compile(null).clone();
assertEquals(profile.get("interior", dimensionBinding, null),
- clone.get("interior", dimensionBinding));
+ clone.get("interior", dimensionBinding));
assertEquals(profile.get("interior.leaf", dimensionBinding, null),
- clone.get("interior.leaf", dimensionBinding));
+ clone.get("interior.leaf", dimensionBinding));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
index 3cf2949f33c..1a6cfee75a5 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
@@ -19,8 +19,8 @@ import com.yahoo.search.query.profile.QueryProfileVariant;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.ValueWithSource;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -28,9 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -38,75 +36,75 @@ import static org.junit.Assert.assertTrue;
public class QueryProfileVariantsTestCase {
@Test
- public void testSimple() {
+ void testSimple() {
QueryProfile profile = new QueryProfile("a");
- profile.set("a","a.deflt", null);
- profile.setDimensions(new String[] {"x","y","z"});
- profile.set("a","a.1.*.*", new String[] {"x1",null,null}, null);
- profile.set("a","a.1.*.1", new String[] {"x1",null,"z1"}, null);
- profile.set("a","a.1.*.5", new String[] {"x1",null,"z5"}, null);
- profile.set("a","a.1.1.*", new String[] {"x1","y1",null}, null);
- profile.set("a","a.1.5.*", new String[] {"x1","y5",null}, null);
- profile.set("a","a.1.1.1", new String[] {"x1","y1","z1"}, null);
- profile.set("a","a.2.1.1", new String[] {"x2","y1","z1"}, null);
- profile.set("a","a.1.2.2", new String[] {"x1","y2","z2"}, null);
- profile.set("a","a.1.2.3", new String[] {"x1","y2","z3"}, null);
- profile.set("a","a.2.*.*", new String[] {"x2" }, null); // Same as ,null,null
+ profile.set("a", "a.deflt", null);
+ profile.setDimensions(new String[]{"x", "y", "z"});
+ profile.set("a", "a.1.*.*", new String[]{"x1", null, null}, null);
+ profile.set("a", "a.1.*.1", new String[]{"x1", null, "z1"}, null);
+ profile.set("a", "a.1.*.5", new String[]{"x1", null, "z5"}, null);
+ profile.set("a", "a.1.1.*", new String[]{"x1", "y1", null}, null);
+ profile.set("a", "a.1.5.*", new String[]{"x1", "y5", null}, null);
+ profile.set("a", "a.1.1.1", new String[]{"x1", "y1", "z1"}, null);
+ profile.set("a", "a.2.1.1", new String[]{"x2", "y1", "z1"}, null);
+ profile.set("a", "a.1.2.2", new String[]{"x1", "y2", "z2"}, null);
+ profile.set("a", "a.1.2.3", new String[]{"x1", "y2", "z3"}, null);
+ profile.set("a", "a.2.*.*", new String[]{"x2" }, null); // Same as ,null,null
CompiledQueryProfile cprofile = profile.compile(null);
// Perfect matches
- assertGet("a.deflt","a", new String[] {null,null,null}, profile, cprofile);
- assertGet("a.1.*.*","a", new String[] {"x1",null,null}, profile, cprofile);
- assertGet("a.1.1.*","a", new String[] {"x1","y1",null}, profile, cprofile);
- assertGet("a.1.5.*","a", new String[] {"x1","y5",null}, profile, cprofile);
- assertGet("a.1.*.1","a", new String[] {"x1",null,"z1"}, profile, cprofile);
- assertGet("a.1.*.5","a", new String[] {"x1",null,"z5"}, profile, cprofile);
- assertGet("a.1.1.1","a", new String[] {"x1","y1","z1"}, profile, cprofile);
- assertGet("a.2.1.1","a", new String[] {"x2","y1","z1"}, profile, cprofile);
- assertGet("a.1.2.2","a", new String[] {"x1","y2","z2"}, profile, cprofile);
- assertGet("a.1.2.3","a", new String[] {"x1","y2","z3"}, profile, cprofile);
- assertGet("a.2.*.*","a", new String[] {"x2",null,null}, profile, cprofile);
+ assertGet("a.deflt", "a", new String[]{null, null, null}, profile, cprofile);
+ assertGet("a.1.*.*", "a", new String[]{"x1", null, null}, profile, cprofile);
+ assertGet("a.1.1.*", "a", new String[]{"x1", "y1", null}, profile, cprofile);
+ assertGet("a.1.5.*", "a", new String[]{"x1", "y5", null}, profile, cprofile);
+ assertGet("a.1.*.1", "a", new String[]{"x1", null, "z1"}, profile, cprofile);
+ assertGet("a.1.*.5", "a", new String[]{"x1", null, "z5"}, profile, cprofile);
+ assertGet("a.1.1.1", "a", new String[]{"x1", "y1", "z1"}, profile, cprofile);
+ assertGet("a.2.1.1", "a", new String[]{"x2", "y1", "z1"}, profile, cprofile);
+ assertGet("a.1.2.2", "a", new String[]{"x1", "y2", "z2"}, profile, cprofile);
+ assertGet("a.1.2.3", "a", new String[]{"x1", "y2", "z3"}, profile, cprofile);
+ assertGet("a.2.*.*", "a", new String[]{"x2", null, null}, profile, cprofile);
// Wildcard matches
- assertGet("a.deflt","a", new String[] {"x?","y?","z?"}, profile, cprofile);
- assertGet("a.deflt","a", new String[] {"x?","y1","z1"}, profile, cprofile);
- assertGet("a.1.*.*","a", new String[] {"x1","y?","z?"}, profile, cprofile);
- assertGet("a.1.*.*","a", new String[] {"x1","y?","z?"}, profile, cprofile);
- assertGet("a.1.1.*","a", new String[] {"x1","y1","z?"}, profile, cprofile);
- assertGet("a.1.*.1","a", new String[] {"x1","y?","z1"}, profile, cprofile);
- assertGet("a.1.5.*","a", new String[] {"x1","y5","z?"}, profile, cprofile);
- assertGet("a.1.*.5","a", new String[] {"x1","y?","z5"}, profile, cprofile);
- assertGet("a.1.5.*","a", new String[] {"x1","y5","z5"}, profile, cprofile); // Left dimension gets precedence
- assertGet("a.2.*.*","a", new String[] {"x2","y?","z?"}, profile, cprofile);
+ assertGet("a.deflt", "a", new String[]{"x?", "y?", "z?"}, profile, cprofile);
+ assertGet("a.deflt", "a", new String[]{"x?", "y1", "z1"}, profile, cprofile);
+ assertGet("a.1.*.*", "a", new String[]{"x1", "y?", "z?"}, profile, cprofile);
+ assertGet("a.1.*.*", "a", new String[]{"x1", "y?", "z?"}, profile, cprofile);
+ assertGet("a.1.1.*", "a", new String[]{"x1", "y1", "z?"}, profile, cprofile);
+ assertGet("a.1.*.1", "a", new String[]{"x1", "y?", "z1"}, profile, cprofile);
+ assertGet("a.1.5.*", "a", new String[]{"x1", "y5", "z?"}, profile, cprofile);
+ assertGet("a.1.*.5", "a", new String[]{"x1", "y?", "z5"}, profile, cprofile);
+ assertGet("a.1.5.*", "a", new String[]{"x1", "y5", "z5"}, profile, cprofile); // Left dimension gets precedence
+ assertGet("a.2.*.*", "a", new String[]{"x2", "y?", "z?"}, profile, cprofile);
}
@Test
- public void testReferenceInVariant() {
+ void testReferenceInVariant() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] { "d1" });
+ test.setDimensions(new String[]{"d1"});
registry.register(test);
QueryProfile references = new QueryProfile("referenced");
- references.setDimensions(new String[] { "d1" });
+ references.setDimensions(new String[]{"d1"});
registry.register(references);
QueryProfile other = new QueryProfile("other");
- other.setDimensions(new String[] { "d1" });
+ other.setDimensions(new String[]{"d1"});
registry.register(other);
- test.set( "a", references, new String[] { "d1v"}, registry);
- test.set( "a.b", "test-value", new String[] { "d1v"}, registry);
- other.set( "a", references, new String[] { "d1v"}, registry);
- other.set("a.b", "other-value", new String[] { "d1v"}, registry);
+ test.set("a", references, new String[]{"d1v"}, registry);
+ test.set("a.b", "test-value", new String[]{"d1v"}, registry);
+ other.set("a", references, new String[]{"d1v"}, registry);
+ other.set("a.b", "other-value", new String[]{"d1v"}, registry);
- assertEquals("test-value", test.get("a.b", new String[] { "d1v"}));
- assertEquals("other-value", other.get("a.b", new String[] { "d1v"}));
- assertNull(references.get("b", new String[] { "d1v"}));
+ assertEquals("test-value", test.get("a.b", new String[]{"d1v"}));
+ assertEquals("other-value", other.get("a.b", new String[]{"d1v"}));
+ assertNull(references.get("b", new String[]{"d1v"}));
var cRegistry = registry.compile();
assertEquals("test-value",
- cRegistry.getComponent("test").get("a.b", Map.of("d1", "d1v")));
+ cRegistry.getComponent("test").get("a.b", Map.of("d1", "d1v")));
}
/**
@@ -114,7 +112,7 @@ public class QueryProfileVariantsTestCase {
* and also setting a value within that variants subspace.
*/
@Test
- public void testVariantReference() {
+ void testVariantReference() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile parent = new QueryProfile("parent");
@@ -123,24 +121,24 @@ public class QueryProfileVariantsTestCase {
QueryProfile referenced = new QueryProfile("referenced");
referenced.addInherited(parent);
- referenced.setDimensions(new String[] {"d2", "d3"});
+ referenced.setDimensions(new String[]{"d2", "d3"});
registry.register(referenced);
QueryProfile base = new QueryProfile("base");
base.setDimensions(new String[]{"d1", "d2", "d3"});
- base.set("a", referenced, new String[] {null, null, "d3-val"}, registry);
- assertEquals("Variant dimensions are not overridden by the referenced dimensions",
- "[d1, d2, d3]",
- ((QueryProfile)base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString());
- base.set("a.b", 1, new String[] {null, null, "d3-val"}, registry);
+ base.set("a", referenced, new String[]{null, null, "d3-val"}, registry);
+ assertEquals("[d1, d2, d3]",
+ ((QueryProfile) base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString(),
+ "Variant dimensions are not overridden by the referenced dimensions");
+ base.set("a.b", 1, new String[]{null, null, "d3-val"}, registry);
QueryProfileVariant aVariants = base.getVariants().getVariants().get(0);
- assertEquals("Variant dimensions are not overridden by the referenced dimensions",
- "[d1, d2, d3]",
- ((QueryProfile)base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString());
+ assertEquals("[d1, d2, d3]",
+ ((QueryProfile) base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString(),
+ "Variant dimensions are not overridden by the referenced dimensions");
}
@Test
- public void testReference() {
+ void testReference() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
registry.register(test);
@@ -151,9 +149,9 @@ public class QueryProfileVariantsTestCase {
QueryProfile other = new QueryProfile("other");
registry.register(other);
- test.set( "a", references, registry);
- test.set( "a.b", "test-value", registry);
- other.set( "a", references, registry);
+ test.set("a", references, registry);
+ test.set("a.b", "test-value", registry);
+ other.set("a", references, registry);
other.set("a.b", "other-value", registry);
assertEquals("test-value", test.get("a.b"));
@@ -162,21 +160,21 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantInReferencedAndParentWithOtherMatchingVariant() {
+ void testVariantInReferencedAndParentWithOtherMatchingVariant() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] { "x", "y" } );
- parent.set("other", "otherValue", new String[] { "x1", "y1" }, registry );
+ parent.setDimensions(new String[]{"x", "y"});
+ parent.set("other", "otherValue", new String[]{"x1", "y1"}, registry);
QueryProfile profile = new QueryProfile("test");
profile.addInherited(parent);
QueryProfile referenced = new QueryProfile("referenced");
- referenced.setDimensions(new String[] { "x", "y", "z" });
+ referenced.setDimensions(new String[]{"x", "y", "z"});
registry.register(parent);
registry.register(profile);
registry.register(referenced);
profile.set("a.b", referenced, registry);
referenced.set("c", "default_value", registry);
- referenced.set("c", "variant_value", new String[] { "x1", null, "z1" }, registry);
+ referenced.set("c", "variant_value", new String[]{"x1", null, "z1"}, registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
@@ -186,9 +184,9 @@ public class QueryProfileVariantsTestCase {
{
Map<String, ValueWithSource> values = cRegistry.findQueryProfile("test")
- .listValuesWithSources(new CompoundName(""),
- new HashMap<>(),
- null);
+ .listValuesWithSources(new CompoundName(""),
+ new HashMap<>(),
+ null);
assertEquals(1, values.size());
assertEquals("default_value", values.get("a.b.c").value());
assertEquals("referenced", values.get("a.b.c").source());
@@ -197,9 +195,9 @@ public class QueryProfileVariantsTestCase {
{
Map<String, ValueWithSource> values = cRegistry.findQueryProfile("test")
- .listValuesWithSources(new CompoundName(""),
- toMap("x=x1", "y=y1", "z=z1"),
- null);
+ .listValuesWithSources(new CompoundName(""),
+ toMap("x=x1", "y=y1", "z=z1"),
+ null);
assertEquals(2, values.size());
assertEquals("variant_value", values.get("a.b.c").value());
assertEquals("referenced", values.get("a.b.c").source());
@@ -212,16 +210,16 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testSwitchingDimensionOrderInReferencedVariantWithFullOverlap() {
+ void testSwitchingDimensionOrderInReferencedVariantWithFullOverlap() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "x", "i", "j", "y" });
+ profile.setDimensions(new String[]{"x", "i", "j", "y"});
QueryProfile referenced = new QueryProfile("referenced");
- referenced.setDimensions(new String[] { "y", "x" });
+ referenced.setDimensions(new String[]{"y", "x"});
registry.register(profile);
registry.register(referenced);
- profile.set("a.b", referenced, new String[] { "x1", "i1", "j1", "y1" }, registry);
- referenced.set("c", "variant_value", new String[] { "y1" }, registry);
+ profile.set("a.b", referenced, new String[]{"x1", "i1", "j1", "y1"}, registry);
+ referenced.set("c", "variant_value", new String[]{"y1"}, registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
@@ -230,16 +228,16 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testSameDimensionOrderInReferencedVariantWithPartialOverlap() {
+ void testSameDimensionOrderInReferencedVariantWithPartialOverlap() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "x", "i", "j", "y" });
+ profile.setDimensions(new String[]{"x", "i", "j", "y"});
QueryProfile referenced = new QueryProfile("referenced");
- referenced.setDimensions(new String[] { "x", "y" });
+ referenced.setDimensions(new String[]{"x", "y"});
registry.register(profile);
registry.register(referenced);
- profile.set("a.b", referenced, new String[] { "x1", "i1", "j1" }, registry);
- referenced.set("c", "variant_value", new String[] { null, "y1" }, registry);
+ profile.set("a.b", referenced, new String[]{"x1", "i1", "j1"}, registry);
+ referenced.set("c", "variant_value", new String[]{null, "y1"}, registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
@@ -247,18 +245,19 @@ public class QueryProfileVariantsTestCase {
assertEquals("variant_value", new Query("?x=x1&i=i1&j=j1&y=y1", cTest).properties().get("a.b.c"));
}
+ // Switching order is not supported
@Test
- @Ignore // Switching order is not supported
- public void testSwitchingDimensionOrderInReferencedVariantWithPartialOverlap() {
+ @Disabled
+ void testSwitchingDimensionOrderInReferencedVariantWithPartialOverlap() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "x", "i", "j", "y" });
+ profile.setDimensions(new String[]{"x", "i", "j", "y"});
QueryProfile referenced = new QueryProfile("referenced");
- referenced.setDimensions(new String[] { "y", "x" });
+ referenced.setDimensions(new String[]{"y", "x"});
registry.register(profile);
registry.register(referenced);
- profile.set("a.b", referenced, new String[] { "x1", "i1", "j1" }, registry);
- referenced.set("c", "variant_value", new String[] { "y1" }, registry);
+ profile.set("a.b", referenced, new String[]{"x1", "i1", "j1"}, registry);
+ referenced.set("c", "variant_value", new String[]{"y1"}, registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
@@ -267,12 +266,12 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testMultipleMatchingVariantsAndDefault() {
+ void testMultipleMatchingVariantsAndDefault() {
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "a", "b" });
+ profile.setDimensions(new String[]{"a", "b"});
profile.set("property1", "property1_default", null);
- profile.set("property1", "property1_variantB", new String[] { null, "b1" }, null);
- profile.set("property2", "property2_variantA", new String[] { "a1", null }, null);
+ profile.set("property1", "property1_variantB", new String[]{null, "b1"}, null);
+ profile.set("property2", "property2_variantA", new String[]{"a1", null}, null);
CompiledQueryProfile cProfile = profile.compile(null);
Query query = new Query("?a=a1&b=b1&b=b1", cProfile);
@@ -281,16 +280,16 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testInheritedVariants() {
+ void testInheritedVariants() {
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] { "parentDim" });
+ parent.setDimensions(new String[]{"parentDim"});
parent.set("property", "defaultValue", null);
- parent.set("property", "variantValue", new String[] { "V2" }, null);
+ parent.set("property", "variantValue", new String[]{"V2"}, null);
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
- child.setDimensions(new String[] { "childDim" });
- child.set("otherProperty", "otherPropertyValue", new String[] { "V1" }, null);
+ child.setDimensions(new String[]{"childDim"});
+ child.set("otherProperty", "otherPropertyValue", new String[]{"V1"}, null);
CompiledQueryProfile cchild = child.compile(null);
assertEquals("defaultValue", new Query("?query=test", cchild).properties().get("property"));
@@ -301,19 +300,19 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testInheritedVariantsMultipleInheritance() {
+ void testInheritedVariantsMultipleInheritance() {
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] { "parentDim" });
+ parent.setDimensions(new String[]{"parentDim"});
parent.set("property", "defaultValue", null);
- parent.set("property", "variantValue", new String[] { "V2" }, null);
+ parent.set("property", "variantValue", new String[]{"V2"}, null);
QueryProfile otherParent = new QueryProfile("otherParent");
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
child.addInherited(otherParent);
- child.setDimensions(new String[] { "childDim" });
- child.set("otherProperty", "otherPropertyValue", new String[] { "V1" }, null);
+ child.setDimensions(new String[]{"childDim"});
+ child.set("otherProperty", "otherPropertyValue", new String[]{"V1"}, null);
CompiledQueryProfile cchild = child.compile(null);
assertEquals("defaultValue", new Query("?query=test", cchild).properties().get("property"));
@@ -324,12 +323,12 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantsOfInlineCompound() {
+ void testVariantsOfInlineCompound() {
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"x"});
+ profile.setDimensions(new String[]{"x"});
profile.set("a.b", "a.b", null);
- profile.set("a.b", "a.b.x1", new String[] {"x1"}, null);
- profile.set("a.b", "a.b.x2", new String[] {"x2"}, null);
+ profile.set("a.b", "a.b.x1", new String[]{"x1"}, null);
+ profile.set("a.b", "a.b.x2", new String[]{"x2"}, null);
CompiledQueryProfile cprofile = profile.compile(null);
@@ -339,13 +338,13 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testOverlappingProfiles() {
+ void testOverlappingProfiles() {
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"region", "model", "bucket"});
- profile.set("a", "us,nokia,* : a", new String[] {"us", "nokia", null }, null);
- profile.set("b", "us,nokia,* : b", new String[] {"us", "nokia", null }, null);
- profile.set("c", "us,*,bucket1: c", new String[] {"us", null, "bucket1"}, null);
- profile.set("d", "us,*,bucket1: d", new String[] {"us", null, "bucket1"}, null);
+ profile.setDimensions(new String[]{"region", "model", "bucket"});
+ profile.set("a", "us,nokia,* : a", new String[]{"us", "nokia", null }, null);
+ profile.set("b", "us,nokia,* : b", new String[]{"us", "nokia", null }, null);
+ profile.set("c", "us,*,bucket1: c", new String[]{"us", null, "bucket1"}, null);
+ profile.set("d", "us,*,bucket1: d", new String[]{"us", null, "bucket1"}, null);
CompiledQueryProfile cprofile = profile.compile(null);
var parameters = toMap("region=us", "model=nokia", "bucket=bucket1");
@@ -360,15 +359,15 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantsOfExplicitCompound() {
+ void testVariantsOfExplicitCompound() {
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a.b", null);
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"x"});
+ profile.setDimensions(new String[]{"x"});
profile.set("a", a1, null);
- profile.set("a.b", "a.b.x1", new String[] {"x1"}, null);
- profile.set("a.b", "a.b.x2", new String[] {"x2"}, null);
+ profile.set("a.b", "a.b.x1", new String[]{"x1"}, null);
+ profile.set("a.b", "a.b.x2", new String[]{"x2"}, null);
CompiledQueryProfile cprofile = profile.compile(null);
@@ -378,11 +377,11 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testCompound() {
+ void testCompound() {
// Configuration phase
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"x","y"});
+ profile.setDimensions(new String[]{"x", "y"});
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a1.b.default", null);
@@ -396,23 +395,23 @@ public class QueryProfileVariantsTestCase {
a2.set("d", "a2.d.default", null);
a2.set("e", "a2.e.default", null);
- profile.set("a",a1, null); // Must set profile references before overrides
+ profile.set("a", a1, null); // Must set profile references before overrides
profile.set("a.b", "a.b.default-override", null);
profile.set("a.c", "a.c.default-override", null);
profile.set("a.d", "a.d.default-override", null);
profile.set("a.g", "a.g.default-override", null);
- String[] d1 = new String[] { "x1","y1" };
+ String[] d1 = new String[]{"x1", "y1"};
profile.set("a", a1, d1, null);
profile.set("a.b", "x1.y1.a.b.default-override", d1, null);
profile.set("a.c", "x1.y1.a.c.default-override", d1, null);
profile.set("a.g", "x1.y1.a.g.default-override", d1, null); // This value is never manifest because the runtime override overrides all variants
- String[] d2 = new String[] { "x1","y2" };
- profile.set("a.b","x1.y2.a.b.default-override", d2, null);
- profile.set("a.c","x1.y2.a.c.default-override", d2, null);
+ String[] d2 = new String[]{"x1", "y2"};
+ profile.set("a.b", "x1.y2.a.b.default-override", d2, null);
+ profile.set("a.c", "x1.y2.a.c.default-override", d2, null);
- String[] d3 = new String[] { "x2","y1" };
+ String[] d3 = new String[]{"x2", "y1"};
profile.set("a", a2, d3, null);
profile.set("a.b", "x2.y1.a.b.default-override", d3, null);
profile.set("a.c", "x2.y1.a.c.default-override", d3, null);
@@ -466,39 +465,39 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantNotInBase() {
+ void testVariantNotInBase() {
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
- test.set("InX1Only", "x1", new String[] { "x1" }, null);
+ test.setDimensions(new String[]{"x"});
+ test.set("InX1Only", "x1", new String[]{"x1"}, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals("x1", ctest.get("InX1Only", toMap("x=x1")));
- assertEquals(null, ctest.get("InX1Only", toMap("x=x2")));
- assertEquals(null, ctest.get("InX1Only"));
+ assertNull(ctest.get("InX1Only", toMap("x=x2")));
+ assertNull(ctest.get("InX1Only"));
}
@Test
- public void testVariantNotInBaseSpaceVariantValue() {
+ void testVariantNotInBaseSpaceVariantValue() {
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] { "x" });
- test.set("InX1Only", "x1", new String[] { "x 1" }, null);
+ test.setDimensions(new String[]{"x"});
+ test.set("InX1Only", "x1", new String[]{"x 1"}, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals("x1", ctest.get("InX1Only", toMap("x=x 1")));
- assertEquals(null, ctest.get("InX1Only", toMap("x=x 2")));
- assertEquals(null, ctest.get("InX1Only"));
+ assertNull(ctest.get("InX1Only", toMap("x=x 2")));
+ assertNull(ctest.get("InX1Only"));
}
@Test
- public void testDimensionsInSuperType() {
+ void testDimensionsInSuperType() {
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] {"x", "y"});
+ parent.setDimensions(new String[]{"x", "y"});
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
child.set("a", "a.default", null);
- child.set("a", "a.x1.y1", new String[] {"x1", "y1"}, null);
- child.set("a", "a.x1.y2", new String[] {"x1", "y2"}, null);
+ child.set("a", "a.x1.y1", new String[]{"x1", "y1"}, null);
+ child.set("a", "a.x1.y2", new String[]{"x1", "y2"}, null);
CompiledQueryProfile cchild = child.compile(null);
@@ -508,15 +507,15 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testDimensionsInSuperTypeRuntime() {
+ void testDimensionsInSuperTypeRuntime() {
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] { "x", "y" });
+ parent.setDimensions(new String[]{"x", "y"});
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
child.set("a", "a.default", null);
child.set("a", "a.x1.y1", new String[]{"x1", "y1"}, null);
child.set("a", "a.x1.y2", new String[]{"x1", "y2"}, null);
- Properties overridable=new QueryProfileProperties(child.compile(null));
+ Properties overridable = new QueryProfileProperties(child.compile(null));
assertEquals("a.default", child.get("a"));
assertEquals("a.x1.y1", overridable.get("a", toMap("x=x1", "y=y1")));
@@ -524,220 +523,220 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantsAreResolvedBeforeInheritance() {
- QueryProfile parent=new QueryProfile("parent");
- parent.setDimensions(new String[] {"x","y"});
- parent.set("a","p.a.default", null);
- parent.set("a","p.a.x1.y1",new String[] {"x1","y1"}, null);
- parent.set("a","p.a.x1.y2",new String[] {"x1","y2"}, null);
- parent.set("b","p.b.default", null);
- parent.set("b","p.b.x1.y1",new String[] {"x1","y1"}, null);
- parent.set("b","p.b.x1.y2",new String[] {"x1","y2"}, null);
- QueryProfile child=new QueryProfile("child");
- child.setDimensions(new String[] {"x","y"});
+ void testVariantsAreResolvedBeforeInheritance() {
+ QueryProfile parent = new QueryProfile("parent");
+ parent.setDimensions(new String[]{"x", "y"});
+ parent.set("a", "p.a.default", null);
+ parent.set("a", "p.a.x1.y1", new String[]{"x1", "y1"}, null);
+ parent.set("a", "p.a.x1.y2", new String[]{"x1", "y2"}, null);
+ parent.set("b", "p.b.default", null);
+ parent.set("b", "p.b.x1.y1", new String[]{"x1", "y1"}, null);
+ parent.set("b", "p.b.x1.y2", new String[]{"x1", "y2"}, null);
+ QueryProfile child = new QueryProfile("child");
+ child.setDimensions(new String[]{"x", "y"});
child.addInherited(parent);
- child.set("a","c.a.default", null);
- child.set("a","c.a.x1.y1",new String[] {"x1","y1"}, null);
+ child.set("a", "c.a.default", null);
+ child.set("a", "c.a.x1.y1", new String[]{"x1", "y1"}, null);
CompiledQueryProfile cchild = child.compile(null);
- assertEquals("c.a.default",cchild.get("a"));
- assertEquals("c.a.x1.y1",cchild.get("a", toMap("x=x1", "y=y1")));
- assertEquals("c.a.default",cchild.get("a", toMap("x=x1", "y=y2")));
- assertEquals("p.b.default",cchild.get("b"));
- assertEquals("p.b.x1.y1",cchild.get("b", toMap("x=x1", "y=y1")));
- assertEquals("p.b.x1.y2",cchild.get("b", toMap("x=x1", "y=y2")));
+ assertEquals("c.a.default", cchild.get("a"));
+ assertEquals("c.a.x1.y1", cchild.get("a", toMap("x=x1", "y=y1")));
+ assertEquals("c.a.default", cchild.get("a", toMap("x=x1", "y=y2")));
+ assertEquals("p.b.default", cchild.get("b"));
+ assertEquals("p.b.x1.y1", cchild.get("b", toMap("x=x1", "y=y1")));
+ assertEquals("p.b.x1.y2", cchild.get("b", toMap("x=x1", "y=y2")));
}
@Test
- public void testVariantsAreResolvedBeforeInheritanceSimplified() {
- QueryProfile parent=new QueryProfile("parent");
- parent.setDimensions(new String[] {"x","y"});
- parent.set("a","p.a.x1.y2",new String[] {"x1","y2"}, null);
+ void testVariantsAreResolvedBeforeInheritanceSimplified() {
+ QueryProfile parent = new QueryProfile("parent");
+ parent.setDimensions(new String[]{"x", "y"});
+ parent.set("a", "p.a.x1.y2", new String[]{"x1", "y2"}, null);
- QueryProfile child=new QueryProfile("child");
- child.setDimensions(new String[] {"x","y"});
+ QueryProfile child = new QueryProfile("child");
+ child.setDimensions(new String[]{"x", "y"});
child.addInherited(parent);
- child.set("a","c.a.default", null);
+ child.set("a", "c.a.default", null);
- assertEquals("c.a.default",child.compile(null).get("a", toMap("x=x1", "y=y2")));
+ assertEquals("c.a.default", child.compile(null).get("a", toMap("x=x1", "y=y2")));
}
@Test
- public void testVariantInheritance() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x","y"});
- QueryProfile defaultParent=new QueryProfile("defaultParent");
- defaultParent.set("a","a-default", null);
- QueryProfile x1Parent=new QueryProfile("x1Parent");
- x1Parent.set("a","a-x1", null);
- x1Parent.set("d","d-x1", null);
- x1Parent.set("e","e-x1", null);
- QueryProfile x1y1Parent=new QueryProfile("x1y1Parent");
- x1y1Parent.set("a","a-x1y1", null);
- QueryProfile x1y2Parent=new QueryProfile("x1y2Parent");
- x1y2Parent.set("a","a-x1y2", null);
- x1y2Parent.set("b","b-x1y2", null);
- x1y2Parent.set("c","c-x1y2", null);
+ void testVariantInheritance() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x", "y"});
+ QueryProfile defaultParent = new QueryProfile("defaultParent");
+ defaultParent.set("a", "a-default", null);
+ QueryProfile x1Parent = new QueryProfile("x1Parent");
+ x1Parent.set("a", "a-x1", null);
+ x1Parent.set("d", "d-x1", null);
+ x1Parent.set("e", "e-x1", null);
+ QueryProfile x1y1Parent = new QueryProfile("x1y1Parent");
+ x1y1Parent.set("a", "a-x1y1", null);
+ QueryProfile x1y2Parent = new QueryProfile("x1y2Parent");
+ x1y2Parent.set("a", "a-x1y2", null);
+ x1y2Parent.set("b", "b-x1y2", null);
+ x1y2Parent.set("c", "c-x1y2", null);
test.addInherited(defaultParent);
- test.addInherited(x1Parent,new String[] {"x1"});
- test.addInherited(x1y1Parent,new String[] {"x1","y1"});
- test.addInherited(x1y2Parent,new String[] {"x1","y2"});
- test.set("c","c-x1",new String[] {"x1"}, null);
- test.set("e","e-x1y2",new String[] {"x1","y2"}, null);
+ test.addInherited(x1Parent, new String[]{"x1"});
+ test.addInherited(x1y1Parent, new String[]{"x1", "y1"});
+ test.addInherited(x1y2Parent, new String[]{"x1", "y2"});
+ test.set("c", "c-x1", new String[]{"x1"}, null);
+ test.set("e", "e-x1y2", new String[]{"x1", "y2"}, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("a-default",ctest.get("a"));
- assertEquals("a-x1",ctest.get("a", toMap("x=x1")));
- assertEquals("a-x1y1",ctest.get("a", toMap("x=x1", "y=y1")));
- assertEquals("a-x1y2",ctest.get("a", toMap("x=x1", "y=y2")));
+ assertEquals("a-default", ctest.get("a"));
+ assertEquals("a-x1", ctest.get("a", toMap("x=x1")));
+ assertEquals("a-x1y1", ctest.get("a", toMap("x=x1", "y=y1")));
+ assertEquals("a-x1y2", ctest.get("a", toMap("x=x1", "y=y2")));
- assertEquals(null,ctest.get("b"));
- assertEquals(null,ctest.get("b", toMap("x=x1")));
- assertEquals(null,ctest.get("b", toMap("x=x1", "y=y1")));
- assertEquals("b-x1y2",ctest.get("b", toMap("x=x1", "y=y2")));
+ assertNull(ctest.get("b"));
+ assertNull(ctest.get("b", toMap("x=x1")));
+ assertNull(ctest.get("b", toMap("x=x1", "y=y1")));
+ assertEquals("b-x1y2", ctest.get("b", toMap("x=x1", "y=y2")));
- assertEquals(null,ctest.get("c"));
- assertEquals("c-x1",ctest.get("c", toMap("x=x1")));
- assertEquals("c-x1",ctest.get("c", toMap("x=x1", "y=y1")));
- assertEquals("c-x1y2",ctest.get("c", toMap("x=x1", "y=y2")));
+ assertNull(ctest.get("c"));
+ assertEquals("c-x1", ctest.get("c", toMap("x=x1")));
+ assertEquals("c-x1", ctest.get("c", toMap("x=x1", "y=y1")));
+ assertEquals("c-x1y2", ctest.get("c", toMap("x=x1", "y=y2")));
- assertEquals(null,ctest.get("d"));
- assertEquals("d-x1",ctest.get("d", toMap("x=x1")));
+ assertNull(ctest.get("d"));
+ assertEquals("d-x1", ctest.get("d", toMap("x=x1")));
- assertEquals("d-x1",ctest.get("d", toMap("x=x1", "y=y1")));
- assertEquals("d-x1",ctest.get("d", toMap("x=x1", "y=y2")));
+ assertEquals("d-x1", ctest.get("d", toMap("x=x1", "y=y1")));
+ assertEquals("d-x1", ctest.get("d", toMap("x=x1", "y=y2")));
- assertEquals(null,ctest.get("d"));
- assertEquals("e-x1",ctest.get("e", toMap("x=x1")));
- assertEquals("e-x1",ctest.get("e", toMap("x=x1", "y=y1")));
- assertEquals("e-x1y2",ctest.get("e", toMap("x=x1", "y=y2")));
+ assertNull(ctest.get("d"));
+ assertEquals("e-x1", ctest.get("e", toMap("x=x1")));
+ assertEquals("e-x1", ctest.get("e", toMap("x=x1", "y=y1")));
+ assertEquals("e-x1y2", ctest.get("e", toMap("x=x1", "y=y2")));
}
@Test
- public void testVariantInheritanceSimplified() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x","y"});
- QueryProfile x1y2Parent=new QueryProfile("x1y2Parent");
- x1y2Parent.set("c","c-x1y2", null);
- test.addInherited(x1y2Parent,new String[] {"x1","y2"});
- test.set("c","c-x1",new String[] {"x1"}, null);
+ void testVariantInheritanceSimplified() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x", "y"});
+ QueryProfile x1y2Parent = new QueryProfile("x1y2Parent");
+ x1y2Parent.set("c", "c-x1y2", null);
+ test.addInherited(x1y2Parent, new String[]{"x1", "y2"});
+ test.set("c", "c-x1", new String[]{"x1"}, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals(null,ctest.get("c"));
- assertEquals("c-x1",ctest.get("c", toMap("x=x1")));
+ assertNull(ctest.get("c"));
+ assertEquals("c-x1", ctest.get("c", toMap("x=x1")));
assertEquals("c-x1", ctest.get("c", toMap("x=x1", "y=y1")));
- assertEquals("c-x1y2",ctest.get("c", toMap("x=x1", "y=y2")));
+ assertEquals("c-x1y2", ctest.get("c", toMap("x=x1", "y=y2")));
}
@Test
- public void testVariantInheritanceWithCompoundReferences() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
- test.set("a.b","default-a.b", null);
+ void testVariantInheritanceWithCompoundReferences() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
+ test.set("a.b", "default-a.b", null);
- QueryProfile ac=new QueryProfile("ac");
- ac.set("a.c","referenced-a.c", null);
- test.addInherited(ac,new String[] {"x1"});
- test.set("a.b","x1-a.b",new String[] {"x1"}, null);
+ QueryProfile ac = new QueryProfile("ac");
+ ac.set("a.c", "referenced-a.c", null);
+ test.addInherited(ac, new String[]{"x1"});
+ test.set("a.b", "x1-a.b", new String[]{"x1"}, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("Basic functionality","default-a.b",ctest.get("a.b"));
- assertEquals("Inherited variance reference works","referenced-a.c",ctest.get("a.c", toMap("x=x1")));
- assertEquals("Inherited variance reference overriding works","x1-a.b",ctest.get("a.b", toMap("x=x1")));
+ assertEquals("default-a.b", ctest.get("a.b"), "Basic functionality");
+ assertEquals("referenced-a.c", ctest.get("a.c", toMap("x=x1")), "Inherited variance reference works");
+ assertEquals("x1-a.b", ctest.get("a.b", toMap("x=x1")), "Inherited variance reference overriding works");
}
@Test
- public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
- test.set("o.a.b","default-a.b", null);
+ void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
+ test.set("o.a.b", "default-a.b", null);
- QueryProfile ac=new QueryProfile("ac");
- ac.set("o.a.c","referenced-a.c", null);
- test.addInherited(ac,new String[] {"x1"});
- test.set("o.a.b","x1-a.b",new String[] {"x1"}, null);
+ QueryProfile ac = new QueryProfile("ac");
+ ac.set("o.a.c", "referenced-a.c", null);
+ test.addInherited(ac, new String[]{"x1"});
+ test.set("o.a.b", "x1-a.b", new String[]{"x1"}, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("Basic functionality","default-a.b",ctest.get("o.a.b"));
- assertEquals("Inherited variance reference works","referenced-a.c",ctest.get("o.a.c", toMap("x=x1")));
- assertEquals("Inherited variance reference overriding works","x1-a.b",ctest.get("o.a.b", toMap("x=x1")));
+ assertEquals("default-a.b", ctest.get("o.a.b"), "Basic functionality");
+ assertEquals("referenced-a.c", ctest.get("o.a.c", toMap("x=x1")), "Inherited variance reference works");
+ assertEquals("x1-a.b", ctest.get("o.a.b", toMap("x=x1")), "Inherited variance reference overriding works");
}
@Test
- public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
+ void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
- QueryProfile ac=new QueryProfile("ac");
- ac.set("a.c","referenced-a.c", null);
- test.addInherited(ac,new String[] {"x1"});
- test.set("a.b","x1-a.b",new String[] {"x1"}, null);
+ QueryProfile ac = new QueryProfile("ac");
+ ac.set("a.c", "referenced-a.c", null);
+ test.addInherited(ac, new String[]{"x1"});
+ test.set("a.b", "x1-a.b", new String[]{"x1"}, null);
- QueryProfile top=new QueryProfile("top");
- top.set("o.a.b","default-a.b", null);
- top.set("o",test, null);
+ QueryProfile top = new QueryProfile("top");
+ top.set("o.a.b", "default-a.b", null);
+ top.set("o", test, null);
CompiledQueryProfile ctop = top.compile(null);
- assertEquals("Basic functionality","default-a.b",ctop.get("o.a.b"));
- assertEquals("Inherited variance reference works","referenced-a.c",ctop.get("o.a.c", toMap("x=x1")));
- assertEquals("Inherited variance reference does not override value set in referent","default-a.b",ctop.get("o.a.b", toMap("x=x1"))); // Note: Changed from x1-a.b in 4.2.3
+ assertEquals("default-a.b", ctop.get("o.a.b"), "Basic functionality");
+ assertEquals("referenced-a.c", ctop.get("o.a.c", toMap("x=x1")), "Inherited variance reference works");
+ assertEquals("default-a.b", ctop.get("o.a.b", toMap("x=x1")), "Inherited variance reference does not override value set in referent"); // Note: Changed from x1-a.b in 4.2.3
}
@Test
- public void testVariantInheritanceOverridesBaseInheritance1() {
- QueryProfile test=new QueryProfile("test");
- QueryProfile baseInherited=new QueryProfile("baseInherited");
- baseInherited.set("a.b","baseInherited-a.b", null);
- QueryProfile variantInherited=new QueryProfile("variantInherited");
- variantInherited.set("a.b","variantInherited-a.b", null);
- test.setDimensions(new String[] {"x"});
+ void testVariantInheritanceOverridesBaseInheritance1() {
+ QueryProfile test = new QueryProfile("test");
+ QueryProfile baseInherited = new QueryProfile("baseInherited");
+ baseInherited.set("a.b", "baseInherited-a.b", null);
+ QueryProfile variantInherited = new QueryProfile("variantInherited");
+ variantInherited.set("a.b", "variantInherited-a.b", null);
+ test.setDimensions(new String[]{"x"});
test.addInherited(baseInherited);
- test.addInherited(variantInherited,new String[] {"x1"});
+ test.addInherited(variantInherited, new String[]{"x1"});
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("baseInherited-a.b",ctest.get("a.b"));
- assertEquals("variantInherited-a.b",ctest.get("a.b",toMap("x=x1")));
+ assertEquals("baseInherited-a.b", ctest.get("a.b"));
+ assertEquals("variantInherited-a.b", ctest.get("a.b", toMap("x=x1")));
}
@Test
- public void testVariantInheritanceOverridesBaseInheritance2() {
- QueryProfile test=new QueryProfile("test");
- QueryProfile baseInherited=new QueryProfile("baseInherited");
- baseInherited.set("a.b","baseInherited-a.b", null);
- QueryProfile variantInherited=new QueryProfile("variantInherited");
- variantInherited.set("a.b","variantInherited-a.b", null);
- test.setDimensions(new String[] {"x"});
+ void testVariantInheritanceOverridesBaseInheritance2() {
+ QueryProfile test = new QueryProfile("test");
+ QueryProfile baseInherited = new QueryProfile("baseInherited");
+ baseInherited.set("a.b", "baseInherited-a.b", null);
+ QueryProfile variantInherited = new QueryProfile("variantInherited");
+ variantInherited.set("a.b", "variantInherited-a.b", null);
+ test.setDimensions(new String[]{"x"});
test.addInherited(baseInherited);
- test.addInherited(variantInherited,new String[] {"x1"});
- test.set("a.c","variant-a.c",new String[] {"x1"}, null);
+ test.addInherited(variantInherited, new String[]{"x1"});
+ test.set("a.c", "variant-a.c", new String[]{"x1"}, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("baseInherited-a.b",ctest.get("a.b"));
- assertEquals("variantInherited-a.b",ctest.get("a.b", toMap("x=x1")));
- assertEquals("variant-a.c",ctest.get("a.c", toMap("x=x1")));
+ assertEquals("baseInherited-a.b", ctest.get("a.b"));
+ assertEquals("variantInherited-a.b", ctest.get("a.b", toMap("x=x1")));
+ assertEquals("variant-a.c", ctest.get("a.c", toMap("x=x1")));
}
@Test
- public void testVariantInheritanceOverridesBaseInheritanceComplex() {
- QueryProfile defaultQP=new QueryProfile("default");
- defaultQP.set("model.defaultIndex","title", null);
+ void testVariantInheritanceOverridesBaseInheritanceComplex() {
+ QueryProfile defaultQP = new QueryProfile("default");
+ defaultQP.set("model.defaultIndex", "title", null);
- QueryProfile root=new QueryProfile("root");
+ QueryProfile root = new QueryProfile("root");
root.addInherited(defaultQP);
- root.set("model.defaultIndex","default", null);
+ root.set("model.defaultIndex", "default", null);
- QueryProfile querybest=new QueryProfile("querybest");
- querybest.set("defaultIndex","title", null);
- querybest.set("queryString","best", null);
+ QueryProfile querybest = new QueryProfile("querybest");
+ querybest.set("defaultIndex", "title", null);
+ querybest.set("queryString", "best", null);
- QueryProfile multi=new QueryProfile("multi");
- multi.setDimensions(new String[] {"x"});
+ QueryProfile multi = new QueryProfile("multi");
+ multi.setDimensions(new String[]{"x"});
multi.addInherited(defaultQP);
- multi.set("model",querybest, null);
- multi.addInherited(root,new String[] {"x1"});
- multi.set("model.queryString","love",new String[] {"x1"}, null);
+ multi.set("model", querybest, null);
+ multi.addInherited(root, new String[]{"x1"});
+ multi.set("model.queryString", "love", new String[]{"x1"}, null);
// Rumtimize
defaultQP.freeze();
@@ -746,461 +745,461 @@ public class QueryProfileVariantsTestCase {
multi.freeze();
Properties runtime = new QueryProfileProperties(multi.compile(null));
- assertEquals("default",runtime.get("model.defaultIndex", toMap("x=x1")));
- assertEquals("love",runtime.get("model.queryString", toMap("x=x1")));
+ assertEquals("default", runtime.get("model.defaultIndex", toMap("x=x1")));
+ assertEquals("love", runtime.get("model.queryString", toMap("x=x1")));
}
@Test
- public void testVariantInheritanceOverridesBaseInheritanceComplexSimplified() {
- QueryProfile root=new QueryProfile("root");
- root.set("model.defaultIndex","default", null);
+ void testVariantInheritanceOverridesBaseInheritanceComplexSimplified() {
+ QueryProfile root = new QueryProfile("root");
+ root.set("model.defaultIndex", "default", null);
- QueryProfile multi=new QueryProfile("multi");
- multi.setDimensions(new String[] {"x"});
- multi.set("model.defaultIndex","title", null);
- multi.addInherited(root,new String[] {"x1"});
+ QueryProfile multi = new QueryProfile("multi");
+ multi.setDimensions(new String[]{"x"});
+ multi.set("model.defaultIndex", "title", null);
+ multi.addInherited(root, new String[]{"x1"});
- assertEquals("default",multi.compile(null).get("model.defaultIndex", toMap("x=x1")));
+ assertEquals("default", multi.compile(null).get("model.defaultIndex", toMap("x=x1")));
}
@Test
- public void testVariantInheritanceOverridesBaseInheritanceMixed() {
- QueryProfile root=new QueryProfile("root");
- root.set("model.defaultIndex","default", null);
+ void testVariantInheritanceOverridesBaseInheritanceMixed() {
+ QueryProfile root = new QueryProfile("root");
+ root.set("model.defaultIndex", "default", null);
- QueryProfile multi=new QueryProfile("multi");
- multi.setDimensions(new String[] {"x"});
- multi.set("model.defaultIndex","title", null);
- multi.set("model.queryString","modelQuery", null);
- multi.addInherited(root,new String[] {"x1"});
- multi.set("model.queryString","modelVariantQuery",new String[] {"x1"}, null);
+ QueryProfile multi = new QueryProfile("multi");
+ multi.setDimensions(new String[]{"x"});
+ multi.set("model.defaultIndex", "title", null);
+ multi.set("model.queryString", "modelQuery", null);
+ multi.addInherited(root, new String[]{"x1"});
+ multi.set("model.queryString", "modelVariantQuery", new String[]{"x1"}, null);
CompiledQueryProfile cmulti = multi.compile(null);
- assertEquals("default",cmulti.get("model.defaultIndex", toMap("x=x1")));
- assertEquals("modelVariantQuery",cmulti.get("model.queryString", toMap("x=x1")));
+ assertEquals("default", cmulti.get("model.defaultIndex", toMap("x=x1")));
+ assertEquals("modelVariantQuery", cmulti.get("model.queryString", toMap("x=x1")));
}
@Test
- public void testListVariantPropertiesNoCompounds() {
- QueryProfile parent1=new QueryProfile("parent1");
- parent1.set("a","parent1-a", null); // Defined everywhere
- parent1.set("b","parent1-b", null); // Defined everywhere, but no variants
- parent1.set("c","parent1-c", null); // Defined in both parents only
-
- QueryProfile parent2=new QueryProfile("parent2");
- parent2.set("a","parent2-a", null);
- parent2.set("b","parent2-b", null);
- parent2.set("c","parent2-c", null);
- parent2.set("d","parent2-d", null); // Defined in second parent only
-
- QueryProfile main=new QueryProfile("main");
- main.setDimensions(new String[] {"x","y"});
+ void testListVariantPropertiesNoCompounds() {
+ QueryProfile parent1 = new QueryProfile("parent1");
+ parent1.set("a", "parent1-a", null); // Defined everywhere
+ parent1.set("b", "parent1-b", null); // Defined everywhere, but no variants
+ parent1.set("c", "parent1-c", null); // Defined in both parents only
+
+ QueryProfile parent2 = new QueryProfile("parent2");
+ parent2.set("a", "parent2-a", null);
+ parent2.set("b", "parent2-b", null);
+ parent2.set("c", "parent2-c", null);
+ parent2.set("d", "parent2-d", null); // Defined in second parent only
+
+ QueryProfile main = new QueryProfile("main");
+ main.setDimensions(new String[]{"x", "y"});
main.addInherited(parent1);
main.addInherited(parent2);
- main.set("a","main-a", null);
- main.set("a","main-a-x1",new String[] {"x1"}, null);
- main.set("e","main-e-x1",new String[] {"x1"}, null); // Defined in two variants only
- main.set("f","main-f-x1",new String[] {"x1"}, null); // Defined in one variants only
- main.set("a","main-a-x1.y1",new String[] {"x1","y1"}, null);
- main.set("a","main-a-x1.y2",new String[] {"x1","y2"}, null);
- main.set("e","main-e-x1.y2",new String[] {"x1","y2"}, null);
- main.set("g","main-g-x1.y2",new String[] {"x1","y2"}, null); // Defined in one variant only
- main.set("b","main-b", null);
-
- QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- inheritedVariant1.set("a","inheritedVariant1-a", null);
- inheritedVariant1.set("h","inheritedVariant1-h", null); // Only defined in two inherited variants
-
- QueryProfile inheritedVariant2=new QueryProfile("inheritedVariant2");
- inheritedVariant2.set("a","inheritedVariant2-a", null);
- inheritedVariant2.set("h","inheritedVariant2-h", null); // Only defined in two inherited variants
- inheritedVariant2.set("i","inheritedVariant2-i", null); // Only defined in one inherited variant
-
- QueryProfile inheritedVariant3=new QueryProfile("inheritedVariant3");
- inheritedVariant3.set("j","inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
-
- main.addInherited(inheritedVariant1,new String[] {"x1"});
- main.addInherited(inheritedVariant3,new String[] {"x1"});
- main.addInherited(inheritedVariant2,new String[] {"x1","y2"});
- main.addInherited(inheritedVariant3,new String[] {"x1","y2"});
+ main.set("a", "main-a", null);
+ main.set("a", "main-a-x1", new String[]{"x1"}, null);
+ main.set("e", "main-e-x1", new String[]{"x1"}, null); // Defined in two variants only
+ main.set("f", "main-f-x1", new String[]{"x1"}, null); // Defined in one variants only
+ main.set("a", "main-a-x1.y1", new String[]{"x1", "y1"}, null);
+ main.set("a", "main-a-x1.y2", new String[]{"x1", "y2"}, null);
+ main.set("e", "main-e-x1.y2", new String[]{"x1", "y2"}, null);
+ main.set("g", "main-g-x1.y2", new String[]{"x1", "y2"}, null); // Defined in one variant only
+ main.set("b", "main-b", null);
+
+ QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
+ inheritedVariant1.set("a", "inheritedVariant1-a", null);
+ inheritedVariant1.set("h", "inheritedVariant1-h", null); // Only defined in two inherited variants
+
+ QueryProfile inheritedVariant2 = new QueryProfile("inheritedVariant2");
+ inheritedVariant2.set("a", "inheritedVariant2-a", null);
+ inheritedVariant2.set("h", "inheritedVariant2-h", null); // Only defined in two inherited variants
+ inheritedVariant2.set("i", "inheritedVariant2-i", null); // Only defined in one inherited variant
+
+ QueryProfile inheritedVariant3 = new QueryProfile("inheritedVariant3");
+ inheritedVariant3.set("j", "inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
+
+ main.addInherited(inheritedVariant1, new String[]{"x1"});
+ main.addInherited(inheritedVariant3, new String[]{"x1"});
+ main.addInherited(inheritedVariant2, new String[]{"x1", "y2"});
+ main.addInherited(inheritedVariant3, new String[]{"x1", "y2"});
// Runtime-ify
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
- int expectedBaseSize=4;
+ int expectedBaseSize = 4;
// No context
- Map<String,Object> listed=properties.listProperties();
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
+ Map<String, Object> listed = properties.listProperties();
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
// Context x=x1
- listed=properties.listProperties(toMap(main, new String[] {"x1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
- assertEquals("main-e-x1",listed.get("e"));
- assertEquals("main-f-x1",listed.get("f"));
- assertEquals("inheritedVariant1-h",listed.get("h"));
- assertEquals("inheritedVariant3-j",listed.get("j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
+ assertEquals("main-e-x1", listed.get("e"));
+ assertEquals("main-f-x1", listed.get("f"));
+ assertEquals("inheritedVariant1-h", listed.get("h"));
+ assertEquals("inheritedVariant3-j", listed.get("j"));
// Context x=x1,y=y1
- listed=properties.listProperties(toMap(main, new String[] {"x1","y1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1.y1",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
- assertEquals("main-e-x1",listed.get("e"));
- assertEquals("main-f-x1",listed.get("f"));
- assertEquals("inheritedVariant1-h",listed.get("h"));
- assertEquals("inheritedVariant3-j",listed.get("j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1.y1", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
+ assertEquals("main-e-x1", listed.get("e"));
+ assertEquals("main-f-x1", listed.get("f"));
+ assertEquals("inheritedVariant1-h", listed.get("h"));
+ assertEquals("inheritedVariant3-j", listed.get("j"));
// Context x=x1,y=y2
- listed=properties.listProperties(toMap(main, new String[] {"x1","y2"}));
- assertEquals(expectedBaseSize+6,listed.size());
- assertEquals("main-a-x1.y2",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
- assertEquals("main-e-x1.y2",listed.get("e"));
- assertEquals("main-f-x1",listed.get("f"));
- assertEquals("main-g-x1.y2",listed.get("g"));
- assertEquals("inheritedVariant2-h",listed.get("h"));
- assertEquals("inheritedVariant2-i",listed.get("i"));
- assertEquals("inheritedVariant3-j",listed.get("j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y2"}));
+ assertEquals(expectedBaseSize + 6, listed.size());
+ assertEquals("main-a-x1.y2", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
+ assertEquals("main-e-x1.y2", listed.get("e"));
+ assertEquals("main-f-x1", listed.get("f"));
+ assertEquals("main-g-x1.y2", listed.get("g"));
+ assertEquals("inheritedVariant2-h", listed.get("h"));
+ assertEquals("inheritedVariant2-i", listed.get("i"));
+ assertEquals("inheritedVariant3-j", listed.get("j"));
// Context x=x1,y=y3
- listed=properties.listProperties(toMap(main, new String[] {"x1","y3"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
- assertEquals("main-e-x1",listed.get("e"));
- assertEquals("main-f-x1",listed.get("f"));
- assertEquals("inheritedVariant1-h",listed.get("h"));
- assertEquals("inheritedVariant3-j",listed.get("j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y3"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
+ assertEquals("main-e-x1", listed.get("e"));
+ assertEquals("main-f-x1", listed.get("f"));
+ assertEquals("inheritedVariant1-h", listed.get("h"));
+ assertEquals("inheritedVariant3-j", listed.get("j"));
// Context x=x2,y=y1
- listed=properties.listProperties(toMap(main, new String[] {"x2","y1"}));
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
+ listed = properties.listProperties(toMap(main, new String[]{"x2", "y1"}));
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
}
@Test
- public void testListVariantPropertiesCompounds1Simplified() {
- QueryProfile main=new QueryProfile("main");
- main.setDimensions(new String[] {"x","y"});
- main.set("a.p1","main-a-x1",new String[] {"x1"}, null);
+ void testListVariantPropertiesCompounds1Simplified() {
+ QueryProfile main = new QueryProfile("main");
+ main.setDimensions(new String[]{"x", "y"});
+ main.set("a.p1", "main-a-x1", new String[]{"x1"}, null);
- QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- inheritedVariant1.set("a.p1","inheritedVariant1-a", null);
- main.addInherited(inheritedVariant1,new String[] {"x1"});
+ QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
+ inheritedVariant1.set("a.p1", "inheritedVariant1-a", null);
+ main.addInherited(inheritedVariant1, new String[]{"x1"});
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
// Context x=x1
- Map<String,Object> listed=properties.listProperties(toMap(main,new String[] {"x1"}));
- assertEquals("main-a-x1",listed.get("a.p1"));
+ Map<String, Object> listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals("main-a-x1", listed.get("a.p1"));
}
@Test
- public void testListVariantPropertiesCompounds1() {
- QueryProfile parent1=new QueryProfile("parent1");
- parent1.set("a.p1","parent1-a", null); // Defined everywhere
- parent1.set("b.p1","parent1-b", null); // Defined everywhere, but no variants
- parent1.set("c.p1","parent1-c", null); // Defined in both parents only
-
- QueryProfile parent2=new QueryProfile("parent2");
- parent2.set("a.p1","parent2-a", null);
- parent2.set("b.p1","parent2-b", null);
- parent2.set("c.p1","parent2-c", null);
- parent2.set("d.p1","parent2-d", null); // Defined in second parent only
-
- QueryProfile main=new QueryProfile("main");
- main.setDimensions(new String[] {"x","y"});
+ void testListVariantPropertiesCompounds1() {
+ QueryProfile parent1 = new QueryProfile("parent1");
+ parent1.set("a.p1", "parent1-a", null); // Defined everywhere
+ parent1.set("b.p1", "parent1-b", null); // Defined everywhere, but no variants
+ parent1.set("c.p1", "parent1-c", null); // Defined in both parents only
+
+ QueryProfile parent2 = new QueryProfile("parent2");
+ parent2.set("a.p1", "parent2-a", null);
+ parent2.set("b.p1", "parent2-b", null);
+ parent2.set("c.p1", "parent2-c", null);
+ parent2.set("d.p1", "parent2-d", null); // Defined in second parent only
+
+ QueryProfile main = new QueryProfile("main");
+ main.setDimensions(new String[]{"x", "y"});
main.addInherited(parent1);
main.addInherited(parent2);
- main.set("a.p1","main-a", null);
- main.set("a.p1","main-a-x1",new String[] {"x1"}, null);
- main.set("e.p1","main-e-x1",new String[] {"x1"}, null); // Defined in two variants only
- main.set("f.p1","main-f-x1",new String[] {"x1"}, null); // Defined in one variants only
- main.set("a.p1","main-a-x1.y1",new String[] {"x1","y1"}, null);
- main.set("a.p1","main-a-x1.y2",new String[] {"x1","y2"}, null);
- main.set("e.p1","main-e-x1.y2",new String[] {"x1","y2"}, null);
- main.set("g.p1","main-g-x1.y2",new String[] {"x1","y2"}, null); // Defined in one variant only
- main.set("b.p1","main-b", null);
+ main.set("a.p1", "main-a", null);
+ main.set("a.p1", "main-a-x1", new String[]{"x1"}, null);
+ main.set("e.p1", "main-e-x1", new String[]{"x1"}, null); // Defined in two variants only
+ main.set("f.p1", "main-f-x1", new String[]{"x1"}, null); // Defined in one variants only
+ main.set("a.p1", "main-a-x1.y1", new String[]{"x1", "y1"}, null);
+ main.set("a.p1", "main-a-x1.y2", new String[]{"x1", "y2"}, null);
+ main.set("e.p1", "main-e-x1.y2", new String[]{"x1", "y2"}, null);
+ main.set("g.p1", "main-g-x1.y2", new String[]{"x1", "y2"}, null); // Defined in one variant only
+ main.set("b.p1", "main-b", null);
+
+ QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
+ inheritedVariant1.set("a.p1", "inheritedVariant1-a", null);
+ inheritedVariant1.set("h.p1", "inheritedVariant1-h", null); // Only defined in two inherited variants
+
+ QueryProfile inheritedVariant2 = new QueryProfile("inheritedVariant2");
+ inheritedVariant2.set("a.p1", "inheritedVariant2-a", null);
+ inheritedVariant2.set("h.p1", "inheritedVariant2-h", null); // Only defined in two inherited variants
+ inheritedVariant2.set("i.p1", "inheritedVariant2-i", null); // Only defined in one inherited variant
+
+ QueryProfile inheritedVariant3 = new QueryProfile("inheritedVariant3");
+ inheritedVariant3.set("j.p1", "inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
+
+ main.addInherited(inheritedVariant1, new String[]{"x1"});
+ main.addInherited(inheritedVariant3, new String[]{"x1"});
+ main.addInherited(inheritedVariant2, new String[]{"x1", "y2"});
+ main.addInherited(inheritedVariant3, new String[]{"x1", "y2"});
- QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- inheritedVariant1.set("a.p1","inheritedVariant1-a", null);
- inheritedVariant1.set("h.p1","inheritedVariant1-h", null); // Only defined in two inherited variants
-
- QueryProfile inheritedVariant2=new QueryProfile("inheritedVariant2");
- inheritedVariant2.set("a.p1","inheritedVariant2-a", null);
- inheritedVariant2.set("h.p1","inheritedVariant2-h", null); // Only defined in two inherited variants
- inheritedVariant2.set("i.p1","inheritedVariant2-i", null); // Only defined in one inherited variant
-
- QueryProfile inheritedVariant3=new QueryProfile("inheritedVariant3");
- inheritedVariant3.set("j.p1","inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
-
- main.addInherited(inheritedVariant1,new String[] {"x1"});
- main.addInherited(inheritedVariant3,new String[] {"x1"});
- main.addInherited(inheritedVariant2,new String[] {"x1","y2"});
- main.addInherited(inheritedVariant3,new String[] {"x1","y2"});
-
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
- int expectedBaseSize=4;
+ int expectedBaseSize = 4;
// No context
- Map<String,Object> listed=properties.listProperties();
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
+ Map<String, Object> listed = properties.listProperties();
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
// Context x=x1
- listed=properties.listProperties(toMap(main,new String[] {"x1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
- assertEquals("main-e-x1",listed.get("e.p1"));
- assertEquals("main-f-x1",listed.get("f.p1"));
- assertEquals("inheritedVariant1-h",listed.get("h.p1"));
- assertEquals("inheritedVariant3-j",listed.get("j.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
+ assertEquals("main-e-x1", listed.get("e.p1"));
+ assertEquals("main-f-x1", listed.get("f.p1"));
+ assertEquals("inheritedVariant1-h", listed.get("h.p1"));
+ assertEquals("inheritedVariant3-j", listed.get("j.p1"));
// Context x=x1,y=y1
- listed=properties.listProperties(toMap(main,new String[] {"x1","y1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1.y1",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
- assertEquals("main-e-x1",listed.get("e.p1"));
- assertEquals("main-f-x1",listed.get("f.p1"));
- assertEquals("inheritedVariant1-h",listed.get("h.p1"));
- assertEquals("inheritedVariant3-j",listed.get("j.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1.y1", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
+ assertEquals("main-e-x1", listed.get("e.p1"));
+ assertEquals("main-f-x1", listed.get("f.p1"));
+ assertEquals("inheritedVariant1-h", listed.get("h.p1"));
+ assertEquals("inheritedVariant3-j", listed.get("j.p1"));
// Context x=x1,y=y2
- listed=properties.listProperties(toMap(main,new String[] {"x1","y2"}));
- assertEquals(expectedBaseSize+6,listed.size());
- assertEquals("main-a-x1.y2",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
- assertEquals("main-e-x1.y2",listed.get("e.p1"));
- assertEquals("main-f-x1",listed.get("f.p1"));
- assertEquals("main-g-x1.y2",listed.get("g.p1"));
- assertEquals("inheritedVariant2-h",listed.get("h.p1"));
- assertEquals("inheritedVariant2-i",listed.get("i.p1"));
- assertEquals("inheritedVariant3-j",listed.get("j.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y2"}));
+ assertEquals(expectedBaseSize + 6, listed.size());
+ assertEquals("main-a-x1.y2", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
+ assertEquals("main-e-x1.y2", listed.get("e.p1"));
+ assertEquals("main-f-x1", listed.get("f.p1"));
+ assertEquals("main-g-x1.y2", listed.get("g.p1"));
+ assertEquals("inheritedVariant2-h", listed.get("h.p1"));
+ assertEquals("inheritedVariant2-i", listed.get("i.p1"));
+ assertEquals("inheritedVariant3-j", listed.get("j.p1"));
// Context x=x1,y=y3
- listed=properties.listProperties(toMap(main,new String[] {"x1","y3"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
- assertEquals("main-e-x1",listed.get("e.p1"));
- assertEquals("main-f-x1",listed.get("f.p1"));
- assertEquals("inheritedVariant1-h",listed.get("h.p1"));
- assertEquals("inheritedVariant3-j",listed.get("j.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y3"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
+ assertEquals("main-e-x1", listed.get("e.p1"));
+ assertEquals("main-f-x1", listed.get("f.p1"));
+ assertEquals("inheritedVariant1-h", listed.get("h.p1"));
+ assertEquals("inheritedVariant3-j", listed.get("j.p1"));
// Context x=x2,y=y1
- listed=properties.listProperties(toMap(main,new String[] {"x2","y1"}));
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x2", "y1"}));
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
}
@Test
- public void testListVariantPropertiesCompounds2() {
- QueryProfile parent1=new QueryProfile("parent1");
- parent1.set("p1.a","parent1-a", null); // Defined everywhere
- parent1.set("p1.b","parent1-b", null); // Defined everywhere, but no variants
- parent1.set("p1.c","parent1-c", null); // Defined in both parents only
-
- QueryProfile parent2=new QueryProfile("parent2");
- parent2.set("p1.a","parent2-a", null);
- parent2.set("p1.b","parent2-b", null);
- parent2.set("p1.c","parent2-c", null);
- parent2.set("p1.d","parent2-d", null); // Defined in second parent only
-
- QueryProfile main=new QueryProfile("main");
- main.setDimensions(new String[] {"x","y"});
+ void testListVariantPropertiesCompounds2() {
+ QueryProfile parent1 = new QueryProfile("parent1");
+ parent1.set("p1.a", "parent1-a", null); // Defined everywhere
+ parent1.set("p1.b", "parent1-b", null); // Defined everywhere, but no variants
+ parent1.set("p1.c", "parent1-c", null); // Defined in both parents only
+
+ QueryProfile parent2 = new QueryProfile("parent2");
+ parent2.set("p1.a", "parent2-a", null);
+ parent2.set("p1.b", "parent2-b", null);
+ parent2.set("p1.c", "parent2-c", null);
+ parent2.set("p1.d", "parent2-d", null); // Defined in second parent only
+
+ QueryProfile main = new QueryProfile("main");
+ main.setDimensions(new String[]{"x", "y"});
main.addInherited(parent1);
main.addInherited(parent2);
- main.set("p1.a","main-a", null);
- main.set("p1.a","main-a-x1",new String[] {"x1"}, null);
- main.set("p1.e","main-e-x1",new String[] {"x1"}, null); // Defined in two variants only
- main.set("p1.f","main-f-x1",new String[] {"x1"}, null); // Defined in one variants only
- main.set("p1.a","main-a-x1.y1",new String[] {"x1","y1"}, null);
- main.set("p1.a","main-a-x1.y2",new String[] {"x1","y2"}, null);
- main.set("p1.e","main-e-x1.y2",new String[] {"x1","y2"}, null);
- main.set("p1.g","main-g-x1.y2",new String[] {"x1","y2"}, null); // Defined in one variant only
- main.set("p1.b","main-b", null);
-
- QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- inheritedVariant1.set("p1.a","inheritedVariant1-a", null);
- inheritedVariant1.set("p1.h","inheritedVariant1-h", null); // Only defined in two inherited variants
-
- QueryProfile inheritedVariant2=new QueryProfile("inheritedVariant2");
- inheritedVariant2.set("p1.a","inheritedVariant2-a", null);
- inheritedVariant2.set("p1.h","inheritedVariant2-h", null); // Only defined in two inherited variants
- inheritedVariant2.set("p1.i","inheritedVariant2-i", null); // Only defined in one inherited variant
-
- QueryProfile inheritedVariant3=new QueryProfile("inheritedVariant3");
- inheritedVariant3.set("p1.j","inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
+ main.set("p1.a", "main-a", null);
+ main.set("p1.a", "main-a-x1", new String[]{"x1"}, null);
+ main.set("p1.e", "main-e-x1", new String[]{"x1"}, null); // Defined in two variants only
+ main.set("p1.f", "main-f-x1", new String[]{"x1"}, null); // Defined in one variants only
+ main.set("p1.a", "main-a-x1.y1", new String[]{"x1", "y1"}, null);
+ main.set("p1.a", "main-a-x1.y2", new String[]{"x1", "y2"}, null);
+ main.set("p1.e", "main-e-x1.y2", new String[]{"x1", "y2"}, null);
+ main.set("p1.g", "main-g-x1.y2", new String[]{"x1", "y2"}, null); // Defined in one variant only
+ main.set("p1.b", "main-b", null);
+
+ QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
+ inheritedVariant1.set("p1.a", "inheritedVariant1-a", null);
+ inheritedVariant1.set("p1.h", "inheritedVariant1-h", null); // Only defined in two inherited variants
+
+ QueryProfile inheritedVariant2 = new QueryProfile("inheritedVariant2");
+ inheritedVariant2.set("p1.a", "inheritedVariant2-a", null);
+ inheritedVariant2.set("p1.h", "inheritedVariant2-h", null); // Only defined in two inherited variants
+ inheritedVariant2.set("p1.i", "inheritedVariant2-i", null); // Only defined in one inherited variant
+
+ QueryProfile inheritedVariant3 = new QueryProfile("inheritedVariant3");
+ inheritedVariant3.set("p1.j", "inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
+
+ main.addInherited(inheritedVariant1, new String[]{"x1"});
+ main.addInherited(inheritedVariant3, new String[]{"x1"});
+ main.addInherited(inheritedVariant2, new String[]{"x1", "y2"});
+ main.addInherited(inheritedVariant3, new String[]{"x1", "y2"});
- main.addInherited(inheritedVariant1,new String[] {"x1"});
- main.addInherited(inheritedVariant3,new String[] {"x1"});
- main.addInherited(inheritedVariant2,new String[] {"x1","y2"});
- main.addInherited(inheritedVariant3,new String[] {"x1","y2"});
-
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
- int expectedBaseSize=4;
+ int expectedBaseSize = 4;
// No context
- Map<String,Object> listed=properties.listProperties();
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
+ Map<String, Object> listed = properties.listProperties();
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
// Context x=x1
- listed=properties.listProperties(toMap(main,new String[] {"x1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
- assertEquals("main-e-x1",listed.get("p1.e"));
- assertEquals("main-f-x1",listed.get("p1.f"));
- assertEquals("inheritedVariant1-h",listed.get("p1.h"));
- assertEquals("inheritedVariant3-j",listed.get("p1.j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
+ assertEquals("main-e-x1", listed.get("p1.e"));
+ assertEquals("main-f-x1", listed.get("p1.f"));
+ assertEquals("inheritedVariant1-h", listed.get("p1.h"));
+ assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y1
- listed=properties.listProperties(toMap(main,new String[] {"x1","y1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1.y1",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
- assertEquals("main-e-x1",listed.get("p1.e"));
- assertEquals("main-f-x1",listed.get("p1.f"));
- assertEquals("inheritedVariant1-h",listed.get("p1.h"));
- assertEquals("inheritedVariant3-j",listed.get("p1.j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1.y1", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
+ assertEquals("main-e-x1", listed.get("p1.e"));
+ assertEquals("main-f-x1", listed.get("p1.f"));
+ assertEquals("inheritedVariant1-h", listed.get("p1.h"));
+ assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y2
- listed=properties.listProperties(toMap(main,new String[] {"x1","y2"}));
- assertEquals(expectedBaseSize+6,listed.size());
- assertEquals("main-a-x1.y2",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
- assertEquals("main-e-x1.y2",listed.get("p1.e"));
- assertEquals("main-f-x1",listed.get("p1.f"));
- assertEquals("main-g-x1.y2",listed.get("p1.g"));
- assertEquals("inheritedVariant2-h",listed.get("p1.h"));
- assertEquals("inheritedVariant2-i",listed.get("p1.i"));
- assertEquals("inheritedVariant3-j",listed.get("p1.j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y2"}));
+ assertEquals(expectedBaseSize + 6, listed.size());
+ assertEquals("main-a-x1.y2", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
+ assertEquals("main-e-x1.y2", listed.get("p1.e"));
+ assertEquals("main-f-x1", listed.get("p1.f"));
+ assertEquals("main-g-x1.y2", listed.get("p1.g"));
+ assertEquals("inheritedVariant2-h", listed.get("p1.h"));
+ assertEquals("inheritedVariant2-i", listed.get("p1.i"));
+ assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y3
- listed=properties.listProperties(toMap(main,new String[] {"x1","y3"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
- assertEquals("main-e-x1",listed.get("p1.e"));
- assertEquals("main-f-x1",listed.get("p1.f"));
- assertEquals("inheritedVariant1-h",listed.get("p1.h"));
- assertEquals("inheritedVariant3-j",listed.get("p1.j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y3"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
+ assertEquals("main-e-x1", listed.get("p1.e"));
+ assertEquals("main-f-x1", listed.get("p1.f"));
+ assertEquals("inheritedVariant1-h", listed.get("p1.h"));
+ assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x2,y=y1
- listed=properties.listProperties(toMap(main,new String[] {"x2","y1"}));
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
+ listed = properties.listProperties(toMap(main, new String[]{"x2", "y1"}));
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
}
@Test
- public void testQueryProfileReferences() {
- QueryProfile main=new QueryProfile("main");
- main.setDimensions(new String[] {"x1"});
- QueryProfile referencedMain=new QueryProfile("referencedMain");
- referencedMain.set("r1","mainReferenced-r1", null); // In both
- referencedMain.set("r2","mainReferenced-r2", null); // Only in this
- QueryProfile referencedVariant=new QueryProfile("referencedVariant");
- referencedVariant.set("r1","variantReferenced-r1", null); // In both
- referencedVariant.set("r3","variantReferenced-r3", null); // Only in this
+ void testQueryProfileReferences() {
+ QueryProfile main = new QueryProfile("main");
+ main.setDimensions(new String[]{"x1"});
+ QueryProfile referencedMain = new QueryProfile("referencedMain");
+ referencedMain.set("r1", "mainReferenced-r1", null); // In both
+ referencedMain.set("r2", "mainReferenced-r2", null); // Only in this
+ QueryProfile referencedVariant = new QueryProfile("referencedVariant");
+ referencedVariant.set("r1", "variantReferenced-r1", null); // In both
+ referencedVariant.set("r3", "variantReferenced-r3", null); // Only in this
- main.set("a",referencedMain, null);
- main.set("a",referencedVariant,new String[] {"x1"}, null);
+ main.set("a", referencedMain, null);
+ main.set("a", referencedVariant, new String[]{"x1"}, null);
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
// No context
- Map<String,Object> listed=properties.listProperties();
- assertEquals(2,listed.size());
- assertEquals("mainReferenced-r1",listed.get("a.r1"));
- assertEquals("mainReferenced-r2",listed.get("a.r2"));
+ Map<String, Object> listed = properties.listProperties();
+ assertEquals(2, listed.size());
+ assertEquals("mainReferenced-r1", listed.get("a.r1"));
+ assertEquals("mainReferenced-r2", listed.get("a.r2"));
// Context x=x1
- listed=properties.listProperties(toMap(main,new String[] {"x1"}));
- assertEquals(3,listed.size());
- assertEquals("variantReferenced-r1",listed.get("a.r1"));
- assertEquals("mainReferenced-r2",listed.get("a.r2"));
- assertEquals("variantReferenced-r3",listed.get("a.r3"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals(3, listed.size());
+ assertEquals("variantReferenced-r1", listed.get("a.r1"));
+ assertEquals("mainReferenced-r2", listed.get("a.r2"));
+ assertEquals("variantReferenced-r3", listed.get("a.r3"));
}
@Test
- public void testQueryProfileReferencesWithSubstitution() {
+ void testQueryProfileReferencesWithSubstitution() {
QueryProfile main = new QueryProfile("main");
- main.setDimensions(new String[] {"x1"});
+ main.setDimensions(new String[]{"x1"});
QueryProfile referencedMain = new QueryProfile("referencedMain");
- referencedMain.set("r1","%{prefix}mainReferenced-r1", null); // In both
- referencedMain.set("r2","%{prefix}mainReferenced-r2", null); // Only in this
+ referencedMain.set("r1", "%{prefix}mainReferenced-r1", null); // In both
+ referencedMain.set("r2", "%{prefix}mainReferenced-r2", null); // Only in this
QueryProfile referencedVariant = new QueryProfile("referencedVariant");
- referencedVariant.set("r1","%{prefix}variantReferenced-r1", null); // In both
- referencedVariant.set("r3","%{prefix}variantReferenced-r3", null); // Only in this
+ referencedVariant.set("r1", "%{prefix}variantReferenced-r1", null); // In both
+ referencedVariant.set("r3", "%{prefix}variantReferenced-r3", null); // Only in this
referencedVariant.set("inthis", "local value", null);
- referencedVariant.set("r4","This has %{.inthis}", null); // Relative
+ referencedVariant.set("r4", "This has %{.inthis}", null); // Relative
main.set("a", referencedMain, null);
- main.set("a", referencedVariant,new String[] {"x1"}, null);
+ main.set("a", referencedVariant, new String[]{"x1"}, null);
main.set("prefix", "mainPrefix:", null);
- main.set("prefix", "variantPrefix:", new String[] {"x1"}, null);
+ main.set("prefix", "variantPrefix:", new String[]{"x1"}, null);
Properties properties = new QueryProfileProperties(main.compile(null));
// No context
- Map<String,Object> listed = properties.listProperties();
+ Map<String, Object> listed = properties.listProperties();
assertEquals(3, listed.size());
assertEquals("mainPrefix:mainReferenced-r1", listed.get("a.r1"));
assertEquals("mainPrefix:mainReferenced-r2", listed.get("a.r2"));
// Context x=x1
- listed = properties.listProperties(toMap(main, new String[] {"x1"}));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
assertEquals(6, listed.size());
assertEquals("variantPrefix:variantReferenced-r1", listed.get("a.r1"));
assertEquals("variantPrefix:mainReferenced-r2", listed.get("a.r2"));
@@ -1209,17 +1208,17 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testNewsCase1() {
+ void testNewsCase1() {
QueryProfile shortcuts = new QueryProfile("shortcuts");
- shortcuts.setDimensions(new String[] {"custid_1", "custid_2", "custid_3", "custid_4", "custid_5", "custid_6"});
+ shortcuts.setDimensions(new String[]{"custid_1", "custid_2", "custid_3", "custid_4", "custid_5", "custid_6"});
shortcuts.set("testout", "outside", null);
shortcuts.set("test.out", "dotoutside", null);
- shortcuts.set("testin", "inside", new String[] {"yahoo","ca","sc"}, null);
- shortcuts.set("test.in", "dotinside", new String[] {"yahoo","ca","sc"}, null);
+ shortcuts.set("testin", "inside", new String[]{"yahoo", "ca", "sc"}, null);
+ shortcuts.set("test.in", "dotinside", new String[]{"yahoo", "ca", "sc"}, null);
- QueryProfile profile=new QueryProfile("default");
- profile.setDimensions(new String[] {"custid_1","custid_2","custid_3","custid_4","custid_5","custid_6"});
- profile.addInherited(shortcuts, new String[] {"yahoo",null,"sc"});
+ QueryProfile profile = new QueryProfile("default");
+ profile.setDimensions(new String[]{"custid_1", "custid_2", "custid_3", "custid_4", "custid_5", "custid_6"});
+ profile.addInherited(shortcuts, new String[]{"yahoo", null, "sc"});
profile.freeze();
Query query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=yahoo&custid_2=ca&custid_3=sc", Method.GET), profile.compile(null));
@@ -1231,103 +1230,103 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testNewsCase2() {
- QueryProfile test=new QueryProfile("test");
+ void testNewsCase2() {
+ QueryProfile test = new QueryProfile("test");
test.setDimensions("sort,resulttypes,rss,age,intl,testid".split(","));
- String[] dimensionValues=new String[] {null,null,"0"};
- test.set("discovery","sources",dimensionValues, null);
- test.set("discoverytypes","article",dimensionValues, null);
- test.set("discovery.sources.count","10",dimensionValues, null);
+ String[] dimensionValues = new String[]{null, null, "0"};
+ test.set("discovery", "sources", dimensionValues, null);
+ test.set("discoverytypes", "article", dimensionValues, null);
+ test.set("discovery.sources.count", "10", dimensionValues, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("sources",ctest.get("discovery", toMap(test, dimensionValues)));
- assertEquals("article",ctest.get("discoverytypes", toMap(test, dimensionValues)));
- assertEquals("10",ctest.get("discovery.sources.count", toMap(test, dimensionValues)));
+ assertEquals("sources", ctest.get("discovery", toMap(test, dimensionValues)));
+ assertEquals("article", ctest.get("discoverytypes", toMap(test, dimensionValues)));
+ assertEquals("10", ctest.get("discovery.sources.count", toMap(test, dimensionValues)));
- Map<String,Object> values=ctest.listValues("",toMap(test,dimensionValues));
- assertEquals(3,values.size());
- assertEquals("sources",values.get("discovery"));
- assertEquals("article",values.get("discoverytypes"));
- assertEquals("10",values.get("discovery.sources.count"));
+ Map<String, Object> values = ctest.listValues("", toMap(test, dimensionValues));
+ assertEquals(3, values.size());
+ assertEquals("sources", values.get("discovery"));
+ assertEquals("article", values.get("discoverytypes"));
+ assertEquals("10", values.get("discovery.sources.count"));
- Map<String,Object> sourceValues=ctest.listValues("discovery.sources",toMap(test,dimensionValues));
- assertEquals(1,sourceValues.size());
- assertEquals("10",sourceValues.get("count"));
+ Map<String, Object> sourceValues = ctest.listValues("discovery.sources", toMap(test, dimensionValues));
+ assertEquals(1, sourceValues.size());
+ assertEquals("10", sourceValues.get("count"));
}
@Test
- public void testRuntimeAssignmentInClone() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
- String[] x1=new String[] {"x1"};
- Map<String,String> x1m=toMap(test,x1);
- test.set("a","30",x1, null);
- test.set("a.b","20",x1, null);
- test.set("a.b.c","10",x1, null);
+ void testRuntimeAssignmentInClone() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
+ String[] x1 = new String[]{"x1"};
+ Map<String, String> x1m = toMap(test, x1);
+ test.set("a", "30", x1, null);
+ test.set("a.b", "20", x1, null);
+ test.set("a.b.c", "10", x1, null);
// Setting in one profile works
Query qMain = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), test.compile(null));
- qMain.properties().set("a.b","50",x1m);
- assertEquals("50",qMain.properties().get("a.b",x1m));
+ qMain.properties().set("a.b", "50", x1m);
+ assertEquals("50", qMain.properties().get("a.b", x1m));
// Cloning
- Query qBranch=qMain.clone();
+ Query qBranch = qMain.clone();
// Setting in main still works
- qMain.properties().set("a.b","51",x1m);
- assertEquals("51",qMain.properties().get("a.b",x1m));
+ qMain.properties().set("a.b", "51", x1m);
+ assertEquals("51", qMain.properties().get("a.b", x1m));
// Clone is not affected by change in original
- assertEquals("50",qBranch.properties().get("a.b",x1m));
+ assertEquals("50", qBranch.properties().get("a.b", x1m));
// Setting in clone works
- qBranch.properties().set("a.b","70",x1m);
- assertEquals("70",qBranch.properties().get("a.b",x1m));
+ qBranch.properties().set("a.b", "70", x1m);
+ assertEquals("70", qBranch.properties().get("a.b", x1m));
// Setting in clone does not affect original
- assertEquals("51",qMain.properties().get("a.b",x1m));
+ assertEquals("51", qMain.properties().get("a.b", x1m));
}
@Test
- public void testIncompatibleDimensions() {
+ void testIncompatibleDimensions() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
- backendBase.setDimensions(new String[] { "sort", "resulttypes", "rss" });
+ backendBase.setDimensions(new String[]{"sort", "resulttypes", "rss"});
backendBase.set("custid", "s", null);
QueryProfile backend = new QueryProfile("backend");
- backend.setDimensions(new String[] { "sort", "offset", "resulttypes", "rss", "age", "lang", "fr", "entry" });
+ backend.setDimensions(new String[]{"sort", "offset", "resulttypes", "rss", "age", "lang", "fr", "entry"});
backend.addInherited(backendBase);
QueryProfile web = new QueryProfile("web");
- web.setDimensions(new String[] { "entry", "recency" });
- web.set("fr", "alerts", new String[] { "alert" }, null);
+ web.setDimensions(new String[]{"entry", "recency"});
+ web.set("fr", "alerts", new String[]{"alert"}, null);
alert.set("config.backend.vertical.news", backend, null);
alert.set("config.backend.multimedia", web, null);
- backend.set("custid", "yahoo/alerts", new String[] { null, null, null, null, null, "en-US", null, "alert"}, null);
+ backend.set("custid", "yahoo/alerts", new String[]{null, null, null, null, null, "en-US", null, "alert"}, null);
CompiledQueryProfile cAlert = alert.compile(null);
assertEquals("yahoo/alerts", cAlert.get("config.backend.vertical.news.custid", toMap("entry=alert", "intl=us", "lang=en-US")));
}
@Test
- public void testIncompatibleDimensionsSimplified() {
+ void testIncompatibleDimensionsSimplified() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
backendBase.set("custid", "s", null);
QueryProfile backend = new QueryProfile("backend");
- backend.setDimensions(new String[] { "sort", "lang", "fr", "entry" });
- backend.set("custid", "yahoo/alerts", new String[] { null, "en-US", null, "alert"}, null);
+ backend.setDimensions(new String[]{"sort", "lang", "fr", "entry"});
+ backend.set("custid", "yahoo/alerts", new String[]{null, "en-US", null, "alert"}, null);
backend.addInherited(backendBase);
QueryProfile web = new QueryProfile("web");
- web.setDimensions(new String[] { "entry", "recency" });
- web.set("fr", "alerts", new String[] { "alert" }, null);
+ web.setDimensions(new String[]{"entry", "recency"});
+ web.set("fr", "alerts", new String[]{"alert"}, null);
alert.set("vertical", backend, null);
alert.set("multimedia", web, null);
@@ -1337,23 +1336,23 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testZoneInfoInContext() {
+ void testZoneInfoInContext() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "environment", "region", "instance" });
+ profile.setDimensions(new String[]{"environment", "region", "instance"});
profile.set("value", "default", registry);
profile.set("value", "prod-region1-instance1",
- toMap("environment=prod", "region=region1", "instance=instance1"),
- registry);
+ toMap("environment=prod", "region=region1", "instance=instance1"),
+ registry);
profile.set("value", "prod-instance2",
- toMap("environment=prod", "instance=instance2"),
- registry);
+ toMap("environment=prod", "instance=instance2"),
+ registry);
profile.set("value", "prod-region3",
- toMap("environment=prod", "region=region3"),
- registry);
+ toMap("environment=prod", "region=region3"),
+ registry);
profile.set("value", "dev",
- toMap("environment=dev"),
- registry);
+ toMap("environment=dev"),
+ registry);
registry.register(profile);
CompiledQueryProfileRegistry cRegistry = registry.compile();
@@ -1361,36 +1360,36 @@ public class QueryProfileVariantsTestCase {
assertValueForZone("default", ZoneInfo.defaultInfo(), null, cTest);
assertValueForZone("prod-region1-instance1",
- new ZoneInfo(new ApplicationId("tenant1", "application1", "instance1"),
- new Zone(Environment.prod, "region1")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant1", "application1", "instance1"),
+ new Zone(Environment.prod, "region1")),
+ null,
+ cTest);
assertValueForZone("prod-instance2",
- new ZoneInfo(new ApplicationId("tenant2", "application2", "instance2"),
- new Zone(Environment.prod, "region1")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant2", "application2", "instance2"),
+ new Zone(Environment.prod, "region1")),
+ null,
+ cTest);
assertValueForZone("prod-region3",
- new ZoneInfo(new ApplicationId("tenant3", "application3", "instance3"),
- new Zone(Environment.prod, "region3")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant3", "application3", "instance3"),
+ new Zone(Environment.prod, "region3")),
+ null,
+ cTest);
assertValueForZone("dev",
- new ZoneInfo(new ApplicationId("tenant4", "application4", "instance4"),
- new Zone(Environment.dev, "region4")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant4", "application4", "instance4"),
+ new Zone(Environment.dev, "region4")),
+ null,
+ cTest);
}
@Test
- public void testZoneInfoInContextWithUnoverridability() {
+ void testZoneInfoInContextWithUnoverridability() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "instance", "environment", "region" });
+ profile.setDimensions(new String[]{"instance", "environment", "region"});
profile.set("value", "default", registry);
profile.set("value", "prod-beta",
- toMap("environment=prod", "instance=beta"),
- registry);
+ toMap("environment=prod", "instance=beta"),
+ registry);
profile.setOverridable("value", false, toMap("environment=prod", "instance=beta"));
registry.register(profile);
@@ -1398,10 +1397,10 @@ public class QueryProfileVariantsTestCase {
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
assertValueForZone("prod-beta",
- new ZoneInfo(new ApplicationId("tenant1", "application1", "beta"),
- new Zone(Environment.prod, "region1")),
- "fromRequest",
- cTest);
+ new ZoneInfo(new ApplicationId("tenant1", "application1", "beta"),
+ new Zone(Environment.prod, "region1")),
+ "fromRequest",
+ cTest);
}
@@ -1413,23 +1412,23 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testZoneInfoInContextSettingNativeProperty() {
+ void testZoneInfoInContextSettingNativeProperty() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "instance", "environment", "region" });
+ profile.setDimensions(new String[]{"instance", "environment", "region"});
profile.set("timeout", "0.3",
- toMap("environment=prod", "instance=beta"),
- registry);
+ toMap("environment=prod", "instance=beta"),
+ registry);
registry.register(profile);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
assertTimeoutForZone(300,
- new ZoneInfo(new ApplicationId("tenant1", "application1", "beta"),
- new Zone(Environment.prod, "region1")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant1", "application1", "beta"),
+ new Zone(Environment.prod, "region1")),
+ null,
+ cTest);
}
private void assertTimeoutForZone(int expected, ZoneInfo zoneInfo, String requestValue, CompiledQueryProfile cTest) {
@@ -1441,8 +1440,7 @@ public class QueryProfileVariantsTestCase {
private void assertGet(String expectedValue, String parameter, String[] dimensionValues, QueryProfile profile, CompiledQueryProfile cprofile) {
Map<String, String> context = toMap(profile,dimensionValues);
- assertEquals("Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'",
- expectedValue, cprofile.get(parameter,context));
+ assertEquals(expectedValue, cprofile.get(parameter,context), "Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'");
}
public static Map<String,String> toMap(QueryProfile profile, String[] dimensionValues) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java
index 0ace8f93f1d..b245648b861 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java
@@ -4,9 +4,9 @@ package com.yahoo.search.query.profile.types.test;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -14,14 +14,14 @@ import static org.junit.Assert.assertEquals;
public class FieldTypeTestCase {
@Test
- public void testConvertToFromString() {
- QueryProfileTypeRegistry registry=new QueryProfileTypeRegistry();
+ void testConvertToFromString() {
+ QueryProfileTypeRegistry registry = new QueryProfileTypeRegistry();
registry.register(new QueryProfileType("foo"));
- assertEquals("string", FieldType.fromString("string",registry).stringValue());
- assertEquals("boolean", FieldType.fromString("boolean",registry).stringValue());
- assertEquals("query-profile", FieldType.fromString("query-profile",registry).stringValue());
- assertEquals("query-profile:foo", FieldType.fromString("query-profile:foo",registry).stringValue());
+ assertEquals("string", FieldType.fromString("string", registry).stringValue());
+ assertEquals("boolean", FieldType.fromString("boolean", registry).stringValue());
+ assertEquals("query-profile", FieldType.fromString("query-profile", registry).stringValue());
+ assertEquals("query-profile:foo", FieldType.fromString("query-profile:foo", registry).stringValue());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java
index dfe4b24e256..5bde89d0282 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java
@@ -13,9 +13,9 @@ import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -55,18 +55,18 @@ public class MandatoryTestCase {
}
@Test
- public void testMandatoryFullySpecifiedQueryProfile() {
+ void testMandatoryFullySpecifiedQueryProfile() {
Fixture1 fixture = new Fixture1();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(fixture.type);
test.set("myString", "aString", fixture.registry);
fixture.registry.register(test);
- QueryProfile myUser=new QueryProfile("user");
+ QueryProfile myUser = new QueryProfile("user");
myUser.setType(fixture.user);
- myUser.set("myUserInteger",1, fixture.registry);
- myUser.set("myUserString",1, fixture.registry);
+ myUser.set("myUserInteger", 1, fixture.registry);
+ myUser.set("myUserString", 1, fixture.registry);
test.set("myUserQueryProfile", myUser, fixture.registry);
fixture.registry.register(myUser);
@@ -77,7 +77,7 @@ public class MandatoryTestCase {
}
@Test
- public void testMandatoryRequestPropertiesNeeded() {
+ void testMandatoryRequestPropertiesNeeded() {
Fixture1 fixture = new Fixture1();
QueryProfile test = new QueryProfile("test");
@@ -94,11 +94,11 @@ public class MandatoryTestCase {
// Underspecified request 1
assertError("Incomplete query: Parameter 'myString' is mandatory in query profile 'test' of type 'testtype' but is not set",
- new Query(HttpRequest.createTestRequest("", Method.GET), cRegistry.getComponent("test")));
+ new Query(HttpRequest.createTestRequest("", Method.GET), cRegistry.getComponent("test")));
// Underspecified request 2
assertError("Incomplete query: Parameter 'myUserQueryProfile.myUserString' is mandatory in query profile 'test' of type 'testtype' but is not set",
- new Query(HttpRequest.createTestRequest("?myString=aString", Method.GET), cRegistry.getComponent("test")));
+ new Query(HttpRequest.createTestRequest("?myString=aString", Method.GET), cRegistry.getComponent("test")));
// Fully specified request
assertError(null, new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("test")));
@@ -106,7 +106,7 @@ public class MandatoryTestCase {
/** Same as above except the whole thing is nested in maps */
@Test
- public void testMandatoryNestedInMaps() {
+ void testMandatoryNestedInMaps() {
Fixture1 fixture = new Fixture1();
QueryProfile topMap = new QueryProfile("topMap");
@@ -123,7 +123,7 @@ public class MandatoryTestCase {
QueryProfile myUser = new QueryProfile("user");
myUser.setType(fixture.user);
- myUser.set("myUserInteger",1, fixture.registry);
+ myUser.set("myUserInteger", 1, fixture.registry);
test.set("myUserQueryProfile", myUser, fixture.registry);
fixture.registry.register(myUser);
@@ -132,11 +132,11 @@ public class MandatoryTestCase {
// Underspecified request 1
assertError("Incomplete query: Parameter 'subMap.test.myString' is mandatory in query profile 'topMap' but is not set",
- new Query(HttpRequest.createTestRequest("", Method.GET), cRegistry.getComponent("topMap")));
+ new Query(HttpRequest.createTestRequest("", Method.GET), cRegistry.getComponent("topMap")));
// Underspecified request 2
assertError("Incomplete query: Parameter 'subMap.test.myUserQueryProfile.myUserString' is mandatory in query profile 'topMap' but is not set",
- new Query(HttpRequest.createTestRequest("?subMap.test.myString=aString", Method.GET), cRegistry.getComponent("topMap")));
+ new Query(HttpRequest.createTestRequest("?subMap.test.myString=aString", Method.GET), cRegistry.getComponent("topMap")));
// Fully specified request
assertError(null, new Query(HttpRequest.createTestRequest("?subMap.test.myString=aString&subMap.test.myUserQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("topMap")));
@@ -144,7 +144,7 @@ public class MandatoryTestCase {
/** Here, no user query profile is referenced in the query profile, but one is chosen in the request */
@Test
- public void testMandatoryUserProfileSetInRequest() {
+ void testMandatoryUserProfileSetInRequest() {
Fixture1 fixture = new Fixture1();
QueryProfile test = new QueryProfile("test");
@@ -161,11 +161,11 @@ public class MandatoryTestCase {
// Underspecified request 1
assertError("Incomplete query: Parameter 'myUserQueryProfile' is mandatory in query profile 'test' of type 'testtype' but is not set",
- new Query(HttpRequest.createTestRequest("?myString=aString", Method.GET), cRegistry.getComponent("test")));
+ new Query(HttpRequest.createTestRequest("?myString=aString", Method.GET), cRegistry.getComponent("test")));
// Underspecified request 1
assertError("Incomplete query: Parameter 'myUserQueryProfile.myUserString' is mandatory in query profile 'test' of type 'testtype' but is not set",
- new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile=user", Method.GET), cRegistry.getComponent("test")));
+ new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile=user", Method.GET), cRegistry.getComponent("test")));
// Fully specified request
assertError(null, new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile=user&myUserQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("test")));
@@ -173,7 +173,7 @@ public class MandatoryTestCase {
/** Here, a partially specified query profile is added to a non-mandatory field, making the request underspecified */
@Test
- public void testNonMandatoryUnderspecifiedUserProfileSetInRequest() {
+ void testNonMandatoryUnderspecifiedUserProfileSetInRequest() {
Fixture1 fixture = new Fixture1();
QueryProfile test = new QueryProfile("test");
@@ -199,7 +199,7 @@ public class MandatoryTestCase {
// Underspecified because an underspecified profile is added
assertError("Incomplete query: Parameter 'myQueryProfile.myUserString' is mandatory in query profile 'test' of type 'testtype' but is not set",
- new Query(HttpRequest.createTestRequest("?myString=aString&myQueryProfile=otherUser", Method.GET), cRegistry.getComponent("test")));
+ new Query(HttpRequest.createTestRequest("?myString=aString&myQueryProfile=otherUser", Method.GET), cRegistry.getComponent("test")));
// Back to fully specified
assertError(null, new Query(HttpRequest.createTestRequest("?myString=aString&myQueryProfile=otherUser&myQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("test")));
@@ -223,7 +223,7 @@ public class MandatoryTestCase {
}
@Test
- public void testMandatoryInParentType() {
+ void testMandatoryInParentType() {
Fixture2 fixture = new Fixture2();
QueryProfile defaultProfile = new QueryProfile("default");
@@ -237,11 +237,11 @@ public class MandatoryTestCase {
CompiledQueryProfileRegistry cRegistry = fixture.registry.compile();
assertError("Incomplete query: Parameter 'foobar' is mandatory in query profile 'mandatory' of type 'mandatory-type' but is not set",
- new Query(QueryTestCase.httpEncode("?queryProfile=mandatory"), cRegistry.getComponent("mandatory")));
+ new Query(QueryTestCase.httpEncode("?queryProfile=mandatory"), cRegistry.getComponent("mandatory")));
}
@Test
- public void testMandatoryInParentTypeWithInheritance() {
+ void testMandatoryInParentTypeWithInheritance() {
Fixture2 fixture = new Fixture2();
QueryProfile defaultProfile = new QueryProfile("default");
@@ -256,7 +256,7 @@ public class MandatoryTestCase {
CompiledQueryProfileRegistry cRegistry = fixture.registry.compile();
assertError("Incomplete query: Parameter 'foobar' is mandatory in query profile 'mandatory' of type 'mandatory-type' but is not set",
- new Query(QueryTestCase.httpEncode("?queryProfile=mandatory"), cRegistry.getComponent("mandatory")));
+ new Query(QueryTestCase.httpEncode("?queryProfile=mandatory"), cRegistry.getComponent("mandatory")));
}
private void assertError(String message,Query query) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
index fa7508ea5ac..37991f7f14f 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
@@ -8,10 +8,10 @@ import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* tests creating invalid names
@@ -21,7 +21,7 @@ import static org.junit.Assert.fail;
public class NameTestCase {
@Test
- public void testNames() {
+ void testNames() {
assertLegalName("aB");
assertIllegalName("a.");
assertLegalName("_a_b");
@@ -33,11 +33,11 @@ public class NameTestCase {
}
@Test
- public void testFieldNames() {
+ void testFieldNames() {
assertLegalFieldName("aB");
try {
- QueryProfile profile=new QueryProfile("test");
- profile.set("a.","anyValue", (QueryProfileRegistry)null);
+ QueryProfile profile = new QueryProfile("test");
+ profile.set("a.", "anyValue", (QueryProfileRegistry) null);
fail("Should have failed");
} catch (IllegalArgumentException e) {
assertEquals("'a.' is not a legal compound name. Names can not end with a dot.", e.getMessage());
@@ -48,12 +48,12 @@ public class NameTestCase {
assertLegalFieldName("/a/b");
assertLegalFieldName("/a/b/");
assertIllegalFieldName("aBc.dooEee.ce_d.-some-other.moreHere",
- "Could not set 'aBc.dooEee.ce_d.-some-other.moreHere' to 'anyValue'",
- "Illegal name '-some-other'");
+ "Could not set 'aBc.dooEee.ce_d.-some-other.moreHere' to 'anyValue'",
+ "Illegal name '-some-other'");
}
@Test
- public void testComponentIdAsCompoundName() {
+ void testComponentIdAsCompoundName() {
String name = "a/b";
assertEquals(new CompoundName(name), new QueryProfileType(name).getComponentIdAsCompoundName());
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java
index 6f884650b5d..72499002ba9 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java
@@ -7,10 +7,10 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.yolean.Exceptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests that properties can not be set even if they are native, if declared not settable in the query profile
@@ -20,7 +20,7 @@ import static org.junit.Assert.fail;
public class NativePropertiesTestCase {
@Test
- public void testNativeInStrict() {
+ void testNativeInStrict() {
QueryProfileType strictType = new QueryProfileType("strict");
strictType.setStrict(true);
QueryProfile strict = new QueryProfile("profile");
@@ -39,7 +39,7 @@ public class NativePropertiesTestCase {
} catch (IllegalArgumentException e) {
// As expected.
assertTrue(Exceptions.toMessageString(e).contains(
- "Could not set 'notnative' to '5':"
+ "Could not set 'notnative' to '5':"
+ " 'notnative' is not declared in query profile type 'strict', and the type is strict"));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java
index 906d43790bd..69d577719c5 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java
@@ -13,10 +13,10 @@ import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests overriding of field values
@@ -29,7 +29,7 @@ public class OverrideTestCase {
private QueryProfileType type, user;
- @Before
+ @BeforeEach
public void setUp() {
type=new QueryProfileType(new ComponentId("testtype"));
user=new QueryProfileType(new ComponentId("user"));
@@ -60,38 +60,38 @@ public class OverrideTestCase {
/** Check that a simple non-overridable string cannot be overridden */
@Test
- public void testSimpleUnoverridable() {
+ void testSimpleUnoverridable() {
QueryProfileRegistry registry = new QueryProfileRegistry();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(type);
- test.set("myString","finalString", (QueryProfileRegistry)null);
+ test.set("myString", "finalString", (QueryProfileRegistry) null);
registry.register(test);
registry.freeze();
// Assert request assignment does not work
Query query = new Query(HttpRequest.createTestRequest("?myString=newValue", Method.GET), registry.compile().getComponent("test"));
- assertEquals(0,query.errors().size());
- assertEquals("finalString",query.properties().get("myString"));
+ assertEquals(0, query.errors().size());
+ assertEquals("finalString", query.properties().get("myString"));
// Assert direct assignment does not work
- query.properties().set("myString","newValue");
- assertEquals("finalString",query.properties().get("myString"));
+ query.properties().set("myString", "newValue");
+ assertEquals("finalString", query.properties().get("myString"));
}
/** Check that a query profile cannot be overridden */
@Test
- public void testUnoverridableQueryProfile() {
+ void testUnoverridableQueryProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
registry.register(test);
- QueryProfile myUser=new QueryProfile("user");
+ QueryProfile myUser = new QueryProfile("user");
myUser.setType(user);
- myUser.set("myUserInteger",1, registry);
- myUser.set("myUserString","userValue", registry);
- test.set("myUserQueryProfile",myUser, registry);
+ myUser.set("myUserInteger", 1, registry);
+ myUser.set("myUserString", "userValue", registry);
+ test.set("myUserQueryProfile", myUser, registry);
registry.register(myUser);
QueryProfile otherUser = new QueryProfile("otherUser");
@@ -102,52 +102,52 @@ public class OverrideTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?myUserQueryprofile=otherUser", Method.GET), cRegistry.getComponent("test"));
- assertEquals(0,query.errors().size());
- assertEquals(1,query.properties().get("myUserQueryProfile.myUserInteger"));
+ assertEquals(0, query.errors().size());
+ assertEquals(1, query.properties().get("myUserQueryProfile.myUserInteger"));
}
/** Check that non-overridables are protected also in nested untyped references */
@Test
- public void testUntypedNestedUnoverridable() {
+ void testUntypedNestedUnoverridable() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile topMap = new QueryProfile("topMap");
registry.register(topMap);
- QueryProfile subMap=new QueryProfile("topSubMap");
- topMap.set("subMap",subMap, registry);
+ QueryProfile subMap = new QueryProfile("topSubMap");
+ topMap.set("subMap", subMap, registry);
registry.register(subMap);
QueryProfile test = new QueryProfile("test");
test.setType(type);
- subMap.set("test",test, registry);
+ subMap.set("test", test, registry);
registry.register(test);
- QueryProfile myUser=new QueryProfile("user");
+ QueryProfile myUser = new QueryProfile("user");
myUser.setType(user);
- myUser.set("myUserString","finalValue", registry);
- test.set("myUserQueryProfile",myUser, registry);
+ myUser.set("myUserString", "finalValue", registry);
+ test.set("myUserQueryProfile", myUser, registry);
registry.register(myUser);
registry.freeze();
Query query = new Query(HttpRequest.createTestRequest("?subMap.test.myUserQueryProfile.myUserString=newValue", Method.GET), registry.compile().getComponent("topMap"));
- assertEquals(0,query.errors().size());
- assertEquals("finalValue",query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
+ assertEquals(0, query.errors().size());
+ assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
- query.properties().set("subMap.test.myUserQueryProfile.myUserString","newValue");
- assertEquals("finalValue",query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
+ query.properties().set("subMap.test.myUserQueryProfile.myUserString", "newValue");
+ assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
}
/** Tests overridability in an inherited field */
@Test
- public void testInheritedNonOverridableInType() {
+ void testInheritedNonOverridableInType() {
QueryProfileRegistry registry = new QueryProfileRegistry();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(type);
- test.set("myString","finalString", (QueryProfileRegistry)null);
+ test.set("myString", "finalString", (QueryProfileRegistry) null);
registry.register(test);
- QueryProfile profile=new QueryProfile("profile");
+ QueryProfile profile = new QueryProfile("profile");
profile.addInherited(test);
registry.register(profile);
@@ -155,16 +155,16 @@ public class OverrideTestCase {
Query query = new Query(HttpRequest.createTestRequest("?myString=newString", Method.GET), registry.compile().getComponent("test"));
- assertEquals(0,query.errors().size());
- assertEquals("finalString",query.properties().get("myString"));
+ assertEquals(0, query.errors().size());
+ assertEquals("finalString", query.properties().get("myString"));
- query.properties().set("myString","newString");
- assertEquals("finalString",query.properties().get("myString"));
+ query.properties().set("myString", "newString");
+ assertEquals("finalString", query.properties().get("myString"));
}
/** Tests overridability in an inherited field */
@Test
- public void testInheritedNonOverridableInProfile() {
+ void testInheritedNonOverridableInProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
@@ -172,7 +172,7 @@ public class OverrideTestCase {
test.setOverridable("myInteger", false, DimensionValues.empty);
registry.register(test);
- QueryProfile profile=new QueryProfile("profile");
+ QueryProfile profile = new QueryProfile("profile");
profile.addInherited(test);
registry.register(profile);
@@ -180,11 +180,11 @@ public class OverrideTestCase {
Query query = new Query(HttpRequest.createTestRequest("?myInteger=32", Method.GET), registry.compile().getComponent("test"));
- assertEquals(0,query.errors().size());
- assertEquals(1,query.properties().get("myInteger"));
+ assertEquals(0, query.errors().size());
+ assertEquals(1, query.properties().get("myInteger"));
- query.properties().set("myInteger",32);
- assertEquals(1,query.properties().get("myInteger"));
+ query.properties().set("myInteger", 32);
+ assertEquals(1, query.properties().get("myInteger"));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java
index d39bfa13126..58d92d84e94 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java
@@ -4,10 +4,10 @@ package com.yahoo.search.query.profile.types.test;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Tests that matching query profiles by path name works
@@ -17,62 +17,62 @@ import static org.junit.Assert.assertNull;
public class PatchMatchingTestCase {
@Test
- public void testPatchMatching() {
- QueryProfileType type=new QueryProfileType("type");
+ void testPatchMatching() {
+ QueryProfileType type = new QueryProfileType("type");
type.setMatchAsPath(true);
- QueryProfile a=new QueryProfile("a");
+ QueryProfile a = new QueryProfile("a");
a.setType(type);
- QueryProfile abee=new QueryProfile("a/bee");
+ QueryProfile abee = new QueryProfile("a/bee");
abee.setType(type);
abee.addInherited(a);
- QueryProfile abeece=new QueryProfile("a/bee/ce");
+ QueryProfile abeece = new QueryProfile("a/bee/ce");
abeece.setType(type);
abeece.addInherited(abee);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee);
registry.register(abeece);
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("a",registry.findQueryProfile("a").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee/cede").getId().getName());
- assertEquals("a",registry.findQueryProfile("a/foo/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
assertNull(registry.findQueryProfile("abee"));
}
@Test
- public void testNoPatchMatching() {
- QueryProfileType type=new QueryProfileType("type");
+ void testNoPatchMatching() {
+ QueryProfileType type = new QueryProfileType("type");
type.setMatchAsPath(false); // Default, but set here for clarity
- QueryProfile a=new QueryProfile("a");
+ QueryProfile a = new QueryProfile("a");
a.setType(type);
- QueryProfile abee=new QueryProfile("a/bee");
+ QueryProfile abee = new QueryProfile("a/bee");
abee.setType(type);
abee.addInherited(a);
- QueryProfile abeece=new QueryProfile("a/bee/ce");
+ QueryProfile abeece = new QueryProfile("a/bee/ce");
abeece.setType(type);
abeece.addInherited(abee);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee);
registry.register(abeece);
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("a",registry.findQueryProfile("a").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
assertNull(registry.findQueryProfile("a/bee/ce/dee")); // Different from test above
assertNull(registry.findQueryProfile("a/bee/ce/dee/eee/")); // Different from test above
assertNull(registry.findQueryProfile("a/bee/cede")); // Different from test above
@@ -82,59 +82,59 @@ public class PatchMatchingTestCase {
/** Check that the path matching property is inherited to subtypes */
@Test
- public void testPatchMatchingInheritance() {
- QueryProfileType type=new QueryProfileType("type");
- QueryProfileType subType=new QueryProfileType("subType");
+ void testPatchMatchingInheritance() {
+ QueryProfileType type = new QueryProfileType("type");
+ QueryProfileType subType = new QueryProfileType("subType");
subType.inherited().add(type);
type.setMatchAsPath(true); // Supertype only
- QueryProfile a=new QueryProfile("a");
+ QueryProfile a = new QueryProfile("a");
a.setType(type);
- QueryProfile abee=new QueryProfile("a/bee");
+ QueryProfile abee = new QueryProfile("a/bee");
abee.setType(subType);
abee.addInherited(a);
- QueryProfile abeece=new QueryProfile("a/bee/ce");
+ QueryProfile abeece = new QueryProfile("a/bee/ce");
abeece.setType(subType);
abeece.addInherited(abee);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee);
registry.register(abeece);
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("a",registry.findQueryProfile("a").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee/cede").getId().getName());
- assertEquals("a",registry.findQueryProfile("a/foo/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
assertNull(registry.findQueryProfile("abee"));
}
/** Check that the path matching works with versioned profiles */
@Test
- public void testPatchMatchingVersions() {
- QueryProfileType type=new QueryProfileType("type");
+ void testPatchMatchingVersions() {
+ QueryProfileType type = new QueryProfileType("type");
type.setMatchAsPath(true);
- QueryProfile a=new QueryProfile("a");
+ QueryProfile a = new QueryProfile("a");
a.setType(type);
- QueryProfile abee11=new QueryProfile("a/bee:1.1");
+ QueryProfile abee11 = new QueryProfile("a/bee:1.1");
abee11.setType(type);
abee11.addInherited(a);
- QueryProfile abee13=new QueryProfile("a/bee:1.3");
+ QueryProfile abee13 = new QueryProfile("a/bee:1.3");
abee13.setType(type);
abee13.addInherited(a);
- QueryProfile abeece=new QueryProfile("a/bee/ce");
+ QueryProfile abeece = new QueryProfile("a/bee/ce");
abeece.setType(type);
abeece.addInherited(abee13);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee11);
registry.register(abee13);
@@ -142,52 +142,52 @@ public class PatchMatchingTestCase {
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("a",registry.findQueryProfile("a").getId().getName());
- assertEquals("a/bee:1.1",registry.findQueryProfile("a/bee:1.1").getId().toString());
- assertEquals("a/bee:1.3",registry.findQueryProfile("a/bee").getId().toString());
- assertEquals("a/bee:1.3",registry.findQueryProfile("a/bee:1").getId().toString());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
- assertEquals("a/bee:1.1",registry.findQueryProfile("a/bee/cede:1.1").getId().toString());
- assertEquals("a/bee:1.3",registry.findQueryProfile("a/bee/cede").getId().toString());
- assertEquals("a/bee:1.3",registry.findQueryProfile("a/bee/cede:1").getId().toString());
- assertEquals("a",registry.findQueryProfile("a/foo/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a").getId().getName());
+ assertEquals("a/bee:1.1", registry.findQueryProfile("a/bee:1.1").getId().toString());
+ assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee").getId().toString());
+ assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee:1").getId().toString());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
+ assertEquals("a/bee:1.1", registry.findQueryProfile("a/bee/cede:1.1").getId().toString());
+ assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee/cede").getId().toString());
+ assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee/cede:1").getId().toString());
+ assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
assertNull(registry.findQueryProfile("abee"));
}
@Test
- public void testQuirkyNames() {
- QueryProfileType type=new QueryProfileType("type");
+ void testQuirkyNames() {
+ QueryProfileType type = new QueryProfileType("type");
type.setMatchAsPath(true);
- QueryProfile a=new QueryProfile("/a");
+ QueryProfile a = new QueryProfile("/a");
a.setType(type);
- QueryProfile abee=new QueryProfile("/a//bee");
+ QueryProfile abee = new QueryProfile("/a//bee");
abee.setType(type);
abee.addInherited(a);
- QueryProfile abeece=new QueryProfile("/a//bee/ce/");
+ QueryProfile abeece = new QueryProfile("/a//bee/ce/");
abeece.setType(type);
abeece.addInherited(abee);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee);
registry.register(abeece);
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("/a",registry.findQueryProfile("/a").getId().getName());
+ assertEquals("/a", registry.findQueryProfile("/a").getId().getName());
assertNull(registry.findQueryProfile("a"));
- assertEquals("/a//bee",registry.findQueryProfile("/a//bee").getId().getName());
- assertEquals("/a//bee/ce/",registry.findQueryProfile("/a//bee/ce/").getId().getName());
- assertEquals("/a//bee/ce/",registry.findQueryProfile("/a//bee/ce").getId().getName());
- assertEquals("/a//bee/ce/",registry.findQueryProfile("/a//bee/ce/dee").getId().getName());
- assertEquals("/a//bee/ce/",registry.findQueryProfile("/a//bee/ce/dee/eee/").getId().getName());
- assertEquals("/a//bee",registry.findQueryProfile("/a//bee/cede").getId().getName());
- assertEquals("/a",registry.findQueryProfile("/a/foo/bee/cede").getId().getName());
- assertEquals("/a",registry.findQueryProfile("/a/bee").getId().getName());
+ assertEquals("/a//bee", registry.findQueryProfile("/a//bee").getId().getName());
+ assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/").getId().getName());
+ assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce").getId().getName());
+ assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/dee").getId().getName());
+ assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/dee/eee/").getId().getName());
+ assertEquals("/a//bee", registry.findQueryProfile("/a//bee/cede").getId().getName());
+ assertEquals("/a", registry.findQueryProfile("/a/foo/bee/cede").getId().getName());
+ assertEquals("/a", registry.findQueryProfile("/a/bee").getId().getName());
assertNull(registry.findQueryProfile("abee"));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java
index 62551447017..cc7b5c4d666 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java
@@ -9,13 +9,10 @@ import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -26,7 +23,7 @@ public class QueryProfileTypeInheritanceTestCase {
private QueryProfileType type, typeStrict, user, userStrict;
- @Before
+ @BeforeEach
public void setUp() {
type=new QueryProfileType(new ComponentId("testtype"));
typeStrict=new QueryProfileType(new ComponentId("testtypeStrict"));
@@ -63,7 +60,7 @@ public class QueryProfileTypeInheritanceTestCase {
}
@Test
- public void testInheritance() {
+ void testInheritance() {
type.inherited().add(user);
type.freeze();
user.freeze();
@@ -71,11 +68,11 @@ public class QueryProfileTypeInheritanceTestCase {
assertFalse(type.isOverridable("myUserString"));
assertEquals("myUserInteger", type.getField("myUserInteger").getName());
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(type);
- test.set("myUserInteger","37", (QueryProfileRegistry)null);
- test.set("myUnknownInteger","38", (QueryProfileRegistry)null);
+ test.set("myUserInteger", "37", (QueryProfileRegistry) null);
+ test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals(37, ctest.get("myUserInteger"));
@@ -83,45 +80,45 @@ public class QueryProfileTypeInheritanceTestCase {
}
@Test
- public void testInheritanceStrict() {
+ void testInheritanceStrict() {
typeStrict.inherited().add(userStrict);
typeStrict.freeze();
userStrict.freeze();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(typeStrict);
- test.set("myUserInteger","37", (QueryProfileRegistry)null);
+ test.set("myUserInteger", "37", (QueryProfileRegistry) null);
try {
- test.set("myUnknownInteger","38", (QueryProfileRegistry)null);
+ test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
fail("Should have failed");
}
catch (IllegalArgumentException e) {
assertEquals("'myUnknownInteger' is not declared in query profile type 'testtypeStrict', and the type is strict",
- e.getCause().getMessage());
+ e.getCause().getMessage());
}
- assertEquals(37,test.get("myUserInteger"));
+ assertEquals(37, test.get("myUserInteger"));
assertNull(test.get("myUnknownInteger"));
}
@Test
- public void testStrictIsInherited() {
+ void testStrictIsInherited() {
type.inherited().add(userStrict);
type.freeze();
userStrict.freeze();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(type);
- test.set("myUserInteger","37", (QueryProfileRegistry)null);
+ test.set("myUserInteger", "37", (QueryProfileRegistry) null);
try {
- test.set("myUnknownInteger","38", (QueryProfileRegistry)null);
+ test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
fail("Should have failed");
}
catch (IllegalArgumentException e) {
assertEquals("'myUnknownInteger' is not declared in query profile type 'testtype', and the type is strict",
- e.getCause().getMessage());
+ e.getCause().getMessage());
}
CompiledQueryProfile ctest = test.compile(null);
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java
index a77de954b3a..21a9b2fe399 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java
@@ -19,19 +19,15 @@ import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* tests query profiles with/and types
@@ -44,7 +40,7 @@ public class QueryProfileTypeTestCase {
private QueryProfileType testtype, emptyInheritingTesttype, testtypeStrict, user, userStrict;
- @Before
+ @BeforeEach
public void setUp() {
registry = new QueryProfileRegistry();
@@ -95,24 +91,24 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testTypedOfPrimitivesAssignmentNonStrict() {
+ void testTypedOfPrimitivesAssignmentNonStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
registry.register(profile);
profile.set("myString", "anyValue", registry);
profile.set("nontypedString", "anyValueToo", registry); // legal because this is not strict
- assertWrongType(profile,"integer", "myInteger","notInteger");
+ assertWrongType(profile, "integer", "myInteger", "notInteger");
assertWrongType(profile, "integer", "myInteger", "1.5");
profile.set("myInteger", 3, registry);
- assertWrongType(profile,"long","myLong","notLong");
+ assertWrongType(profile, "long", "myLong", "notLong");
assertWrongType(profile, "long", "myLong", "1.5");
profile.set("myLong", 4000000000000L, registry);
assertWrongType(profile, "float", "myFloat", "notFloat");
profile.set("myFloat", 3.14f, registry);
assertWrongType(profile, "double", "myDouble", "notDouble");
- profile.set("myDouble",2.18, registry);
- profile.set("myBoolean",true, registry);
+ profile.set("myDouble", 2.18, registry);
+ profile.set("myBoolean", true, registry);
String tensorString1 = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
profile.set("ranking.features.query(myTensor1)", tensorString1, registry);
@@ -122,12 +118,12 @@ public class QueryProfileTypeTestCase {
profile.set("ranking.features.query(myTensor3)", tensorString3, registry);
profile.set("myQuery", "...", registry); // TODO
- profile.set("myQueryProfile.anyString","value1", registry);
- profile.set("myQueryProfile.anyDouble",8.76, registry);
- profile.set("myUserQueryProfile.myUserString","value2", registry);
+ profile.set("myQueryProfile.anyString", "value1", registry);
+ profile.set("myQueryProfile.anyDouble", 8.76, registry);
+ profile.set("myUserQueryProfile.myUserString", "value2", registry);
profile.set("myUserQueryProfile.anyString", "value3", registry); // Legal because user is not strict
assertWrongType(profile, "integer", "myUserQueryProfile.myUserInteger", "notInteger");
- profile.set("myUserQueryProfile.uint",1337, registry); // Set using alias
+ profile.set("myUserQueryProfile.uint", 1337, registry); // Set using alias
profile.set("myUserQueryProfile.anyDouble", 9.13, registry); // Legal because user is not strict
CompiledQueryProfileRegistry cRegistry = registry.compile();
@@ -162,22 +158,22 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testTypedOfPrimitivesAssignmentStrict() {
+ void testTypedOfPrimitivesAssignmentStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtypeStrict);
profile.set("myString", "anyValue", registry);
assertNotPermitted(profile, "nontypedString", "anyValueToo"); // Illegal because this is strict
- assertWrongType(profile,"integer","myInteger","notInteger");
+ assertWrongType(profile, "integer", "myInteger", "notInteger");
assertWrongType(profile, "integer", "myInteger", "1.5");
profile.set("myInteger", 3, registry);
- assertWrongType(profile,"long","myLong","notLong");
+ assertWrongType(profile, "long", "myLong", "notLong");
assertWrongType(profile, "long", "myLong", "1.5");
profile.set("myLong", 4000000000000L, registry);
assertWrongType(profile, "float", "myFloat", "notFloat");
profile.set("myFloat", 3.14f, registry);
assertWrongType(profile, "double", "myDouble", "notDouble");
- profile.set("myDouble",2.18, registry);
+ profile.set("myDouble", 2.18, registry);
profile.set("myQueryProfile.anyString", "value1", registry);
profile.set("myQueryProfile.anyDouble", 8.76, registry);
profile.set("myUserQueryProfile.myUserString", "value2", registry);
@@ -204,22 +200,22 @@ public class QueryProfileTypeTestCase {
/** Tests assigning a subprofile directly */
@Test
- public void testTypedAssignmentOfQueryProfilesNonStrict() {
+ void testTypedAssignmentOfQueryProfilesNonStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
- QueryProfile map1=new QueryProfile("myMap1");
+ QueryProfile map1 = new QueryProfile("myMap1");
map1.set("key1", "value1", registry);
- QueryProfile map2=new QueryProfile("myMap2");
+ QueryProfile map2 = new QueryProfile("myMap2");
map2.set("key2", "value2", registry);
- QueryProfile myUser=new QueryProfile("myUser");
+ QueryProfile myUser = new QueryProfile("myUser");
myUser.setType(user);
myUser.set("myUserString", "userValue1", registry);
myUser.set("myUserInteger", 442, registry);
- assertWrongType(profile,"reference to a query profile","myQueryProfile","aString");
+ assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
profile.set("myQueryProfile", map1, registry);
profile.set("someMap", map2, registry); // Legal because this is not strict
assertWrongType(profile, "reference to a query profile of type 'user'", "myUserQueryProfile", map1);
@@ -235,14 +231,14 @@ public class QueryProfileTypeTestCase {
/** Tests assigning a subprofile directly */
@Test
- public void testTypedAssignmentOfQueryProfilesStrict() {
+ void testTypedAssignmentOfQueryProfilesStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtypeStrict);
- QueryProfile map1=new QueryProfile("myMap1");
+ QueryProfile map1 = new QueryProfile("myMap1");
map1.set("key1", "value1", registry);
- QueryProfile map2=new QueryProfile("myMap2");
+ QueryProfile map2 = new QueryProfile("myMap2");
map2.set("key2", "value2", registry);
QueryProfile myUser = new QueryProfile("myUser");
@@ -250,10 +246,10 @@ public class QueryProfileTypeTestCase {
myUser.set("myUserString", "userValue1", registry);
myUser.set("myUserInteger", 442, registry);
- assertWrongType(profile,"reference to a query profile","myQueryProfile","aString");
+ assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
profile.set("myQueryProfile", map1, registry);
- assertNotPermitted(profile,"someMap", map2);
- assertWrongType(profile,"reference to a query profile of type 'userStrict'", "myUserQueryProfile", map1);
+ assertNotPermitted(profile, "someMap", map2);
+ assertWrongType(profile, "reference to a query profile of type 'userStrict'", "myUserQueryProfile", map1);
profile.set("myUserQueryProfile", myUser, registry);
CompiledQueryProfile cprofile = profile.compile(null);
@@ -266,7 +262,7 @@ public class QueryProfileTypeTestCase {
/** Tests assigning a subprofile as an id string */
@Test
- public void testTypedAssignmentOfQueryProfileReferencesNonStrict() {
+ void testTypedAssignmentOfQueryProfileReferencesNonStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
@@ -286,21 +282,21 @@ public class QueryProfileTypeTestCase {
registry.register(map2);
registry.register(myUser);
- assertWrongType(profile,"reference to a query profile", "myQueryProfile", "aString");
+ assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
registry.register(map1);
profile.set("myQueryProfile", "myMap1", registry);
registry.register(map2);
profile.set("someMap", "myMap2", registry); // NOTICE: Will set as a string because we cannot know this is a reference
assertWrongType(profile, "reference to a query profile of type 'user'", "myUserQueryProfile", "myMap1");
registry.register(myUser);
- profile.set("myUserQueryProfile","myUser", registry);
+ profile.set("myUserQueryProfile", "myUser", registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cprofile = cRegistry.getComponent("test");
assertEquals("value1", cprofile.get("myQueryProfile.key1"));
assertEquals("myMap2", cprofile.get("someMap"));
- assertNull("Asking for an value which cannot be completely resolved returns null", cprofile.get("someMap.key2"));
+ assertNull(cprofile.get("someMap.key2"), "Asking for an value which cannot be completely resolved returns null");
assertEquals("userValue1", cprofile.get("myUserQueryProfile.myUserString"));
assertEquals(442, cprofile.get("myUserQueryProfile.myUserInteger"));
}
@@ -310,11 +306,11 @@ public class QueryProfileTypeTestCase {
* Here there exists a user profile already, and then a new one is overwritten
*/
@Test
- public void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQuery() {
+ void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQuery() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
- QueryProfile myUser=new QueryProfile("myUser");
+ QueryProfile myUser = new QueryProfile("myUser");
myUser.setType(user);
myUser.set("myUserString", "userValue1", registry);
myUser.set("myUserInteger", 442, registry);
@@ -332,8 +328,8 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfile cprofile = cRegistry.getComponent("test");
Query query = new Query(HttpRequest.createTestRequest("?myUserQueryProfile=newUser",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cprofile);
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cprofile);
assertEquals(0, query.errors().size());
@@ -346,7 +342,7 @@ public class QueryProfileTypeTestCase {
* Here no user profile is set before it is assigned in the query
*/
@Test
- public void testTypedAssignmentOfQueryProfileReferencesNonStrictThroughQuery() {
+ void testTypedAssignmentOfQueryProfileReferencesNonStrictThroughQuery() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
@@ -361,8 +357,8 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfile cprofile = cRegistry.getComponent("test");
Query query = new Query(HttpRequest.createTestRequest("?myUserQueryProfile=newUser",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cprofile);
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cprofile);
assertEquals(0, query.errors().size());
@@ -375,7 +371,7 @@ public class QueryProfileTypeTestCase {
* Here no user profile is set before it is assigned in the query
*/
@Test
- public void testTypedAssignmentOfQueryProfileReferencesStrictThroughQuery() {
+ void testTypedAssignmentOfQueryProfileReferencesStrictThroughQuery() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtypeStrict);
@@ -401,13 +397,13 @@ public class QueryProfileTypeTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'myUserQueryProfile.someKey' to 'value': 'someKey' is not declared in query profile type 'userStrict', and the type is strict",
- Exceptions.toMessageString(e));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testTensorRankFeatureInRequest() {
+ void testTensorRankFeatureInRequest() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
registry.register(profile);
@@ -415,16 +411,16 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query(HttpRequest.createTestRequest("?" + urlEncode("ranking.features.query(myTensor1)") +
- "=" + urlEncode(tensorString),
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("test"));
+ "=" + urlEncode(tensorString),
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cRegistry.getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(Tensor.from(tensorString), query.properties().get("ranking.features.query(myTensor1)"));
assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
@Test
- public void testTensorRankFeatureSetProgrammatically() {
+ void testTensorRankFeatureSetProgrammatically() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
registry.register(profile);
@@ -432,13 +428,13 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query(HttpRequest.createTestRequest("?", com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("test"));
+ cRegistry.getComponent("test"));
query.properties().set("ranking.features.query(myTensor1)", Tensor.from(tensorString));
assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
@Test
- public void testTensorRankFeatureSetProgrammaticallyWithWrongType() {
+ void testTensorRankFeatureSetProgrammaticallyWithWrongType() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
registry.register(profile);
@@ -446,15 +442,15 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "tensor(x[3]):[0.1, 0.2, 0.3]";
Query query = new Query(HttpRequest.createTestRequest("?", com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("test"));
+ cRegistry.getComponent("test"));
try {
- query.getRanking().getFeatures().put("query(myTensor1)",Tensor.from(tensorString));
+ query.getRanking().getFeatures().put("query(myTensor1)", Tensor.from(tensorString));
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'ranking.features.query(myTensor1)' to 'tensor(x[3]):[0.1, 0.2, 0.3]': " +
- "Require a tensor of type tensor(a{},b{})",
- Exceptions.toMessageString(e));
+ "Require a tensor of type tensor(a{},b{})",
+ Exceptions.toMessageString(e));
}
try {
query.properties().set("ranking.features.query(myTensor1)", Tensor.from(tensorString));
@@ -462,14 +458,14 @@ public class QueryProfileTypeTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'ranking.features.query(myTensor1)' to 'tensor(x[3]):[0.1, 0.2, 0.3]': " +
- "Require a tensor of type tensor(a{},b{})",
- Exceptions.toMessageString(e));
+ "Require a tensor of type tensor(a{},b{})",
+ Exceptions.toMessageString(e));
}
}
// Expected to work exactly as testTensorRankFeatureInRequest
@Test
- public void testTensorRankFeatureInRequestWithInheritedQueryProfileType() {
+ void testTensorRankFeatureInRequestWithInheritedQueryProfileType() {
QueryProfile profile = new QueryProfile("test");
profile.setType(emptyInheritingTesttype);
registry.register(profile);
@@ -477,16 +473,16 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query(HttpRequest.createTestRequest("?" + urlEncode("ranking.features.query(myTensor1)") +
- "=" + urlEncode(tensorString),
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("test"));
+ "=" + urlEncode(tensorString),
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cRegistry.getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(Tensor.from(tensorString), query.properties().get("ranking.features.query(myTensor1)"));
assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
@Test
- public void testUnembeddedTensorRankFeatureInRequest() {
+ void testUnembeddedTensorRankFeatureInRequest() {
String text = "text to embed into a tensor";
Tensor embedding1 = Tensor.from("tensor<float>(x[5]):[3,7,4,0,0]]");
Tensor embedding2 = Tensor.from("tensor<float>(x[5]):[1,2,3,4,0]]");
@@ -500,7 +496,7 @@ public class QueryProfileTypeTestCase {
assertEmbedQuery("embed(emb1, '" + text + "')", embedding1, embedders);
assertEmbedQuery("embed(emb1, \"" + text + "\")", embedding1, embedders);
assertEmbedQueryFails("embed(emb2, \"" + text + "\")", embedding1, embedders,
- "Can't find embedder 'emb2'. Valid embedders are emb1");
+ "Can't find embedder 'emb2'. Valid embedders are emb1");
embedders = Map.of(
"emb1", new MockEmbedder(text, Language.UNKNOWN, embedding1),
@@ -530,7 +526,7 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testIllegalStrictAssignmentFromRequest() {
+ void testIllegalStrictAssignmentFromRequest() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtypeStrict);
@@ -541,13 +537,13 @@ public class QueryProfileTypeTestCase {
try {
new Query(HttpRequest.createTestRequest("?myUserQueryProfile.nondeclared=someValue",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- profile.compile(null));
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ profile.compile(null));
fail("Above statement should throw");
} catch (IllegalArgumentException e) {
// As expected.
assertTrue(Exceptions.toMessageString(e).contains(
- "Could not set 'myUserQueryProfile.nondeclared' to 'someValue': 'nondeclared' is not declared in query profile type 'userStrict', and the type is strict"));
+ "Could not set 'myUserQueryProfile.nondeclared' to 'someValue': 'nondeclared' is not declared in query profile type 'userStrict', and the type is strict"));
}
}
@@ -557,7 +553,7 @@ public class QueryProfileTypeTestCase {
* The whole thing is accessed through a two levels of nontyped top-level profiles
*/
@Test
- public void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
+ void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
@@ -586,8 +582,8 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myUserQueryProfile=newUser",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("topMap"));
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cRegistry.getComponent("topMap"));
assertEquals(0, query.errors().size());
@@ -599,7 +595,7 @@ public class QueryProfileTypeTestCase {
* Same as previous test but using the untyped myQueryProfile reference instead of the typed myUserQueryProfile
*/
@Test
- public void testAnonTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
+ void testAnonTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
@@ -630,15 +626,15 @@ public class QueryProfileTypeTestCase {
Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myQueryProfile=newUser", com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("topMap"));
assertEquals(0, query.errors().size());
- assertEquals("newUserValue1",query.properties().get("subMap.typeProfile.myQueryProfile.myUserString"));
- assertEquals(845,query.properties().get("subMap.typeProfile.myQueryProfile.myUserInteger"));
+ assertEquals("newUserValue1", query.properties().get("subMap.typeProfile.myQueryProfile.myUserString"));
+ assertEquals(845, query.properties().get("subMap.typeProfile.myQueryProfile.myUserInteger"));
}
/**
* Tests setting a illegal value in a strict profile nested under untyped maps
*/
@Test
- public void testSettingValueInStrictTypeNestedUnderUntypedMaps() {
+ void testSettingValueInStrictTypeNestedUnderUntypedMaps() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
@@ -656,13 +652,13 @@ public class QueryProfileTypeTestCase {
try {
new Query(
HttpRequest.createTestRequest("?subMap.typeProfile.someValue=value",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
cRegistry.getComponent("topMap"));
fail("Above statement should throw");
} catch (IllegalArgumentException e) {
// As expected.
assertTrue(Exceptions.toMessageString(e).contains(
- "Could not set 'subMap.typeProfile.someValue' to 'value': 'someValue' is not declared in query profile type 'testtypeStrict', and the type is strict"));
+ "Could not set 'subMap.typeProfile.someValue' to 'value': 'someValue' is not declared in query profile type 'testtypeStrict', and the type is strict"));
}
}
@@ -672,15 +668,15 @@ public class QueryProfileTypeTestCase {
* The whole thing is accessed through a two levels of nontyped top-level profiles
*/
@Test
- public void testTypedSettingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
+ void testTypedSettingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
- topMap.set("subMap",subMap, registry);
+ topMap.set("subMap", subMap, registry);
QueryProfile test = new QueryProfile("test");
test.setType(testtype);
- subMap.set("typeProfile",test, registry);
+ subMap.set("typeProfile", test, registry);
QueryProfile newUser = new QueryProfile("newUser");
newUser.setType(user);
@@ -694,8 +690,8 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myUserQueryProfile=newUser",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("topMap"));
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cRegistry.getComponent("topMap"));
assertEquals(0, query.errors().size());
assertEquals("newUserValue1", query.properties().get("subMap.typeProfile.myUserQueryProfile.myUserString"));
@@ -703,14 +699,14 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testNestedTypeName() {
+ void testNestedTypeName() {
ComponentId.resetGlobalCountersForTests();
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType type = new QueryProfileType("testType");
registry.getTypeRegistry().register(type);
type.addField(new FieldDescription("ranking.features.query(embedding_profile)",
- "tensor<float>(model{},x[128])"),
- registry.getTypeRegistry());
+ "tensor<float>(model{},x[128])"),
+ registry.getTypeRegistry());
QueryProfile test = new QueryProfile("test");
registry.register(test);
test.setType(type);
@@ -723,15 +719,15 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testNestedTypeNameUsingBuiltInTypes() {
+ void testNestedTypeNameUsingBuiltInTypes() {
ComponentId.resetGlobalCountersForTests();
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType type = new QueryProfileType("testType");
type.inherited().add(Query.getArgumentType()); // Include native type checking
registry.getTypeRegistry().register(type);
type.addField(new FieldDescription("ranking.features.query(embedding_profile)",
- "tensor<float>(model{},x[128])"),
- registry.getTypeRegistry());
+ "tensor<float>(model{},x[128])"),
+ registry.getTypeRegistry());
QueryProfile test = new QueryProfile("test");
registry.register(test);
test.setType(type);
@@ -745,7 +741,7 @@ public class QueryProfileTypeTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("'foo' is not a valid property in 'ranking'. See the query api for valid keys starting by 'ranking'.",
- e.getCause().getMessage());
+ e.getCause().getMessage());
}
// With a prefix we're not in the built-in type space
diff --git a/container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java b/container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java
index 5fbe8858186..46859ab1cbe 100644
--- a/container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java
@@ -2,13 +2,12 @@
package com.yahoo.search.query.properties.test;
import com.yahoo.processing.request.properties.PropertyMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -16,24 +15,24 @@ import static org.junit.Assert.assertTrue;
public class PropertyMapTestCase {
@Test
- public void testCloning() {
+ void testCloning() {
PropertyMap map = new PropertyMap();
map.set("clonable", new ClonableObject());
map.set("nonclonable", new NonClonableObject());
- map.set("clonableArray", new ClonableObject[] {new ClonableObject()});
- map.set("nonclonableArray", new NonClonableObject[] {new NonClonableObject()});
+ map.set("clonableArray", new ClonableObject[]{new ClonableObject()});
+ map.set("nonclonableArray", new NonClonableObject[]{new NonClonableObject()});
map.set("clonableList", Collections.singletonList(new ClonableObject()));
map.set("nonclonableList", Collections.singletonList(new NonClonableObject()));
assertNotNull(map.get("clonable"));
assertNotNull(map.get("nonclonable"));
- PropertyMap mapClone=map.clone();
+ PropertyMap mapClone = map.clone();
assertTrue(map.get("clonable") != mapClone.get("clonable"));
- assertTrue(map.get("nonclonable") == mapClone.get("nonclonable"));
+ assertEquals(map.get("nonclonable"), mapClone.get("nonclonable"));
assertTrue(map.get("clonableArray") != mapClone.get("clonableArray"));
assertTrue(first(map.get("clonableArray")) != first(mapClone.get("clonableArray")));
- assertTrue(first(map.get("nonclonableArray")) == first(mapClone.get("nonclonableArray")));
+ assertEquals(first(map.get("nonclonableArray")), first(mapClone.get("nonclonableArray")));
}
private Object first(Object object) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java
index 2a123b4bbda..23b41092660 100644
--- a/container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java
@@ -5,9 +5,9 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests that dimension arguments in queries are transferred correctly to dimension values
@@ -17,18 +17,18 @@ import static org.junit.Assert.assertEquals;
public class RequestContextPropertiesTestCase {
@Test
- public void testIt() {
- QueryProfile p=new QueryProfile("test");
- p.setDimensions(new String[] {"x"});
- p.set("a","a-default", (QueryProfileRegistry)null);
- p.set("a","a-x1",new String[] {"x1"}, null);
- p.set("a","a-+x1",new String[] {"+x1"}, null);
+ void testIt() {
+ QueryProfile p = new QueryProfile("test");
+ p.setDimensions(new String[]{"x"});
+ p.set("a", "a-default", (QueryProfileRegistry) null);
+ p.set("a", "a-x1", new String[]{"x1"}, null);
+ p.set("a", "a-+x1", new String[]{"+x1"}, null);
Query q1 = new Query(QueryTestCase.httpEncode("?query=foo"), p.compile(null));
- assertEquals("a-default",q1.properties().get("a"));
- Query q2 = new Query(QueryTestCase.httpEncode("?query=foo&x=x1"),p.compile(null));
- assertEquals("a-x1",q2.properties().get("a"));
- Query q3 = new Query(QueryTestCase.httpEncode("?query=foo&x=+x1"),p.compile(null));
- assertEquals("a-+x1",q3.properties().get("a"));
+ assertEquals("a-default", q1.properties().get("a"));
+ Query q2 = new Query(QueryTestCase.httpEncode("?query=foo&x=x1"), p.compile(null));
+ assertEquals("a-x1", q2.properties().get("a"));
+ Query q3 = new Query(QueryTestCase.httpEncode("?query=foo&x=+x1"), p.compile(null));
+ assertEquals("a-+x1", q3.properties().get("a"));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java
index 11c249c5cdb..0e9bf8d41ec 100644
--- a/container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java
@@ -1,15 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.properties.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Arrays;
import java.util.HashSet;
import com.yahoo.processing.request.properties.PropertyMap;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.search.query.properties.SubProperties;
/**
@@ -18,19 +17,21 @@ import com.yahoo.search.query.properties.SubProperties;
public class SubPropertiesTestCase {
@Test
- public void testSubProperties() {
- PropertyMap map = new PropertyMap() {{
- set("a.e","1");
- set("a.f",2);
- set("b.e","3");
- set("f",3);
- set("e","2");
- set("d","a");
- }};
+ void testSubProperties() {
+ PropertyMap map = new PropertyMap() {
+ {
+ set("a.e", "1");
+ set("a.f", 2);
+ set("b.e", "3");
+ set("f", 3);
+ set("e", "2");
+ set("d", "a");
+ }
+ };
SubProperties sub = new SubProperties("a", map);
- assertEquals("1",sub.get("e"));
- assertEquals(2,sub.get("f"));
+ assertEquals("1", sub.get("e"));
+ assertEquals(2, sub.get("f"));
assertNull(sub.get("d"));
assertEquals(new HashSet<>(Arrays.asList("e", "f")), sub.listProperties("").keySet());
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java
index 72b77377bf2..e502cf538aa 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java
@@ -1,12 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.rewrite;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertSame;
import com.yahoo.prelude.query.WeakAndItem;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.AndItem;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.query.CompositeItem;
import com.yahoo.prelude.query.Item;
import com.yahoo.language.process.SpecialTokenRegistry;
@@ -25,7 +26,7 @@ public class RewriterFeaturesTestCase {
private static final String ASCII_ELLIPSIS = "...";
@Test
- public final void testConvertStringToQTree() {
+ final void testConvertStringToQTree() {
Execution placeholder = new Execution(Context.createContextStub());
SpecialTokenRegistry tokenRegistry = new SpecialTokenRegistry(
new SpecialtokensConfig(
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java
index d9a3603bdaf..668d070b3e2 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java
@@ -8,8 +8,8 @@ import com.yahoo.search.searchchain.*;
import com.yahoo.search.query.rewrite.*;
import com.yahoo.search.query.rewrite.rewriters.*;
import com.yahoo.search.query.rewrite.RewritesConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test Cases for GenericExpansionRewriter
@@ -29,7 +29,7 @@ public class GenericExpansionRewriterTestCase {
* Load the GenericExpansionRewriterSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
@@ -44,149 +44,149 @@ public class GenericExpansionRewriterTestCase {
* MaxRewrites=3, PartialPhraseMatch is on, type=adv case
*/
@Test
- public void testPartialPhraseMaxRewriteAdvType() {
+ void testPartialPhraseMaxRewriteAdvType() {
utils.assertRewrittenQuery("?query=(modern new york city travel phone number) OR (travel agency) OR travel&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=3",
- "query 'OR (AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 " +
- "(AND new york city travel)) (OR pn (AND phone number))) ta (AND travel agency) " +
- "tr travel'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=3",
+ "query 'OR (AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 " +
+ "(AND new york city travel)) (OR pn (AND phone number))) ta (AND travel agency) " +
+ "tr travel'");
}
/**
* PartialPhraseMatch is off, type=adv case
*/
@Test
- public void testPartialPhraseNoMaxRewriteAdvType() {
+ void testPartialPhraseNoMaxRewriteAdvType() {
utils.assertRewrittenQuery("?query=(modern new york city travel phone number) OR (travel agency) OR travel&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'OR (AND modern new york city travel phone number) " +
- "ta (AND travel agency) tr travel'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'OR (AND modern new york city travel phone number) " +
+ "ta (AND travel agency) tr travel'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, type=adv, added filter case
*/
@Test
- public void testFullPhraseNoMaxRewriteAdvTypeFilter() {
+ void testFullPhraseNoMaxRewriteAdvTypeFilter() {
utils.assertRewrittenQuery("?query=ca OR (modern new york city travel phone number) OR (travel agency) OR travel&" +
- "type=adv&filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'RANK (OR california ca (AND modern new york city travel phone number) " +
- "ta (AND travel agency) tr travel) |citystate:santa |clara |ca'");
+ "type=adv&filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'RANK (OR california ca (AND modern new york city travel phone number) " +
+ "ta (AND travel agency) tr travel) |citystate:santa |clara |ca'");
}
/**
* MaxRewrites=0 (i.e No MaxRewrites), PartialPhraseMatch is on, type=adv, added filter case
*/
@Test
- public void testPartialPhraseNoMaxRewriteAdvTypeFilter() {
+ void testPartialPhraseNoMaxRewriteAdvTypeFilter() {
utils.assertRewrittenQuery("?query=ca OR (modern new york city travel phone number) OR (travel agency) OR travel&" +
- "type=adv&filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=0",
- "query 'RANK (OR california ca (AND modern (OR \"rewrite11 rewrite12\" " +
- "rewrite2 rewrite3 rewrite4 rewrite5 (AND new york city travel)) " +
- "(OR pn (AND phone number))) ta (AND travel agency) tr travel) " +
- "|citystate:santa |clara |ca'");
+ "type=adv&filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=0",
+ "query 'RANK (OR california ca (AND modern (OR \"rewrite11 rewrite12\" " +
+ "rewrite2 rewrite3 rewrite4 rewrite5 (AND new york city travel)) " +
+ "(OR pn (AND phone number))) ta (AND travel agency) tr travel) " +
+ "|citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, single word, added filter case
*/
@Test
- public void testFullPhraseNoMaxRewriteSingleWordFilter() {
+ void testFullPhraseNoMaxRewriteSingleWordFilter() {
utils.assertRewrittenQuery("?query=ca&type=all&" +
- "filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'RANK (OR california ca) |citystate:santa |clara |ca'");
+ "filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'RANK (OR california ca) |citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is on, single word, added filter case
*/
@Test
- public void testPartialPhraseNoMaxRewriteSingleWordFilter() {
+ void testPartialPhraseNoMaxRewriteSingleWordFilter() {
utils.assertRewrittenQuery("?query=ca&type=all&" +
- "filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'RANK (OR california ca) |citystate:santa |clara |ca'");
+ "filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'RANK (OR california ca) |citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, multi word, added filter case
*/
@Test
- public void testFullPhraseNoMaxRewriteMultiWordFilter() {
+ void testFullPhraseNoMaxRewriteMultiWordFilter() {
utils.assertRewrittenQuery("?query=travel agency&type=all&" +
- "filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'RANK (OR ta (AND travel agency)) |citystate:santa |clara |ca'");
+ "filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'RANK (OR ta (AND travel agency)) |citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is on, multi word, added filter case
*/
@Test
- public void testPartialPhraseNoMaxRewriteMultiWordFilter() {
+ void testPartialPhraseNoMaxRewriteMultiWordFilter() {
utils.assertRewrittenQuery("?query=modern new york city travel phone number&" +
- "filter=citystate:santa clara ca&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'RANK (AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 " +
- "rewrite4 rewrite5 (AND new york city travel)) (OR pn (AND phone number))) " +
- "|citystate:santa |clara |ca'");
+ "filter=citystate:santa clara ca&type=all&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'RANK (AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 " +
+ "rewrite4 rewrite5 (AND new york city travel)) (OR pn (AND phone number))) " +
+ "|citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, single word
*/
@Test
- public void testFullPhraseNoMaxRewriteSingleWord() {
+ void testFullPhraseNoMaxRewriteSingleWord() {
utils.assertRewrittenQuery("?query=ca&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'OR california ca'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'OR california ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is on, single word
*/
@Test
- public void testPartialPhraseNoMaxRewriteSingleWord() {
+ void testPartialPhraseNoMaxRewriteSingleWord() {
utils.assertRewrittenQuery("?query=ca&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'OR california ca'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'OR california ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, multi word
*/
@Test
- public void testFullPhraseNoMaxRewriteMultiWord() {
+ void testFullPhraseNoMaxRewriteMultiWord() {
utils.assertRewrittenQuery("?query=travel agency&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'OR ta (AND travel agency)'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'OR ta (AND travel agency)'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, multi word, no full match
*/
@Test
- public void testFullPhraseNoMaxRewriteMultiWordNoMatch() {
+ void testFullPhraseNoMaxRewriteMultiWordNoMatch() {
utils.assertRewrittenQuery("?query=nyc travel agency&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'AND nyc travel agency'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'AND nyc travel agency'");
}
/**
* No MaxRewrites, PartialPhraseMatch is on, multi word
*/
@Test
- public void testPartialPhraseNoMaxRewriteMultiWord() {
+ void testPartialPhraseNoMaxRewriteMultiWord() {
utils.assertRewrittenQuery("?query=modern new york city travel phone number&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 rewrite4 rewrite5 "+
- "(AND new york city travel)) (OR pn (AND phone number))'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 rewrite4 rewrite5 " +
+ "(AND new york city travel)) (OR pn (AND phone number))'");
}
/**
@@ -195,10 +195,10 @@ public class GenericExpansionRewriterTestCase {
* Should rewrite travel but not travel agency in this case
*/
@Test
- public void testPartialPhraseMultiWordRankTree() {
+ void testPartialPhraseMultiWordRankTree() {
utils.assertRewrittenQuery("?query=travel RANK agency&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'RANK (OR tr travel) agency'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'RANK (OR tr travel) agency'");
}
/**
@@ -207,10 +207,10 @@ public class GenericExpansionRewriterTestCase {
* Should rewrite travel but not travel agency in this case
*/
@Test
- public void testFullPhraseMultiWordRankTree() {
+ void testFullPhraseMultiWordRankTree() {
utils.assertRewrittenQuery("?query=travel RANK agency&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'RANK (OR tr travel) agency'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'RANK (OR tr travel) agency'");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java
index 6c9f9c248ea..36eb06a3a92 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java
@@ -6,10 +6,10 @@ import com.yahoo.search.searchchain.*;
import com.yahoo.search.intent.model.*;
import com.yahoo.search.query.rewrite.*;
import com.yahoo.search.query.rewrite.rewriters.*;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test Cases for MisspellRewriter
@@ -25,7 +25,7 @@ public class MisspellRewriterTestCase {
* Load the QueryRewriteSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
MisspellRewriter searcher = new MisspellRewriter();
Execution execution = QueryRewriteSearcherTestUtils.createExecutionObj(searcher);
@@ -37,18 +37,18 @@ public class MisspellRewriterTestCase {
* QLAS returns spell correction: qss_rw=0.9 qss_sugg=1.0
*/
@Test
- public void testQSSRewriteQSSSuggestWithRewrite() {
+ void testQSSRewriteQSSSuggestWithRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("will smith rw", 0.9,
- true, false),
- utils.createInterpretation("will smith sugg", 1.0,
- false, true));
+ utils.createInterpretation("will smith rw", 0.9,
+ true, false),
+ utils.createInterpretation("will smith sugg", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
- "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith sugg)'",
- intentModel);
+ REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
+ "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith sugg)'",
+ intentModel);
}
/**
@@ -56,19 +56,19 @@ public class MisspellRewriterTestCase {
* QLAS returns spell correction: qss_rw=0.9 qss_rw=0.9 qss_sugg=1.0
*/
@Test
- public void testQSSRewriteWithRewrite() {
+ void testQSSRewriteWithRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("will smith rw1", 0.9,
- true, false),
- utils.createInterpretation("will smith rw2", 0.9,
- true, false),
- utils.createInterpretation("will smith sugg", 1.0,
- false, true));
+ utils.createInterpretation("will smith rw1", 0.9,
+ true, false),
+ utils.createInterpretation("will smith rw2", 0.9,
+ true, false),
+ utils.createInterpretation("will smith sugg", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true",
- "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith rw1)'",
- intentModel);
+ REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true",
+ "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith rw1)'",
+ intentModel);
}
/**
@@ -76,19 +76,19 @@ public class MisspellRewriterTestCase {
* QLAS returns spell correction: qss_rw=1.0 qss_sugg=0.9 qss_sugg=0.8
*/
@Test
- public void testQSSSuggWithRewrite() {
+ void testQSSSuggWithRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("will smith rw", 1.0,
- true, false),
- utils.createInterpretation("will smith sugg1", 0.9,
- false, true),
- utils.createInterpretation("will smith sugg2", 0.8,
- false, true));
+ utils.createInterpretation("will smith rw", 1.0,
+ true, false),
+ utils.createInterpretation("will smith sugg1", 0.9,
+ false, true),
+ utils.createInterpretation("will smith sugg2", 0.8,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
- "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith sugg1)'",
- intentModel);
+ REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
+ "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith sugg1)'",
+ intentModel);
}
/**
@@ -96,16 +96,16 @@ public class MisspellRewriterTestCase {
* QLAS returns spell correction: qss_rw=1.0 qss_sugg=1.0
*/
@Test
- public void testFeautureOffWithRewrite() {
+ void testFeautureOffWithRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("will smith rw", 1.0,
- true, false),
- utils.createInterpretation("will smith sugg", 1.0,
- false, true));
+ utils.createInterpretation("will smith rw", 1.0,
+ true, false),
+ utils.createInterpretation("will smith sugg", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith",
- "query 'WEAKAND(100) willl smith'",
- intentModel);
+ "query 'WEAKAND(100) willl smith'",
+ intentModel);
}
/**
@@ -113,18 +113,18 @@ public class MisspellRewriterTestCase {
* QLAS returns no spell correction
*/
@Test
- public void testQSSRewriteQSSSuggWithoutRewrite() {
+ void testQSSRewriteQSSSuggWithoutRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("use diff query for testing", 1.0,
- false, false),
- utils.createInterpretation("use diff query for testing", 1.0,
- false, false));
+ utils.createInterpretation("use diff query for testing", 1.0,
+ false, false),
+ utils.createInterpretation("use diff query for testing", 1.0,
+ false, false));
utils.assertRewrittenQuery("?query=will+smith&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
- "query 'WEAKAND(100) will smith'",
- intentModel);
+ REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
+ "query 'WEAKAND(100) will smith'",
+ intentModel);
}
/**
@@ -132,7 +132,7 @@ public class MisspellRewriterTestCase {
* It should throw exception
*/
@Test
- public void testNullIntentModelException() {
+ void testNullIntentModelException() {
try {
RewriterUtils.getSpellCorrected(new Query("willl smith"), true, true);
fail();
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java
index c99ddcd6c62..98a93a572e9 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java
@@ -8,8 +8,8 @@ import com.yahoo.search.searchchain.*;
import com.yahoo.search.query.rewrite.*;
import com.yahoo.search.query.rewrite.rewriters.*;
import com.yahoo.search.query.rewrite.RewritesConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test Cases for NameRewriter
@@ -29,7 +29,7 @@ public class NameRewriterTestCase {
* Load the NameRewriterSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
@@ -44,29 +44,29 @@ public class NameRewriterTestCase {
* RewritesAsEquiv and OriginalAsUnit are on
*/
@Test
- public void testRewritesAsEquivAndOriginalAsUnit() {
+ void testRewritesAsEquivAndOriginalAsUnit() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
- "query 'OR \"will smith\" (AND will smith movies) " +
- "(AND will smith news) (AND will smith imdb) " +
- "(AND will smith lyrics) (AND will smith dead) " +
- "(AND will smith nfl) (AND will smith new movie hancock) " +
- "(AND will smith biography)'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
+ "query 'OR \"will smith\" (AND will smith movies) " +
+ "(AND will smith news) (AND will smith imdb) " +
+ "(AND will smith lyrics) (AND will smith dead) " +
+ "(AND will smith nfl) (AND will smith new movie hancock) " +
+ "(AND will smith biography)'");
}
/**
* RewritesAsEquiv is on
*/
@Test
- public void testRewritesAsEquiv() {
+ void testRewritesAsEquiv() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&",
- "query 'OR (AND will smith) (AND will smith movies) " +
- "(AND will smith news) (AND will smith imdb) " +
- "(AND will smith lyrics) (AND will smith dead) " +
- "(AND will smith nfl) (AND will smith new movie hancock) " +
- "(AND will smith biography)'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&",
+ "query 'OR (AND will smith) (AND will smith movies) " +
+ "(AND will smith news) (AND will smith imdb) " +
+ "(AND will smith lyrics) (AND will smith dead) " +
+ "(AND will smith nfl) (AND will smith new movie hancock) " +
+ "(AND will smith biography)'");
}
/**
@@ -74,57 +74,57 @@ public class NameRewriterTestCase {
* Should not rewrite
*/
@Test
- public void testComplextQueryRewritesAsEquiv() {
+ void testComplextQueryRewritesAsEquiv() {
utils.assertRewrittenQuery("?query=((will smith) OR (willl smith)) AND (tom cruise)&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&",
- "query 'AND (OR (AND will smith) (AND willl smith)) (AND tom cruise)'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&",
+ "query 'AND (OR (AND will smith) (AND willl smith)) (AND tom cruise)'");
}
/**
* Single word query for RewritesAsEquiv and OriginalAsUnit on case
*/
@Test
- public void testSingleWordForRewritesAsEquivAndOriginalAsUnit() {
+ void testSingleWordForRewritesAsEquivAndOriginalAsUnit() {
utils.assertRewrittenQuery("?query=obama&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
- "query 'OR obama (AND obama \"nobel peace prize\") " +
- "(AND obama wiki) (AND obama nobel prize) " +
- "(AND obama nobel peace prize) (AND obama wears mom jeans) " +
- "(AND obama sucks) (AND obama news) (AND malia obama) " +
- "(AND obama speech) (AND obama nobel) (AND obama wikipedia) " +
- "(AND barack obama biography) (AND obama snl) " +
- "(AND obama peace prize) (AND michelle obama) (AND barack obama)'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
+ "query 'OR obama (AND obama \"nobel peace prize\") " +
+ "(AND obama wiki) (AND obama nobel prize) " +
+ "(AND obama nobel peace prize) (AND obama wears mom jeans) " +
+ "(AND obama sucks) (AND obama news) (AND malia obama) " +
+ "(AND obama speech) (AND obama nobel) (AND obama wikipedia) " +
+ "(AND barack obama biography) (AND obama snl) " +
+ "(AND obama peace prize) (AND michelle obama) (AND barack obama)'");
}
/**
* RewritesAsUnitEquiv and OriginalAsUnitEquiv are on
*/
@Test
- public void testRewritesAsUnitEquivAndOriginalAsUnitEquiv() {
+ void testRewritesAsUnitEquivAndOriginalAsUnitEquiv() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV +
- "=true",
- "query 'OR (AND will smith) \"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV +
+ "=true",
+ "query 'OR (AND will smith) \"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'");
}
/**
* Single word query for RewritesAsUnitEquiv and OriginalAsUnitEquiv on case
*/
@Test
- public void testSingleWordForRewritesAsUnitEquivAndOriginalAsUnitEquiv() {
+ void testSingleWordForRewritesAsUnitEquivAndOriginalAsUnitEquiv() {
utils.assertRewrittenQuery("?query=obama&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV +
- "=true",
- "query 'OR obama \"obama nobel peace prize\" \"obama wiki\" \"obama nobel prize\" \"obama nobel peace prize\" \"obama wears mom jeans\" \"obama sucks\" \"obama news\" \"malia obama\" \"obama speech\" \"obama nobel\" \"obama wikipedia\" \"barack obama biography\" \"obama snl\" \"obama peace prize\" \"michelle obama\" \"barack obama\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV +
+ "=true",
+ "query 'OR obama \"obama nobel peace prize\" \"obama wiki\" \"obama nobel prize\" \"obama nobel peace prize\" \"obama wears mom jeans\" \"obama sucks\" \"obama news\" \"malia obama\" \"obama speech\" \"obama nobel\" \"obama wikipedia\" \"barack obama biography\" \"obama snl\" \"obama peace prize\" \"michelle obama\" \"barack obama\"'");
}
/**
@@ -132,11 +132,11 @@ public class NameRewriterTestCase {
* for RewritesAsEquiv and OriginalAsUnit on case
*/
@Test
- public void testBoostingQueryForRewritesAsEquivAndOriginalAsUnit() {
+ void testBoostingQueryForRewritesAsEquivAndOriginalAsUnit() {
utils.assertRewrittenQuery("?query=angelina jolie&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
- "query '\"angelina jolie\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
+ "query '\"angelina jolie\"'");
}
/**
@@ -144,39 +144,39 @@ public class NameRewriterTestCase {
* RewritesAsEquiv and OriginalAsUnit on case
*/
@Test
- public void testFSANoMatchForRewritesAsEquivAndOriginalAsUnit() {
+ void testFSANoMatchForRewritesAsEquivAndOriginalAsUnit() {
utils.assertRewrittenQuery("?query=tom cruise&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
- "query 'AND tom cruise'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
+ "query 'AND tom cruise'");
}
/**
* RewritesAsUnitEquiv is on
*/
@Test
- public void testRewritesAsUnitEquiv() {
+ void testRewritesAsUnitEquiv() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true",
- "query 'OR (AND will smith) \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true",
+ "query 'OR (AND will smith) \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'");
}
/**
* RewritesAsUnitEquiv is on and MaxRewrites is set to 2
*/
@Test
- public void testRewritesAsUnitEquivAndMaxRewrites() {
+ void testRewritesAsUnitEquivAndMaxRewrites() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=2",
- "query 'OR (AND will smith) \"will smith movies\" " +
- "\"will smith news\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=2",
+ "query 'OR (AND will smith) \"will smith movies\" " +
+ "\"will smith news\"'");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java
index 8906dbfa386..4848483688e 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java
@@ -10,8 +10,8 @@ import com.yahoo.search.intent.model.*;
import com.yahoo.search.query.rewrite.RewritesConfig;
import com.yahoo.search.query.rewrite.*;
import com.yahoo.search.query.rewrite.rewriters.*;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Generic Test Cases for QueryRewriteSearcher
@@ -36,7 +36,7 @@ public class QueryRewriteSearcherTestCase {
* Load the QueryRewriteSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
// Instantiate Name Rewriter
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
@@ -61,7 +61,7 @@ public class QueryRewriteSearcherTestCase {
* Query will be passed to next rewriter
*/
@Test
- public void testInvalidFSAConfigPath() {
+ void testInvalidFSAConfigPath() {
// Instantiate Name Rewriter with fake FSA path
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(FAKE_FSA_CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
@@ -80,9 +80,9 @@ public class QueryRewriteSearcherTestCase {
QueryRewriteSearcherTestUtils utilsWithFakePath = new QueryRewriteSearcherTestUtils(execution);
utilsWithFakePath.assertRewrittenQuery("?query=will smith&type=all&" +
- NAME_REWRITER_NAME + "." +
- RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true",
- "query 'AND will smith'");
+ NAME_REWRITER_NAME + "." +
+ RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true",
+ "query 'AND will smith'");
}
/**
@@ -90,19 +90,19 @@ public class QueryRewriteSearcherTestCase {
* It should skip to the next rewriter
*/
@Test
- public void testExceptionInRewriter() {
+ void testExceptionInRewriter() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
- "query 'OR (AND will smith) " +
- "\"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'");
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
+ "query 'OR (AND will smith) " +
+ "\"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'");
}
/**
@@ -110,26 +110,26 @@ public class QueryRewriteSearcherTestCase {
* Query will be rewritten twice
*/
@Test
- public void testTwoRewritersInChain() {
+ void testTwoRewritersInChain() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("wills smith", 0.9,
- true, false),
- utils.createInterpretation("will smith", 1.0,
- false, true));
+ utils.createInterpretation("wills smith", 0.9,
+ true, false),
+ utils.createInterpretation("will smith", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&type=all&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
- "query 'OR (AND willl smith) (AND will smith) " +
- "\"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'",
- intentModel);
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
+ "query 'OR (AND willl smith) (AND will smith) " +
+ "\"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'",
+ intentModel);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java
index c12a3fb0e14..960eea5bba7 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java
@@ -13,10 +13,11 @@ import com.yahoo.text.interpretation.Interpretation;
import com.yahoo.text.interpretation.Annotations;
import com.yahoo.config.subscription.ConfigGetter;
import com.yahoo.component.chain.Chain;
-import org.junit.Assert;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test utilities for QueryRewriteSearcher
*
@@ -73,7 +74,7 @@ public class QueryRewriteSearcherTestUtils {
public void assertRewrittenQuery(String origQuery, String finalQuery) {
Query query = new Query(QueryTestCase.httpEncode(origQuery));
Result result = execution.search(query);
- Assert.assertEquals(finalQuery, result.getQuery().toString());
+ assertEquals(finalQuery, result.getQuery().toString());
}
/**
@@ -89,7 +90,7 @@ public class QueryRewriteSearcherTestUtils {
Query query = new Query(origQuery);
intentModel.setTo(query);
Result result = execution.search(query);
- Assert.assertEquals(finalQuery, result.getQuery().toString());
+ assertEquals(finalQuery, result.getQuery().toString());
}
/**
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java
index 96626738c35..56797768f56 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java
@@ -12,8 +12,8 @@ import com.yahoo.search.searchchain.SearchChainRegistry;
import com.yahoo.search.query.rewrite.RewritesConfig;
import com.yahoo.search.intent.model.*;
import com.yahoo.component.chain.Chain;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test Cases for SearchChainDispatcherSearcher
@@ -35,7 +35,7 @@ public class SearchChainDispatcherSearcherTestCase {
* Load the QueryRewriteSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
// Instantiate Name Rewriter
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
@@ -70,26 +70,26 @@ public class SearchChainDispatcherSearcherTestCase {
* Query will be rewritten twice
*/
@Test
- public void testMarketChain() {
+ void testMarketChain() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("wills smith", 0.9,
- true, false),
- utils.createInterpretation("will smith", 1.0,
- false, true));
+ utils.createInterpretation("wills smith", 0.9,
+ true, false),
+ utils.createInterpretation("will smith", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&type=all&QRWChain=" + US_MARKET_SEARCH_CHAIN + "&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
- "query 'OR (AND willl smith) (AND will smith) " +
- "\"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'",
- intentModel);
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
+ "query 'OR (AND willl smith) (AND will smith) " +
+ "\"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'",
+ intentModel);
}
/**
@@ -97,13 +97,13 @@ public class SearchChainDispatcherSearcherTestCase {
* Query will be passed to next rewriter
*/
@Test
- public void testInvalidMarketChain() {
+ void testInvalidMarketChain() {
utils.assertRewrittenQuery("?query=will smith&type=all&QRWChain=abc&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true",
- "query 'AND will smith'");
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true",
+ "query 'AND will smith'");
}
/**
@@ -111,13 +111,13 @@ public class SearchChainDispatcherSearcherTestCase {
* Query will be passed to next rewriter
*/
@Test
- public void testEmptyMarketChain() {
+ void testEmptyMarketChain() {
utils.assertRewrittenQuery("?query=will smith&type=all&QRWChain=&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true",
- "query 'AND will smith'");
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true",
+ "query 'AND will smith'");
}
/**
@@ -125,7 +125,7 @@ public class SearchChainDispatcherSearcherTestCase {
* should be executed
*/
@Test
- public void testChainContinuation() {
+ void testChainContinuation() {
// Instantiate Name Rewriter
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
@@ -156,24 +156,24 @@ public class SearchChainDispatcherSearcherTestCase {
new QueryRewriteSearcherTestUtils(execution);
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("wills smith", 0.9,
- true, false),
- utils.createInterpretation("will smith", 1.0,
- false, true));
+ utils.createInterpretation("wills smith", 0.9,
+ true, false),
+ utils.createInterpretation("will smith", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&type=all&QRWChain=" + US_MARKET_SEARCH_CHAIN + "&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
- "query 'OR (AND willl smith) (AND will smith) " +
- "\"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'",
- intentModel);
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
+ "query 'OR (AND willl smith) (AND will smith) " +
+ "\"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'",
+ intentModel);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java
index 6f856144b8a..49d43bdc4c2 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java
@@ -4,18 +4,16 @@ package com.yahoo.search.query.test;
import com.yahoo.prelude.query.Item;
import com.yahoo.search.Query;
import com.yahoo.search.query.Model;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.LinkedHashSet;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
@@ -25,13 +23,13 @@ public class ModelTestCase {
String oldConfigId;
- @Before
+ @BeforeEach
public void setUp() {
oldConfigId = System.getProperty("config.id");
System.setProperty("config.id", "file:src/test/java/com/yahoo/prelude/test/fieldtypes/field-info.cfg");
}
- @After
+ @AfterEach
public void tearDown() {
if (oldConfigId == null)
System.getProperties().remove("config.id");
@@ -40,30 +38,30 @@ public class ModelTestCase {
}
@Test
- public void testCopyParameters() {
+ void testCopyParameters() {
Query q1 = new Query("?query=test1&filter=test2&default-index=content&default-index=lala&encoding=iso8859-1");
Query q2 = q1.clone();
Model r1 = q1.getModel();
Model r2 = q2.getModel();
assertTrue(r1 != r2);
- assertEquals(r1,r2);
- assertEquals("test1",r2.getQueryString());
+ assertEquals(r1, r2);
+ assertEquals("test1", r2.getQueryString());
}
@Test
- public void testSetQuery() {
+ void testSetQuery() {
Query q1 = new Query("?query=test1");
Item r1 = q1.getModel().getQueryTree();
- q1.properties().set("query","test2");
+ q1.properties().set("query", "test2");
q1.getModel().setQueryString(q1.getModel().getQueryString()); // Force reparse
- assertNotSame(r1,q1.getModel().getQueryTree());
- q1.properties().set("query","test1");
+ assertNotSame(r1, q1.getModel().getQueryTree());
+ q1.properties().set("query", "test1");
q1.getModel().setQueryString(q1.getModel().getQueryString()); // Force reparse
- assertEquals(r1,q1.getModel().getQueryTree());
+ assertEquals(r1, q1.getModel().getQueryTree());
}
@Test
- public void testSetofSetters() {
+ void testSetofSetters() {
Query q1 = new Query("?query=test1&encoding=iso-8859-1&language=en&default-index=subject&filter=" + enc("\u00C5"));
Model r1 = q1.getModel();
assertEquals(r1.getQueryString(), "test1");
@@ -82,23 +80,23 @@ public class ModelTestCase {
}
@Test
- public void testSearchPath() {
- assertEquals("c6/r8",new Query("?query=test1&model.searchPath=c6/r8").getModel().getSearchPath());
- assertEquals("c6/r8",new Query("?query=test1&searchpath=c6/r8").getModel().getSearchPath());
+ void testSearchPath() {
+ assertEquals("c6/r8", new Query("?query=test1&model.searchPath=c6/r8").getModel().getSearchPath());
+ assertEquals("c6/r8", new Query("?query=test1&searchpath=c6/r8").getModel().getSearchPath());
}
@Test
- public void testClone() {
- Query q= new Query();
+ void testClone() {
+ Query q = new Query();
Model sr = new Model(q);
sr.setRestrict("music, cheese,other");
sr.setSources("cluster1");
assertEquals(sr.getSources(), new LinkedHashSet<>(Arrays.asList(new String[]{"cluster1"})));
- assertEquals(sr.getRestrict(),new LinkedHashSet<>(Arrays.asList(new String[]{"cheese","music","other"})));
+ assertEquals(sr.getRestrict(), new LinkedHashSet<>(Arrays.asList(new String[]{"cheese", "music", "other"})));
}
@Test
- public void testEquals() {
+ void testEquals() {
Query q = new Query();
Model sra = new Model(q);
sra.setRestrict("music,cheese");
@@ -107,20 +105,20 @@ public class ModelTestCase {
Model srb = new Model(q);
srb.setRestrict(" cheese , music");
srb.setSources("cluster1,cluster2");
- assertEquals(sra,srb);
+ assertEquals(sra, srb);
srb.setRestrict("music,cheese");
- assertNotSame(sra,srb);
+ assertNotSame(sra, srb);
}
@Test
- public void testSearchRestrictQueryParameters() {
- Query query=new Query("?query=test&search=news,archive&restrict=fish,bird");
+ void testSearchRestrictQueryParameters() {
+ Query query = new Query("?query=test&search=news,archive&restrict=fish,bird");
assertTrue(query.getModel().getSources().contains("news"));
assertTrue(query.getModel().getSources().contains("archive"));
- assertEquals(2,query.getModel().getSources().size());
+ assertEquals(2, query.getModel().getSources().size());
assertTrue(query.getModel().getRestrict().contains("fish"));
assertTrue(query.getModel().getRestrict().contains("bird"));
- assertEquals(2,query.getModel().getRestrict().size());
+ assertEquals(2, query.getModel().getRestrict().size());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java
index c28e64196a2..df97c03ae68 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java
@@ -6,10 +6,10 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.yahoo.jdisc.http.HttpRequest.Method;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -19,49 +19,49 @@ public class ParametersTestCase {
private final double delta = 0.000001;
@Test
- public void testSettingRankProperty() {
+ void testSettingRankProperty() {
Query query = new Query("?query=test&ranking.properties.dotProduct.X=(a:1,b:2)");
assertEquals("[(a:1,b:2)]", query.getRanking().getProperties().get("dotProduct.X").toString());
}
@Test
- public void testSettingRankPropertyAsAlias() {
+ void testSettingRankPropertyAsAlias() {
Query query = new Query("?query=test&rankproperty.dotProduct.X=(a:1,b:2)");
assertEquals("[(a:1,b:2)]", query.getRanking().getProperties().get("dotProduct.X").toString());
}
@Test
- public void testSettingRankFeature() {
+ void testSettingRankFeature() {
Query query = new Query("?query=test&ranking.features.matches=3");
assertEquals(3, query.getRanking().getFeatures().getDouble("matches").getAsDouble(), delta);
}
@Test
- public void testSettingRankFeatureAsAlias() {
+ void testSettingRankFeatureAsAlias() {
Query query = new Query("?query=test&rankfeature.matches=3");
assertEquals(3, query.getRanking().getFeatures().getDouble("matches").getAsDouble(), delta);
}
@Test
- public void testSettingRankPropertyWithQueryProfile() {
+ void testSettingRankPropertyWithQueryProfile() {
Query query = new Query(HttpRequest.createTestRequest("?query=test&ranking.properties.dotProduct.X=(a:1,b:2)", Method.GET), createProfile());
assertEquals("[(a:1,b:2)]", query.getRanking().getProperties().get("dotProduct.X").toString());
}
@Test
- public void testSettingRankPropertyAsAliasWithQueryProfile() {
+ void testSettingRankPropertyAsAliasWithQueryProfile() {
Query query = new Query(HttpRequest.createTestRequest("?query=test&rankproperty.dotProduct.X=(a:1,b:2)", Method.GET), createProfile());
assertEquals("[(a:1,b:2)]", query.getRanking().getProperties().get("dotProduct.X").toString());
}
@Test
- public void testSettingRankFeatureWithQueryProfile() {
+ void testSettingRankFeatureWithQueryProfile() {
Query query = new Query(HttpRequest.createTestRequest("?query=test&ranking.features.matches=3", Method.GET), createProfile());
assertEquals(3, query.getRanking().getFeatures().getDouble("matches").getAsDouble(), delta);
}
@Test
- public void testSettingRankFeatureAsAliasWithQueryProfile() {
+ void testSettingRankFeatureAsAliasWithQueryProfile() {
Query query = new Query(HttpRequest.createTestRequest("?query=test&rankfeature.matches=3", Method.GET), createProfile());
assertEquals(3, query.getRanking().getFeatures().getDouble("matches").getAsDouble(), delta);
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java
index aafbeaf5825..4aefd3c82e0 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java
@@ -4,11 +4,9 @@ package com.yahoo.search.query.test;
import com.yahoo.prelude.query.Highlight;
import com.yahoo.search.Query;
import com.yahoo.search.query.Presentation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Arne Bergene Fossaa
@@ -16,20 +14,20 @@ import static org.junit.Assert.assertTrue;
public class PresentationTestCase {
@Test
- public void testClone() {
- Query q= new Query("");
+ void testClone() {
+ Query q = new Query("");
Presentation p = new Presentation(q);
p.setBolding(true);
Highlight h = new Highlight();
- h.addHighlightTerm("date","today");
+ h.addHighlightTerm("date", "today");
p.setHighlight(h);
- Presentation pc = (Presentation)p.clone();
- h.addHighlightTerm("title","Hello");
+ Presentation pc = (Presentation) p.clone();
+ h.addHighlightTerm("title", "Hello");
assertTrue(pc.getBolding());
pc.getHighlight().getHighlightItems();
assertTrue(pc.getHighlight().getHighlightItems().containsKey("date"));
assertFalse(pc.getHighlight().getHighlightItems().containsKey("title"));
- assertEquals(p,pc);
+ assertEquals(p, pc);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java
index 0644a2b02e8..b1e406c47d7 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java
@@ -10,7 +10,7 @@ import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.serialization.TypedBinaryFormat;
import com.yahoo.text.Utf8;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author geirst
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertEquals;
public class RankFeaturesTestCase {
@Test
- public void requireThatRankPropertiesTakesBothStringAndObject() {
+ void requireThatRankPropertiesTakesBothStringAndObject() {
RankProperties p = new RankProperties();
p.put("string", "b");
p.put("object", 7);
@@ -37,7 +37,7 @@ public class RankFeaturesTestCase {
@Test
@SuppressWarnings("deprecation")
- public void requireThatRankFeaturesUsingDoubleAndDoubleToStringEncodeTheSameWay() {
+ void requireThatRankFeaturesUsingDoubleAndDoubleToStringEncodeTheSameWay() {
RankFeatures withDouble = new RankFeatures(new Ranking(new Query()));
withDouble.put("query(myDouble)", 3.8);
assertEquals(3.8, withDouble.getDouble("query(myDouble)").getAsDouble(), 0.000001);
@@ -56,7 +56,7 @@ public class RankFeaturesTestCase {
}
@Test
- public void requireThatSingleTensorIsBinaryEncoded() {
+ void requireThatSingleTensorIsBinaryEncoded() {
TensorType type = new TensorType.Builder().mapped("x").mapped("y").mapped("z").build();
Tensor tensor = Tensor.from(type, "{ {x:a, y:b, z:c}:2.0, {x:a, y:b, z:c2}:3.0 }");
assertTensorEncodingAndDecoding(type, "query(my_tensor)", "my_tensor", tensor);
@@ -64,7 +64,7 @@ public class RankFeaturesTestCase {
}
@Test
- public void requireThatMultipleTensorsAreBinaryEncoded() {
+ void requireThatMultipleTensorsAreBinaryEncoded() {
TensorType type = new TensorType.Builder().mapped("x").mapped("y").mapped("z").build();
Tensor tensor1 = Tensor.from(type, "{ {x:a, y:b, z:c}:2.0, {x:a, y:b, z:c2}:3.0 }");
Tensor tensor2 = Tensor.from(type, "{ {x:a, y:b, z:c}:5.0 }");
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java
index 7a9080f46db..a6bc7460f2e 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java
@@ -3,10 +3,10 @@ package com.yahoo.search.query.test;
import com.yahoo.search.Query;
import com.yahoo.search.query.Sorting;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author Arne Bergene Fossaa
@@ -17,7 +17,7 @@ public class RankingTestCase {
/** Tests setting rank feature values */
@Test
- public void testRankFeatures() {
+ void testRankFeatures() {
// Check initializing from query
Query query = new Query("?query=test&ranking.features.query(name)=0.1&ranking.features.fieldMatch(foo)=0.2");
assertEquals(0.1, query.getRanking().getFeatures().getDouble("query(name)").getAsDouble(), delta);
@@ -30,8 +30,8 @@ public class RankingTestCase {
assertEquals(0.2, query.getRanking().getFeatures().getDouble("fieldMatch(foo)").getAsDouble(), delta);
// Check programmatic setting + that the clone really has a separate object
- assertFalse(clone.getRanking().getFeatures() == query.getRanking().getFeatures());
- clone.properties().set("ranking.features.query(name)","0.3");
+ assertNotNull(query.getRanking().getFeatures());
+ clone.properties().set("ranking.features.query(name)", "0.3");
assertEquals(0.3, clone.getRanking().getFeatures().getDouble("query(name)").getAsDouble(), delta);
assertEquals(0.1, query.getRanking().getFeatures().getDouble("query(name)").getAsDouble(), delta);
@@ -47,7 +47,7 @@ public class RankingTestCase {
// This test is order dependent. Fix this!!
@Test
- public void test_setting_rank_feature_values() {
+ void test_setting_rank_feature_values() {
// Check initializing from query
Query query = new Query("?query=test&ranking.properties.foo=bar1&ranking.properties.foo2=bar2&ranking.properties.other=10");
assertEquals("bar1", query.getRanking().getProperties().get("foo").get(0));
@@ -57,13 +57,13 @@ public class RankingTestCase {
// Test cloning
Query clone = query.clone();
- assertFalse(clone.getRanking().getProperties() == query.getRanking().getProperties());
+ assertNotNull(query.getRanking().getProperties());
assertEquals("bar1", clone.getRanking().getProperties().get("foo").get(0));
assertEquals("bar2", clone.getRanking().getProperties().get("foo2").get(0));
assertEquals("10", clone.getRanking().getProperties().get("other").get(0));
// Check programmatic setting mean addition
- clone.properties().set("ranking.properties.other","12");
+ clone.properties().set("ranking.properties.other", "12");
assertEquals("[10, 12]", clone.getRanking().getProperties().get("other").toString());
assertEquals("[10]", query.getRanking().getProperties().get("other").toString());
@@ -74,14 +74,14 @@ public class RankingTestCase {
/** Test setting sorting to null does not cause an exception. */
@Test
- public void testResetSorting() {
+ void testResetSorting() {
Query q = new Query();
- q.getRanking().setSorting((Sorting)null);
- q.getRanking().setSorting((String)null);
+ q.getRanking().setSorting((Sorting) null);
+ q.getRanking().setSorting((String) null);
}
@Test
- public void testStructuredRankProperty() {
+ void testStructuredRankProperty() {
Query query = new Query("?query=abc&rankproperty.distanceToPath(gps_position).path=(0,0,10,0,10,5,20,5)");
assertEquals("(0,0,10,0,10,5,20,5)", query.getRanking().getProperties().get("distanceToPath(gps_position).path").get(0));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java b/container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java
index b351bfb927a..07beabe14f3 100644
--- a/container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java
@@ -19,13 +19,11 @@ import com.yahoo.search.query.textserialize.item.ItemContext;
import com.yahoo.search.query.textserialize.item.ItemFormHandler;
import com.yahoo.search.query.textserialize.parser.ParseException;
import com.yahoo.search.query.textserialize.parser.Parser;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.StringReader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Tony Vaagenes
@@ -40,12 +38,12 @@ public class ParseItemTestCase {
}
@Test
- public void parse_and() throws ParseException {
+ void parse_and() throws ParseException {
assertTrue(parse("(AND)") instanceof AndItem);
}
@Test
- public void parse_and_with_children() throws ParseException {
+ void parse_and_with_children() throws ParseException {
AndItem andItem = (AndItem) parse("(AND (WORD 'first') (WORD 'second'))");
assertEquals(2, andItem.getItemCount());
@@ -53,116 +51,120 @@ public class ParseItemTestCase {
}
@Test
- public void parse_or() throws ParseException {
+ void parse_or() throws ParseException {
assertTrue(parse("(OR)") instanceof OrItem);
}
@Test
- public void parse_and_not_rest() throws ParseException {
+ void parse_and_not_rest() throws ParseException {
assertTrue(parse("(AND-NOT-REST)") instanceof NotItem);
}
@Test
- public void parse_and_not_rest_with_children() throws ParseException {
+ void parse_and_not_rest_with_children() throws ParseException {
NotItem notItem = (NotItem) parse("(AND-NOT-REST (WORD 'positive') (WORD 'negative'))");
assertEquals("positive", getWord(notItem.getPositiveItem()));
assertEquals("negative", getWord(notItem.getItem(1)));
}
@Test
- public void parse_and_not_rest_with_only_negated_children() throws ParseException {
+ void parse_and_not_rest_with_only_negated_children() throws ParseException {
NotItem notItem = (NotItem) parse("(AND-NOT-REST null (WORD 'negated-item'))");
assertTrue(notItem.getPositiveItem() instanceof TrueItem);
assertTrue(notItem.getItem(1) instanceof WordItem);
}
@Test
- public void parse_rank() throws ParseException {
+ void parse_rank() throws ParseException {
assertTrue(parse("(RANK (WORD 'first'))") instanceof RankItem);
}
@Test
- public void parse_word() throws ParseException {
+ void parse_word() throws ParseException {
WordItem wordItem = (WordItem) parse("(WORD 'text')");
assertEquals("text", wordItem.getWord());
}
- @Test(expected = IllegalArgumentException.class)
- public void fail_when_word_given_multiple_strings() throws ParseException {
- parse("(WORD 'one' 'invalid')");
+ @Test
+ void fail_when_word_given_multiple_strings() throws ParseException {
+ assertThrows(IllegalArgumentException.class, () -> {
+ parse("(WORD 'one' 'invalid')");
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void fail_when_word_given_no_string() throws ParseException {
- parse("(WORD)");
+ @Test
+ void fail_when_word_given_no_string() throws ParseException {
+ assertThrows(IllegalArgumentException.class, () -> {
+ parse("(WORD)");
+ });
}
@Test
- public void parse_int() throws ParseException {
+ void parse_int() throws ParseException {
IntItem intItem = (IntItem) parse("(INT '[42;]')");
assertEquals("[42;]", intItem.getNumber());
}
@Test
- public void parse_range() throws ParseException {
+ void parse_range() throws ParseException {
IntItem intItem = (IntItem) parse("(INT '[42;73]')");
assertEquals("[42;73]", intItem.getNumber());
}
@Test
- public void parse_range_withlimit() throws ParseException {
+ void parse_range_withlimit() throws ParseException {
IntItem intItem = (IntItem) parse("(INT '[42;73;32]')");
assertEquals("[42;73;32]", intItem.getNumber());
}
@Test
- public void parse_prefix() throws ParseException {
+ void parse_prefix() throws ParseException {
PrefixItem prefixItem = (PrefixItem) parse("(PREFIX 'word')");
assertEquals("word", prefixItem.getWord());
}
@Test
- public void parse_subString() throws ParseException {
+ void parse_subString() throws ParseException {
SubstringItem subStringItem = (SubstringItem) parse("(SUBSTRING 'word')");
assertEquals("word", subStringItem.getWord());
}
@Test
- public void parse_exactString() throws ParseException {
+ void parse_exactString() throws ParseException {
ExactStringItem subStringItem = (ExactStringItem) parse("(EXACT 'word')");
assertEquals("word", subStringItem.getWord());
}
@Test
- public void parse_suffix() throws ParseException {
+ void parse_suffix() throws ParseException {
SuffixItem suffixItem = (SuffixItem) parse("(SUFFIX 'word')");
assertEquals("word", suffixItem.getWord());
}
@Test
- public void parse_phrase() throws ParseException {
+ void parse_phrase() throws ParseException {
PhraseItem phraseItem = (PhraseItem) parse("(PHRASE (WORD 'word'))");
assertTrue(phraseItem.getItem(0) instanceof WordItem);
}
@Test
- public void parse_near() throws ParseException {
+ void parse_near() throws ParseException {
assertTrue(parse("(NEAR)") instanceof NearItem);
}
@Test
- public void parse_onear() throws ParseException {
+ void parse_onear() throws ParseException {
assertTrue(parse("(ONEAR)") instanceof ONearItem);
}
@Test
- public void parse_near_with_distance() throws ParseException {
+ void parse_near_with_distance() throws ParseException {
NearItem nearItem = (NearItem) parse("(NEAR {'distance' 42} (WORD 'first'))");
assertEquals(42, nearItem.getDistance());
}
@Test
- public void parse_items_with_connectivity() throws ParseException {
+ void parse_items_with_connectivity() throws ParseException {
AndItem andItem = (AndItem) parse("(AND (WORD {'id' '1'} 'first') (WORD {'connectivity' ['1' 23.5]} 'second'))");
WordItem secondItem = (WordItem) andItem.getItem(1);
@@ -171,13 +173,13 @@ public class ParseItemTestCase {
}
@Test
- public void parse_word_with_index() throws ParseException {
+ void parse_word_with_index() throws ParseException {
WordItem wordItem = (WordItem) parse("(WORD {'index' 'someIndex'} 'text')");
assertEquals("someIndex", wordItem.getIndexName());
}
@Test
- public void parse_unicode_word() throws ParseException {
+ void parse_unicode_word() throws ParseException {
WordItem wordItem = (WordItem) parse("(WORD 'trăm')");
assertEquals("trăm", wordItem.getWord());
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java b/container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java
index 133382cbe91..65458cfb8ee 100644
--- a/container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java
@@ -11,12 +11,12 @@ import com.yahoo.prelude.query.PhraseItem;
import com.yahoo.prelude.query.WordItem;
import com.yahoo.search.query.textserialize.parser.ParseException;
import com.yahoo.search.query.textserialize.serializer.QueryTreeSerializer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.yahoo.search.query.textserialize.item.test.ParseItemTestCase.parse;
import static com.yahoo.search.query.textserialize.item.test.ParseItemTestCase.getWord;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Tony Vaagenes
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue;
public class SerializeItemTestCase {
@Test
- public void serialize_word_item() {
+ void serialize_word_item() {
WordItem item = new WordItem("test that \" and \\ works");
item.setIndexName("index\"Name");
@@ -34,7 +34,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_and_item() {
+ void serialize_and_item() {
AndItem andItem = new AndItem();
andItem.addItem(new WordItem("first"));
andItem.addItem(new WordItem("second"));
@@ -46,12 +46,12 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_or_item() {
+ void serialize_or_item() {
assertTrue(serializeThenParse(new OrItem()) instanceof OrItem);
}
@Test
- public void serialize_not_item() {
+ void serialize_not_item() {
NotItem notItem = new NotItem();
{
notItem.addItem(new WordItem("first"));
@@ -62,7 +62,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_near_item() {
+ void serialize_near_item() {
int distance = 23;
NearItem nearItem = new NearItem(distance);
{
@@ -77,8 +77,8 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_phrase_item() throws ParseException {
- PhraseItem phraseItem = new PhraseItem(new String[] {"first", "second"});
+ void serialize_phrase_item() throws ParseException {
+ PhraseItem phraseItem = new PhraseItem(new String[]{"first", "second"});
phraseItem.setIndexName("indexName");
PhraseItem deSerialized = serializeThenParse(phraseItem);
@@ -88,7 +88,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_equiv_item() {
+ void serialize_equiv_item() {
EquivItem equivItem = new EquivItem();
equivItem.addItem(new WordItem("first"));
@@ -97,7 +97,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_connectivity() {
+ void serialize_connectivity() {
OrItem orItem = new OrItem();
{
WordItem first = new WordItem("first");
@@ -117,7 +117,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_significance() {
+ void serialize_significance() {
EquivItem equivItem = new EquivItem();
equivItem.setSignificance(24.2);
@@ -126,7 +126,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_unique_id() {
+ void serialize_unique_id() {
EquivItem equivItem = new EquivItem();
equivItem.setUniqueID(42);
@@ -135,7 +135,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_weight() {
+ void serialize_weight() {
EquivItem equivItem = new EquivItem();
equivItem.setWeight(42);
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/BooleanAttributeParserTest.java b/container-search/src/test/java/com/yahoo/search/querytransform/BooleanAttributeParserTest.java
index 66fdbdcb267..9889c479b84 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/BooleanAttributeParserTest.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/BooleanAttributeParserTest.java
@@ -2,13 +2,13 @@
package com.yahoo.search.querytransform;
import com.yahoo.prelude.query.PredicateQueryItem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.math.BigInteger;
import java.util.Iterator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author magnarn
@@ -16,7 +16,7 @@ import static org.junit.Assert.fail;
public class BooleanAttributeParserTest {
@Test
- public void requireThatParseHandlesAllFormats() {
+ void requireThatParseHandlesAllFormats() {
assertParse(null, 0);
assertParse("{}", 0);
assertParse("{foo:bar}", 1);
@@ -37,7 +37,7 @@ public class BooleanAttributeParserTest {
}
@Test
- public void requireThatIllegalStringsFail() {
+ void requireThatIllegalStringsFail() {
assertException("{foo:[bar:[baz]}");
assertException("{foo:[bar:baz}");
assertException("{foo:bar:[0,1,2}");
@@ -60,7 +60,7 @@ public class BooleanAttributeParserTest {
}
@Test
- public void requireThatTermsCanHaveBitmaps() {
+ void requireThatTermsCanHaveBitmaps() {
PredicateQueryItem q = assertParse("{foo:bar:0x1}", 1);
PredicateQueryItem.Entry[] features = new PredicateQueryItem.Entry[q.getFeatures().size()];
q.getFeatures().toArray(features);
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/BooleanSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/BooleanSearcherTestCase.java
index 599b0ca4443..247c96f0676 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/BooleanSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/BooleanSearcherTestCase.java
@@ -8,12 +8,12 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test BooleanSearcher
@@ -27,13 +27,13 @@ public class BooleanSearcherTestCase {
Execution.Context.createContextStub());
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
exec = buildExec();
}
@Test
- public void requireThatAttributeMapToSingleFeature() {
+ void requireThatAttributeMapToSingleFeature() {
PredicateQueryItem item = buildPredicateQueryItem("{gender:female}", null);
assertEquals(1, item.getFeatures().size());
assertEquals(0, item.getRangeFeatures().size());
@@ -43,7 +43,7 @@ public class BooleanSearcherTestCase {
}
@Test
- public void requireThatAttributeListMapToMultipleFeatures() {
+ void requireThatAttributeListMapToMultipleFeatures() {
PredicateQueryItem item = buildPredicateQueryItem("{gender:[female,male]}", null);
assertEquals(2, item.getFeatures().size());
assertEquals(0, item.getRangeFeatures().size());
@@ -51,7 +51,7 @@ public class BooleanSearcherTestCase {
}
@Test
- public void requireThatRangeAttributesMapToRangeTerm() {
+ void requireThatRangeAttributesMapToRangeTerm() {
PredicateQueryItem item = buildPredicateQueryItem(null, "{age:25}");
assertEquals(0, item.getFeatures().size());
assertEquals(1, item.getRangeFeatures().size());
@@ -63,17 +63,17 @@ public class BooleanSearcherTestCase {
}
@Test
- public void requireThatQueryWithoutBooleanPropertiesIsUnchanged() {
+ void requireThatQueryWithoutBooleanPropertiesIsUnchanged() {
Query q = new Query("");
q.getModel().getQueryTree().setRoot(new WordItem("foo", "otherfield"));
Result r = exec.search(q);
- WordItem root = (WordItem)r.getQuery().getModel().getQueryTree().getRoot();
+ WordItem root = (WordItem) r.getQuery().getModel().getQueryTree().getRoot();
assertEquals("foo", root.getWord());
}
@Test
- public void requireThatBooleanSearcherCanBuildPredicateQueryItem() {
+ void requireThatBooleanSearcherCanBuildPredicateQueryItem() {
PredicateQueryItem root = buildPredicateQueryItem("{gender:female}", "{age:23:[2, 3, 5]}");
Collection<PredicateQueryItem.Entry> features = root.getFeatures();
@@ -92,7 +92,7 @@ public class BooleanSearcherTestCase {
}
@Test
- public void requireThatKeysAndValuesCanContainSpaces() {
+ void requireThatKeysAndValuesCanContainSpaces() {
PredicateQueryItem item = buildPredicateQueryItem("{'My Key':'My Value'}", null);
assertEquals(1, item.getFeatures().size());
assertEquals(0, item.getRangeFeatures().size());
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java
index 025c3ff7a32..3a8442bc12d 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/LowercasingTestCase.java
@@ -2,19 +2,16 @@
package com.yahoo.search.querytransform;
-import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.yahoo.prelude.IndexModel;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.SearchDefinition;
import com.yahoo.prelude.query.SameElementItem;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.component.chain.Chain;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
@@ -69,7 +66,7 @@ public class LowercasingTestCase {
}
@Test
- public void simple() {
+ void simple() {
Query q = new Query();
AndItem root = new AndItem();
WordItem tmp;
@@ -92,7 +89,7 @@ public class LowercasingTestCase {
}
@Test
- public void slightlyMoreComplexTree() {
+ void slightlyMoreComplexTree() {
Query q = new Query();
AndItem a0 = new AndItem();
OrItem o0 = new OrItem();
@@ -148,7 +145,7 @@ public class LowercasingTestCase {
}
@Test
- public void testWeightedSet() {
+ void testWeightedSet() {
Query q = new Query();
AndItem root = new AndItem();
WeightedSetItem tmp;
@@ -170,11 +167,11 @@ public class LowercasingTestCase {
}
@Test
- public void testDisableLowercasingWeightedSet() {
+ void testDisableLowercasingWeightedSet() {
Execution execution = new Execution(new Chain<Searcher>(
- new VespaLowercasingSearcher(new LowercasingConfig(
- new LowercasingConfig.Builder()
- .transform_weighted_sets(false)))),
+ new VespaLowercasingSearcher(new LowercasingConfig(
+ new LowercasingConfig.Builder()
+ .transform_weighted_sets(false)))),
Execution.Context.createContextStub(createIndexFacts()));
Query q = new Query();
@@ -198,7 +195,7 @@ public class LowercasingTestCase {
}
@Test
- public void testLowercasingWordAlternatives() {
+ void testLowercasingWordAlternatives() {
Execution execution = new Execution(new Chain<Searcher>(new VespaLowercasingSearcher(new LowercasingConfig(
new LowercasingConfig.Builder().transform_weighted_sets(false)))), Execution.Context.createContextStub(createIndexFacts()));
@@ -221,7 +218,7 @@ public class LowercasingTestCase {
}
@Test
- public void testLowercasingSameElement() {
+ void testLowercasingSameElement() {
Query q = new Query();
SameElementItem root = new SameElementItem(SARR);
root.addItem(new WordItem("ABC", BAMSE, true));
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java
index d2010ec852e..438f36b32a6 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/WandSearcherTestCase.java
@@ -19,17 +19,14 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.ListIterator;
import static com.yahoo.container.protect.Error.INVALID_QUERY_PARAMETER;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Testing of WandSearcher.
@@ -88,17 +85,17 @@ public class WandSearcherTestCase {
assertEquals(expWeight, wordItem.getWeight());
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
exec = buildExec();
}
@Test
- public void requireThatVespaWandCanBeSpecified() {
+ void requireThatVespaWandCanBeSpecified() {
Query q = buildDefaultQuery();
Result r = exec.search(q);
- WeakAndItem root = (WeakAndItem)TestUtils.getQueryTreeRoot(r);
+ WeakAndItem root = (WeakAndItem) TestUtils.getQueryTreeRoot(r);
assertEquals(100, root.getN());
assertEquals(3, root.getItemCount());
ListIterator<Item> itr = root.getItemIterator();
@@ -109,21 +106,21 @@ public class WandSearcherTestCase {
}
@Test
- public void requireThatVespaWandHeapSizeCanBeSpecified() {
+ void requireThatVespaWandHeapSizeCanBeSpecified() {
Query q = buildDefaultQuery(VESPA_FIELD, "50");
Result r = exec.search(q);
- WeakAndItem root = (WeakAndItem)TestUtils.getQueryTreeRoot(r);
+ WeakAndItem root = (WeakAndItem) TestUtils.getQueryTreeRoot(r);
assertEquals(50, root.getN());
}
@Test
- public void requireThatWandCanBeSpecifiedTogetherWithNonAndQueryRoot() {
+ void requireThatWandCanBeSpecifiedTogetherWithNonAndQueryRoot() {
Query q = buildDefaultQuery();
q.getModel().getQueryTree().setRoot(new WordItem("foo", "otherfield"));
Result r = exec.search(q);
- AndItem root = (AndItem)TestUtils.getQueryTreeRoot(r);
+ AndItem root = (AndItem) TestUtils.getQueryTreeRoot(r);
assertEquals(2, root.getItemCount());
ListIterator<Item> itr = root.getItemIterator();
assertTrue(itr.next() instanceof WordItem);
@@ -132,7 +129,7 @@ public class WandSearcherTestCase {
}
@Test
- public void requireThatWandCanBeSpecifiedTogetherWithAndQueryRoot() {
+ void requireThatWandCanBeSpecifiedTogetherWithAndQueryRoot() {
Query q = buildDefaultQuery();
{
AndItem root = new AndItem();
@@ -142,7 +139,7 @@ public class WandSearcherTestCase {
}
Result r = exec.search(q);
- AndItem root = (AndItem)TestUtils.getQueryTreeRoot(r);
+ AndItem root = (AndItem) TestUtils.getQueryTreeRoot(r);
assertEquals(3, root.getItemCount());
ListIterator<Item> itr = root.getItemIterator();
assertTrue(itr.next() instanceof WordItem);
@@ -153,42 +150,42 @@ public class WandSearcherTestCase {
@Test
- public void requireThatNothingIsAddedWithoutWandPropertiesSet() {
+ void requireThatNothingIsAddedWithoutWandPropertiesSet() {
Query foo = new Query("");
foo.getModel().getQueryTree().setRoot(new WordItem("foo", "otherfield"));
Result r = exec.search(foo);
- WordItem root = (WordItem)TestUtils.getQueryTreeRoot(r);
+ WordItem root = (WordItem) TestUtils.getQueryTreeRoot(r);
assertEquals("foo", root.getWord());
}
@Test
- public void requireThatErrorIsReturnedOnInvalidTokenList() {
+ void requireThatErrorIsReturnedOnInvalidTokenList() {
Query q = buildQuery(VESPA_FIELD, "{a1,b:1}", null, null, null, null);
Result r = exec.search(q);
ErrorMessage msg = r.hits().getError();
assertNotNull(msg);
assertEquals(INVALID_QUERY_PARAMETER.code, msg.getCode());
- assertEquals("'{a1,b:1}' is not a legal sparse vector string: Expected ':' starting at position 3 but was ','",msg.getDetailedMessage());
+ assertEquals("'{a1,b:1}' is not a legal sparse vector string: Expected ':' starting at position 3 but was ','", msg.getDetailedMessage());
}
@Test
- public void requireThatErrorIsReturnedOnUnknownField() {
+ void requireThatErrorIsReturnedOnUnknownField() {
Query q = buildDefaultQuery("unknown", "50");
Result r = exec.search(q);
ErrorMessage msg = r.hits().getError();
assertNotNull(msg);
assertEquals(INVALID_QUERY_PARAMETER.code, msg.getCode());
- assertEquals("Field 'unknown' was not found in index facts for search definitions [test]",msg.getDetailedMessage());
+ assertEquals("Field 'unknown' was not found in index facts for search definitions [test]", msg.getDetailedMessage());
}
@Test
- public void requireThatVespaOrCanBeSpecified() {
+ void requireThatVespaOrCanBeSpecified() {
Query q = buildQuery(VESPA_FIELD, "{a:1,b:2,c:3}", null, "or", null, null);
Result r = exec.search(q);
- OrItem root = (OrItem)TestUtils.getQueryTreeRoot(r);
+ OrItem root = (OrItem) TestUtils.getQueryTreeRoot(r);
assertEquals(3, root.getItemCount());
ListIterator<Item> itr = root.getItemIterator();
assertWordItem("a", VESPA_FIELD, 1, itr.next());
@@ -205,11 +202,11 @@ public class WandSearcherTestCase {
}
@Test
- public void requireThatDefaultParallelWandCanBeSpecified() {
+ void requireThatDefaultParallelWandCanBeSpecified() {
Query q = buildQuery(VESPA_FIELD, "{a:1,b:2,c:3}", null, "parallel", null, null);
Result r = exec.search(q);
- WandItem root = (WandItem)TestUtils.getQueryTreeRoot(r);
+ WandItem root = (WandItem) TestUtils.getQueryTreeRoot(r);
assertEquals(VESPA_FIELD, root.getIndexName());
assertEquals(100, root.getTargetNumHits());
assertEquals(0.0, root.getScoreThreshold(), delta);
@@ -218,11 +215,11 @@ public class WandSearcherTestCase {
}
@Test
- public void requireThatParallelWandCanBeSpecified() {
+ void requireThatParallelWandCanBeSpecified() {
Query q = buildQuery(VESPA_FIELD, "{a:1,b:2,c:3}", "50", "parallel", "70.5", "2.3");
Result r = exec.search(q);
- WandItem root = (WandItem)TestUtils.getQueryTreeRoot(r);
+ WandItem root = (WandItem) TestUtils.getQueryTreeRoot(r);
assertEquals(VESPA_FIELD, root.getIndexName());
assertEquals(50, root.getTargetNumHits());
assertEquals(70.5, root.getScoreThreshold(), delta);
@@ -231,11 +228,11 @@ public class WandSearcherTestCase {
}
@Test
- public void requireThatDotProductCanBeSpecified() {
+ void requireThatDotProductCanBeSpecified() {
Query q = buildQuery(VESPA_FIELD, "{a:1,b:2,c:3}", null, "dotProduct", null, null);
Result r = exec.search(q);
- DotProductItem root = (DotProductItem)TestUtils.getQueryTreeRoot(r);
+ DotProductItem root = (DotProductItem) TestUtils.getQueryTreeRoot(r);
assertEquals(VESPA_FIELD, root.getIndexName());
assertWeightedSetItem(root);
}
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/WeakAndReplacementSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/WeakAndReplacementSearcherTestCase.java
index 54f6bcd4c23..30d06510409 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/WeakAndReplacementSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/WeakAndReplacementSearcherTestCase.java
@@ -8,11 +8,11 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.stream.IntStream;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class WeakAndReplacementSearcherTestCase {
@@ -42,20 +42,18 @@ public class WeakAndReplacementSearcherTestCase {
}
-
-
@Test
- public void requireOrItemsToBeReplaced() {
+ void requireOrItemsToBeReplaced() {
Query query = buildDefaultQuery(true);
Result result = buildExec().search(query);
Item root = TestUtils.getQueryTreeRoot(result);
assertFalse(orItemsExist(root));
assertTrue(root instanceof WeakAndItem);
- assertEquals(N, ((WeakAndItem)root).getN());
+ assertEquals(N, ((WeakAndItem) root).getN());
}
@Test
- public void requireQueryPropertyToWork() {
+ void requireQueryPropertyToWork() {
Query query = buildDefaultQuery(false);
Item preRoot = query.getModel().getQueryTree().getRoot();
Result result = buildExec().search(query);
@@ -65,7 +63,7 @@ public class WeakAndReplacementSearcherTestCase {
}
@Test
- public void requireDoNothingOnNoOrItems() {
+ void requireDoNothingOnNoOrItems() {
Query query = new Query();
query.properties().set(WEAKAND_REPLACE, true);
AndItem andItem = new AndItem();
@@ -78,7 +76,7 @@ public class WeakAndReplacementSearcherTestCase {
}
@Test
- public void requireChildrenAreTheSame() {
+ void requireChildrenAreTheSame() {
Query query = new Query();
query.properties().set(WEAKAND_REPLACE, true);
OrItem preRoot = new OrItem();
@@ -87,7 +85,7 @@ public class WeakAndReplacementSearcherTestCase {
query.getModel().getQueryTree().setRoot(preRoot);
Result result = buildExec().search(query);
- WeakAndItem root = (WeakAndItem)TestUtils.getQueryTreeRoot(result);
+ WeakAndItem root = (WeakAndItem) TestUtils.getQueryTreeRoot(result);
assertEquals(preRoot.getItem(0), root.getItem(0));
assertEquals(preRoot.getItem(1), root.getItem(1));
}
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
index 460ae1f641c..8dccf7d0f38 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
@@ -33,12 +33,10 @@ import com.yahoo.search.querytransform.NGramSearcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.yahoo.search.searchchain.Execution.Context.createContextStub;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -103,7 +101,7 @@ public class NGramSearcherTestCase {
}
@Test
- public void testMixedDocTypes() {
+ void testMixedDocTypes() {
{
Query q = new Query("?query=abc&restrict=song");
createMixedSetupExecution().search(q);
@@ -127,7 +125,7 @@ public class NGramSearcherTestCase {
}
@Test
- public void testMixedClusters() {
+ void testMixedClusters() {
{
Query q = new Query("?query=abc&search=songOnly");
createMixedSetupExecution().search(q);
@@ -151,42 +149,42 @@ public class NGramSearcherTestCase {
}
@Test
- public void testNGramRewritingMixedQuery() {
+ void testNGramRewritingMixedQuery() {
Query q = new Query("?query=foo+gram3:engul+test:bar");
createExecution().search(q);
assertEquals("WEAKAND(100) foo (AND gram3:eng gram3:ngu gram3:gul) test:bar", q.getModel().getQueryTree().toString());
}
@Test
- public void testNGramRewritingNGramOnly() {
+ void testNGramRewritingNGramOnly() {
Query q = new Query("?query=gram3:engul");
createExecution().search(q);
assertEquals("WEAKAND(100) (AND gram3:eng gram3:ngu gram3:gul)", q.getModel().getQueryTree().toString());
}
@Test
- public void testNGramRewriting2NGramsOnly() {
+ void testNGramRewriting2NGramsOnly() {
Query q = new Query("?query=gram3:engul+gram2:123");
createExecution().search(q);
assertEquals("WEAKAND(100) (AND gram3:eng gram3:ngu gram3:gul) (AND gram2:12 gram2:23)", q.getModel().getQueryTree().toString());
}
@Test
- public void testNGramRewritingShortOnly() {
+ void testNGramRewritingShortOnly() {
Query q = new Query("?query=gram3:en");
createExecution().search(q);
assertEquals("WEAKAND(100) gram3:en", q.getModel().getQueryTree().toString());
}
@Test
- public void testNGramRewritingShortInMixes() {
+ void testNGramRewritingShortInMixes() {
Query q = new Query("?query=test:a+gram3:en");
createExecution().search(q);
assertEquals("WEAKAND(100) test:a gram3:en", q.getModel().getQueryTree().toString());
}
@Test
- public void testNGramRewritingPhrase() {
+ void testNGramRewritingPhrase() {
Query q = new Query("?query=gram3:%22engul+a+holi%22");
createExecution().search(q);
assertEquals("WEAKAND(100) gram3:\"eng ngu gul a hol oli\"", q.getModel().getQueryTree().toString());
@@ -197,19 +195,19 @@ public class NGramSearcherTestCase {
* so the ngram rewriter cannot know to keep the grams as a phrase in this case.
*/
@Test
- public void testNGramRewritingPhraseSingleTerm() {
+ void testNGramRewritingPhraseSingleTerm() {
Query q = new Query("?query=gram3:%22engul%22");
createExecution().search(q);
assertEquals("WEAKAND(100) (AND gram3:eng gram3:ngu gram3:gul)", q.getModel().getQueryTree().toString());
}
@Test
- public void testNGramRewritingAdditionalTermInfo() {
+ void testNGramRewritingAdditionalTermInfo() {
Query q = new Query("?query=gram3:engul!50+foo+gram2:123!150");
createExecution().search(q);
- WeakAndItem root = (WeakAndItem)q.getModel().getQueryTree().getRoot();
- AndItem gram3And = (AndItem)root.getItem(0);
- AndItem gram2And = (AndItem)root.getItem(2);
+ WeakAndItem root = (WeakAndItem) q.getModel().getQueryTree().getRoot();
+ AndItem gram3And = (AndItem) root.getItem(0);
+ AndItem gram2And = (AndItem) root.getItem(2);
assertExtraTermInfo(50, "engul", gram3And.getItem(0));
assertExtraTermInfo(50, "engul", gram3And.getItem(1));
@@ -227,21 +225,21 @@ public class NGramSearcherTestCase {
}
@Test
- public void testNGramRewritingExplicitDefault() {
+ void testNGramRewritingExplicitDefault() {
Query q = new Query("?query=default:engul");
createExecution().search(q);
- assertEquals("WEAKAND(100) (AND default:eng default:ngu default:gul)" ,q.getModel().getQueryTree().toString());
+ assertEquals("WEAKAND(100) (AND default:eng default:ngu default:gul)", q.getModel().getQueryTree().toString());
}
@Test
- public void testNGramRewritingImplicitDefault() {
+ void testNGramRewritingImplicitDefault() {
Query q = new Query("?query=engul");
createExecution().search(q);
assertEquals("WEAKAND(100) (AND eng ngu gul)", q.getModel().getQueryTree().toString());
}
@Test
- public void testGramsWithSegmentation() {
+ void testGramsWithSegmentation() {
Searcher searcher = createSearcher();
assertGramsWithSegmentation(new Chain<>(searcher));
assertGramsWithSegmentation(new Chain<>(new CJKSearcher(), searcher));
@@ -259,7 +257,7 @@ public class NGramSearcherTestCase {
}
@Test
- public void testGramsWithSegmentationSingleSegment() {
+ void testGramsWithSegmentationSingleSegment() {
Searcher searcher = createSearcher();
assertGramsWithSegmentationSingleSegment(new Chain<>(searcher));
assertGramsWithSegmentationSingleSegment(new Chain<>(new CJKSearcher(), searcher));
@@ -277,7 +275,7 @@ public class NGramSearcherTestCase {
}
@Test
- public void testGramsWithSegmentationSubstringSegmented() {
+ void testGramsWithSegmentationSubstringSegmented() {
Searcher searcher = createSearcher();
assertGramsWithSegmentationSubstringSegmented(new Chain<>(searcher));
assertGramsWithSegmentationSubstringSegmented(new Chain<>(new CJKSearcher(), searcher));
@@ -296,7 +294,7 @@ public class NGramSearcherTestCase {
}
@Test
- public void testGramsWithSegmentationMixed() {
+ void testGramsWithSegmentationMixed() {
Searcher searcher = createSearcher();
assertGramsWithSegmentationMixed(new Chain<>(searcher));
assertGramsWithSegmentationMixed(new Chain<>(new CJKSearcher(), searcher));
@@ -315,7 +313,7 @@ public class NGramSearcherTestCase {
}
@Test
- public void testGramsWithSegmentationMixedAndPhrases() {
+ void testGramsWithSegmentationMixedAndPhrases() {
Searcher searcher = createSearcher();
assertGramsWithSegmentationMixedAndPhrases(new Chain<>(searcher));
assertGramsWithSegmentationMixedAndPhrases(new Chain<>(new CJKSearcher(), searcher));
@@ -334,19 +332,20 @@ public class NGramSearcherTestCase {
}
@Test
- public void testNGramRecombining() {
+ void testNGramRecombining() {
Query q = new Query("?query=ignored");
Result r = new Execution(new Chain<>(createSearcher(), new MockBackend1()), createContextStub(createIndexFacts())).search(q);
Hit h1 = r.hits().get("hit1");
assertEquals("Should be untouched,\u001feven if containing \u001f",
- h1.getField("test").toString());
+ h1.getField("test").toString());
assertTrue(h1.getField("test") instanceof String);
- assertEquals("Blue red Ed A",h1.getField("gram2").toString());
+ assertEquals("Blue red Ed A", h1.getField("gram2").toString());
assertTrue(h1.getField("gram2") instanceof XMLString);
- assertEquals("Separators on borders work","Blue red ed a\u001f",
- h1.getField("gram3").toString());
+ assertEquals("Blue red ed a\u001f",
+ h1.getField("gram3").toString(),
+ "Separators on borders work");
assertTrue(h1.getField("gram3") instanceof String);
Hit h2 = r.hits().get("hit2");
@@ -356,7 +355,7 @@ public class NGramSearcherTestCase {
Hit h3 = r.hits().get("hit3");
assertEquals("\u001ffin\u001f \u001fen\u001f \u001fa\u001f", h3.getField("gram2").toString());
assertEquals("#Logging in #Java is like that \"Judean P\u001fopul\u001far Front\" scene from \"Life of Brian\".",
- h3.getField("gram3").toString());
+ h3.getField("gram3").toString());
}
private Item parseQuery(String query, Query.Type type) {
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java
index df6cd046b74..927a891a797 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/RangeQueryOptimizerTestCase.java
@@ -19,12 +19,12 @@ import com.yahoo.search.query.parser.ParserEnvironment;
import com.yahoo.search.query.parser.ParserFactory;
import com.yahoo.search.querytransform.RangeQueryOptimizer;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Iterator;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -35,9 +35,9 @@ public class RangeQueryOptimizerTestCase {
private static IndexFacts indexFacts = createIndexFacts();
@Test
- public void testRangeOptimizing() {
+ void testRangeOptimizing() {
assertOptimized("s:<15", "s:<15");
- assertOptimized("AND a s:[1999;2002]","a AND s:[1999;2002]");
+ assertOptimized("AND a s:[1999;2002]", "a AND s:[1999;2002]");
assertOptimized("AND s:<10;15>", "s:<15 AND s:>10");
assertOptimized("AND s:give s:5 s:me", "s:give s:5 s:me");
assertOptimized("AND s:[;15> b:<10;]", "s:<15 AND b:>10");
@@ -59,7 +59,7 @@ public class RangeQueryOptimizerTestCase {
}
@Test
- public void testRangeOptimizingCarriesOverItemAttributesWhenNotOptimized() {
+ void testRangeOptimizingCarriesOverItemAttributesWhenNotOptimized() {
Query query = new Query();
AndItem root = new AndItem();
query.getModel().getQueryTree().setRoot(root);
@@ -69,14 +69,14 @@ public class RangeQueryOptimizerTestCase {
intItem.setRanked(false);
root.addItem(intItem);
assertOptimized("Not optimized", "AND |s:<15;]!500", query);
- IntItem transformedIntItem = (IntItem)((AndItem)query.getModel().getQueryTree().getRoot()).getItem(0);
- assertTrue("Filter was carried over", transformedIntItem.isFilter());
- assertFalse("Ranked was carried over", transformedIntItem.isRanked());
- assertEquals("Weight was carried over", 500, transformedIntItem.getWeight());
+ IntItem transformedIntItem = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(0);
+ assertTrue(transformedIntItem.isFilter(), "Filter was carried over");
+ assertFalse(transformedIntItem.isRanked(), "Ranked was carried over");
+ assertEquals(500, transformedIntItem.getWeight(), "Weight was carried over");
}
@Test
- public void testRangeOptimizingCarriesOverItemAttributesWhenOptimized() {
+ void testRangeOptimizingCarriesOverItemAttributesWhenOptimized() {
Query query = new Query();
AndItem root = new AndItem();
query.getModel().getQueryTree().setRoot(root);
@@ -94,14 +94,14 @@ public class RangeQueryOptimizerTestCase {
root.addItem(intItem2);
assertOptimized("Optimized", "AND |s:<15;30>!500", query);
- IntItem transformedIntItem = (IntItem)((AndItem)query.getModel().getQueryTree().getRoot()).getItem(0);
- assertTrue("Filter was carried over", transformedIntItem.isFilter());
- assertFalse("Ranked was carried over", transformedIntItem.isRanked());
- assertEquals("Weight was carried over", 500, transformedIntItem.getWeight());
+ IntItem transformedIntItem = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(0);
+ assertTrue(transformedIntItem.isFilter(), "Filter was carried over");
+ assertFalse(transformedIntItem.isRanked(), "Ranked was carried over");
+ assertEquals(500, transformedIntItem.getWeight(), "Weight was carried over");
}
@Test
- public void testNoRangeOptimizingWhenAttributesAreIncompatible() {
+ void testNoRangeOptimizingWhenAttributesAreIncompatible() {
Query query = new Query();
AndItem root = new AndItem();
query.getModel().getQueryTree().setRoot(root);
@@ -120,19 +120,19 @@ public class RangeQueryOptimizerTestCase {
assertOptimized("Not optimized", "AND |s:<15;]!500 s:[;30>!500", query);
- IntItem transformedIntItem1 = (IntItem)((AndItem)query.getModel().getQueryTree().getRoot()).getItem(0);
- assertTrue("Filter was carried over", transformedIntItem1.isFilter());
- assertFalse("Ranked was carried over", transformedIntItem1.isRanked());
- assertEquals("Weight was carried over", 500, transformedIntItem1.getWeight());
+ IntItem transformedIntItem1 = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(0);
+ assertTrue(transformedIntItem1.isFilter(), "Filter was carried over");
+ assertFalse(transformedIntItem1.isRanked(), "Ranked was carried over");
+ assertEquals(500, transformedIntItem1.getWeight(), "Weight was carried over");
- IntItem transformedIntItem2 = (IntItem)((AndItem)query.getModel().getQueryTree().getRoot()).getItem(1);
- assertFalse("Filter was carried over", transformedIntItem2.isFilter());
- assertFalse("Ranked was carried over", transformedIntItem2.isRanked());
- assertEquals("Weight was carried over", 500, transformedIntItem2.getWeight());
+ IntItem transformedIntItem2 = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(1);
+ assertFalse(transformedIntItem2.isFilter(), "Filter was carried over");
+ assertFalse(transformedIntItem2.isRanked(), "Ranked was carried over");
+ assertEquals(500, transformedIntItem2.getWeight(), "Weight was carried over");
}
@Test
- public void testDifferentCompatibleRangesPerFieldAreOptimizedSeparately() {
+ void testDifferentCompatibleRangesPerFieldAreOptimizedSeparately() {
Query query = new Query();
AndItem root = new AndItem();
query.getModel().getQueryTree().setRoot(root);
@@ -155,21 +155,21 @@ public class RangeQueryOptimizerTestCase {
assertOptimized("Optimized", "AND s:<15;30> s:<100;150>", query);
- IntItem transformedIntItem1 = (IntItem)((AndItem)query.getModel().getQueryTree().getRoot()).getItem(0);
- assertFalse("Ranked was carried over", transformedIntItem1.isRanked());
+ IntItem transformedIntItem1 = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(0);
+ assertFalse(transformedIntItem1.isRanked(), "Ranked was carried over");
- IntItem transformedIntItem2 = (IntItem)((AndItem)query.getModel().getQueryTree().getRoot()).getItem(1);
- assertTrue("Ranked was carried over", transformedIntItem2.isRanked());
+ IntItem transformedIntItem2 = (IntItem) ((AndItem) query.getModel().getQueryTree().getRoot()).getItem(1);
+ assertTrue(transformedIntItem2.isRanked(), "Ranked was carried over");
}
@Test
- public void assertOptmimizedYQLQuery() {
+ void assertOptmimizedYQLQuery() {
Query query = new Query("/?query=select%20%2A%20from%20sources%20%2A%20where%20%28range%28s%2C%20100000%2C%20100000%29%20OR%20range%28t%2C%20-20000000000L%2C%20-20000000000L%29%20OR%20range%28t%2C%2030%2C%2030%29%29%3B&type=yql");
assertOptimized("YQL usage of the IntItem API works", "OR s:100000 t:-20000000000 t:30", query);
}
@Test
- public void testTracing() {
+ void testTracing() {
Query notOptimized = new Query("/?tracelevel=2");
notOptimized.getModel().getQueryTree().setRoot(parseQuery("s:<15"));
assertOptimized("", "s:<15", notOptimized);
@@ -200,7 +200,7 @@ public class RangeQueryOptimizerTestCase {
private Query assertOptimized(String explanation, String expected, Query query) {
Chain<Searcher> chain = new Chain<>("test", new RangeQueryOptimizer());
new Execution(chain, Execution.Context.createContextStub(indexFacts)).search(query);
- assertEquals(explanation, expected, query.getModel().getQueryTree().getRoot().toString());
+ assertEquals(expected, query.getModel().getQueryTree().getRoot().toString(), explanation);
return query;
}
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java
index ccdb612b9ba..3b9c2651bf6 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/SortingDegraderTestCase.java
@@ -13,9 +13,9 @@ import com.yahoo.search.grouping.GroupingQueryParser;
import com.yahoo.search.query.properties.DefaultProperties;
import com.yahoo.search.querytransform.SortingDegrader;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -23,7 +23,7 @@ import static org.junit.Assert.*;
public class SortingDegraderTestCase {
@Test
- public void testDegradingAscending() {
+ void testDegradingAscending() {
Query query = new Query("?ranking.sorting=%2ba1%20-a2");
execute(query);
assertEquals("a1", query.getRanking().getMatchPhase().getAttribute());
@@ -33,7 +33,7 @@ public class SortingDegraderTestCase {
}
@Test
- public void testDegradingDescending() {
+ void testDegradingDescending() {
Query query = new Query("?ranking.sorting=-a1%20-a2");
execute(query);
assertEquals("a1", query.getRanking().getMatchPhase().getAttribute());
@@ -42,7 +42,7 @@ public class SortingDegraderTestCase {
}
@Test
- public void testDegradingNonDefaultMaxHits() {
+ void testDegradingNonDefaultMaxHits() {
Query query = new Query("?ranking.sorting=-a1%20-a2&ranking.matchPhase.maxHits=37");
execute(query);
assertEquals("a1", query.getRanking().getMatchPhase().getAttribute());
@@ -51,7 +51,7 @@ public class SortingDegraderTestCase {
}
@Test
- public void testDegradingNonDefaultMaxFilterCoverage() {
+ void testDegradingNonDefaultMaxFilterCoverage() {
Query query = new Query("?ranking.sorting=-a1%20-a2&ranking.matchPhase.maxFilterCoverage=0.37");
execute(query);
assertEquals("a1", query.getRanking().getMatchPhase().getAttribute());
@@ -60,7 +60,7 @@ public class SortingDegraderTestCase {
}
@Test
- public void testDegradingNonDefaultIllegalMaxFilterCoverage() {
+ void testDegradingNonDefaultIllegalMaxFilterCoverage() {
try {
Query query = new Query("?ranking.sorting=-a1%20-a2&ranking.matchPhase.maxFilterCoverage=37");
assertTrue(false);
@@ -75,7 +75,7 @@ public class SortingDegraderTestCase {
}
@Test
- public void testNoDegradingWhenGrouping() {
+ void testNoDegradingWhenGrouping() {
Query query = new Query("?ranking.sorting=%2ba1%20-a2&select=all(group(a1)%20each(output(a1)))");
execute(query);
assertNull(query.getRanking().getMatchPhase().getAttribute());
@@ -83,28 +83,28 @@ public class SortingDegraderTestCase {
}
@Test
- public void testNoDegradingWhenNonFastSearchAttribute() {
+ void testNoDegradingWhenNonFastSearchAttribute() {
Query query = new Query("?ranking.sorting=%2bnonFastSearchAttribute%20-a2");
execute(query);
assertNull(query.getRanking().getMatchPhase().getAttribute());
}
@Test
- public void testNoDegradingWhenNonNumericalAttribute() {
+ void testNoDegradingWhenNonNumericalAttribute() {
Query query = new Query("?ranking.sorting=%2bstringAttribute%20-a2");
execute(query);
assertNull(query.getRanking().getMatchPhase().getAttribute());
}
@Test
- public void testNoDegradingWhenTurnedOff() {
+ void testNoDegradingWhenTurnedOff() {
Query query = new Query("?ranking.sorting=-a1%20-a2&sorting.degrading=false");
execute(query);
assertNull(query.getRanking().getMatchPhase().getAttribute());
}
@Test
- public void testAccessAllDegradingParametersInQuery() {
+ void testAccessAllDegradingParametersInQuery() {
Query query = new Query("?ranking.matchPhase.maxHits=555&ranking.matchPhase.attribute=foo&ranking.matchPhase.ascending=true");
execute(query);
@@ -118,7 +118,7 @@ public class SortingDegraderTestCase {
}
@Test
- public void testDegradingWithLargeMaxHits() {
+ void testDegradingWithLargeMaxHits() {
Query query = new Query("?ranking.sorting=%2ba1%20-a2");
query.properties().set(DefaultProperties.MAX_HITS, 13 * 1000);
query.properties().set(DefaultProperties.MAX_OFFSET, 8 * 1000);
@@ -129,7 +129,7 @@ public class SortingDegraderTestCase {
}
@Test
- public void testDegradingWithoutPaginationSupport() {
+ void testDegradingWithoutPaginationSupport() {
Query query = new Query("?ranking.sorting=%2ba1%20-a2&hits=7&offset=1");
query.properties().set(DefaultProperties.MAX_HITS, 13 * 1000);
query.properties().set(DefaultProperties.MAX_OFFSET, 8 * 1000);
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/AsyncGroupPopulationTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/AsyncGroupPopulationTestCase.java
index 7db29568d5b..c038b3c67c9 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/AsyncGroupPopulationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/AsyncGroupPopulationTestCase.java
@@ -13,7 +13,7 @@ import com.yahoo.search.result.HitGroup;
import com.yahoo.search.result.Relevance;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.text.Utf8;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -25,8 +25,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test adding hits to a hit group during rendering.
@@ -98,7 +98,7 @@ public class AsyncGroupPopulationTestCase {
}
@Test
- public final void test() throws InterruptedException, ExecutionException,
+ final void test() throws InterruptedException, ExecutionException,
IOException {
String rawExpected = "{"
+ " \"root\": {"
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
index 7ddc087feb7..9486eeb92de 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
@@ -56,13 +56,12 @@ import com.yahoo.tensor.serialization.TypedBinaryFormat;
import com.yahoo.text.Utf8;
import com.yahoo.yolean.Exceptions;
import com.yahoo.yolean.trace.TraceNode;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -78,9 +77,9 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Functional testing of {@link JsonRenderer}.
@@ -92,14 +91,11 @@ public class JsonRendererTestCase {
private static final ObjectMapper jsonMapper = new ObjectMapper();
- @Rule
- public Timeout globalTimeout = Timeout.seconds(300);
-
private static ThreadPoolExecutor executor;
private static JsonRenderer blueprint;
private JsonRenderer renderer;
- @BeforeClass
+ @BeforeAll
public static void createExecutorAndBlueprint() {
ThreadFactory threadFactory = ThreadFactoryFactory.getThreadFactory("test-rendering");
executor = new ThreadPoolExecutor(4, 4, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), threadFactory);
@@ -107,14 +103,14 @@ public class JsonRendererTestCase {
blueprint = new JsonRenderer(executor);
}
- @Before
+ @BeforeEach
public void createClone() {
// Use the shared renderer as a prototype object, as specified in the API contract
renderer = (JsonRenderer) blueprint.clone();
renderer.init();
}
- @After
+ @AfterEach
public void deconstructClone() {
if (renderer != null) {
renderer.deconstruct();
@@ -122,7 +118,7 @@ public class JsonRendererTestCase {
}
}
- @AfterClass
+ @AfterAll
public static void deconstructBlueprintAndExecutor() throws InterruptedException {
blueprint.deconstruct();
blueprint = null;
@@ -134,7 +130,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testDocumentId() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testDocumentId() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -163,30 +160,31 @@ public class JsonRendererTestCase {
}
@Test
- public void testTensorShortForm() throws ExecutionException, InterruptedException, IOException {
+ @Timeout(300)
+ void testTensorShortForm() throws ExecutionException, InterruptedException, IOException {
String expected = "{" +
"\"root\":{" +
- "\"id\":\"toplevel\"," +
- "\"relevance\":1.0," +
- "\"fields\":{" +
- "\"totalCount\":1" +
- "}," +
- "\"children\":[{" +
- "\"id\":\"tensors\"," +
- "\"relevance\":1.0," +
- "\"fields\":{" +
- "\"tensor_standard\":{\"type\":\"tensor(x{},y{})\",\"cells\":[{\"address\":{\"x\":\"a\",\"y\":\"0\"},\"value\":1.0},{\"address\":{\"x\":\"b\",\"y\":\"1\"},\"value\":2.0}]}," +
- "\"tensor_indexed\":{\"type\":\"tensor(x[2],y[3])\",\"values\":[[1.0,2.0,3.0],[4.0,5.0,6.0]]}," +
- "\"tensor_single_mapped\":{\"type\":\"tensor(x{})\",\"cells\":{\"a\":1.0,\"b\":2.0}}," +
- "\"tensor_mixed\":{\"type\":\"tensor(x{},y[2])\",\"blocks\":{\"a\":[1.0,2.0],\"b\":[3.0,4.0]}}," +
- "\"summaryfeatures\":{" +
- "\"tensor_standard\":{\"type\":\"tensor(x{},y{})\",\"cells\":[{\"address\":{\"x\":\"a\",\"y\":\"0\"},\"value\":1.0},{\"address\":{\"x\":\"b\",\"y\":\"1\"},\"value\":2.0}]}," +
- "\"tensor_indexed\":{\"type\":\"tensor(x[2],y[3])\",\"values\":[[1.0,2.0,3.0],[4.0,5.0,6.0]]}," +
- "\"tensor_single_mapped\":{\"type\":\"tensor(x{})\",\"cells\":{\"a\":1.0,\"b\":2.0}}," +
- "\"tensor_mixed\":{\"type\":\"tensor(x{},y[2])\",\"blocks\":{\"a\":[1.0,2.0],\"b\":[3.0,4.0]}}" +
- "}" +
- "}" +
- "}]" +
+ "\"id\":\"toplevel\"," +
+ "\"relevance\":1.0," +
+ "\"fields\":{" +
+ "\"totalCount\":1" +
+ "}," +
+ "\"children\":[{" +
+ "\"id\":\"tensors\"," +
+ "\"relevance\":1.0," +
+ "\"fields\":{" +
+ "\"tensor_standard\":{\"type\":\"tensor(x{},y{})\",\"cells\":[{\"address\":{\"x\":\"a\",\"y\":\"0\"},\"value\":1.0},{\"address\":{\"x\":\"b\",\"y\":\"1\"},\"value\":2.0}]}," +
+ "\"tensor_indexed\":{\"type\":\"tensor(x[2],y[3])\",\"values\":[[1.0,2.0,3.0],[4.0,5.0,6.0]]}," +
+ "\"tensor_single_mapped\":{\"type\":\"tensor(x{})\",\"cells\":{\"a\":1.0,\"b\":2.0}}," +
+ "\"tensor_mixed\":{\"type\":\"tensor(x{},y[2])\",\"blocks\":{\"a\":[1.0,2.0],\"b\":[3.0,4.0]}}," +
+ "\"summaryfeatures\":{" +
+ "\"tensor_standard\":{\"type\":\"tensor(x{},y{})\",\"cells\":[{\"address\":{\"x\":\"a\",\"y\":\"0\"},\"value\":1.0},{\"address\":{\"x\":\"b\",\"y\":\"1\"},\"value\":2.0}]}," +
+ "\"tensor_indexed\":{\"type\":\"tensor(x[2],y[3])\",\"values\":[[1.0,2.0,3.0],[4.0,5.0,6.0]]}," +
+ "\"tensor_single_mapped\":{\"type\":\"tensor(x{})\",\"cells\":{\"a\":1.0,\"b\":2.0}}," +
+ "\"tensor_mixed\":{\"type\":\"tensor(x{},y[2])\",\"blocks\":{\"a\":[1.0,2.0],\"b\":[3.0,4.0]}}" +
+ "}" +
+ "}" +
+ "}]" +
"}}\n";
Slime slime = new Slime();
@@ -222,12 +220,13 @@ public class JsonRendererTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'presentation.format.tensors' to 'unknown': Value must be 'long' or 'short', not 'unknown'",
- Exceptions.toMessageString(e));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testDataTypes() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testDataTypes() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -298,7 +297,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testTracing() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testTracing() throws IOException, InterruptedException, ExecutionException {
// which clearly shows a trace child is created once too often...
String expected = "{"
+ " \"root\": {"
@@ -353,7 +353,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testTracingOfSlime() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testTracingOfSlime() throws IOException, InterruptedException, ExecutionException {
// which clearly shows a trace child is created once too often...
String expected = "{"
+ " \"root\": {"
@@ -406,10 +407,10 @@ public class JsonRendererTestCase {
e2.search(subQuery);
Value.ArrayValue access = new Value.ArrayValue();
Slime slime = new Slime();
- slime.setObject().setString("colour","yellow");
+ slime.setObject().setString("colour", "yellow");
access.add(new SlimeAdapter(slime.get()));
slime = new Slime();
- slime.setObject().setString("colour","green");
+ slime.setObject().setString("colour", "green");
access.add(new SlimeAdapter(slime.get()));
subQuery.trace(access, 1);
q.trace("marker", 1);
@@ -418,7 +419,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testEmptyTracing() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testEmptyTracing() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"fields\": {"
@@ -444,7 +446,8 @@ public class JsonRendererTestCase {
@SuppressWarnings({"unchecked"})
@Test
- public void testTracingWithEmptySubtree() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testTracingWithEmptySubtree() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"fields\": {"
@@ -495,17 +498,18 @@ public class JsonRendererTestCase {
}
@Test
- public void trace_is_not_included_if_tracelevel_0() throws IOException, ExecutionException, InterruptedException {
+ @Timeout(300)
+ void trace_is_not_included_if_tracelevel_0() throws IOException, ExecutionException, InterruptedException {
String expected =
"{" +
- " \"root\": {" +
- " \"id\": \"toplevel\"," +
- " \"relevance\": 1.0," +
- " \"fields\": {" +
- " \"totalCount\": 0" +
- " }" +
- " }" +
- "}";
+ " \"root\": {" +
+ " \"id\": \"toplevel\"," +
+ " \"relevance\": 1.0," +
+ " \"fields\": {" +
+ " \"totalCount\": 0" +
+ " }" +
+ " }" +
+ "}";
Query q = new Query("/?query=a&tracelevel=0");
Execution execution = new Execution(Execution.Context.createContextStub());
Result r = new Result(q);
@@ -516,7 +520,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testTracingOfNodesWithBothChildrenAndData() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testTracingOfNodesWithBothChildrenAndData() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"fields\": {"
@@ -561,7 +566,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testTracingOfNodesWithBothChildrenAndDataAndEmptySubnode() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testTracingOfNodesWithBothChildrenAndDataAndEmptySubnode() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"fields\": {"
@@ -602,7 +608,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testTracingOfNestedNodesWithDataAndSubnodes() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testTracingOfNestedNodesWithDataAndSubnodes() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"fields\": {"
@@ -650,7 +657,8 @@ public class JsonRendererTestCase {
}
@Test
- public void test() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void test() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -716,7 +724,7 @@ public class JsonRendererTestCase {
Query q = new Query("/?query=a&tracelevel=5");
Execution execution = new Execution(Execution.Context.createContextStub());
Result r = new Result(q);
- r.setCoverage(new Coverage(500, 500,1,1));
+ r.setCoverage(new Coverage(500, 500, 1, 1));
FastHit h = new FastHit("http://localhost/", .95);
h.setField("$a", "Hello, world.");
@@ -737,7 +745,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testCoverage() throws InterruptedException, ExecutionException, IOException {
+ @Timeout(300)
+ void testCoverage() throws InterruptedException, ExecutionException, IOException {
String expected = "{"
+ " \"root\": {"
+ " \"coverage\": {"
@@ -771,7 +780,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testMoreTypes() throws InterruptedException, ExecutionException, IOException {
+ @Timeout(300)
+ void testMoreTypes() throws InterruptedException, ExecutionException, IOException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -795,8 +805,8 @@ public class JsonRendererTestCase {
+ "}";
Result r = newEmptyResult();
Hit h = new Hit("moredatatypestuff");
- h.setField("byte", (byte)8);
- h.setField("short", (short)16);
+ h.setField("byte", (byte) 8);
+ h.setField("short", (short) 16);
h.setField("bigInteger", new BigInteger("340282366920938463463374607431768211455"));
h.setField("bigDecimal", new BigDecimal("340282366920938463463374607431768211456.5"));
h.setField("nanNumber", NanNumber.NaN);
@@ -807,7 +817,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testNullField() throws InterruptedException, ExecutionException, IOException {
+ @Timeout(300)
+ void testNullField() throws InterruptedException, ExecutionException, IOException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -836,7 +847,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testHitWithSource() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testHitWithSource() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -863,7 +875,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testErrorWithStackTrace() throws InterruptedException, ExecutionException, IOException {
+ @Timeout(300)
+ void testErrorWithStackTrace() throws InterruptedException, ExecutionException, IOException {
String expected = "{"
+ " \"root\": {"
+ " \"errors\": ["
@@ -896,13 +909,15 @@ public class JsonRendererTestCase {
}
@Test
- public void testContentHeader() {
+ @Timeout(300)
+ void testContentHeader() {
assertEquals("utf-8", renderer.getEncoding());
assertEquals("application/json", renderer.getMimeType());
}
@Test
- public void testGrouping() throws InterruptedException, ExecutionException, IOException {
+ @Timeout(300)
+ void testGrouping() throws InterruptedException, ExecutionException, IOException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -988,7 +1003,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testGroupingWithBucket() throws InterruptedException, ExecutionException, IOException {
+ @Timeout(300)
+ void testGroupingWithBucket() throws InterruptedException, ExecutionException, IOException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -1051,7 +1067,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testJsonObjects() throws InterruptedException, ExecutionException, IOException {
+ @Timeout(300)
+ void testJsonObjects() throws InterruptedException, ExecutionException, IOException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -1097,7 +1114,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testFieldValueInHit() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testFieldValueInHit() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -1132,7 +1150,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testHiddenFields() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testHiddenFields() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -1157,7 +1176,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testDebugRendering() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testDebugRendering() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -1188,7 +1208,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testTimingRendering() throws InterruptedException, ExecutionException, IOException {
+ @Timeout(300)
+ void testTimingRendering() throws InterruptedException, ExecutionException, IOException {
String expected = "{"
+ " \"root\": {"
+ " \"fields\": {"
@@ -1208,7 +1229,7 @@ public class JsonRendererTestCase {
new UselessSearcher("first"), new UselessSearcher("second"),
new UselessSearcher("third")));
ElapsedTimeTestCase.doInjectTimeSource(t, new CreativeTimeSource(
- new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L }));
+ new long[]{1L, 2L, 3L, 4L, 5L, 6L, 7L}));
t.sampleSearch(0, true);
t.sampleSearch(1, true);
t.sampleSearch(2, true);
@@ -1223,7 +1244,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testJsonCallback() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testJsonCallback() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -1244,7 +1266,7 @@ public class JsonRendererTestCase {
+ "}";
String jsonCallback = "some_function_name";
- Result r = newEmptyResult(new String[] {"query=a", "jsoncallback="+jsonCallback} );
+ Result r = newEmptyResult(new String[]{"query=a", "jsoncallback=" + jsonCallback});
Hit h = new Hit("jsonCallbackTest");
h.setField("documentid", new DocumentId("id:unittest:smoke::whee"));
r.hits().add(h);
@@ -1261,7 +1283,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testMapInField() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testMapInField() throws IOException, InterruptedException, ExecutionException {
String expected = "{"
+ " \"root\": {"
+ " \"children\": ["
@@ -1288,18 +1311,18 @@ public class JsonRendererTestCase {
Hit h = new Hit("MapInField");
Value.ArrayValue atop = new Value.ArrayValue();
atop.add(new Value.ObjectValue()
- .put("key", new Value.StringValue("foo"))
- .put("value", new Value.StringValue("string foo")))
- .add(new Value.ObjectValue()
- .put("key", new Value.StringValue("bar"))
- .put("value", new Value.ArrayValue()
- .add(new Value.StringValue("array bar elem 1"))
- .add(new Value.StringValue("array bar elem 2"))))
- .add(new Value.ObjectValue()
- .put("key", new Value.StringValue("baz"))
- .put("value", new Value.ObjectValue()
- .put("f1", new Value.StringValue("object baz field 1"))
- .put("f2", new Value.StringValue("object baz field 2"))));
+ .put("key", new Value.StringValue("foo"))
+ .put("value", new Value.StringValue("string foo")))
+ .add(new Value.ObjectValue()
+ .put("key", new Value.StringValue("bar"))
+ .put("value", new Value.ArrayValue()
+ .add(new Value.StringValue("array bar elem 1"))
+ .add(new Value.StringValue("array bar elem 2"))))
+ .add(new Value.ObjectValue()
+ .put("key", new Value.StringValue("baz"))
+ .put("value", new Value.ObjectValue()
+ .put("f1", new Value.StringValue("object baz field 1"))
+ .put("f2", new Value.StringValue("object baz field 2"))));
h.setField("structured", atop);
r.hits().add(h);
r.setTotalHitCount(1L);
@@ -1314,21 +1337,22 @@ public class JsonRendererTestCase {
}
@Test
- public void testMapDeepInFields() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testMapDeepInFields() throws IOException, InterruptedException, ExecutionException {
Result r = new Result(new Query("/?renderer.json.jsonMaps=true"));
var expected = dataFromSimplified(
"{root: { id:'toplevel', relevance:1.0, fields: { totalCount: 1 }," +
- " children: [ { id: 'myHitName', relevance: 1.0," +
- " fields: { " +
- " f1: [ 'v1', { mykey1: 'myvalue1', mykey2: 'myvalue2' } ]," +
- " f2: { i1: 'v2', i2: { mykey3: 'myvalue3' }, i3: 'v3' }," +
- " f3: { j1: 42, j2: 17.75, j3: [ 'v4', 'v5' ] }," +
- " f4: { mykey4: 'myvalue4', mykey5: 'myvalue5' }," +
- " f5: { '10001': 'myvalue6', '10002': 'myvalue7' }," +
- " f6: { i4: 'v6', i5: { '-17': 'myvalue8', '-42': 'myvalue9' } }" +
- " }" +
- " } ]" +
- "}}");
+ " children: [ { id: 'myHitName', relevance: 1.0," +
+ " fields: { " +
+ " f1: [ 'v1', { mykey1: 'myvalue1', mykey2: 'myvalue2' } ]," +
+ " f2: { i1: 'v2', i2: { mykey3: 'myvalue3' }, i3: 'v3' }," +
+ " f3: { j1: 42, j2: 17.75, j3: [ 'v4', 'v5' ] }," +
+ " f4: { mykey4: 'myvalue4', mykey5: 'myvalue5' }," +
+ " f5: { '10001': 'myvalue6', '10002': 'myvalue7' }," +
+ " f6: { i4: 'v6', i5: { '-17': 'myvalue8', '-42': 'myvalue9' } }" +
+ " }" +
+ " } ]" +
+ "}}");
Hit h = new Hit("myHitName");
h.setField("f1", dataFromSimplified("[ 'v1', [ { key: 'mykey1', value: 'myvalue1' }, { key: 'mykey2', value: 'myvalue2' } ] ]"));
h.setField("f2", dataFromSimplified("{ i1: 'v2', i2: [ { key: 'mykey3', value: 'myvalue3' } ], i3: 'v3' }"));
@@ -1349,17 +1373,17 @@ public class JsonRendererTestCase {
r = new Result(new Query("/?renderer.json.jsonMaps=false"));
expected = dataFromSimplified(
"{root:{id:'toplevel',relevance:1.0,fields:{totalCount:1}," +
- " children: [ { id: 'myHitName', relevance: 1.0," +
- " fields: { " +
- " f1: [ 'v1', [ { key: 'mykey1', value: 'myvalue1' }, { key: 'mykey2', value: 'myvalue2' } ] ]," +
- " f2: { i1: 'v2', i2: [ { key: 'mykey3', value: 'myvalue3' } ], i3: 'v3' }," +
- " f3: { j1: 42, j2: 17.75, j3: [ 'v4', 'v5' ] }," +
- " f4: { mykey4: 'myvalue4', mykey5: 'myvalue5' }," +
- " f5: [ { key: 10001, value: 'myvalue6' }, { key: 10002, value: 'myvalue7' } ]," +
- " f6: { i4: 'v6', i5: [ { key: -17, value: 'myvalue8' }, { key: -42, value: 'myvalue9' } ] }" +
- " }" +
- " } ]" +
- "}}");
+ " children: [ { id: 'myHitName', relevance: 1.0," +
+ " fields: { " +
+ " f1: [ 'v1', [ { key: 'mykey1', value: 'myvalue1' }, { key: 'mykey2', value: 'myvalue2' } ] ]," +
+ " f2: { i1: 'v2', i2: [ { key: 'mykey3', value: 'myvalue3' } ], i3: 'v3' }," +
+ " f3: { j1: 42, j2: 17.75, j3: [ 'v4', 'v5' ] }," +
+ " f4: { mykey4: 'myvalue4', mykey5: 'myvalue5' }," +
+ " f5: [ { key: 10001, value: 'myvalue6' }, { key: 10002, value: 'myvalue7' } ]," +
+ " f6: { i4: 'v6', i5: [ { key: -17, value: 'myvalue8' }, { key: -42, value: 'myvalue9' } ] }" +
+ " }" +
+ " } ]" +
+ "}}");
r.hits().add(h);
r.setTotalHitCount(1L);
summary = render(r);
@@ -1367,19 +1391,20 @@ public class JsonRendererTestCase {
}
@Test
- public void testWsetInFields() throws IOException, InterruptedException, ExecutionException {
+ @Timeout(300)
+ void testWsetInFields() throws IOException, InterruptedException, ExecutionException {
Result r = new Result(new Query("/?renderer.json.jsonWsets=true"));
var expected = dataFromSimplified(
"{root: { id:'toplevel', relevance:1.0, fields: { totalCount: 1 }," +
- " children: [ { id: 'myHitName', relevance: 1.0," +
- " fields: { " +
- " f1: [ 'v1', { mykey1: 10, mykey2: 20 } ]," +
- " f2: { i1: 'v2', i2: { mykey3: 30 }, i3: 'v3' }," +
- " f3: { j1: 42, j2: 17.75, j3: [ 'v4', 'v5' ] }," +
- " f4: { mykey4: 40, mykey5: 50 }" +
- " }" +
- " } ]" +
- "}}");
+ " children: [ { id: 'myHitName', relevance: 1.0," +
+ " fields: { " +
+ " f1: [ 'v1', { mykey1: 10, mykey2: 20 } ]," +
+ " f2: { i1: 'v2', i2: { mykey3: 30 }, i3: 'v3' }," +
+ " f3: { j1: 42, j2: 17.75, j3: [ 'v4', 'v5' ] }," +
+ " f4: { mykey4: 40, mykey5: 50 }" +
+ " }" +
+ " } ]" +
+ "}}");
Hit h = new Hit("myHitName");
h.setField("f1", dataFromSimplified("[ 'v1', [ { item: 'mykey1', weight: 10 }, { item: 'mykey2', weight: 20 } ] ]"));
h.setField("f2", dataFromSimplified("{ i1: 'v2', i2: [ { item: 'mykey3', weight: 30 } ], i3: 'v3' }"));
@@ -1393,15 +1418,15 @@ public class JsonRendererTestCase {
r = new Result(new Query("/?renderer.json.jsonWsets=false"));
expected = dataFromSimplified(
"{root:{id:'toplevel',relevance:1.0,fields:{totalCount:1}," +
- " children: [ { id: 'myHitName', relevance: 1.0," +
- " fields: { " +
- " f1: [ 'v1', [ { item: 'mykey1', weight: 10 }, { item: 'mykey2', weight: 20 } ] ]," +
- " f2: { i1: 'v2', i2: [ { item: 'mykey3', weight: 30 } ], i3: 'v3' }," +
- " f3: { j1: 42, j2: 17.75, j3: [ 'v4', 'v5' ] }," +
- " f4: [ { item: 'mykey4', weight: 40 }, { item: 'mykey5', weight: 50 } ]" +
- " }" +
- " } ]" +
- "}}");
+ " children: [ { id: 'myHitName', relevance: 1.0," +
+ " fields: { " +
+ " f1: [ 'v1', [ { item: 'mykey1', weight: 10 }, { item: 'mykey2', weight: 20 } ] ]," +
+ " f2: { i1: 'v2', i2: [ { item: 'mykey3', weight: 30 } ], i3: 'v3' }," +
+ " f3: { j1: 42, j2: 17.75, j3: [ 'v4', 'v5' ] }," +
+ " f4: [ { item: 'mykey4', weight: 40 }, { item: 'mykey5', weight: 50 } ]" +
+ " }" +
+ " } ]" +
+ "}}");
r.hits().add(h);
r.setTotalHitCount(1L);
summary = render(r);
@@ -1409,7 +1434,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testThatTheJsonValidatorCanCatchErrors() {
+ @Timeout(300)
+ void testThatTheJsonValidatorCanCatchErrors() {
String json = "{"
+ " \"root\": {"
+ " \"invalidvalue\": 1adsf,"
@@ -1422,7 +1448,8 @@ public class JsonRendererTestCase {
}
@Test
- public void testDynamicSummary() throws Exception {
+ @Timeout(300)
+ void testDynamicSummary() throws Exception {
String content = "\uFFF9Feeding\uFFFAfeed\uFFFB \u001F\uFFF9documents\uFFFAdocument\uFFFB\u001F into Vespa \uFFF9is\uFFFAbe\u001Eincrement of a set of \u001F\uFFF9documents\uFFFAdocument\uFFFB\u001F fed into Vespa \uFFF9is\u001Efloat in XML when \u001Fdocument\u001F attribute \uFFF9is\uFFFAbe\uFFFB int\u001E";
Result result = createResult("one", content, true);
@@ -1430,24 +1457,24 @@ public class JsonRendererTestCase {
String expected =
"{ " +
- " \"root\":{ " +
- " \"id\":\"toplevel\"," +
- " \"relevance\":1.0," +
- " \"fields\":{ " +
- " \"totalCount\":0" +
- " }," +
- " \"children\":[ " +
- " { " +
- " \"id\":\"http://abc.html/\"," +
- " \"relevance\":1.0," +
- " \"fields\":{ " +
- " \"sddocname\":\"one\"," +
- " \"dynteaser\":\"Feeding <hi>documents</hi> into Vespa is<sep />increment of a set of <hi>documents</hi> fed into Vespa <sep />float in XML when <hi>document</hi> attribute is int<sep />\"" +
- " }" +
- " }" +
- " ]" +
- " }" +
- "}";
+ " \"root\":{ " +
+ " \"id\":\"toplevel\"," +
+ " \"relevance\":1.0," +
+ " \"fields\":{ " +
+ " \"totalCount\":0" +
+ " }," +
+ " \"children\":[ " +
+ " { " +
+ " \"id\":\"http://abc.html/\"," +
+ " \"relevance\":1.0," +
+ " \"fields\":{ " +
+ " \"sddocname\":\"one\"," +
+ " \"dynteaser\":\"Feeding <hi>documents</hi> into Vespa is<sep />increment of a set of <hi>documents</hi> fed into Vespa <sep />float in XML when <hi>document</hi> attribute is int<sep />\"" +
+ " }" +
+ " }" +
+ " ]" +
+ " }" +
+ "}";
assertEqualJson(expected, summary);
}
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java
index 2166000cf7a..c473c11005d 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/SyncDefaultRendererTestCase.java
@@ -14,16 +14,16 @@ import com.yahoo.search.statistics.ElapsedTimeTestCase.CreativeTimeSource;
import com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher;
import com.yahoo.search.statistics.TimeTracker;
import com.yahoo.text.Utf8;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Check the legacy sync default renderer doesn't spontaneously combust.
@@ -34,28 +34,28 @@ public class SyncDefaultRendererTestCase {
SyncDefaultRenderer d;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
d = new SyncDefaultRenderer();
d.init();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
}
@Test
- public final void testGetEncoding() {
+ final void testGetEncoding() {
assertEquals("utf-8", d.getEncoding());
}
@Test
- public final void testGetMimeType() {
+ final void testGetMimeType() {
assertEquals("text/xml", d.getMimeType());
}
@Test
- public void testRenderWriterResult() throws InterruptedException, ExecutionException {
+ void testRenderWriterResult() throws InterruptedException, ExecutionException {
Query q = new Query("/?query=a&tracelevel=5");
q.getPresentation().setTiming(true);
Result r = new Result(q);
@@ -65,7 +65,7 @@ public class SyncDefaultRendererTestCase {
new UselessSearcher("first"), new UselessSearcher("second"),
new UselessSearcher("third")));
ElapsedTimeTestCase.doInjectTimeSource(t, new CreativeTimeSource(
- new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L }));
+ new long[]{1L, 2L, 3L, 4L, 5L, 6L, 7L}));
t.sampleSearch(0, true);
t.sampleSearch(1, true);
t.sampleSearch(2, true);
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
index a8b38130333..50234e4022c 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
@@ -24,13 +24,13 @@ import com.yahoo.search.statistics.ElapsedTimeTestCase;
import com.yahoo.search.statistics.ElapsedTimeTestCase.CreativeTimeSource;
import com.yahoo.search.statistics.TimeTracker;
import com.yahoo.text.Utf8;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.util.concurrent.CompletableFuture;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test the XML renderer
@@ -41,21 +41,21 @@ import static org.junit.Assert.assertTrue;
public class XMLRendererTestCase {
@Test
- public void testGetEncoding() {
+ void testGetEncoding() {
XmlRenderer renderer = new XmlRenderer();
renderer.init();
assertEquals("utf-8", renderer.getEncoding());
}
@Test
- public void testGetMimeType() {
+ void testGetMimeType() {
XmlRenderer renderer = new XmlRenderer();
renderer.init();
assertEquals("text/xml", renderer.getMimeType());
}
@Test
- public void testXmlRendering() throws Exception {
+ void testXmlRendering() throws Exception {
Query q = new Query("/?query=a");
Result result = new Result(q);
@@ -82,31 +82,31 @@ public class XMLRendererTestCase {
String expected =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
- "<result total-hit-count=\"0\" coverage-docs=\"500\" coverage-nodes=\"1\" coverage-full=\"false\" coverage=\"0\" results-full=\"0\" results=\"1\">\n" +
- " <error code=\"18\">Internal server error.</error>\n" +
- " <errordetails>\n" +
- " <error error=\"Internal server error.\" code=\"18\">message</error>\n" +
- " </errordetails>\n" +
- " <group relevancy=\"1.0\">\n" +
- " <hit type=\"summary\" relevancy=\"0.9\">\n" +
- " <field name=\"relevancy\">0.9</field>\n" +
- " <field name=\"c\">d</field>\n" +
- " </hit>\n" +
- " </group>\n" +
- " <hit type=\"grouphit\" relevancy=\"1.0\">\n" +
- " <id>type grouphit</id>\n" +
- " </hit>\n" +
- " <hit type=\"summary\" relevancy=\"0.95\">\n" +
- " <field name=\"relevancy\">0.95</field>\n" +
- " <field name=\"b\">foo</field>\n" +
- " </hit>\n" +
- "</result>\n";
+ "<result total-hit-count=\"0\" coverage-docs=\"500\" coverage-nodes=\"1\" coverage-full=\"false\" coverage=\"0\" results-full=\"0\" results=\"1\">\n" +
+ " <error code=\"18\">Internal server error.</error>\n" +
+ " <errordetails>\n" +
+ " <error error=\"Internal server error.\" code=\"18\">message</error>\n" +
+ " </errordetails>\n" +
+ " <group relevancy=\"1.0\">\n" +
+ " <hit type=\"summary\" relevancy=\"0.9\">\n" +
+ " <field name=\"relevancy\">0.9</field>\n" +
+ " <field name=\"c\">d</field>\n" +
+ " </hit>\n" +
+ " </group>\n" +
+ " <hit type=\"grouphit\" relevancy=\"1.0\">\n" +
+ " <id>type grouphit</id>\n" +
+ " </hit>\n" +
+ " <hit type=\"summary\" relevancy=\"0.95\">\n" +
+ " <field name=\"relevancy\">0.95</field>\n" +
+ " <field name=\"b\">foo</field>\n" +
+ " </hit>\n" +
+ "</result>\n";
assertEquals(expected, summary);
}
@Test
- public void testXmlRenderingOfDynamicSummary() throws Exception {
+ void testXmlRenderingOfDynamicSummary() throws Exception {
String content = "\uFFF9Feeding\uFFFAfeed\uFFFB \u001F\uFFF9documents\uFFFAdocument\uFFFB\u001F into Vespa \uFFF9is\uFFFAbe\u001Eincrement of a set of \u001F\uFFF9documents\uFFFAdocument\uFFFB\u001F fed into Vespa \uFFF9is\u001Efloat in XML when \u001Fdocument\u001F attribute \uFFF9is\uFFFAbe\uFFFB int\u001E";
Result result = createResult("one", content, true);
@@ -114,18 +114,18 @@ public class XMLRendererTestCase {
String expected =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
- "<result total-hit-count=\"0\">\n" +
- " <hit relevancy=\"1.0\">\n" +
- " <field name=\"relevancy\">1.0</field>\n" +
- " <field name=\"sddocname\">one</field>\n" +
- " <field name=\"dynteaser\">Feeding <hi>documents</hi> into Vespa is<sep />increment of a set of <hi>documents</hi> fed into Vespa <sep />float in XML when <hi>document</hi> attribute is int<sep /></field>\n" +
- " </hit>\n" +
- "</result>\n";
+ "<result total-hit-count=\"0\">\n" +
+ " <hit relevancy=\"1.0\">\n" +
+ " <field name=\"relevancy\">1.0</field>\n" +
+ " <field name=\"sddocname\">one</field>\n" +
+ " <field name=\"dynteaser\">Feeding <hi>documents</hi> into Vespa is<sep />increment of a set of <hi>documents</hi> fed into Vespa <sep />float in XML when <hi>document</hi> attribute is int<sep /></field>\n" +
+ " </hit>\n" +
+ "</result>\n";
assertEquals(expected, summary);
}
@Test
- public void testXmlRenderingWithTimeTracking() throws Exception {
+ void testXmlRenderingWithTimeTracking() throws Exception {
Query q = new Query("/?query=a&tracelevel=5");
q.getPresentation().setTiming(true);
@@ -133,9 +133,9 @@ public class XMLRendererTestCase {
result.setCoverage(new Coverage(500, 1));
TimeTracker t = new TimeTracker(new Chain<Searcher>(new NoopSearcher("first"),
- new NoopSearcher("second"),
- new NoopSearcher("third")));
- ElapsedTimeTestCase.doInjectTimeSource(t, new CreativeTimeSource(new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L }));
+ new NoopSearcher("second"),
+ new NoopSearcher("third")));
+ ElapsedTimeTestCase.doInjectTimeSource(t, new CreativeTimeSource(new long[]{1L, 2L, 3L, 4L, 5L, 6L, 7L}));
t.sampleSearch(0, true);
t.sampleSearch(1, true);
t.sampleSearch(2, true);
@@ -148,7 +148,7 @@ public class XMLRendererTestCase {
String summary = render(result);
assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<result total-hit-count=\"0\"",
- summary.substring(0, 67));
+ summary.substring(0, 67));
assertTrue(summary.contains("querytime="));
assertTrue(summary.contains("summaryfetchtime="));
assertTrue(summary.contains("searchtime="));
diff --git a/container-search/src/test/java/com/yahoo/search/result/DefaultErrorHitTestCase.java b/container-search/src/test/java/com/yahoo/search/result/DefaultErrorHitTestCase.java
index 5c9af0c756e..42095e263dd 100644
--- a/container-search/src/test/java/com/yahoo/search/result/DefaultErrorHitTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/DefaultErrorHitTestCase.java
@@ -1,13 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.result;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.Iterator;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* @author Steinar Knutsen
@@ -17,13 +16,13 @@ public class DefaultErrorHitTestCase {
private static final String SOURCE = "nalle";
DefaultErrorHit de;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
de = new DefaultErrorHit(SOURCE, ErrorMessage.createUnspecifiedError("DefaultErrorHitTestCase"));
}
@Test
- public void testSetSourceTakeTwo() {
+ void testSetSourceTakeTwo() {
assertEquals(SOURCE, de.getSource());
de.setSource(null);
assertNull(de.getSource());
@@ -36,19 +35,19 @@ public class DefaultErrorHitTestCase {
}
@Test
- public void testToString() {
+ void testToString() {
assertEquals("Error: Source 'nalle': 5: Unspecified error: DefaultErrorHitTestCase", de.toString());
}
@Test
- public void testSetMainError() {
+ void testSetMainError() {
ErrorMessage e = ErrorMessage.createBackendCommunicationError("abc");
assertNull(e.getSource());
de.addError(e);
assertEquals(SOURCE, e.getSource());
boolean caught = false;
try {
- new DefaultErrorHit(SOURCE, (ErrorMessage)null);
+ new DefaultErrorHit(SOURCE, (ErrorMessage) null);
} catch (NullPointerException ex) {
caught = true;
}
@@ -64,7 +63,7 @@ public class DefaultErrorHitTestCase {
}
@Test
- public void testAddError() {
+ void testAddError() {
ErrorMessage e = ErrorMessage.createBackendCommunicationError("ljkhlkjh");
assertNull(e.getSource());
de.addError(e);
@@ -79,7 +78,7 @@ public class DefaultErrorHitTestCase {
}
@Test
- public void testAddErrors() {
+ void testAddErrors() {
DefaultErrorHit other = new DefaultErrorHit("abc", ErrorMessage.createBadRequest("sdasd"));
de.addErrors(other);
int i = 0;
@@ -98,7 +97,7 @@ public class DefaultErrorHitTestCase {
}
@Test
- public void testHasOnlyErrorCode() {
+ void testHasOnlyErrorCode() {
assertTrue(de.hasOnlyErrorCode(com.yahoo.container.protect.Error.UNSPECIFIED.code));
assertFalse(de.hasOnlyErrorCode(com.yahoo.container.protect.Error.BACKEND_COMMUNICATION_ERROR.code));
diff --git a/container-search/src/test/java/com/yahoo/search/result/FeatureDataTestCase.java b/container-search/src/test/java/com/yahoo/search/result/FeatureDataTestCase.java
index f7b9817437f..5d423eceb98 100644
--- a/container-search/src/test/java/com/yahoo/search/result/FeatureDataTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/FeatureDataTestCase.java
@@ -6,12 +6,12 @@ import com.yahoo.slime.Cursor;
import com.yahoo.slime.Slime;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.serialization.TypedBinaryFormat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author bratseth
@@ -21,7 +21,7 @@ public class FeatureDataTestCase {
private static final double delta = 0.00000001;
@Test
- public void testFeatureData() {
+ void testFeatureData() {
Cursor features = new Slime().setObject();
features.setDouble("scalar1", 1.5);
features.setDouble("scalar2", 2.5);
@@ -32,11 +32,11 @@ public class FeatureDataTestCase {
FeatureData featureData = new FeatureData(new SlimeAdapter(features));
assertEquals("scalar1,scalar2,tensor1,tensor2",
- featureData.featureNames().stream().sorted().collect(Collectors.joining(",")));
+ featureData.featureNames().stream().sorted().collect(Collectors.joining(",")));
assertNull(featureData.getDouble("nosuch1"));
assertEquals(1.5, featureData.getDouble("scalar1"), delta);
assertEquals(2.5, featureData.getDouble("scalar2"), delta);
- assertEquals("Cached lookup", 2.5, featureData.getDouble("scalar2"), delta);
+ assertEquals(2.5, featureData.getDouble("scalar2"), delta, "Cached lookup");
assertNull(featureData.getDouble("nosuch2"));
assertNull(featureData.getDouble("nosuch2"));
@@ -45,17 +45,17 @@ public class FeatureDataTestCase {
assertEquals(Tensor.from(2.5), featureData.getTensor("scalar2"));
assertEquals(tensor1, featureData.getTensor("tensor1"));
assertEquals(tensor2, featureData.getTensor("tensor2"));
- assertEquals("Cached lookup", tensor2, featureData.getTensor("tensor2"));
+ assertEquals(tensor2, featureData.getTensor("tensor2"), "Cached lookup");
assertNull(featureData.getTensor("nosuch2"));
assertNull(featureData.getTensor("nosuch2"));
String expectedJson =
"{" +
- "\"scalar1\":1.5," +
- "\"scalar2\":2.5," +
- "\"tensor1\":{\"type\":\"tensor(x[3])\",\"cells\":[{\"address\":{\"x\":\"0\"},\"value\":1.5},{\"address\":{\"x\":\"1\"},\"value\":2.0},{\"address\":{\"x\":\"2\"},\"value\":2.5}]}," +
- "\"tensor2\":{\"type\":\"tensor()\",\"cells\":[{\"address\":{},\"value\":0.5}]}" +
- "}";
+ "\"scalar1\":1.5," +
+ "\"scalar2\":2.5," +
+ "\"tensor1\":{\"type\":\"tensor(x[3])\",\"cells\":[{\"address\":{\"x\":\"0\"},\"value\":1.5},{\"address\":{\"x\":\"1\"},\"value\":2.0},{\"address\":{\"x\":\"2\"},\"value\":2.5}]}," +
+ "\"tensor2\":{\"type\":\"tensor()\",\"cells\":[{\"address\":{},\"value\":0.5}]}" +
+ "}";
assertEquals(expectedJson, featureData.toJson());
}
diff --git a/container-search/src/test/java/com/yahoo/search/result/NanNumberTestCase.java b/container-search/src/test/java/com/yahoo/search/result/NanNumberTestCase.java
index c6e5c87efb2..0790b6754fe 100644
--- a/container-search/src/test/java/com/yahoo/search/result/NanNumberTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/NanNumberTestCase.java
@@ -1,9 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.result;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Integrity test for representation of undefined numeric field values.
@@ -14,27 +15,27 @@ public class NanNumberTestCase {
@Test
- public final void testIntValue() {
+ final void testIntValue() {
assertEquals(0, NanNumber.NaN.intValue());
}
@Test
- public final void testLongValue() {
+ final void testLongValue() {
assertEquals(0L, NanNumber.NaN.longValue());
}
@Test
- public final void testFloatValue() {
+ final void testFloatValue() {
assertTrue(Float.isNaN(NanNumber.NaN.floatValue()));
}
@Test
- public final void testDoubleValue() {
+ final void testDoubleValue() {
assertTrue(Double.isNaN(NanNumber.NaN.doubleValue()));
}
@Test
- public final void testToString() {
+ final void testToString() {
assertEquals("", NanNumber.NaN.toString());
}
diff --git a/container-search/src/test/java/com/yahoo/search/result/PositionsDataTestCase.java b/container-search/src/test/java/com/yahoo/search/result/PositionsDataTestCase.java
index 96039beafa5..a112cb41a64 100644
--- a/container-search/src/test/java/com/yahoo/search/result/PositionsDataTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/PositionsDataTestCase.java
@@ -3,9 +3,9 @@ package com.yahoo.search.result;
import com.yahoo.data.access.simple.Value;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Arne Juul
@@ -13,7 +13,7 @@ import org.junit.Test;
public class PositionsDataTestCase {
@Test
- public void testRenderingOfSinglePosition() {
+ void testRenderingOfSinglePosition() {
Value.ObjectValue pos = createPosition(-122057174, 37374821, "N37.374821;W122.057174");
PositionsData pd = new PositionsData(pos.inspect());
@@ -23,7 +23,7 @@ public class PositionsDataTestCase {
}
@Test
- public void testRenderingOfMultiplePositions() {
+ void testRenderingOfMultiplePositions() {
Value.ArrayValue arr = new Value.ArrayValue();
arr.add(createPosition(-122057174, 37374821, "N37.374821;W122.057174"));
arr.add(createPosition(3, -7, "S0.000007;E0.000003"));
@@ -31,9 +31,9 @@ public class PositionsDataTestCase {
PositionsData pd = new PositionsData(arr.inspect());
assertXml("<position x=\"-122057174\" y=\"37374821\" latlong=\"N37.374821;W122.057174\" />" +
- "<position x=\"3\" y=\"-7\" latlong=\"S0.000007;E0.000003\" />", pd);
+ "<position x=\"3\" y=\"-7\" latlong=\"S0.000007;E0.000003\" />", pd);
assertJson("[{\"x\":-122057174,\"y\":37374821,\"latlong\":\"N37.374821;W122.057174\"}," +
- "{\"x\":3,\"y\":-7,\"latlong\":\"S0.000007;E0.000003\"}]", pd);
+ "{\"x\":3,\"y\":-7,\"latlong\":\"S0.000007;E0.000003\"}]", pd);
}
private Value.ObjectValue createPosition(long x, long y, String latlong) {
diff --git a/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java b/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java
index d95a8068570..c0b0a90b682 100644
--- a/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java
@@ -4,10 +4,10 @@ package com.yahoo.search.result.test;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.result.Coverage;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author Steinar Knutsen
@@ -15,14 +15,14 @@ import static org.junit.Assert.assertNull;
public class CoverageTestCase {
@Test
- public void testZeroCoverage() {
+ void testZeroCoverage() {
Coverage c = new Coverage(0L, 0, 0, 0);
assertEquals(0, c.getResultPercentage());
assertEquals(0, c.getResultSets());
}
@Test
- public void testActiveCoverage() {
+ void testActiveCoverage() {
Coverage c = new Coverage(6, 5);
assertEquals(5, c.getActive());
assertEquals(6, c.getDocs());
@@ -34,7 +34,7 @@ public class CoverageTestCase {
}
@Test
- public void testDefaultCoverage() {
+ void testDefaultCoverage() {
boolean create = true;
Result r1 = new Result(new Query());
@@ -46,18 +46,18 @@ public class CoverageTestCase {
}
@Test
- public void testDefaultSearchScenario() {
+ void testDefaultSearchScenario() {
boolean create = true;
Result federationSearcherResult = new Result(new Query());
Result singleSourceResult = new Result(new Query());
federationSearcherResult.mergeWith(singleSourceResult);
- assertNull(federationSearcherResult.getCoverage( !create));
+ assertNull(federationSearcherResult.getCoverage(!create));
assertEquals(0, federationSearcherResult.getCoverage(create).getResultSets());
}
@Test
- public void testRequestingCoverageSearchScenario() {
+ void testRequestingCoverageSearchScenario() {
boolean create = true;
Result federationSearcherResult = new Result(new Query());
@@ -68,7 +68,7 @@ public class CoverageTestCase {
}
@Test
- public void testCoverageConversion() {
+ void testCoverageConversion() {
Coverage c = new Coverage(6, 10);
c.setDegradedReason(7);
com.yahoo.container.logging.Coverage lc = c.toLoggingCoverage();
diff --git a/container-search/src/test/java/com/yahoo/search/result/test/DeepHitIteratorTestCase.java b/container-search/src/test/java/com/yahoo/search/result/test/DeepHitIteratorTestCase.java
index 1147cd67460..21a10bf8325 100644
--- a/container-search/src/test/java/com/yahoo/search/result/test/DeepHitIteratorTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/test/DeepHitIteratorTestCase.java
@@ -7,12 +7,9 @@ import java.util.NoSuchElementException;
import com.yahoo.search.result.DeepHitIterator;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Ensure that the {@link DeepHitIterator} works as intended.
@@ -22,7 +19,7 @@ import static org.junit.Assert.fail;
public class DeepHitIteratorTestCase {
@Test
- public void testEmpty() {
+ void testEmpty() {
HitGroup hits = new HitGroup();
Iterator<Hit> it = hits.deepIterator();
assertFalse(it.hasNext());
@@ -35,7 +32,7 @@ public class DeepHitIteratorTestCase {
}
@Test
- public void testRemove() {
+ void testRemove() {
HitGroup hits = new HitGroup();
hits.add(new Hit("foo"));
hits.add(new Hit("bar"));
@@ -62,7 +59,7 @@ public class DeepHitIteratorTestCase {
}
@Test
- public void testShallow() {
+ void testShallow() {
HitGroup hits = new HitGroup();
hits.add(new Hit("foo"));
hits.add(new Hit("bar"));
@@ -79,7 +76,7 @@ public class DeepHitIteratorTestCase {
}
@Test
- public void testDeep() {
+ void testDeep() {
HitGroup grandParent = new HitGroup();
grandParent.add(new Hit("a"));
HitGroup parent = new HitGroup();
@@ -114,7 +111,7 @@ public class DeepHitIteratorTestCase {
}
@Test
- public void testFirstHitIsGroup() {
+ void testFirstHitIsGroup() {
HitGroup root = new HitGroup();
HitGroup group = new HitGroup();
group.add(new Hit("foo"));
@@ -130,7 +127,7 @@ public class DeepHitIteratorTestCase {
}
@Test
- public void testSecondHitIsGroup() {
+ void testSecondHitIsGroup() {
HitGroup root = new HitGroup();
root.add(new Hit("foo"));
HitGroup group = new HitGroup();
@@ -146,7 +143,7 @@ public class DeepHitIteratorTestCase {
}
@Test
- public void testOrder() {
+ void testOrder() {
HitGroup root = new HitGroup();
MyHitGroup group = new MyHitGroup();
group.add(new Hit("foo"));
diff --git a/container-search/src/test/java/com/yahoo/search/result/test/FillingTestCase.java b/container-search/src/test/java/com/yahoo/search/result/test/FillingTestCase.java
index ea5c11cb055..8c833ca76f3 100644
--- a/container-search/src/test/java/com/yahoo/search/result/test/FillingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/test/FillingTestCase.java
@@ -3,13 +3,11 @@ package com.yahoo.search.result.test;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -17,16 +15,16 @@ import static org.junit.Assert.assertTrue;
public class FillingTestCase {
@Test
- public void testFillingAPIConsistency() {
- HitGroup group=new HitGroup();
+ void testFillingAPIConsistency() {
+ HitGroup group = new HitGroup();
group.add(new Hit("hit:1"));
group.add(new Hit("hit:2"));
assertTrue(group.isFilled("summary"));
}
@Test
- public void testFillingAPIConsistencyTwoPhase() {
- HitGroup group=new HitGroup();
+ void testFillingAPIConsistencyTwoPhase() {
+ HitGroup group = new HitGroup();
group.add(createNonFilled("hit:1"));
group.add(createNonFilled("hit:2"));
assertFalse(group.isFilled("summary"));
@@ -36,8 +34,8 @@ public class FillingTestCase {
}
@Test
- public void testFillingAPIConsistencyThreePhase() {
- HitGroup group=new HitGroup();
+ void testFillingAPIConsistencyThreePhase() {
+ HitGroup group = new HitGroup();
group.add(createNonFilled("hit:1"));
group.add(createNonFilled("hit:2"));
assertFalse(group.isFilled("summary"));
@@ -54,7 +52,7 @@ public class FillingTestCase {
}
@Test
- public void testPartiallyFilledWith2Hits() {
+ void testPartiallyFilledWith2Hits() {
Hit hit1 = new Hit("id1");
Hit hit2 = new Hit("id2");
@@ -69,7 +67,7 @@ public class FillingTestCase {
}
@Test
- public void testPartiallyFilledDiverse() {
+ void testPartiallyFilledDiverse() {
Hit hit1 = new Hit("id1");
Hit hit2 = new Hit("id2");
Hit hit3 = new Hit("id3");
diff --git a/container-search/src/test/java/com/yahoo/search/result/test/HitGroupTestCase.java b/container-search/src/test/java/com/yahoo/search/result/test/HitGroupTestCase.java
index 8196cf4ac74..cc4e6193103 100644
--- a/container-search/src/test/java/com/yahoo/search/result/test/HitGroupTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/result/test/HitGroupTestCase.java
@@ -7,17 +7,13 @@ import com.yahoo.search.result.ErrorHit;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -25,21 +21,21 @@ import static org.junit.Assert.assertTrue;
public class HitGroupTestCase {
@Test
- public void testErrorsConsistencyUsingErrorOperations() {
+ void testErrorsConsistencyUsingErrorOperations() {
HitGroup hits = new HitGroup();
Query query = new Query();
query.errors().add(ErrorMessage.createIllegalQuery("test1"));
query.errors().add(ErrorMessage.createTimeout("test2"));
hits.setQuery(query);
-
+
hits.addError(ErrorMessage.createForbidden("test3"));
hits.addError(ErrorMessage.createUnspecifiedError("test4"));
-
+
assertEquals(4, hits.getErrorHit().errors().size());
assertEquals(0, query.errors().size());
assertEquals(Optional.of(hits.getErrorHit()), errorHitIn(hits.asList()));
-
+
DefaultErrorHit removedErrors = hits.removeErrorHit();
assertNotNull(removedErrors);
assertEquals(4, removedErrors.errors().size());
@@ -50,7 +46,7 @@ public class HitGroupTestCase {
}
@Test
- public void testErrorsConsistencyUsingHitOperations() {
+ void testErrorsConsistencyUsingHitOperations() {
HitGroup hits = new HitGroup();
Query query = new Query();
@@ -66,7 +62,7 @@ public class HitGroupTestCase {
assertEquals(0, query.errors().size());
assertEquals(Optional.of(hits.getErrorHit()), errorHitIn(hits.asList()));
- DefaultErrorHit removedErrors = (DefaultErrorHit)hits.remove(errors.getId());
+ DefaultErrorHit removedErrors = (DefaultErrorHit) hits.remove(errors.getId());
assertNotNull(removedErrors);
assertEquals(4, removedErrors.errors().size());
assertNull(hits.get(removedErrors.getId().toString()));
@@ -76,39 +72,39 @@ public class HitGroupTestCase {
}
@Test
- public void testRecursiveGet() {
+ void testRecursiveGet() {
// Level 1
- HitGroup g1=new HitGroup();
+ HitGroup g1 = new HitGroup();
g1.add(new Hit("1"));
// Level 2
- HitGroup g1_1=new HitGroup();
+ HitGroup g1_1 = new HitGroup();
g1_1.add(new Hit("1.1"));
g1.add(g1_1);
- HitGroup g1_2=new HitGroup();
+ HitGroup g1_2 = new HitGroup();
g1_2.add(new Hit("1.2"));
g1.add(g1_2);
// Level 3
- HitGroup g1_1_1=new HitGroup();
+ HitGroup g1_1_1 = new HitGroup();
g1_1_1.add(new Hit("1.1.1"));
g1_1.add(g1_1_1);
- HitGroup g1_1_2=new HitGroup();
+ HitGroup g1_1_2 = new HitGroup();
g1_1_2.add(new Hit("1.1.2"));
g1_1.add(g1_1_2);
- HitGroup g1_2_1=new HitGroup();
+ HitGroup g1_2_1 = new HitGroup();
g1_2_1.add(new Hit("1.2.1"));
g1_2.add(g1_2_1);
- HitGroup g1_2_2=new HitGroup();
+ HitGroup g1_2_2 = new HitGroup();
g1_2_2.add(new Hit("1.2.2"));
g1_2.add(g1_2_2);
// Level 4
- HitGroup g1_1_1_1=new HitGroup();
+ HitGroup g1_1_1_1 = new HitGroup();
g1_1_1_1.add(new Hit("1.1.1.1"));
g1_1_1.add(g1_1_1_1);
@@ -121,49 +117,49 @@ public class HitGroupTestCase {
assertNotNull(g1.get("1.2.2"));
assertNotNull(g1.get("1.1.1.1"));
- assertNotNull(g1.get("1",-1));
- assertNotNull(g1.get("1.1",-1));
- assertNotNull(g1.get("1.2",-1));
- assertNotNull(g1.get("1.1.1",-1));
- assertNotNull(g1.get("1.1.2",-1));
- assertNotNull(g1.get("1.2.1",-1));
- assertNotNull(g1.get("1.2.2",-1));
- assertNotNull(g1.get("1.1.1.1",-1));
-
- assertNotNull(g1.get("1",0));
- assertNull(g1.get("1.1",0));
- assertNull(g1.get("1.2",0));
- assertNull(g1.get("1.1.1",0));
- assertNull(g1.get("1.1.2",0));
- assertNull(g1.get("1.2.1",0));
- assertNull(g1.get("1.2.2",0));
- assertNull(g1.get("1.1.1.1",0));
-
- assertNotNull(g1.get("1",1));
- assertNotNull(g1.get("1.1",1));
- assertNotNull(g1.get("1.2",1));
- assertNull(g1.get("1.1.1",1));
- assertNull(g1.get("1.1.2",1));
- assertNull(g1.get("1.2.1",1));
- assertNull(g1.get("1.2.2",1));
- assertNull(g1.get("1.1.1.1",1));
-
- assertNotNull(g1.get("1",2));
- assertNotNull(g1.get("1.1",2));
- assertNotNull(g1.get("1.2",2));
- assertNotNull(g1.get("1.1.1",2));
- assertNotNull(g1.get("1.1.2",2));
- assertNotNull(g1.get("1.2.1",2));
- assertNotNull(g1.get("1.2.2",2));
- assertNull(g1.get("1.1.1.1",2));
-
- assertNotNull(g1.get("1.1.1.1",3));
-
- assertNull(g1.get("3",2));
+ assertNotNull(g1.get("1", -1));
+ assertNotNull(g1.get("1.1", -1));
+ assertNotNull(g1.get("1.2", -1));
+ assertNotNull(g1.get("1.1.1", -1));
+ assertNotNull(g1.get("1.1.2", -1));
+ assertNotNull(g1.get("1.2.1", -1));
+ assertNotNull(g1.get("1.2.2", -1));
+ assertNotNull(g1.get("1.1.1.1", -1));
+
+ assertNotNull(g1.get("1", 0));
+ assertNull(g1.get("1.1", 0));
+ assertNull(g1.get("1.2", 0));
+ assertNull(g1.get("1.1.1", 0));
+ assertNull(g1.get("1.1.2", 0));
+ assertNull(g1.get("1.2.1", 0));
+ assertNull(g1.get("1.2.2", 0));
+ assertNull(g1.get("1.1.1.1", 0));
+
+ assertNotNull(g1.get("1", 1));
+ assertNotNull(g1.get("1.1", 1));
+ assertNotNull(g1.get("1.2", 1));
+ assertNull(g1.get("1.1.1", 1));
+ assertNull(g1.get("1.1.2", 1));
+ assertNull(g1.get("1.2.1", 1));
+ assertNull(g1.get("1.2.2", 1));
+ assertNull(g1.get("1.1.1.1", 1));
+
+ assertNotNull(g1.get("1", 2));
+ assertNotNull(g1.get("1.1", 2));
+ assertNotNull(g1.get("1.2", 2));
+ assertNotNull(g1.get("1.1.1", 2));
+ assertNotNull(g1.get("1.1.2", 2));
+ assertNotNull(g1.get("1.2.1", 2));
+ assertNotNull(g1.get("1.2.2", 2));
+ assertNull(g1.get("1.1.1.1", 2));
+
+ assertNotNull(g1.get("1.1.1.1", 3));
+
+ assertNull(g1.get("3", 2));
}
@Test
- public void testThatHitGroupIsUnFillable() {
+ void testThatHitGroupIsUnFillable() {
HitGroup hg = new HitGroup("test");
{
Hit hit = new Hit("http://nalle.balle/1.html", 832);
@@ -185,7 +181,7 @@ public class HitGroupTestCase {
}
@Test
- public void testThatHitGroupIsFillable() {
+ void testThatHitGroupIsFillable() {
HitGroup hg = new HitGroup("test");
{
Hit hit = new Hit("http://nalle.balle/1.html", 832);
@@ -209,7 +205,7 @@ public class HitGroupTestCase {
}
@Test
- public void testThatHitGroupIsFillableAfterFillableChangeunderTheHood() {
+ void testThatHitGroupIsFillableAfterFillableChangeunderTheHood() {
HitGroup hg = new HitGroup("test");
{
Hit hit = new Hit("http://nalle.balle/1.html", 832);
diff --git a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java
index d2cd2c4bb33..40d6f19c275 100644
--- a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java
+++ b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java
@@ -2,9 +2,9 @@
package com.yahoo.search.schema;
import com.yahoo.tensor.TensorType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -12,38 +12,38 @@ import static org.junit.Assert.assertEquals;
public class SchemaInfoTest {
@Test
- public void testSchemaInfoConfiguration() {
+ void testSchemaInfoConfiguration() {
assertEquals(SchemaInfoTester.createSchemaInfoFromConfig(), SchemaInfoTester.createSchemaInfo());
}
@Test
- public void testInputResolution() {
+ void testInputResolution() {
var tester = new SchemaInfoTester();
tester.assertInput(TensorType.fromSpec("tensor(a{},b{})"),
- "", "", "commonProfile", "query(myTensor1)");
+ "", "", "commonProfile", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(a{},b{})"),
- "ab", "", "commonProfile", "query(myTensor1)");
+ "ab", "", "commonProfile", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(a{},b{})"),
- "a", "", "commonProfile", "query(myTensor1)");
+ "a", "", "commonProfile", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(a{},b{})"),
- "b", "", "commonProfile", "query(myTensor1)");
+ "b", "", "commonProfile", "query(myTensor1)");
tester.assertInputConflict(TensorType.fromSpec("tensor(a{},b{})"),
- "", "", "inconsistent", "query(myTensor1)");
+ "", "", "inconsistent", "query(myTensor1)");
tester.assertInputConflict(TensorType.fromSpec("tensor(a{},b{})"),
- "ab", "", "inconsistent", "query(myTensor1)");
+ "ab", "", "inconsistent", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(a{},b{})"),
- "ab", "a", "inconsistent", "query(myTensor1)");
+ "ab", "a", "inconsistent", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(x[10])"),
- "ab", "b", "inconsistent", "query(myTensor1)");
+ "ab", "b", "inconsistent", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(a{},b{})"),
- "a", "", "inconsistent", "query(myTensor1)");
+ "a", "", "inconsistent", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(x[10])"),
- "b", "", "inconsistent", "query(myTensor1)");
+ "b", "", "inconsistent", "query(myTensor1)");
tester.assertInput(null,
- "a", "", "bOnly", "query(myTensor1)");
+ "a", "", "bOnly", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(a{},b{})"),
- "ab", "", "bOnly", "query(myTensor1)");
+ "ab", "", "bOnly", "query(myTensor1)");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java
index 45bf5af5258..4e7dc27e73c 100644
--- a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java
+++ b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java
@@ -15,7 +15,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java
index f0be6a25f92..298bcc82d99 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java
@@ -7,7 +7,7 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Iterator;
@@ -17,7 +17,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -28,16 +28,16 @@ public class AsyncExecutionOfOneChainTestCase {
/** Tests having a result with some slow source data which should pass directly to rendering */
@Test
- public void testParallelExecutionOfOneChain() {
+ void testParallelExecutionOfOneChain() {
ExecutorService executor = Executors.newFixedThreadPool(16);
// Setup
- Chain<Searcher> mainChain=new Chain<>(new ParallelExecutor(executor),new ResultProcessor(),new RegularProvider());
+ Chain<Searcher> mainChain = new Chain<>(new ParallelExecutor(executor), new ResultProcessor(), new RegularProvider());
// Execute
- Result result=new Execution(mainChain, Execution.Context.createContextStub()).search(new Query());
+ Result result = new Execution(mainChain, Execution.Context.createContextStub()).search(new Query());
// Verify
- assertEquals("Received 2 hits from 3 threads",3*2,result.hits().size());
+ assertEquals(3 * 2, result.hits().size(), "Received 2 hits from 3 threads");
assertEquals(1.0, result.hits().get("thread-0:hit-0").getRelevance().getScore(), delta);
assertEquals(1.0, result.hits().get("thread-1:hit-0").getRelevance().getScore(), delta);
assertEquals(1.0, result.hits().get("thread-2:hit-0").getRelevance().getScore(), delta);
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java
index 8f23c7eef83..0e4d1350a03 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java
@@ -7,17 +7,14 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test for aynchrounous execution
@@ -56,10 +53,10 @@ public class AsyncExecutionTestCase {
// This should take ~50+ ms
@Test
- public void testAsync() {
+ void testAsync() {
List<Searcher> searchList = new ArrayList<>();
- searchList.add(new WaitingSearcher("one",60000));
- searchList.add(new WaitingSearcher("two",0));
+ searchList.add(new WaitingSearcher("one", 60000));
+ searchList.add(new WaitingSearcher("two", 0));
Chain<Searcher> searchChain = new Chain<>(new ComponentId("chain"), searchList);
AsyncExecution asyncExecution = new AsyncExecution(searchChain, Execution.Context.createContextStub());
@@ -70,23 +67,23 @@ public class AsyncExecutionTestCase {
}
@Test
- public void testWaitForAll() {
+ void testWaitForAll() {
Chain<Searcher> slowChain = new Chain<>(
new ComponentId("slow"),
- Arrays.asList(new Searcher[]{new WaitingSearcher("slow",30000)}
+ Arrays.asList(new Searcher[]{new WaitingSearcher("slow", 30000)}
)
);
Chain<Searcher> fastChain = new Chain<>(
new ComponentId("fast"),
Arrays.asList(new Searcher[]{new SimpleSearcher()})
- );
+ );
FutureResult slowFuture = new AsyncExecution(slowChain, Execution.Context.createContextStub()).search(new Query("?hits=0"));
FutureResult fastFuture = new AsyncExecution(fastChain, Execution.Context.createContextStub()).search(new Query("?hits=0"));
fastFuture.get();
- FutureResult [] reslist = new FutureResult[]{slowFuture,fastFuture};
- List<Result> results = AsyncExecution.waitForAll(Arrays.asList(reslist),0);
+ FutureResult [] reslist = new FutureResult[]{slowFuture, fastFuture};
+ List<Result> results = AsyncExecution.waitForAll(Arrays.asList(reslist), 0);
//assertTrue(slowFuture.isCancelled());
assertTrue(fastFuture.isDone() && !fastFuture.isCancelled());
@@ -96,27 +93,27 @@ public class AsyncExecutionTestCase {
}
@Test
- public void testSync() {
- Query query=new Query("?query=test");
- Searcher searcher=new ResultProducingSearcher();
- Result result=new Execution(searcher, Execution.Context.createContextStub()).search(query);
+ void testSync() {
+ Query query = new Query("?query=test");
+ Searcher searcher = new ResultProducingSearcher();
+ Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
- assertEquals(1,result.hits().size());
- assertEquals("hello",result.hits().get(0).getField("test"));
+ assertEquals(1, result.hits().size());
+ assertEquals("hello", result.hits().get(0).getField("test"));
}
@Test
- public void testSyncThroughSync() {
- Query query=new Query("?query=test");
- Searcher searcher=new ResultProducingSearcher();
- Result result=new Execution(new Execution(searcher, Execution.Context.createContextStub())).search(query);
+ void testSyncThroughSync() {
+ Query query = new Query("?query=test");
+ Searcher searcher = new ResultProducingSearcher();
+ Result result = new Execution(new Execution(searcher, Execution.Context.createContextStub())).search(query);
- assertEquals(1,result.hits().size());
- assertEquals("hello",result.hits().get(0).getField("test"));
+ assertEquals(1, result.hits().size());
+ assertEquals("hello", result.hits().get(0).getField("test"));
}
@Test
- public void testAsyncThroughSync() {
+ void testAsyncThroughSync() {
Query query = new Query("?query=test");
Searcher searcher = new ResultProducingSearcher();
FutureResult futureResult = new AsyncExecution(new Execution(searcher, Execution.Context.createContextStub())).search(query);
@@ -144,7 +141,7 @@ public class AsyncExecutionTestCase {
}
@Test
- public void testAsyncExecutionTimeout() {
+ void testAsyncExecutionTimeout() {
Chain<Searcher> chain = new Chain<>(new Searcher() {
@Override
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java b/container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java
index 341e55df777..e25a946c18b 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java
@@ -5,16 +5,16 @@ import com.yahoo.component.chain.Chain;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests async execution of search chains.
@@ -26,12 +26,12 @@ public class VespaAsyncSearcherTest {
private ExecutorService executor;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
executor = Executors.newFixedThreadPool(16);
}
- @After
+ @AfterEach
public void tearDown() {
assertEquals(0, executor.shutdownNow().size());
}
@@ -69,7 +69,7 @@ public class VespaAsyncSearcherTest {
}
@Test
- public void testAsyncExecution() {
+ void testAsyncExecution() {
Chain<Searcher> chain = new Chain<>(new FirstSearcher(), new SecondSearcher());
Execution execution = new Execution(chain, Execution.Context.createContextStub());
Query query = new Query();
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java
index 553a9233bf1..614d481cf77 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java
@@ -6,6 +6,8 @@ import java.io.IOException;
import java.util.Arrays;
import com.yahoo.component.chain.dependencies.After;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.yahoo.component.chain.dependencies.Before;
import com.yahoo.component.chain.dependencies.Dependencies;
import com.yahoo.component.chain.dependencies.Provides;
@@ -17,11 +19,9 @@ import com.yahoo.search.handler.SearchHandler;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChainRegistry;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
* @author Tony Vaagenes
@@ -34,14 +34,14 @@ public class DependencyConfigTestCase {
public static final String root = "src/test/java/com/yahoo/search/searchchain/config/test/dependencyConfig";
- @BeforeClass
+ @BeforeAll
public static void createComponentsConfig() throws IOException {
SearchChainConfigurerTestCase.
createComponentsConfig(root + "/chains.cfg", root + "/handlers.cfg", root + "/components.cfg");
setUp();
}
- @AfterClass
+ @AfterAll
public static void removeComponentsConfig() {
new File(root + "/components.cfg").delete();
tearDown();
@@ -69,7 +69,7 @@ public class DependencyConfigTestCase {
}
@Test
- public void test() {
+ void test() {
Dependencies dependencies = registry.getSearcherRegistry().getComponent(Searcher1.class.getName()).getDependencies();
assertTrue(dependencies.provides().containsAll(Arrays.asList("P", "P1", "P2", Searcher1.class.getSimpleName())));
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java
index 781370d9e25..e851d221116 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java
@@ -14,9 +14,9 @@ import com.yahoo.search.searchchain.ExecutionFactory;
import com.yahoo.search.searchchain.SearchChain;
import com.yahoo.search.searchchain.SearchChainRegistry;
import com.yahoo.search.searchchain.SearcherRegistry;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.File;
@@ -36,13 +36,7 @@ import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -65,12 +59,12 @@ public class SearchChainConfigurerTestCase {
}
}
- @BeforeClass
+ @BeforeAll
public static void createDefaultComponentsConfigs() throws IOException {
createComponentsConfig(testDir + "chains.cfg", testDir + "handlers.cfg", testDir + "components.cfg");
}
- @AfterClass
+ @AfterAll
public static void removeDefaultComponentsConfigs() {
new File(testDir + "components.cfg").delete();
}
@@ -81,7 +75,7 @@ public class SearchChainConfigurerTestCase {
}
@Test
- public synchronized void testConfiguration() {
+ synchronized void testConfiguration() {
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper("dir:" + testDir);
SearchChain simple = getSearchChainRegistryFrom(configurer).getComponent("simple");
@@ -130,7 +124,7 @@ public class SearchChainConfigurerTestCase {
public static final class DeclaredTestSearcher extends TestSearcher {}
@Test
- public void testConfigurableSearcher() {
+ void testConfigurableSearcher() {
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper("dir:" + testDir);
SearchChain configurable = getSearchChainRegistryFrom(configurer).getComponent("configurable");
@@ -138,9 +132,9 @@ public class SearchChainConfigurerTestCase {
Searcher s = configurable.searchers().get(0);
assertTrue(s instanceof ConfigurableSearcher);
- ConfigurableSearcher searcher = (ConfigurableSearcher)s;
- assertEquals("Value from int.cfg file", 7, searcher.intConfig.intVal());
- assertEquals("Value from string.cfg file", "com.yahoo.search.searchchain.config.test", searcher.stringConfig.stringVal());
+ ConfigurableSearcher searcher = (ConfigurableSearcher) s;
+ assertEquals(7, searcher.intConfig.intVal(), "Value from int.cfg file");
+ assertEquals("com.yahoo.search.searchchain.config.test", searcher.stringConfig.stringVal(), "Value from string.cfg file");
configurer.shutdown();
}
@@ -149,7 +143,7 @@ public class SearchChainConfigurerTestCase {
* that does not contain any bootstrap configs.
*/
@Test
- public void testSearcherConfigUpdate() throws IOException {
+ void testSearcherConfigUpdate() throws IOException {
File cfgDir = getCfgDir();
copyFile(testDir + "handlers.cfg", cfgDir + "/handlers.cfg");
copyFile(testDir + "qr-search.cfg", cfgDir + "/qr-search.cfg");
@@ -167,11 +161,11 @@ public class SearchChainConfigurerTestCase {
SearcherRegistry searchers = getSearchChainRegistryFrom(configurer).getSearcherRegistry();
assertEquals(3, searchers.getComponentCount());
- IntSearcher intSearcher = (IntSearcher)searchers.getComponent(IntSearcher.class.getName());
+ IntSearcher intSearcher = (IntSearcher) searchers.getComponent(IntSearcher.class.getName());
assertEquals(16, intSearcher.intConfig.intVal());
- StringSearcher stringSearcher = (StringSearcher)searchers.getComponent(StringSearcher.class.getName());
+ StringSearcher stringSearcher = (StringSearcher) searchers.getComponent(StringSearcher.class.getName());
DeclaredTestSearcher noConfigSearcher =
- (DeclaredTestSearcher)searchers.getComponent(DeclaredTestSearcher.class.getName());
+ (DeclaredTestSearcher) searchers.getComponent(DeclaredTestSearcher.class.getName());
// Update int config for IntSearcher,
printFile(new File(cfgDir + "/int.cfg"), "intVal 17\n");
@@ -183,7 +177,7 @@ public class SearchChainConfigurerTestCase {
assertEquals(3, searchers.getComponentCount());
// Searcher with updated config is re-instantiated.
- IntSearcher intSearcher2 = (IntSearcher)searchers.getComponent(IntSearcher.class.getName());
+ IntSearcher intSearcher2 = (IntSearcher) searchers.getComponent(IntSearcher.class.getName());
assertNotSame(intSearcher, intSearcher2);
assertEquals(17, intSearcher2.intConfig.intVal());
@@ -203,7 +197,7 @@ public class SearchChainConfigurerTestCase {
* and that a searcher that has been removed from the configuration is not in the new registry.
*/
@Test
- public void testChainsConfigUpdate() throws IOException {
+ void testChainsConfigUpdate() throws IOException {
File cfgDir = getCfgDir();
copyFile(testDir + "handlers.cfg", cfgDir + "/handlers.cfg");
copyFile(testDir + "qr-search.cfg", cfgDir + "/qr-search.cfg");
@@ -225,7 +219,7 @@ public class SearchChainConfigurerTestCase {
assertNull(searchers.getComponent(ConfigurableSearcher.class.getName()));
assertNull(searchers.getComponent(DeclaredTestSearcher.class.getName()));
- IntSearcher intSearcher = (IntSearcher)searchers.getComponent(IntSearcher.class.getName());
+ IntSearcher intSearcher = (IntSearcher) searchers.getComponent(IntSearcher.class.getName());
// Update chains config
copyFile(testDir + "chainsConfigUpdate_2.cfg", cfgDir + "/chains.cfg");
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java
index 129437a5429..bc535e4e214 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java
@@ -17,14 +17,9 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests basic search chain execution functionality
@@ -34,31 +29,31 @@ import static org.junit.Assert.assertTrue;
public class ExecutionTestCase {
@Test
- public void testLinearExecutions() {
+ void testLinearExecutions() {
// Make a chain
- List<Searcher> searchers1=new ArrayList<>();
+ List<Searcher> searchers1 = new ArrayList<>();
searchers1.add(new TestSearcher("searcher1"));
searchers1.add(new TestSearcher("searcher2"));
searchers1.add(new TestSearcher("searcher3"));
searchers1.add(new TestSearcher("searcher4"));
- Chain<Searcher> chain1=new Chain<>(new ComponentId("chain1"), searchers1);
+ Chain<Searcher> chain1 = new Chain<>(new ComponentId("chain1"), searchers1);
// Make another chain containing two of the same searcher instances and two new
- List<Searcher> searchers2=new ArrayList<>(searchers1);
- searchers2.set(1,new TestSearcher("searcher5"));
- searchers2.set(3,new TestSearcher("searcher6"));
- Chain<Searcher> chain2=new Chain<>(new ComponentId("chain2"), searchers2);
+ List<Searcher> searchers2 = new ArrayList<>(searchers1);
+ searchers2.set(1, new TestSearcher("searcher5"));
+ searchers2.set(3, new TestSearcher("searcher6"));
+ Chain<Searcher> chain2 = new Chain<>(new ComponentId("chain2"), searchers2);
// Execute both
- Query query=new Query("test");
- Result result1=new Execution(chain1, Execution.Context.createContextStub()).search(query);
- Result result2=new Execution(chain2, Execution.Context.createContextStub()).search(query);
+ Query query = new Query("test");
+ Result result1 = new Execution(chain1, Execution.Context.createContextStub()).search(query);
+ Result result2 = new Execution(chain2, Execution.Context.createContextStub()).search(query);
// Verify results
- assertEquals(4,result1.getConcreteHitCount());
+ assertEquals(4, result1.getConcreteHitCount());
assertNotNull(result1.hits().get("searcher1-1"));
assertNotNull(result1.hits().get("searcher2-1"));
assertNotNull(result1.hits().get("searcher3-1"));
assertNotNull(result1.hits().get("searcher4-1"));
- assertEquals(4,result2.getConcreteHitCount());
+ assertEquals(4, result2.getConcreteHitCount());
assertNotNull(result2.hits().get("searcher1-2"));
assertNotNull(result2.hits().get("searcher5-1"));
assertNotNull(result2.hits().get("searcher3-2"));
@@ -66,20 +61,20 @@ public class ExecutionTestCase {
}
@Test
- public void testNestedExecution() {
+ void testNestedExecution() {
// Make a chain
- List<Searcher> searchers1=new ArrayList<>();
+ List<Searcher> searchers1 = new ArrayList<>();
searchers1.add(new FillableTestSearcher("searcher1"));
searchers1.add(new WorkflowSearcher());
searchers1.add(new TestSearcher("searcher2"));
searchers1.add(new FillingSearcher());
searchers1.add(new FillableTestSearcherAtTheEnd("searcher3"));
- Chain<Searcher> chain1=new Chain<>(new ComponentId("chain1"), searchers1);
+ Chain<Searcher> chain1 = new Chain<>(new ComponentId("chain1"), searchers1);
// Execute it
- Query query=new Query("test");
- Result result1=new Execution(chain1, Execution.Context.createContextStub()).search(query);
+ Query query = new Query("test");
+ Result result1 = new Execution(chain1, Execution.Context.createContextStub()).search(query);
// Verify results
- assertEquals(7,result1.getConcreteHitCount());
+ assertEquals(7, result1.getConcreteHitCount());
assertNotNull(result1.hits().get("searcher1-1"));
assertNotNull(result1.hits().get("searcher2-1"));
assertNotNull(result1.hits().get("searcher3-1"));
@@ -90,7 +85,7 @@ public class ExecutionTestCase {
}
@Test
- public void testContextCacheSingleLengthSearchChain() {
+ void testContextCacheSingleLengthSearchChain() {
IndexFacts[] contextsBefore = new IndexFacts[1];
IndexFacts[] contextsAfter = new IndexFacts[1];
List<Searcher> l = new ArrayList<>(1);
@@ -103,7 +98,7 @@ public class ExecutionTestCase {
}
@Test
- public void testContextCache() {
+ void testContextCache() {
IndexFacts[] contextsBefore = new IndexFacts[5];
IndexFacts[] contextsAfter = new IndexFacts[5];
List<Searcher> l = new ArrayList<>(5);
@@ -129,7 +124,7 @@ public class ExecutionTestCase {
}
@Test
- public void testContextCacheMoreSearchers() {
+ void testContextCacheMoreSearchers() {
IndexFacts[] contextsBefore = new IndexFacts[7];
IndexFacts[] contextsAfter = new IndexFacts[7];
List<Searcher> l = new ArrayList<>(7);
@@ -161,7 +156,7 @@ public class ExecutionTestCase {
}
@Test
- public void testBasicFill() {
+ void testBasicFill() {
Chain<Searcher> chain = new Chain<Searcher>(new FillableResultSearcher());
Execution execution = new Execution(chain, Execution.Context.createContextStub());
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java
index 15517270cb9..c78c0d75477 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java
@@ -14,16 +14,15 @@ import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChainRegistry;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests using the async capabilities of the Processing parent framework of searchers.
@@ -33,16 +32,16 @@ import static org.junit.Assert.assertTrue;
public class FutureDataTestCase {
@Test
- public void testAsyncFederation() throws InterruptedException, ExecutionException {
+ void testAsyncFederation() throws InterruptedException, ExecutionException {
// Setup environment
AsyncProviderSearcher asyncProviderSearcher = new AsyncProviderSearcher();
Searcher syncProviderSearcher = new SyncProviderSearcher();
Chain<Searcher> asyncSource = new Chain<>(new ComponentId("async"), asyncProviderSearcher);
Chain<Searcher> syncSource = new Chain<>(new ComponentId("sync"), syncProviderSearcher);
- SearchChainResolver searchChainResolver=
+ SearchChainResolver searchChainResolver =
new SearchChainResolver.Builder().addSearchChain(new ComponentId("sync"), new FederationOptions().setUseByDefault(true)).
- addSearchChain(new ComponentId("async"), new FederationOptions().setUseByDefault(true)).
- build();
+ addSearchChain(new ComponentId("async"), new FederationOptions().setUseByDefault(true)).
+ build();
Chain<Searcher> main = new Chain<>(new FederationSearcher(new ComponentId("federator"), searchChainResolver));
SearchChainRegistry searchChainRegistry = new SearchChainRegistry();
searchChainRegistry.register(main);
@@ -54,32 +53,32 @@ public class FutureDataTestCase {
Result result = new Execution(main, Execution.Context.createContextStub(searchChainRegistry)).search(query);
assertNotNull(result);
- HitGroup syncGroup = (HitGroup)result.hits().get("source:sync");
+ HitGroup syncGroup = (HitGroup) result.hits().get("source:sync");
assertNotNull(syncGroup);
- HitGroup asyncGroup = (HitGroup)result.hits().get("source:async");
+ HitGroup asyncGroup = (HitGroup) result.hits().get("source:async");
assertNotNull(asyncGroup);
- assertEquals("Got all sync data", 3, syncGroup.size());
+ assertEquals(3, syncGroup.size(), "Got all sync data");
assertEquals("sync:0", syncGroup.get(0).getId().toString());
assertEquals("sync:1", syncGroup.get(1).getId().toString());
assertEquals("sync:2", syncGroup.get(2).getId().toString());
- assertTrue(asyncGroup.incoming()==asyncProviderSearcher.incomingData);
- assertEquals("Got no async data yet", 0, asyncGroup.size());
+ assertEquals(asyncGroup.incoming(), asyncProviderSearcher.incomingData);
+ assertEquals(0, asyncGroup.size(), "Got no async data yet");
asyncProviderSearcher.simulateOneHitIOComplete(new Hit("async:0"));
- assertEquals("Got no async data yet, as we haven't completed the incoming buffer and there is no data listener", 0, asyncGroup.size());
+ assertEquals(0, asyncGroup.size(), "Got no async data yet, as we haven't completed the incoming buffer and there is no data listener");
asyncProviderSearcher.simulateOneHitIOComplete(new Hit("async:1"));
asyncProviderSearcher.simulateAllHitsIOComplete();
- assertEquals("Got no async data yet, as we haven't pulled it", 0, asyncGroup.size());
+ assertEquals(0, asyncGroup.size(), "Got no async data yet, as we haven't pulled it");
asyncGroup.completeFuture().get();
- assertEquals("Completed, so we have the data", 2, asyncGroup.size());
+ assertEquals(2, asyncGroup.size(), "Completed, so we have the data");
assertEquals("async:0", asyncGroup.get(0).getId().toString());
assertEquals("async:1", asyncGroup.get(1).getId().toString());
}
@Test
- public void testFutureData() throws InterruptedException, ExecutionException, TimeoutException {
+ void testFutureData() throws InterruptedException, ExecutionException, TimeoutException {
// Set up
AsyncProviderSearcher futureDataSource = new AsyncProviderSearcher();
Chain<Searcher> chain = new Chain<>(Collections.<Searcher>singletonList(futureDataSource));
@@ -89,16 +88,14 @@ public class FutureDataTestCase {
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
// Verify the result prior to completion of delayed data
- assertEquals("The result has been returned, but no hits are available yet",
- 0, result.hits().getConcreteSize());
+ assertEquals(0, result.hits().getConcreteSize(), "The result has been returned, but no hits are available yet");
// pretend we're the IO layer and complete delayed data - this is typically done in a callback from jDisc
futureDataSource.simulateOneHitIOComplete(new Hit("hit:0"));
futureDataSource.simulateOneHitIOComplete(new Hit("hit:1"));
futureDataSource.simulateAllHitsIOComplete();
- assertEquals("Async arriving hits are still not visible because we haven't asked for them",
- 0, result.hits().getConcreteSize());
+ assertEquals(0, result.hits().getConcreteSize(), "Async arriving hits are still not visible because we haven't asked for them");
// Results with future hit groups will be passed to rendering directly and start rendering immediately.
// For this test we block and wait for the data instead:
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java
index d7fd73a81e6..3e7a152122e 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java
@@ -2,7 +2,7 @@
package com.yahoo.search.searchchain.test;
import static com.yahoo.search.searchchain.test.SimpleSearchChain.searchChain;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
@@ -19,7 +19,7 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChain;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests basic search chain functionality - creation, inheritance and ordering
@@ -30,17 +30,17 @@ import org.junit.Test;
public class SearchChainTestCase {
@Test
- public void testEmptySearchChain() {
+ void testEmptySearchChain() {
SearchChain empty = new SearchChain(new ComponentId("empty"));
assertEquals("empty", empty.getId().getName());
}
@Test
- public void testSearchChainCreation() {
- assertEquals("test",searchChain.getId().stringValue());
- assertEquals("test",searchChain.getId().getName());
+ void testSearchChainCreation() {
+ assertEquals("test", searchChain.getId().stringValue());
+ assertEquals("test", searchChain.getId().getName());
assertEquals(Version.emptyVersion, searchChain.getId().getVersion());
- assertEquals(new Version(),searchChain.getId().getVersion());
+ assertEquals(new Version(), searchChain.getId().getVersion());
assertEqualMembers(Arrays.asList("one", "two"), searcherNames(searchChain.searchers()));
}
@@ -60,28 +60,28 @@ public class SearchChainTestCase {
}
@Test
- public void testSearchChainToStringEmpty() {
+ void testSearchChainToStringEmpty() {
assertEquals("chain 'test' []", new Chain<>(new ComponentId("test"), createSearchers(0)).toString());
}
@Test
- public void testSearchChainToStringVeryShort() {
- assertEquals("chain 'test' [s1]", new Chain<>(new ComponentId("test"),createSearchers(1)).toString());
+ void testSearchChainToStringVeryShort() {
+ assertEquals("chain 'test' [s1]", new Chain<>(new ComponentId("test"), createSearchers(1)).toString());
}
@Test
- public void testSearchChainToStringShort() {
- assertEquals("chain 'test' [s1 -> s2 -> s3]", new Chain<>(new ComponentId("test"),createSearchers(3)).toString());
+ void testSearchChainToStringShort() {
+ assertEquals("chain 'test' [s1 -> s2 -> s3]", new Chain<>(new ComponentId("test"), createSearchers(3)).toString());
}
@Test
- public void testSearchChainToStringLong() {
- assertEquals("chain 'test' [s1 -> s2 -> ... -> s4]", new Chain<>(new ComponentId("test"),createSearchers(4)).toString());
+ void testSearchChainToStringLong() {
+ assertEquals("chain 'test' [s1 -> s2 -> ... -> s4]", new Chain<>(new ComponentId("test"), createSearchers(4)).toString());
}
@Test
- public void testSearchChainToStringVeryLong() {
- assertEquals("chain 'test' [s1 -> s2 -> ... -> s10]", new Chain<>(new ComponentId("test"),createSearchers(10)).toString());
+ void testSearchChainToStringVeryLong() {
+ assertEquals("chain 'test' [s1 -> s2 -> ... -> s10]", new Chain<>(new ComponentId("test"), createSearchers(10)).toString());
}
private List<Searcher> createSearchers(int count) {
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java
index 04b1fd85872..f2c8551126b 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java
@@ -10,7 +10,7 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.yolean.trace.TraceNode;
import com.yahoo.yolean.trace.TraceVisitor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
@@ -19,8 +19,8 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Tests tracing scenarios where traces from multiple executions over the same query are involved.
@@ -30,27 +30,27 @@ import static org.junit.Assert.assertFalse;
public class TraceTestCase {
@Test
- public void testTracingOnCorrectAPIUseNonParallel() {
- assertTracing(true,false);
+ void testTracingOnCorrectAPIUseNonParallel() {
+ assertTracing(true, false);
}
@Test
- public void testTracingOnIncorrectAPIUseNonParallel() {
- assertTracing(false,false);
+ void testTracingOnIncorrectAPIUseNonParallel() {
+ assertTracing(false, false);
}
@Test
- public void testTracingOnCorrectAPIUseParallel() {
+ void testTracingOnCorrectAPIUseParallel() {
assertTracing(true, true);
}
@Test
- public void testTracingOnIncorrectAPIUseParallel() {
- assertTracing(false,true);
+ void testTracingOnIncorrectAPIUseParallel() {
+ assertTracing(false, true);
}
@Test
- public void testTraceWithQuery() {
+ void testTraceWithQuery() {
testQueryInTrace(true, "trace.query=true");
testQueryInTrace(false, "trace.query=false");
testQueryInTrace(true, "");
@@ -71,13 +71,13 @@ public class TraceTestCase {
assertEquals(" During tracer1: 0", trace.next());
}
- @Test
- public void testTraceInvocationsUnfillableHits() {
+ @Test
+ void testTraceInvocationsUnfillableHits() {
final int traceLevel = 5;
Query query = new Query("?trace.level=" + traceLevel);
- Chain<Searcher> forkingChain = new Chain<>(new Tracer("tracer1"),
- new Tracer("tracer2"),
- new Backend("backend1", false));
+ Chain<Searcher> forkingChain = new Chain<>(new Tracer("tracer1"),
+ new Tracer("tracer2"),
+ new Backend("backend1", false));
Execution execution = new Execution(forkingChain, Execution.Context.createContextStub());
Result result = execution.search(query);
execution.fill(result, "mySummary");
@@ -104,12 +104,12 @@ public class TraceTestCase {
}
@Test
- public void testTraceInvocationsFillableHits() {
+ void testTraceInvocationsFillableHits() {
final int traceLevel = 5;
Query query = new Query("?tracelevel=" + traceLevel);
Chain<Searcher> forkingChain = new Chain<>(new Tracer("tracer1"),
- new Tracer("tracer2"),
- new Backend("backend1", true));
+ new Tracer("tracer2"),
+ new Backend("backend1", true));
Execution execution = new Execution(forkingChain, Execution.Context.createContextStub());
Result result = execution.search(query);
execution.fill(result, "mySummary");
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.java
index 577963ef2b3..1cf8159e19e 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.java
@@ -14,13 +14,14 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.yql.YqlParser;
import com.yahoo.vespa.config.search.AttributesConfig;
import com.yahoo.vespa.config.search.AttributesConfig.Attribute;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author alexeyche
@@ -64,10 +65,10 @@ public class ValidateFuzzySearcherTestCase {
@Test
- public void testQueriesToAllAttributes() {
+ void testQueriesToAllAttributes() {
final Set<String> validAttributes = Set.of("string_single", "string_array", "string_weightedset");
- for (String attribute: attributes) {
+ for (String attribute : attributes) {
String q = makeQuery(attribute, "fuzzy");
Result r = doSearch(searcher, q);
if (validAttributes.contains(attribute)) {
@@ -79,28 +80,28 @@ public class ValidateFuzzySearcherTestCase {
}
@Test
- public void testInvalidEmptyStringQuery() {
+ void testInvalidEmptyStringQuery() {
String q = makeQuery("string_single", "");
Result r = doSearch(searcher, q);
assertErrMsg("FUZZY(,2,0) string_single: fuzzy query must be non-empty", r);
}
@Test
- public void testInvalidQueryWrongMaxEditDistance() {
+ void testInvalidQueryWrongMaxEditDistance() {
String q = makeQuery("string_single", "fuzzy", -1, 0);
Result r = doSearch(searcher, q);
assertErrMsg("FUZZY(fuzzy,-1,0) string_single:fuzzy has invalid maxEditDistance -1: Must be >= 0", r);
}
@Test
- public void testInvalidQueryWrongPrefixLength() {
+ void testInvalidQueryWrongPrefixLength() {
String q = makeQuery("string_single", "fuzzy", 2, -1);
Result r = doSearch(searcher, q);
assertErrMsg("FUZZY(fuzzy,2,-1) string_single:fuzzy has invalid prefixLength -1: Must be >= 0", r);
}
@Test
- public void testInvalidQueryWrongAttributeName() {
+ void testInvalidQueryWrongAttributeName() {
String q = makeQuery("wrong_name", "fuzzy");
Result r = doSearch(searcher, q);
assertErrMsg("FUZZY(fuzzy,2,0) wrong_name:fuzzy field is not a string attribute", r);
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
index c2f4ee31aa8..b8be0b3dd43 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
@@ -16,10 +16,10 @@ import com.yahoo.search.yql.YqlParser;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.vespa.config.search.AttributesConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author arnej
@@ -103,7 +103,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testValidQueryDoubleVectors() {
+ void testValidQueryDoubleVectors() {
String q = makeQuery("dvector", "qvector");
Tensor t = makeTensor(tt_dense_dvector_3);
Result r = doSearch(searcher, q, t);
@@ -111,7 +111,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testValidQueryFloatVectors() {
+ void testValidQueryFloatVectors() {
String q = makeQuery("fvector", "qvector");
Tensor t = makeTensor(tt_dense_fvector_3);
Result r = doSearch(searcher, q, t);
@@ -119,7 +119,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testValidQueryDoubleVectorAgainstFloatVector() {
+ void testValidQueryDoubleVectorAgainstFloatVector() {
String q = makeQuery("dvector", "qvector");
Tensor t = makeTensor(tt_dense_fvector_3);
Result r = doSearch(searcher, q, t);
@@ -127,7 +127,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testValidQueryFloatVectorAgainstDoubleVector() {
+ void testValidQueryFloatVectorAgainstDoubleVector() {
String q = makeQuery("fvector", "qvector");
Tensor t = makeTensor(tt_dense_dvector_3);
Result r = doSearch(searcher, q, t);
@@ -152,7 +152,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testMissingTargetNumHits() {
+ void testMissingTargetNumHits() {
String q = "select * from sources * where nearestNeighbor(dvector,qvector)";
Tensor t = makeTensor(tt_dense_dvector_3);
Result r = doSearch(searcher, q, t);
@@ -160,7 +160,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testMissingQueryTensor() {
+ void testMissingQueryTensor() {
String q = makeQuery("dvector", "foo");
Tensor t = makeTensor(tt_dense_dvector_3);
Result r = doSearch(searcher, q, t);
@@ -168,7 +168,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testWrongTensorType() {
+ void testWrongTensorType() {
String q = makeQuery("dvector", "qvector");
Tensor t = makeTensor(tt_dense_dvector_2, 2);
Result r = doSearch(searcher, q, t);
@@ -176,7 +176,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testNotAttribute() {
+ void testNotAttribute() {
String q = makeQuery("foo", "qvector");
Tensor t = makeTensor(tt_dense_dvector_3);
Result r = doSearch(searcher, q, t);
@@ -184,7 +184,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testWrongAttributeType() {
+ void testWrongAttributeType() {
String q = makeQuery("simple", "qvector");
Tensor t = makeTensor(tt_dense_dvector_3);
Result r = doSearch(searcher, q, t);
@@ -192,7 +192,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testSeveralAttributesWithSameName() {
+ void testSeveralAttributesWithSameName() {
String q = makeQuery("threetypes", "qvector");
Tensor t1 = makeTensor(tt_dense_fvector_3);
Result r1 = doSearch(searcher, q, t1);
@@ -206,7 +206,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testSparseTensor() {
+ void testSparseTensor() {
String q = makeQuery("sparse", "qvector");
Tensor t = makeTensor(tt_sparse_vector_x);
Result r = doSearch(searcher, q, t);
@@ -214,7 +214,7 @@ public class ValidateNearestNeighborTestCase {
}
@Test
- public void testMatrix() {
+ void testMatrix() {
String q = makeQuery("matrix", "qvector");
Tensor t = makeMatrix(tt_dense_matrix_xy);
Result r = doSearch(searcher, q, t);
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/CacheControlSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/CacheControlSearcherTestCase.java
index b0fd77897fc..dc99185f4b8 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/test/CacheControlSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/test/CacheControlSearcherTestCase.java
@@ -8,15 +8,12 @@ import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchers.CacheControlSearcher;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import static com.yahoo.search.searchers.CacheControlSearcher.CACHE_CONTROL_HEADER;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Unit test cases for CacheControlSearcher.
@@ -54,17 +51,17 @@ public class CacheControlSearcherTestCase {
* @param cacheheaders - The "Cache-Control" headers from the response ListMap
*/
private void assertCacheHeaders(String[] values, List<String> cacheheaders) {
- assertNotNull("No headers to test for (was null)", values);
- assertTrue("No headers to test for (no elements in array)", values.length > 0);
- assertNotNull("No cache headers set in response", cacheheaders);
+ assertNotNull(values, "No headers to test for (was null)");
+ assertTrue(values.length > 0, "No headers to test for (no elements in array)");
+ assertNotNull(cacheheaders, "No cache headers set in response");
assertEquals(values.length, cacheheaders.size());
for (String header : values) {
- assertTrue("Cache header does not contain header '" + header + "'", cacheheaders.contains(header));
+ assertTrue(cacheheaders.contains(header), "Cache header does not contain header '" + header + "'");
}
}
@Test
- public void testNoHeader() {
+ void testNoHeader() {
Chain<Searcher> chain = getSearchChain();
Query query = new Query("?query=foo&custid=foo");
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
@@ -72,7 +69,7 @@ public class CacheControlSearcherTestCase {
}
@Test
- public void testInvalidAgeParams() {
+ void testInvalidAgeParams() {
Chain<Searcher> chain = getSearchChain();
try {
@@ -97,7 +94,7 @@ public class CacheControlSearcherTestCase {
}
@Test
- public void testMaxAge() {
+ void testMaxAge() {
Chain<Searcher> chain = getSearchChain();
Query query = new Query("?query=foo&custid=foo&cachecontrol.maxage=120");
@@ -106,7 +103,7 @@ public class CacheControlSearcherTestCase {
}
@Test
- public void testNoCache() {
+ void testNoCache() {
Chain<Searcher> chain = getSearchChain();
Query query = new Query("?query=foo&custid=foo&cachecontrol.maxage=120&noCache");
@@ -119,7 +116,7 @@ public class CacheControlSearcherTestCase {
}
@Test
- public void testStateWhileRevalidate() {
+ void testStateWhileRevalidate() {
Chain<Searcher> chain = getSearchChain();
Query query = new Query("?query=foo&custid=foo&cachecontrol.staleage=3600");
@@ -128,7 +125,7 @@ public class CacheControlSearcherTestCase {
}
@Test
- public void testStaleAndMaxAge() {
+ void testStaleAndMaxAge() {
Chain<Searcher> chain = getSearchChain();
Query query = new Query("?query=foo&custid=foo&cachecontrol.maxage=60&cachecontrol.staleage=3600");
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/ConnectionControlSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/ConnectionControlSearcherTestCase.java
index 48dc0975efe..5323149ae1d 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/test/ConnectionControlSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/test/ConnectionControlSearcherTestCase.java
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.searchers.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -12,8 +12,7 @@ import java.net.SocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.component.chain.Chain;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.jdisc.Container;
@@ -35,7 +34,7 @@ import com.yahoo.search.searchers.ConnectionControlSearcher;
public class ConnectionControlSearcherTestCase {
@Test
- public final void test() throws URISyntaxException {
+ final void test() throws URISyntaxException {
URI uri = new URI("http://finance.yahoo.com/?connectioncontrol.maxlifetime=1");
long connectedAtMillis = 0L;
long nowMillis = 2L * 1000L;
@@ -44,7 +43,7 @@ public class ConnectionControlSearcherTestCase {
}
@Test
- public final void testForcedClose() throws URISyntaxException {
+ final void testForcedClose() throws URISyntaxException {
URI uri = new URI("http://finance.yahoo.com/?connectioncontrol.maxlifetime=0");
long connectedAtMillis = 0L;
long nowMillis = 0L;
@@ -53,7 +52,7 @@ public class ConnectionControlSearcherTestCase {
}
@Test
- public final void testNormalCloseWithoutJdisc() {
+ final void testNormalCloseWithoutJdisc() {
long nowMillis = 2L;
Query query = new Query("/?connectioncontrol.maxlifetime=1");
Execution e = new Execution(new Chain<Searcher>(ConnectionControlSearcher.createTestInstance(() -> nowMillis)),
@@ -63,7 +62,7 @@ public class ConnectionControlSearcherTestCase {
}
@Test
- public final void testNoMaxLifetime() throws URISyntaxException {
+ final void testNoMaxLifetime() throws URISyntaxException {
URI uri = new URI("http://finance.yahoo.com/");
long connectedAtMillis = 0L;
long nowMillis = 0L;
@@ -72,7 +71,7 @@ public class ConnectionControlSearcherTestCase {
}
@Test
- public final void testYoungEnoughConnection() throws URISyntaxException {
+ final void testYoungEnoughConnection() throws URISyntaxException {
URI uri = new URI("http://finance.yahoo.com/?connectioncontrol.maxlifetime=1");
long connectedAtMillis = 0L;
long nowMillis = 500L;
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/InputCheckingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/InputCheckingSearcherTestCase.java
index 91784c82800..2cd65f65209 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/test/InputCheckingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/test/InputCheckingSearcherTestCase.java
@@ -1,16 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.searchers.test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.yahoo.component.chain.Chain;
import com.yahoo.metrics.simple.MetricReceiver;
import com.yahoo.prelude.IndexFacts;
@@ -30,44 +29,44 @@ public class InputCheckingSearcherTestCase {
Execution execution;
- @Before
+ @BeforeEach
public void setUp() {
execution = new Execution(new Chain<Searcher>(new InputCheckingSearcher(MetricReceiver.nullImplementation)),
Execution.Context.createContextStub());
}
- @After
+ @AfterEach
public void tearDown() {
execution = null;
}
@Test
- public void testCommonCase() {
+ void testCommonCase() {
Result r = execution.search(new Query("/search/?query=three+blind+mice"));
assertNull(r.hits().getErrorHit());
}
@Test
- public void candidateButAsciiOnly() {
+ void candidateButAsciiOnly() {
Result r = execution.search(new Query("/search/?query=a+a+a+a+a+a"));
assertNull(r.hits().getErrorHit());
}
@Test
- public void candidateButValid() throws UnsupportedEncodingException {
+ void candidateButValid() throws UnsupportedEncodingException {
Result r = execution.search(new Query("/search/?query=" + URLEncoder.encode("å å å å å å", "UTF-8")));
assertNull(r.hits().getErrorHit());
}
@Test
- public void candidateButValidAndOutsideFirst256() throws UnsupportedEncodingException {
+ void candidateButValidAndOutsideFirst256() throws UnsupportedEncodingException {
Result r = execution.search(new Query("/search/?query=" + URLEncoder.encode("œ œ œ œ œ œ", "UTF-8")));
assertNull(r.hits().getErrorHit());
}
@Test
- public void testDoubleEncoded() throws UnsupportedEncodingException {
+ void testDoubleEncoded() throws UnsupportedEncodingException {
String rawQuery = "å å å å å å";
byte[] encodedOnce = Utf8.toBytes(rawQuery);
char[] secondEncodingBuffer = new char[encodedOnce.length];
@@ -80,37 +79,37 @@ public class InputCheckingSearcherTestCase {
}
@Test
- public void testRepeatedConsecutiveTermsInPhrase() {
+ void testRepeatedConsecutiveTermsInPhrase() {
Result r = execution.search(new Query("/search/?query=%22a.b.0.0.0.0.0.c%22"));
assertNull(r.hits().getErrorHit());
r = execution.search(new Query("/search/?query=%22a.b.0.0.0.0.0.0.c%22"));
assertNotNull(r.hits().getErrorHit());
assertEquals("More than 5 occurrences of term '0' in a row detected in phrase : \"a b 0 0 0 0 0 0 c\"",
- r.hits().getErrorHit().errorIterator().next().getDetailedMessage());
+ r.hits().getErrorHit().errorIterator().next().getDetailedMessage());
r = execution.search(new Query("/search/?query=a.b.0.0.0.1.0.0.0.c"));
assertNull(r.hits().getErrorHit());
}
@Test
- public void testThatMaxRepeatedConsecutiveTermsInPhraseIs5() {
+ void testThatMaxRepeatedConsecutiveTermsInPhraseIs5() {
Result r = execution.search(new Query("/search/?query=%22a.b.0.0.0.0.0.c%22"));
assertNull(r.hits().getErrorHit());
r = execution.search(new Query("/search/?query=%22a.b.0.0.0.0.0.0.c%22"));
assertNotNull(r.hits().getErrorHit());
assertEquals("More than 5 occurrences of term '0' in a row detected in phrase : \"a b 0 0 0 0 0 0 c\"",
- r.hits().getErrorHit().errorIterator().next().getDetailedMessage());
+ r.hits().getErrorHit().errorIterator().next().getDetailedMessage());
r = execution.search(new Query("/search/?query=%22a.b.0.0.0.1.0.0.0.c%22"));
assertNull(r.hits().getErrorHit());
}
@Test
- public void testThatMaxRepeatedTermsInPhraseIs10() {
+ void testThatMaxRepeatedTermsInPhraseIs10() {
Result r = execution.search(new Query("/search/?query=%220.a.1.a.2.a.3.a.4.a.5.a.6.a.7.a.9.a%22"));
assertNull(r.hits().getErrorHit());
r = execution.search(new Query("/search/?query=%220.a.1.a.2.a.3.a.4.a.5.a.6.a.7.a.8.a.9.a.10.a%22"));
assertNotNull(r.hits().getErrorHit());
assertEquals("Phrase contains more than 10 occurrences of term 'a' in phrase : \"0 a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8 a 9 a 10 a\"",
- r.hits().getErrorHit().errorIterator().next().getDetailedMessage());
+ r.hits().getErrorHit().errorIterator().next().getDetailedMessage());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java
index d5fb1c0cfe3..64fb4354003 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java
@@ -7,10 +7,10 @@ import com.yahoo.prelude.SearchDefinition;
import com.yahoo.search.Query;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchers.QueryValidator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author bratseth
@@ -18,7 +18,7 @@ import static org.junit.Assert.fail;
public class QueryValidatorTestCase {
@Test
- public void testValidation() {
+ void testValidation() {
SearchDefinition sd = new SearchDefinition("test");
sd.addCommand("mytensor1", "type tensor(x[100]");
sd.addCommand("mytensor2", "type tensor<float>(x[100]");
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java
index 4ee57112960..102f9bda5dc 100755
--- a/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java
@@ -14,15 +14,13 @@ import com.yahoo.search.config.RateLimitingConfig;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchers.RateLimitingSearcher;
import com.yahoo.yolean.chain.After;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.yahoo.test.ManualClock;
import java.time.Duration;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Unit tests for RateLimitingSearcher
@@ -32,7 +30,7 @@ import static org.junit.Assert.assertFalse;
public class RateLimitingSearcherTestCase {
@Test
- public void testRateLimiting() {
+ void testRateLimiting() {
RateLimitingConfig.Builder rateLimitingConfig = new RateLimitingConfig.Builder();
rateLimitingConfig.maxAvailableCapacity(4);
rateLimitingConfig.capacityIncrement(2);
@@ -46,36 +44,36 @@ public class RateLimitingSearcherTestCase {
MetricReceiver.MockReceiver metric = new MetricReceiver.MockReceiver();
Chain<Searcher> chain = new Chain<>("test", new RateLimitingSearcher(new RateLimitingConfig(rateLimitingConfig),
- new ClusterInfoConfig(clusterInfoConfig),
- metric, clock),
- new CostSettingSearcher());
- assertEquals("'rate' request are available initially", 2, tryRequests(chain, "id1"));
- assertTrue("However, don't reject if we dryRun", executeWasAllowed(chain, "id1", true));
+ new ClusterInfoConfig(clusterInfoConfig),
+ metric, clock),
+ new CostSettingSearcher());
+ assertEquals(2, tryRequests(chain, "id1"), "'rate' request are available initially");
+ assertTrue(executeWasAllowed(chain, "id1", true), "However, don't reject if we dryRun");
clock.advance(Duration.ofMillis(1500)); // causes 2 new requests to become available
- assertEquals("'rate' new requests became available", 2, tryRequests(chain, "id1"));
+ assertEquals(2, tryRequests(chain, "id1"), "'rate' new requests became available");
- assertEquals("Another id", 2, tryRequests(chain, "id2"));
+ assertEquals(2, tryRequests(chain, "id2"), "Another id");
clock.advance(Duration.ofMillis(1000000));
- assertEquals("'maxAvailableCapacity' request became available", 4, tryRequests(chain, "id2"));
+ assertEquals(4, tryRequests(chain, "id2"), "'maxAvailableCapacity' request became available");
- assertFalse("If quota is set to 0, all requests are rejected, even initially", executeWasAllowed(chain, "id3", 0));
+ assertFalse(executeWasAllowed(chain, "id3", 0), "If quota is set to 0, all requests are rejected, even initially");
clock.advance(Duration.ofMillis(1000000));
- assertTrue("A single query which costs more than capacity is allowed as cost is calculated after allowing it",
- executeWasAllowed(chain, "id1", 8, 8, false));
- assertFalse("capacity is -4: disallowing", executeWasAllowed(chain, "id1"));
+ assertTrue(executeWasAllowed(chain, "id1", 8, 8, false),
+ "A single query which costs more than capacity is allowed as cost is calculated after allowing it");
+ assertFalse(executeWasAllowed(chain, "id1"), "capacity is -4: disallowing");
clock.advance(Duration.ofMillis(1000));
- assertFalse("capacity is -2: disallowing", executeWasAllowed(chain, "id1"));
+ assertFalse(executeWasAllowed(chain, "id1"), "capacity is -2: disallowing");
clock.advance(Duration.ofMillis(1000));
- assertFalse("capacity is 0: disallowing", executeWasAllowed(chain, "id1"));
+ assertFalse(executeWasAllowed(chain, "id1"), "capacity is 0: disallowing");
clock.advance(Duration.ofMillis(1000));
assertTrue(executeWasAllowed(chain, "id1"));
// check metrics
- Map<Point,UntypedMetric> map = metric.getSnapshot().getMapForMetric("requestsOverQuota");
- assertEquals(requestsToTry-2 + 1 + requestsToTry-2 + 3, map.get(metric.point("id", "id1")).getCount());
- assertEquals(requestsToTry-2 + requestsToTry-4, map.get(metric.point("id", "id2")).getCount());
+ Map<Point, UntypedMetric> map = metric.getSnapshot().getMapForMetric("requestsOverQuota");
+ assertEquals(requestsToTry - 2 + 1 + requestsToTry - 2 + 3, map.get(metric.point("id", "id1")).getCount());
+ assertEquals(requestsToTry - 2 + requestsToTry - 4, map.get(metric.point("id", "id2")).getCount());
}
private int requestsToTry = 50;
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java
index 1b3689a94b0..a040575c4b4 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java
@@ -9,12 +9,12 @@ import com.yahoo.search.searchers.ValidateMatchPhaseSearcher;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.vespa.config.search.AttributesConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author baldersheim
@@ -61,7 +61,7 @@ public class ValidateMatchPhaseSearcherTestCase {
}
@Test
- public void testMatchPhaseAttribute() {
+ void testMatchPhaseAttribute() {
assertEquals("", search(""));
assertEquals("", match("ok"));
assertEquals(getErrorMatch("not_numeric"), match("not_numeric"));
@@ -71,7 +71,7 @@ public class ValidateMatchPhaseSearcherTestCase {
}
@Test
- public void testDiversityAttribute() {
+ void testDiversityAttribute() {
assertEquals("", search(""));
assertEquals("", diversify("ok"));
assertEquals("", diversify("not_numeric"));
diff --git a/container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java b/container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java
index c7983a55e8b..4d6b2e4cbe3 100644
--- a/container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/statistics/ElapsedTimeTestCase.java
@@ -10,11 +10,9 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.statistics.TimeTracker.Activity;
import com.yahoo.search.statistics.TimeTracker.SearcherTimer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Check sanity of TimeTracker and ElapsedTime.
@@ -145,9 +143,9 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testBasic() {
+ void testBasic() {
TimeTracker t = new TimeTracker(null);
- t.injectTimeSource(new CreativeTimeSource(new long[] {1L, 2L, 3L, 4L}));
+ t.injectTimeSource(new CreativeTimeSource(new long[]{1L, 2L, 3L, 4L}));
Query q = new Query();
Result r = new Result(q);
t.sampleSearch(0, false);
@@ -164,9 +162,9 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testMultiSearchAndPing() {
+ void testMultiSearchAndPing() {
TimeTracker t = new TimeTracker(null);
- t.injectTimeSource(new CreativeTimeSource(new long[] {1L, 4L, 16L, 32L, 64L, 128L, 256L}));
+ t.injectTimeSource(new CreativeTimeSource(new long[]{1L, 4L, 16L, 32L, 64L, 128L, 256L}));
Query q = new Query();
Result r = new Result(q);
t.sampleSearch(0, false);
@@ -189,7 +187,7 @@ public class ElapsedTimeTestCase {
// multiple adds is supposed to be safe
assertEquals(255L, t.totalTime());
TimeTracker tx = new TimeTracker(null);
- tx.injectTimeSource(new CreativeTimeSource(new long[] {1L, 2L, 3L, 4L}));
+ tx.injectTimeSource(new CreativeTimeSource(new long[]{1L, 2L, 3L, 4L}));
Query qx = new Query();
Result rx = new Result(qx);
tx.sampleSearch(0, false);
@@ -203,12 +201,12 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testBasicBreakdown() {
+ void testBasicBreakdown() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
new UselessSearcher("third")));
- t.injectTimeSource(new CreativeTimeSource(new long[] { 1L, 2L, 3L,
- 4L, 5L, 6L, 7L }));
+ t.injectTimeSource(new CreativeTimeSource(new long[]{1L, 2L, 3L,
+ 4L, 5L, 6L, 7L}));
t.sampleSearch(0, true);
t.sampleSearch(1, true);
t.sampleSearch(2, true);
@@ -223,7 +221,7 @@ public class ElapsedTimeTestCase {
// This test is to make sure the other tests correctly simulate the call
// order into the TimeTracker
@Test
- public void testBasicBreakdownFullyWiredIn() {
+ void testBasicBreakdownFullyWiredIn() {
Chain<? extends Searcher> chain = new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
new UselessSearcher("third"));
@@ -250,7 +248,7 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testBasicBreakdownWithFillFullyWiredIn() {
+ void testBasicBreakdownWithFillFullyWiredIn() {
Chain<? extends Searcher> chain = new Chain<>(
new UselessSearcher("first"), new UselessSearcher("second"),
new AlmostUselessSearcher("third"));
@@ -279,7 +277,7 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testBasicBreakdownFullyWiredInFirstSearcherNotFirstInChain() {
+ void testBasicBreakdownFullyWiredInFirstSearcherNotFirstInChain() {
Chain<? extends Searcher> chain = new Chain<>(
new TestingSearcher(),
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -289,7 +287,7 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testBasicBreakdownWithFillFullyWiredInFirstSearcherNotFirstInChain() {
+ void testBasicBreakdownWithFillFullyWiredInFirstSearcherNotFirstInChain() {
Chain<? extends Searcher> chain = new Chain<>(
new SecondTestingSearcher(),
new UselessSearcher("first"), new UselessSearcher("second"),
@@ -299,7 +297,7 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testTimingWithShortChain() {
+ void testTimingWithShortChain() {
Chain<? extends Searcher> chain = new Chain<>(
new ShortChainTestingSearcher(),
new NoForwardSearcher());
@@ -308,12 +306,12 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testBasicBreakdownReturnInsideSearchChain() {
+ void testBasicBreakdownReturnInsideSearchChain() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
new UselessSearcher("third")));
- t.injectTimeSource(new CreativeTimeSource(new long[] { 1L, 2L, 3L,
- 4L, 5L, 6L }));
+ t.injectTimeSource(new CreativeTimeSource(new long[]{1L, 2L, 3L,
+ 4L, 5L, 6L}));
t.sampleSearch(0, true);
t.sampleSearch(1, true);
t.sampleSearch(2, true);
@@ -325,16 +323,16 @@ public class ElapsedTimeTestCase {
assertEquals(Long.valueOf(1L), searchers[1].getInvoking(Activity.SEARCH));
assertEquals(Long.valueOf(1L), searchers[2].getInvoking(Activity.SEARCH));
assertNull(searchers[2].getReturning(Activity.SEARCH));
- assertEquals(Long.valueOf(1L) ,searchers[1].getReturning(Activity.SEARCH));
- assertEquals(Long.valueOf(1L) ,searchers[0].getReturning(Activity.SEARCH));
+ assertEquals(Long.valueOf(1L), searchers[1].getReturning(Activity.SEARCH));
+ assertEquals(Long.valueOf(1L), searchers[0].getReturning(Activity.SEARCH));
}
@Test
- public void testBasicBreakdownWithFill() {
+ void testBasicBreakdownWithFill() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
new UselessSearcher("third")));
- t.injectTimeSource(new CreativeTimeSource(new long[] { 1L, 2L, 3L,
+ t.injectTimeSource(new CreativeTimeSource(new long[]{1L, 2L, 3L,
4L, 5L, 6L, 7L, 7L, 8L, 9L, 10L}));
t.sampleSearch(0, true);
t.sampleSearch(1, true);
@@ -400,7 +398,7 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testMixedActivity() {
+ void testMixedActivity() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
new UselessSearcher("third")));
@@ -424,7 +422,7 @@ public class ElapsedTimeTestCase {
}
@Test
- public void testReportGeneration() {
+ void testReportGeneration() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(
new UselessSearcher("first"), new UselessSearcher("second"),
new UselessSearcher("third")));
diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
index 7cd7e20b76f..f8a77445a40 100644
--- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
@@ -45,8 +45,8 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.yolean.Exceptions;
import org.json.JSONObject;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@@ -59,14 +59,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -74,10 +67,10 @@ import static org.junit.Assert.fail;
public class QueryTestCase {
@Test
- public void testIt() throws Exception {
+ void testIt() throws Exception {
JSONObject newroot = new JSONObject("{\"key\": 3}");
var hit = new FastHit();
- hit.setField("data", (JsonProducer)s -> s.append(newroot));
+ hit.setField("data", (JsonProducer) s -> s.append(newroot));
var field = hit.getField("data");
if (field instanceof JsonProducer) {
System.out.println((((JsonProducer) field).toJson()));
@@ -85,7 +78,7 @@ public class QueryTestCase {
}
@Test
- public void testSimpleFunctionality() {
+ void testSimpleFunctionality() {
Query q = new Query(QueryTestCase.httpEncode("/sdfsd.html?query=this is a simple query&aParameter"));
assertEquals("this is a simple query", q.getModel().getQueryString());
assertNotNull(q.getModel().getQueryTree());
@@ -105,23 +98,23 @@ public class QueryTestCase {
}
// TODO: YQL work in progress (jon)
- @Ignore
+ @Disabled
@Test
- public void testSimpleProgram() {
+ void testSimpleProgram() {
Query q = new Query(httpEncode("?program=select * from * where myfield contains(word)"));
assertEquals("", q.getModel().getQueryTree().toString());
}
// TODO: YQL work in progress (jon)
- @Ignore
+ @Disabled
@Test
- public void testSimpleProgramParameterAlias() {
+ void testSimpleProgramParameterAlias() {
Query q = new Query(httpEncode("/sdfsd.html?yql=select * from source where myfield contains(word)"));
assertEquals("", q.getModel().getQueryTree().toString());
}
@Test
- public void testClone() {
+ void testClone() {
Query q = new Query(httpEncode("/sdfsd.html?query=this+is+a+simple+query&aParameter"));
q.getPresentation().setHighlight(new Highlight());
Query p = q.clone();
@@ -157,10 +150,10 @@ public class QueryTestCase {
}
@Test
- public void testCloneWithConnectivity() {
+ void testCloneWithConnectivity() {
List<String> l = List.of("a", "b", "c", "a");
printIt(l.stream().filter(i -> isA(i)).collect(Collectors.toList()));
- printIt(l.stream().filter(i -> ! isA(i)).collect(Collectors.toList()));
+ printIt(l.stream().filter(i -> !isA(i)).collect(Collectors.toList()));
Query q = new Query();
WordItem a = new WordItem("a");
@@ -200,18 +193,18 @@ public class QueryTestCase {
Query qClone = q.clone();
assertEquals(q, qClone);
- RankItem rankClone = (RankItem)qClone.getModel().getQueryTree().getRoot();
- AndItem and1Clone = (AndItem)rankClone.getItem(0);
- AndItem and2Clone = (AndItem)rankClone.getItem(1);
- OrItem orClone = (OrItem)and1Clone.getItem(2);
+ RankItem rankClone = (RankItem) qClone.getModel().getQueryTree().getRoot();
+ AndItem and1Clone = (AndItem) rankClone.getItem(0);
+ AndItem and2Clone = (AndItem) rankClone.getItem(1);
+ OrItem orClone = (OrItem) and1Clone.getItem(2);
- WordItem aClone = (WordItem)and1Clone.getItem(0);
- WordItem bClone = (WordItem)and1Clone.getItem(1);
- WordItem cClone = (WordItem)orClone.getItem(0);
- WordItem dClone = (WordItem)orClone.getItem(1);
- WordItem eClone = (WordItem)and1Clone.getItem(3);
- WordItem fClone = (WordItem)and2Clone.getItem(0);
- WordItem gClone = (WordItem)and2Clone.getItem(1);
+ WordItem aClone = (WordItem) and1Clone.getItem(0);
+ WordItem bClone = (WordItem) and1Clone.getItem(1);
+ WordItem cClone = (WordItem) orClone.getItem(0);
+ WordItem dClone = (WordItem) orClone.getItem(1);
+ WordItem eClone = (WordItem) and1Clone.getItem(3);
+ WordItem fClone = (WordItem) and2Clone.getItem(0);
+ WordItem gClone = (WordItem) and2Clone.getItem(1);
assertTrue(rankClone != rank);
assertTrue(and1Clone != and1);
@@ -226,12 +219,12 @@ public class QueryTestCase {
assertTrue(fClone != f);
assertTrue(gClone != g);
- assertTrue(aClone.getConnectedItem() == bClone);
- assertTrue(bClone.getConnectedItem() == cClone);
- assertTrue(cClone.getConnectedItem() == dClone);
- assertTrue(dClone.getConnectedItem() == eClone);
- assertTrue(eClone.getConnectedItem() == fClone);
- assertTrue(fClone.getConnectedItem() == gClone);
+ assertEquals(aClone.getConnectedItem(), bClone);
+ assertEquals(bClone.getConnectedItem(), cClone);
+ assertEquals(cClone.getConnectedItem(), dClone);
+ assertEquals(dClone.getConnectedItem(), eClone);
+ assertEquals(eClone.getConnectedItem(), fClone);
+ assertEquals(fClone.getConnectedItem(), gClone);
double delta = 0.0000001;
assertEquals(0.1, aClone.getConnectivity(), delta);
@@ -243,7 +236,7 @@ public class QueryTestCase {
}
@Test
- public void test_that_cloning_preserves_timeout() {
+ void test_that_cloning_preserves_timeout() {
Query original = new Query();
original.setTimeout(9876L);
@@ -252,7 +245,7 @@ public class QueryTestCase {
}
@Test
- public void testTimeout() {
+ void testTimeout() {
// yes, this test depends on numbers which have exact IEEE representations
Query q = new Query(httpEncode("/search?timeout=500"));
assertEquals(500000L, q.getTimeout());
@@ -283,20 +276,20 @@ public class QueryTestCase {
assertEquals(42000, q.getTimeout());
assertEquals(0, q.errors().size());
- q=new Query();
+ q = new Query();
q.setTimeout(53L);
assertEquals(53L, q.properties().get("timeout"));
assertEquals(53L, q.getTimeout());
// This is the unfortunate consequence of this legacy:
- q=new Query();
+ q = new Query();
q.properties().set("timeout", 53L);
assertEquals(53L * 1000, q.properties().get("timeout"));
assertEquals(53L * 1000, q.getTimeout());
}
@Test
- public void testUnparseableTimeout() {
+ void testUnparseableTimeout() {
try {
new Query(httpEncode("/search?timeout=nalle"));
fail("Above statement should throw");
@@ -307,7 +300,7 @@ public class QueryTestCase {
}
@Test
- public void testCloneTimeout() {
+ void testCloneTimeout() {
Query q = new Query(httpEncode("/search?timeout=300ms"));
assertEquals(300, q.getTimeout());
Query clonedQ = q.clone();
@@ -315,7 +308,7 @@ public class QueryTestCase {
}
@Test
- public void testQueryProfileSubstitution1() {
+ void testQueryProfileSubstitution1() {
QueryProfile profile = new QueryProfile("myProfile");
profile.set("myField", "Profile: %{queryProfile}", null);
Query q = new Query(QueryTestCase.httpEncode("/search?queryProfile=myProfile"), profile.compile(null));
@@ -323,7 +316,7 @@ public class QueryTestCase {
}
@Test
- public void testQueryProfileSourceAccess() {
+ void testQueryProfileSourceAccess() {
QueryProfile profile = new QueryProfile("myProfile");
profile.set("myField", "Profile: %{queryProfile}", null);
Query query = new Query(QueryTestCase.httpEncode("/search?queryProfile=myProfile"), profile.compile(null));
@@ -333,7 +326,7 @@ public class QueryTestCase {
}
@Test
- public void testBooleanParameter() {
+ void testBooleanParameter() {
QueryProfile profile = new QueryProfile("myProfile");
Query query = new Query("/?query=something&ranking.softtimeout.enable=false", profile.compile(null));
assertFalse(query.properties().getBoolean("ranking.softtimeout.enable"));
@@ -341,7 +334,7 @@ public class QueryTestCase {
}
@Test
- public void testQueryProfileSubstitution2() {
+ void testQueryProfileSubstitution2() {
QueryProfile profile = new QueryProfile("myProfile");
profile.set("model.language", "en-US", null);
profile.set("myField", "Language: %{lang}", null);
@@ -350,7 +343,7 @@ public class QueryTestCase {
}
@Test
- public void testQueryProfileSubstitution3() {
+ void testQueryProfileSubstitution3() {
QueryProfile profile = new QueryProfile("myProfile");
profile.set("model.locale", "en-US", null);
profile.set("myField", "Language: %{lang}, locale: %{locale}", null);
@@ -359,7 +352,7 @@ public class QueryTestCase {
}
@Test
- public void testTimeoutInRequestOverridesQueryProfile() {
+ void testTimeoutInRequestOverridesQueryProfile() {
QueryProfile profile = new QueryProfile("test");
profile.set("timeout", 318, null);
Query q = new Query(QueryTestCase.httpEncode("/search?timeout=500"), profile.compile(null));
@@ -367,7 +360,7 @@ public class QueryTestCase {
}
@Test
- public void testQueryProfileClearAndSet() {
+ void testQueryProfileClearAndSet() {
QueryProfile profile = new QueryProfile("myProfile");
profile.set("b", "b-value", null);
Query q = new Query(QueryTestCase.httpEncode("/search?queryProfile=myProfile"), profile.compile(null));
@@ -375,7 +368,7 @@ public class QueryTestCase {
assertContains(q.properties().listProperties("b"), "b-value");
q.properties().set("b", null, null);
- assertContains(q.properties().listProperties("b"), (Object)null);
+ assertContains(q.properties().listProperties("b"), (Object) null);
q.properties().set("b", "b-value", null);
assertEquals("b-value", q.properties().get("b"));
@@ -383,7 +376,7 @@ public class QueryTestCase {
}
@Test
- public void testQueryProfileClearValue() {
+ void testQueryProfileClearValue() {
QueryProfile profile = new QueryProfile("myProfile");
profile.set("a", "a-value", null);
profile.set("b", "b-value", null);
@@ -397,10 +390,10 @@ public class QueryTestCase {
assertContains(q.properties().listProperties("b"), "b-value", "b.c-value", "b.d-value");
q.properties().set("a", null, null);
- assertEquals(null, q.properties().get("a"));
+ assertNull(q.properties().get("a"));
q.properties().set("b", null, null);
- assertEquals(null, q.properties().get("b"));
+ assertNull(q.properties().get("b"));
assertEquals("b.c-value", q.properties().get("b.c"));
assertEquals("b.d-value", q.properties().get("b.d"));
assertContains(q.properties().listProperties("b"), null, "b.c-value", "b.d-value");
@@ -413,67 +406,67 @@ public class QueryTestCase {
assertContains(q.properties().listProperties("b"), "b-value", "b.c-value", "b.d-value", "b.e-value", "b.f-value");
q.properties().clearAll("b");
- assertEquals(null, q.properties().get("b"));
- assertEquals(null, q.properties().get("b.c"));
- assertEquals(null, q.properties().get("b.d"));
- assertEquals(null, q.properties().get("b.e"));
- assertEquals(null, q.properties().get("b.f"));
- assertContains(q.properties().listProperties("b"), (Object)null);
+ assertNull(q.properties().get("b"));
+ assertNull(q.properties().get("b.c"));
+ assertNull(q.properties().get("b.d"));
+ assertNull(q.properties().get("b.e"));
+ assertNull(q.properties().get("b.f"));
+ assertContains(q.properties().listProperties("b"), (Object) null);
}
@Test
- public void testNotEqual() {
+ void testNotEqual() {
Query q = new Query("/?query=something+test&nocache");
Query p = new Query("/?query=something+test");
- assertEquals(q,p);
- assertEquals(q.hashCode(),p.hashCode());
+ assertEquals(q, p);
+ assertEquals(q.hashCode(), p.hashCode());
Query r = new Query("?query=something+test&hits=5");
- assertNotSame(q,r);
- assertNotSame(q.hashCode(),r.hashCode());
+ assertNotSame(q, r);
+ assertNotSame(q.hashCode(), r.hashCode());
}
@Test
- public void testEqual() {
- assertEquals(new Query("?query=12").hashCode(),new Query("?query=12").hashCode());
- assertEquals(new Query("?query=12"),new Query("?query=12"));
+ void testEqual() {
+ assertEquals(new Query("?query=12").hashCode(), new Query("?query=12").hashCode());
+ assertEquals(new Query("?query=12"), new Query("?query=12"));
}
@Test
- public void testUtf8Decoding() {
+ void testUtf8Decoding() {
Query q = new Query("/?query=beyonc%C3%A9");
assertEquals("WEAKAND(100) beyonc\u00e9", q.getModel().getQueryTree().toString());
}
@Test
- public void testQueryProfileInSubstitution() {
+ void testQueryProfileInSubstitution() {
QueryProfile testProfile = new QueryProfile("test");
testProfile.setOverridable("u", false, DimensionValues.empty);
- testProfile.set("d","e", null);
- testProfile.set("u","11", null);
+ testProfile.set("d", "e", null);
+ testProfile.set("u", "11", null);
testProfile.set("foo.bar", "wiz", null);
Query q = new Query(QueryTestCase.httpEncode("?query=a:>5&a=b&traceLevel=5&sources=a,b&u=12&foo.bar2=wiz2&c.d=foo&queryProfile=test"),
- testProfile.compile(null));
+ testProfile.compile(null));
String trace = q.getContext(false).getTrace().toString();
String[] traceLines = trace.split("\n");
}
@Test
- public void testDefaultIndex() {
+ void testDefaultIndex() {
Query q = new Query("?query=hi%20hello%20keyword:kanoo%20" +
- "default:munkz%20%22phrases+too%22&default-index=def");
+ "default:munkz%20%22phrases+too%22&default-index=def");
assertEquals("WEAKAND(100) def:hi def:hello keyword:kanoo default:munkz def:\"phrases too\"",
- q.getModel().getQueryTree().toString());
+ q.getModel().getQueryTree().toString());
}
@Test
- public void testHashCode() {
+ void testHashCode() {
Query p = new Query("?query=foo&type=any");
Query q = new Query("?query=foo&type=all");
assertTrue(p.hashCode() != q.hashCode());
}
@Test
- public void testSimpleQueryParsing() {
+ void testSimpleQueryParsing() {
Query q = new Query("/search?query=foobar&offset=10&hits=20");
assertEquals("WEAKAND(100) foobar", q.getModel().getQueryTree().toString());
assertEquals(10, q.getOffset());
@@ -482,15 +475,15 @@ public class QueryTestCase {
/** "input.*" is an alias for "ranking.feature.*", but just "input" is not */
@Test
- public void testPrefixAlias() {
+ void testPrefixAlias() {
Query q = new Query("/search?query=foobar&input=foo",
- new QueryProfile("test").compile(null));
+ new QueryProfile("test").compile(null));
assertEquals("foo", q.properties().get("input"));
}
/** Test that GET parameter names are case in-sensitive */
@Test
- public void testGETParametersCase() {
+ void testGETParametersCase() {
Query q = new Query("?QUERY=testing&hits=10&oFfSeT=10");
assertEquals("testing", q.getModel().getQueryString());
assertEquals(10, q.getHits());
@@ -499,19 +492,19 @@ public class QueryTestCase {
/** Test that we get the last value if a parameter is assigned multiple times */
@Test
- public void testRepeatedParameter() {
+ void testRepeatedParameter() {
Query q = new Query("?query=test&hits=5&hits=10");
assertEquals(10, q.getHits());
}
@Test
- public void testNoCache() {
+ void testNoCache() {
Query q = new Query("search?query=foobar&nocache");
assertTrue(q.getNoCache());
}
@Test
- public void testSessionCache() {
+ void testSessionCache() {
Query q = new Query("search?query=foobar&groupingSessionCache");
assertTrue(q.getGroupingSessionCache());
q = new Query("search?query=foobar");
@@ -531,7 +524,7 @@ public class QueryTestCase {
}
@Test
- public void testSetting() {
+ void testSetting() {
Query q = new Query();
q.properties().set("test", "test");
assertEquals(q.properties().get("test"), "test");
@@ -544,21 +537,21 @@ public class QueryTestCase {
}
@Test
- public void testAlias() {
+ void testAlias() {
Query q = new Query("search?query=testing&language=en");
assertEquals(q.getModel().getLanguage(), q.properties().get("model.language"));
}
@Test
- public void testTracing() {
+ void testTracing() {
Query q = new Query("?query=foo&type=all&traceLevel=2");
assertEquals(2, q.getTrace().getLevel());
q.trace(true, 1, "trace1");
- q.trace(false,2, "trace2");
+ q.trace(false, 2, "trace2");
q.trace(true, 3, "Ignored");
q.trace(true, 2, "trace3-1", ", ", "trace3-2");
- q.trace(false,1, "trace4-1", ", ", "trace4-2");
- q.trace(false,3, "Ignored-1", "Ignored-2");
+ q.trace(false, 1, "trace4-1", ", ", "trace4-2");
+ q.trace(false, 3, "Ignored-1", "Ignored-2");
Set<String> traces = new HashSet<>();
for (String trace : q.getContext(true).getTrace().traceNode().descendants(String.class))
traces.add(trace);
@@ -569,10 +562,10 @@ public class QueryTestCase {
}
@Test
- public void testNullTracing() {
+ void testNullTracing() {
Query q = new Query("?query=foo&traceLevel=2");
assertEquals(2, q.getTrace().getLevel());
- q.trace(false,2, "trace2 ", null);
+ q.trace(false, 2, "trace2 ", null);
Set<String> traces = new HashSet<>();
for (String trace : q.getContext(true).getTrace().traceNode().descendants(String.class))
traces.add(trace);
@@ -580,20 +573,20 @@ public class QueryTestCase {
}
@Test
- public void testExplain() {
+ void testExplain() {
Query q = new Query("?query=foo&explainLevel=2");
assertEquals(2, q.getTrace().getExplainLevel());
assertEquals(0, q.getTrace().getLevel());
}
@Test
- public void testQueryPropertyResolveTracing() {
+ void testQueryPropertyResolveTracing() {
QueryProfile testProfile = new QueryProfile("test");
testProfile.setOverridable("u", false, DimensionValues.empty);
- testProfile.set("d","e", null);
- testProfile.set("u","11", null);
+ testProfile.set("d", "e", null);
+ testProfile.set("u", "11", null);
testProfile.set("foo.bar", "wiz", null);
- Query q = new Query(QueryTestCase.httpEncode("?query=a:>5&a=b&traceLevel=5&sources=a,b&u=12&foo.bar2=wiz2&c.d=foo&queryProfile=test"),testProfile.compile(null));
+ Query q = new Query(QueryTestCase.httpEncode("?query=a:>5&a=b&traceLevel=5&sources=a,b&u=12&foo.bar2=wiz2&c.d=foo&queryProfile=test"), testProfile.compile(null));
String trace = q.getContext(false).getTrace().toString();
String[] traceLines = trace.split("\n");
assertTrue(contains("query: a:>5 (from request)", traceLines));
@@ -605,7 +598,7 @@ public class QueryTestCase {
}
@Test
- public void testNonleafInRequestDoesNotOverrideProfile() {
+ void testNonleafInRequestDoesNotOverrideProfile() {
QueryProfile testProfile = new QueryProfile("test");
testProfile.set("a.b", "foo", null);
testProfile.freeze();
@@ -622,7 +615,7 @@ public class QueryTestCase {
}
@Test
- public void testQueryPropertyResolveTracing2() {
+ void testQueryPropertyResolveTracing2() {
QueryProfile defaultProfile = new QueryProfile("default");
defaultProfile.freeze();
Query q = new Query(QueryTestCase.httpEncode("?query=dvd&a.b=foo&tracelevel=9"), defaultProfile.compile(null));
@@ -633,7 +626,7 @@ public class QueryTestCase {
}
@Test
- public void testNativeProperties() {
+ void testNativeProperties() {
Set<String> nativeProperties = Query.nativeProperties.stream().map(CompoundName::toString).collect(Collectors.toSet());
// Sample the content
assertTrue(nativeProperties.contains("hits"));
@@ -642,16 +635,16 @@ public class QueryTestCase {
}
@Test
- public void testQueryPropertyListingAndTrace() {
+ void testQueryPropertyListingAndTrace() {
QueryProfile defaultProfile = new QueryProfile("default");
defaultProfile.setDimensions(new String[]{"x"});
- defaultProfile.set("a.b","a.b-x1-value", new String[] {"x1"}, null);
+ defaultProfile.set("a.b", "a.b-x1-value", new String[]{"x1"}, null);
defaultProfile.set("a.b", "a.b-x2-value", new String[]{"x2"}, null);
defaultProfile.freeze();
{
- Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"),defaultProfile.compile(null));
- Map<String,Object> propertyList = q.properties().listProperties();
+ Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"), defaultProfile.compile(null));
+ Map<String, Object> propertyList = q.properties().listProperties();
assertEquals("a.b-x1-value", propertyList.get("a.b"));
String trace = q.getContext(false).getTrace().toString();
String[] traceLines = trace.split("\n");
@@ -660,14 +653,14 @@ public class QueryTestCase {
{
Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"), defaultProfile.compile(null));
- Map<String,Object> propertyList = q.properties().listProperties("a");
+ Map<String, Object> propertyList = q.properties().listProperties("a");
assertEquals(1, propertyList.size());
assertEquals("a.b-x1-value", propertyList.get("b"));
}
{
- Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x2"),defaultProfile.compile(null));
- Map<String,Object> propertyList = q.properties().listProperties();
+ Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x2"), defaultProfile.compile(null));
+ Map<String, Object> propertyList = q.properties().listProperties();
assertEquals("a.b-x2-value", propertyList.get("a.b"));
String trace = q.getContext(false).getTrace().toString();
String[] traceLines = trace.split("\n");
@@ -676,45 +669,45 @@ public class QueryTestCase {
}
@Test
- public void testQueryPropertyListingThreeLevel() {
+ void testQueryPropertyListingThreeLevel() {
QueryProfile defaultProfile = new QueryProfile("default");
- defaultProfile.setDimensions(new String[] {"x"});
+ defaultProfile.setDimensions(new String[]{"x"});
defaultProfile.set("a.b.c", "a.b.c-x1-value", new String[]{"x1"}, null);
defaultProfile.set("a.b.c", "a.b.c-x2-value", new String[]{"x2"}, null);
defaultProfile.freeze();
{
- Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"),defaultProfile.compile(null));
- Map<String,Object> propertyList = q.properties().listProperties();
+ Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"), defaultProfile.compile(null));
+ Map<String, Object> propertyList = q.properties().listProperties();
assertEquals("a.b.c-x1-value", propertyList.get("a.b.c"));
}
{
- Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"),defaultProfile.compile(null));
- Map<String,Object> propertyList = q.properties().listProperties("a");
+ Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"), defaultProfile.compile(null));
+ Map<String, Object> propertyList = q.properties().listProperties("a");
assertEquals(1, propertyList.size());
assertEquals("a.b.c-x1-value", propertyList.get("b.c"));
}
{
- Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"),defaultProfile.compile(null));
- Map<String,Object> propertyList = q.properties().listProperties("a.b");
+ Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x1"), defaultProfile.compile(null));
+ Map<String, Object> propertyList = q.properties().listProperties("a.b");
assertEquals(1, propertyList.size());
assertEquals("a.b.c-x1-value", propertyList.get("c"));
}
{
- Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x2"),defaultProfile.compile(null));
- Map<String,Object> propertyList = q.properties().listProperties();
+ Query q = new Query(QueryTestCase.httpEncode("?tracelevel=9&x=x2"), defaultProfile.compile(null));
+ Map<String, Object> propertyList = q.properties().listProperties();
assertEquals("a.b.c-x2-value", propertyList.get("a.b.c"));
}
}
@Test
- public void testQueryPropertyReplacement() {
+ void testQueryPropertyReplacement() {
QueryProfile defaultProfile = new QueryProfile("default");
- defaultProfile.set("model.queryString","myquery", null);
- defaultProfile.set("queryUrl","http://provider:80?query=%{model.queryString}", null);
+ defaultProfile.set("model.queryString", "myquery", null);
+ defaultProfile.set("queryUrl", "http://provider:80?query=%{model.queryString}", null);
defaultProfile.freeze();
Query q1 = new Query(QueryTestCase.httpEncode(""), defaultProfile.compile(null));
@@ -725,17 +718,17 @@ public class QueryTestCase {
assertEquals("foo", q2.getModel().getQueryString());
assertEquals("http://provider:80?query=foo", q2.properties().get("queryUrl"));
- Query q3 = new Query(QueryTestCase.httpEncode("?query=foo"),defaultProfile.compile(null));
- assertEquals("foo",q3.getModel().getQueryString());
- assertEquals("http://provider:80?query=foo",q3.properties().get("queryUrl"));
+ Query q3 = new Query(QueryTestCase.httpEncode("?query=foo"), defaultProfile.compile(null));
+ assertEquals("foo", q3.getModel().getQueryString());
+ assertEquals("http://provider:80?query=foo", q3.properties().get("queryUrl"));
- Query q4 = new Query(QueryTestCase.httpEncode("?query=foo"),defaultProfile.compile(null));
+ Query q4 = new Query(QueryTestCase.httpEncode("?query=foo"), defaultProfile.compile(null));
q4.getModel().setQueryString("bar");
- assertEquals("http://provider:80?query=bar",q4.properties().get("queryUrl"));
+ assertEquals("http://provider:80?query=bar", q4.properties().get("queryUrl"));
}
@Test
- public void testNoQueryString() {
+ void testNoQueryString() {
Query q = new Query(httpEncode("?tracelevel=1"));
Chain<Searcher> chain = new Chain<>(new RandomSearcher());
new Execution(chain, Execution.Context.createContextStub()).search(q);
@@ -743,7 +736,7 @@ public class QueryTestCase {
}
@Test
- public void testSetCollapseField() {
+ void testSetCollapseField() {
Query q = new Query(httpEncode("?collapsefield=foo&presentation.format=tiled"));
assertEquals("foo", q.properties().get("collapsefield"));
assertEquals("tiled", q.properties().get("presentation.format"));
@@ -751,44 +744,44 @@ public class QueryTestCase {
}
@Test
- public void testSetNullProperty() {
+ void testSetNullProperty() {
QueryProfile profile = new QueryProfile("test");
- profile.set("property","initialValue", null);
+ profile.set("property", "initialValue", null);
Query query = new Query(httpEncode("?query=test"), profile.compile(null));
- assertEquals("initialValue",query.properties().get("property"));
+ assertEquals("initialValue", query.properties().get("property"));
query.properties().set("property", null);
assertNull(query.properties().get("property"));
}
@Test
- public void testSetNullPropertyNoQueryProfile() {
+ void testSetNullPropertyNoQueryProfile() {
Query query = new Query();
query.properties().set("a", null);
assertNull(query.properties().get("a"));
}
@Test
- public void testMissingParameter() {
+ void testMissingParameter() {
Query q = new Query("?query=foo&hits=");
assertEquals(0, q.errors().size());
}
@Test
- public void testModelProperties() {
+ void testModelProperties() {
{
Query query = new Query();
query.properties().set("model.searchPath", "foo");
- assertEquals("Set dynamic get dynamic works","foo", query.properties().get("model.searchPath"));
- assertEquals("Set dynamic get static works","foo", query.getModel().getSearchPath());
+ assertEquals("foo", query.properties().get("model.searchPath"), "Set dynamic get dynamic works");
+ assertEquals("foo", query.getModel().getSearchPath(), "Set dynamic get static works");
Map<String, Object> properties = query.properties().listProperties();
- assertEquals("Listing built-in properties works", "foo", properties.get("model.searchPath"));
+ assertEquals("foo", properties.get("model.searchPath"), "Listing built-in properties works");
}
{
Query query = new Query();
query.getModel().setSearchPath("foo");
- assertEquals("Set static get dynamic works","foo", query.properties().get("model.searchPath"));
- assertEquals("Set static get static works","foo", query.getModel().getSearchPath());
+ assertEquals("foo", query.properties().get("model.searchPath"), "Set static get dynamic works");
+ assertEquals("foo", query.getModel().getSearchPath(), "Set static get static works");
}
{
@@ -801,7 +794,7 @@ public class QueryTestCase {
}
@Test
- public void testThatSessionIdIsUniquePerQuery() {
+ void testThatSessionIdIsUniquePerQuery() {
Query q = new Query();
assertNull(q.getSessionId());
assertNull(q.getSessionId());
@@ -816,8 +809,9 @@ public class QueryTestCase {
assertNotEquals(q.getSessionId(), q2.getSessionId("node-0"));
assertNotEquals(q.getSessionId().toString(), q2.getSessionId("node-0").toString());
}
+
@Test
- public void testThatCloneGetANewSessionId() {
+ void testThatCloneGetANewSessionId() {
Query q = new Query();
q.getSessionId("node-0");
Query clonedQ = q.clone();
@@ -826,7 +820,7 @@ public class QueryTestCase {
}
@Test
- public void testThatSessionIdIsUniquePerRankProfilePerQuery() {
+ void testThatSessionIdIsUniquePerRankProfilePerQuery() {
Query q = new Query();
SessionId s1 = q.getSessionId("node-0");
q.getRanking().setProfile("my-profile");
@@ -835,7 +829,7 @@ public class QueryTestCase {
}
@Test
- public void testThatSessionIdIsNotSharedIfCreatedAfterClone() {
+ void testThatSessionIdIsNotSharedIfCreatedAfterClone() {
Query q = new Query();
Query q2 = q.clone();
assertNull(q.getSessionId());
@@ -849,7 +843,7 @@ public class QueryTestCase {
}
@Test
- public void testPositiveTerms() {
+ void testPositiveTerms() {
Query q = new Query(httpEncode("/?query=-a \"b c\" d e"));
Item i = q.getModel().getQueryTree().getRoot();
List<IndexedItem> l = QueryTree.getPositiveTerms(i);
@@ -857,18 +851,18 @@ public class QueryTestCase {
}
@Test
- public void testHeuristicLanguageDetectionTextExtraction() {
+ void testHeuristicLanguageDetectionTextExtraction() {
assertDetectionText("b ", "a:b", "text:a", "text:default");
assertDetectionText("b ", "b", "text:default");
- assertDetectionText("b ", "b","text:b", "text:default");
- assertDetectionText("a b ", "a:b","text:b", "text:default");
- assertDetectionText("foo bar fuz ", "foo a:bar --() fuz","text:a", "text:default");
- assertDetectionText(" 彭 博士 觀 風向 彭 博士 觀 風向 彭 博士 觀 風向 ","headline:\"彭 博士 觀 風向\" content:\"彭 博士 觀 風向\" description:\"彭 博士 觀 風向\" sddocname:contentindexing!0 embargo:<1484665288753!0 expires:>1484665288753!0",
- "text:headline", "text:content", "text:description", "text:default", "nontext:tags", "nontext:sddocname", "nontext:embargo", "nontext:expires");
+ assertDetectionText("b ", "b", "text:b", "text:default");
+ assertDetectionText("a b ", "a:b", "text:b", "text:default");
+ assertDetectionText("foo bar fuz ", "foo a:bar --() fuz", "text:a", "text:default");
+ assertDetectionText(" 彭 博士 觀 風向 彭 博士 觀 風向 彭 博士 觀 風向 ", "headline:\"彭 博士 觀 風向\" content:\"彭 博士 觀 風向\" description:\"彭 博士 觀 風向\" sddocname:contentindexing!0 embargo:<1484665288753!0 expires:>1484665288753!0",
+ "text:headline", "text:content", "text:description", "text:default", "nontext:tags", "nontext:sddocname", "nontext:embargo", "nontext:expires");
}
@Test
- public void testCompositeChildVerification() {
+ void testCompositeChildVerification() {
CompositeItem root = new AndItem();
try {
root.addItem(null);
@@ -908,7 +902,7 @@ public class QueryTestCase {
}
@Test
- public void queryLanguageAlternatives() {
+ void queryLanguageAlternatives() {
// Given:
// Person = {
// Name: 'Joe',
@@ -967,13 +961,13 @@ public class QueryTestCase {
}
@Test
- public void testImplicitPhraseIsDefault() {
+ void testImplicitPhraseIsDefault() {
Query query = new Query(httpEncode("?query=it's fine"));
assertEquals("WEAKAND(100) (SAND it s) fine", query.getModel().getQueryTree().toString());
}
@Test
- public void testImplicitPhrase() {
+ void testImplicitPhrase() {
Query query = new Query(httpEncode("?query=myfield:it's myfield:a.b myfield:c&type=all"));
SearchDefinition test = new SearchDefinition("test");
@@ -988,7 +982,7 @@ public class QueryTestCase {
}
@Test
- public void testImplicitAnd() {
+ void testImplicitAnd() {
Query query = new Query(httpEncode("?query=myfield:it's myfield:a.b myfield:c"));
SearchDefinition test = new SearchDefinition("test");
@@ -1001,18 +995,18 @@ public class QueryTestCase {
assertEquals("WEAKAND(100) (SAND myfield:it myfield:s) (AND myfield:a myfield:b) myfield:c", query.getModel().getQueryTree().toString());
// 'it' and 's' should have connectivity 1
- WeakAndItem root = (WeakAndItem)query.getModel().getQueryTree().getRoot();
- AndSegmentItem sand = (AndSegmentItem)root.getItem(0);
- WordItem it = (WordItem)sand.getItem(0);
+ WeakAndItem root = (WeakAndItem) query.getModel().getQueryTree().getRoot();
+ AndSegmentItem sand = (AndSegmentItem) root.getItem(0);
+ WordItem it = (WordItem) sand.getItem(0);
assertEquals("it", it.getWord());
- WordItem s = (WordItem)sand.getItem(1);
+ WordItem s = (WordItem) sand.getItem(1);
assertEquals("s", s.getWord());
assertEquals(s, it.getConnectedItem());
assertEquals(1.0, it.getConnectivity(), 0.00000001);
}
@Test
- public void testImplicitAndConnectivity() {
+ void testImplicitAndConnectivity() {
SearchDefinition test = new SearchDefinition("test");
Index myField = new Index("myfield");
myField.addCommand("phrase-segmenting false");
@@ -1024,7 +1018,7 @@ public class QueryTestCase {
query.getModel().setExecution(new Execution(Execution.Context.createContextStub(new IndexFacts(indexModel))));
assertEquals("WEAKAND(100) (AND myfield:b myfield:c myfield:d)", query.getModel().getQueryTree().toString());
WeakAndItem root = (WeakAndItem) query.getModel().getQueryTree().getRoot();
- AndItem and = (AndItem)root.getItem(0);
+ AndItem and = (AndItem) root.getItem(0);
WordItem b = (WordItem) and.getItem(0);
WordItem c = (WordItem) and.getItem(1);
WordItem d = (WordItem) and.getItem(2);
@@ -1040,7 +1034,7 @@ public class QueryTestCase {
assertEquals("WEAKAND(100) myfield:a (AND myfield:b myfield:c myfield:d) myfield:e", query.getModel().getQueryTree().toString());
WeakAndItem root = (WeakAndItem) query.getModel().getQueryTree().getRoot();
WordItem a = (WordItem) root.getItem(0);
- AndItem and = (AndItem)root.getItem(1);
+ AndItem and = (AndItem) root.getItem(1);
WordItem b = (WordItem) and.getItem(0);
WordItem c = (WordItem) and.getItem(1);
WordItem d = (WordItem) and.getItem(2);
@@ -1056,7 +1050,7 @@ public class QueryTestCase {
}
@Test
- public void testImplicitAndInPhrase() {
+ void testImplicitAndInPhrase() {
Query query = new Query(httpEncode("?query=myfield:\"it's fine\""));
SearchDefinition test = new SearchDefinition("test");
@@ -1071,7 +1065,7 @@ public class QueryTestCase {
}
@Test
- public void testOldStyleSelect() {
+ void testOldStyleSelect() {
// The same as testOldStyleSelectAndNativeQueryProfileType but not inheriting native
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType type = new QueryProfileType("mytype");
@@ -1081,15 +1075,15 @@ public class QueryTestCase {
registry.getTypeRegistry().register(type);
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(httpEncode("?query=sddocname:sentence&select=all(group(context_id) max(10) each(each(output(summary()))))"),
- cRegistry.findQueryProfile("default"));
+ cRegistry.findQueryProfile("default"));
GroupingQueryParser parser = new GroupingQueryParser();
parser.search(query, new Execution(parser, Execution.Context.createContextStub()));
assertEquals("[all(group(context_id) max(10) each(each(output(summary())))), all(group(context_id) max(10) each(each(output(summary()))))]",
- query.getSelect().getGrouping().toString());
+ query.getSelect().getGrouping().toString());
}
@Test
- public void testOldStyleSelectAndNativeQueryProfileType() {
+ void testOldStyleSelectAndNativeQueryProfileType() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType type = new QueryProfileType("mytype");
type.inherited().add(registry.getType("native"));
@@ -1099,11 +1093,11 @@ public class QueryTestCase {
registry.getTypeRegistry().register(type);
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(httpEncode("?query=sddocname:sentence&select=all(group(context_id) max(10) each(each(output(summary()))))"),
- cRegistry.findQueryProfile("default"));
+ cRegistry.findQueryProfile("default"));
GroupingQueryParser parser = new GroupingQueryParser();
parser.search(query, new Execution(parser, Execution.Context.createContextStub()));
assertEquals("[all(group(context_id) max(10) each(each(output(summary())))), all(group(context_id) max(10) each(each(output(summary()))))]",
- query.getSelect().getGrouping().toString());
+ query.getSelect().getGrouping().toString());
}
/**
@@ -1111,7 +1105,7 @@ public class QueryTestCase {
* This is special because presentation.format is a native query profile.
*/
@Test
- public void testSettingNativeQueryProfileValueInQueryProfile() {
+ void testSettingNativeQueryProfileValueInQueryProfile() {
{
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("default");
@@ -1140,7 +1134,7 @@ public class QueryTestCase {
type.inherited().add(registry.getType("native"));
registry.getTypeRegistry().register(type);
type.addField(new FieldDescription("ranking.features.query(embedding)", "tensor(x[5])"),
- registry.getTypeRegistry());
+ registry.getTypeRegistry());
QueryProfile profile = new QueryProfile("default");
profile.setType(type);
registry.register(profile);
@@ -1169,13 +1163,12 @@ public class QueryTestCase {
private void assertContains(Map<String, Object> properties, Object ... expectedValues) {
if (expectedValues == null) {
assertEquals(1, properties.size());
- assertTrue("Contains value null", properties.containsValue(null));
+ assertTrue(properties.containsValue(null), "Contains value null");
}
else {
- assertEquals(properties + " contains values " + Arrays.toString(expectedValues),
- expectedValues.length, properties.size());
+ assertEquals(expectedValues.length, properties.size(), properties + " contains values " + Arrays.toString(expectedValues));
for (Object expectedValue : expectedValues)
- assertTrue("Contains value " + expectedValue, properties.containsValue(expectedValue));
+ assertTrue(properties.containsValue(expectedValue), "Contains value " + expectedValue);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/test/RequestParameterPreservationTestCase.java b/container-search/src/test/java/com/yahoo/search/test/RequestParameterPreservationTestCase.java
index cc47ec813df..a1f3a3a5a1c 100644
--- a/container-search/src/test/java/com/yahoo/search/test/RequestParameterPreservationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/test/RequestParameterPreservationTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.search.test;
import com.yahoo.search.Query;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -12,14 +12,14 @@ import static org.junit.Assert.assertEquals;
public class RequestParameterPreservationTestCase {
@Test
- public void testPreservation() {
- Query query=new Query("?query=test...&offset=15&hits=10");
- query.setWindow(25,13);
- assertEquals(25,query.getOffset());
- assertEquals(13,query.getHits());
+ void testPreservation() {
+ Query query = new Query("?query=test...&offset=15&hits=10");
+ query.setWindow(25, 13);
+ assertEquals(25, query.getOffset());
+ assertEquals(13, query.getHits());
assertEquals("15", query.getHttpRequest().getProperty("offset"));
assertEquals("10", query.getHttpRequest().getProperty("hits"));
- assertEquals("test...",query.getHttpRequest().getProperty("query"));
+ assertEquals("test...", query.getHttpRequest().getProperty("query"));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java
index 8a6a48afd9f..3d4f52472a8 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java
@@ -1,13 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.yql;
-import static org.junit.Assert.*;
-
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.yahoo.component.chain.Chain;
import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.search.Query;
@@ -31,7 +29,7 @@ public class FieldFilterTestCase {
private Execution.Context context;
private Execution execution;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Query query = new Query("?query=test");
@@ -58,7 +56,7 @@ public class FieldFilterTestCase {
return h;
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
searchChain = null;
context = null;
@@ -66,7 +64,7 @@ public class FieldFilterTestCase {
}
@Test
- public final void testBasic() {
+ final void testBasic() {
final Query query = new Query("?query=test&presentation.summaryFields=" + FIELD_B);
Result result = execution.search(query);
execution.fill(result);
@@ -77,7 +75,7 @@ public class FieldFilterTestCase {
}
@Test
- public final void testNoFiltering() {
+ final void testNoFiltering() {
final Query query = new Query("?query=test");
Result result = execution.search(query);
execution.fill(result);
diff --git a/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
index 1ef9fe5832f..1e6e29bb700 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
@@ -18,19 +18,17 @@ import com.yahoo.search.query.Sorting.UcaSorter;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.searchchain.Execution;
import org.apache.http.client.utils.URIBuilder;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Smoke test for first generation YQL+ integration.
@@ -41,14 +39,14 @@ public class MinimalQueryInserterTestCase {
private Execution.Context context;
private Execution execution;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
searchChain = new Chain<>(new MinimalQueryInserter());
context = Execution.Context.createContextStub();
execution = new Execution(searchChain, context);
}
- @After
+ @AfterEach
public void tearDown() {
searchChain = null;
context = null;
@@ -56,7 +54,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void requireThatGroupingStepsAreAttachedToQuery() {
+ void requireThatGroupingStepsAreAttachedToQuery() {
URIBuilder builder = new URIBuilder();
builder.setPath("search/");
@@ -70,24 +68,24 @@ public class MinimalQueryInserterTestCase {
assertEquals("foo", query.getPresentation().getSummaryFields().toArray(new String[1])[0]);
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count())))");
+ "| all(group(a) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
assertGrouping("[[]all(group(a) each(output(count())))]", query);
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count()))) " +
- "| all(group(b) each(output(count())))");
+ "| all(group(a) each(output(count()))) " +
+ "| all(group(b) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
assertGrouping("[[]all(group(a) each(output(count())))," +
- " []all(group(b) each(output(count())))]", query);
+ " []all(group(b) each(output(count())))]", query);
}
@Test
- public void requireThatGroupingContinuationsAreAttachedToQuery() {
+ void requireThatGroupingContinuationsAreAttachedToQuery() {
URIBuilder builder = new URIBuilder();
builder.setPath("search/");
@@ -98,36 +96,36 @@ public class MinimalQueryInserterTestCase {
assertGrouping("[]", query);
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
- "all(group(a) each(output(count())))");
+ "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
+ "all(group(a) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
assertGrouping("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))]", query);
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
- "all(group(a) each(output(count()))) " +
- "| { continuations:['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }" +
- "all(group(b) each(output(count())))");
+ "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
+ "all(group(a) each(output(count()))) " +
+ "| { continuations:['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }" +
+ "all(group(b) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
assertGrouping("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))," +
- " [BCBBBBBDBF, BCBJBPCBJCCJ]all(group(b) each(output(count())))]", query);
+ " [BCBBBBBDBF, BCBJBPCBJCCJ]all(group(b) each(output(count())))]", query);
}
- @Test
- @Ignore
// TODO: YQL work in progress (jon)
- public void testTmp() {
+ @Test
+ @Disabled
+ void testTmp() {
Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
//execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
}
@Test
- public void testSearch() {
+ void testSearch() {
Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna (WEAKAND(100) easilyRecognizedString)", query.getModel().getQueryTree().toString());
@@ -135,25 +133,25 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testExplicitLanguageIsHonoredWithVerbatimQuery() {
+ void testExplicitLanguageIsHonoredWithVerbatimQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
Query query = new Query("search/?language=ja" + "&yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
- assertEquals("title:"+ japaneseWord, query.getModel().getQueryTree().toString());
+ assertEquals("title:" + japaneseWord, query.getModel().getQueryTree().toString());
}
@Test
- public void testUserLanguageIsDetectedWithVerbatimQuery() {
+ void testUserLanguageIsDetectedWithVerbatimQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
Query query = new Query("search/?yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
- assertEquals("title:"+ japaneseWord, query.getModel().getQueryTree().toString());
+ assertEquals("title:" + japaneseWord, query.getModel().getQueryTree().toString());
}
@Test
- public void testUserLanguageIsDetectedWithUserInput() {
+ void testUserLanguageIsDetectedWithUserInput() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
Query query = new Query("search/?userString=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userInput(@userString)");
execution.search(query);
@@ -162,7 +160,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testUserLanguageIsDetectedWithUserQuery() {
+ void testUserLanguageIsDetectedWithUserQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
Query query = new Query("search/?query=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
@@ -171,14 +169,14 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testUserQueryFailsWithoutArgument() {
+ void testUserQueryFailsWithoutArgument() {
Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna (WEAKAND(100) easilyRecognizedString)", query.getModel().getQueryTree().toString());
}
@Test
- public void testSearchFromAllSourcesWithUserSource() {
+ void testSearchFromAllSourcesWithUserSource() {
Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna (WEAKAND(100) easilyRecognizedString)", query.getModel().getQueryTree().toString());
@@ -186,7 +184,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testSearchFromAllSourcesWithoutUserSource() {
+ void testSearchFromAllSourcesWithoutUserSource() {
Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna (WEAKAND(100) easilyRecognizedString)", query.getModel().getQueryTree().toString());
@@ -194,7 +192,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testSearchFromSomeSourcesWithoutUserSource() {
+ void testSearchFromSomeSourcesWithoutUserSource() {
Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna (WEAKAND(100) easilyRecognizedString)", query.getModel().getQueryTree().toString());
@@ -204,7 +202,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testSearchFromSomeSourcesWithUserSource() {
+ void testSearchFromSomeSourcesWithUserSource() {
Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna (WEAKAND(100) easilyRecognizedString)", query.getModel().getQueryTree().toString());
@@ -215,7 +213,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public final void testSearchFromSomeSourcesWithOverlappingUserSource() {
+ final void testSearchFromSomeSourcesWithOverlappingUserSource() {
final Query query = new Query("search/?query=easilyRecognizedString&sources=abc,sourceA&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna (WEAKAND(100) easilyRecognizedString)", query.getModel().getQueryTree().toString());
@@ -226,17 +224,17 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testLimitAndOffset() {
+ void testLimitAndOffset() {
Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2031offset%207");
execution.search(query);
assertEquals(7, query.getOffset());
assertEquals(24, query.getHits());
assertEquals("select * from sources * where title contains \"madonna\" limit 31 offset 7",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
@Test
- public void testMaxOffset() {
+ void testMaxOffset() {
Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040031offset%2040000");
Result r = execution.search(query);
assertEquals(1, r.hits().getErrorHit().errors().size());
@@ -246,7 +244,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testMaxLimit() {
+ void testMaxLimit() {
Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040000offset%207");
Result r = execution.search(query);
assertEquals(1, r.hits().getErrorHit().errors().size());
@@ -256,7 +254,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testTimeout() {
+ void testTimeout() {
Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20timeout%2051");
execution.search(query);
assertEquals(51L, query.getTimeout());
@@ -264,12 +262,12 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testTimeoutWithGrouping() {
+ void testTimeoutWithGrouping() {
var select = "select x, y, z from sources * "
+ "where (x > 0 AND y contains \"foo\" AND z contains \"bar\") "
+ "order by x limit 20 offset 10 timeout 30 "
+ "| all(group(y) max(3) each(output(count())))";
- Query query = new Query("search/?yql="+ URLEncoder.encode(select, Charsets.UTF_8));
+ Query query = new Query("search/?yql=" + URLEncoder.encode(select, Charsets.UTF_8));
execution.search(query);
assertEquals(10, query.getHits());
@@ -281,7 +279,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testOrdering() {
+ void testOrdering() {
{
String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
@@ -335,28 +333,28 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void testStringRepresentation() {
+ void testStringRepresentation() {
String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
assertEquals("select ignoredfield from ignoredsource where title contains \"madonna\" order by something, shoesize desc limit 300 timeout 3",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
@Test
- public void testAndSegmenting() {
+ void testAndSegmenting() {
Query query = new Query("?yql=select%20%2A%20from%20sources%20%2A%20where%20%5B%7B%22defaultIndex%22%3A%20%22default%22%2C%22grammar%22%3A%20%22web%22%2C%22stem%22%3A%20true%2C%22allowEmpty%22%3A%20true%7D%5DuserInput%28%40animal%29%3B&animal=m%26m%27s&tracelevel=3");
execution.search(query);
assertEquals("select * from sources * where (default contains \"m\" AND default contains ({origin: {original: \"m\\'s\", offset: 0, length: 3}, andSegmenting: true}phrase(\"m\", \"s\")))",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
@Test
- public void globalMaxGroupsIsCarriedOver() {
+ void globalMaxGroupsIsCarriedOver() {
URIBuilder builder = new URIBuilder();
builder.setPath("search/");
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count())))");
+ "| all(group(a) each(output(count())))");
Query query = new Query(builder.toString());
query.properties().set("grouping.globalMaxGroups", -1);
execution.search(query);
@@ -365,12 +363,12 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void globalMaxGroupsCannotBeSetInRequest() {
+ void globalMaxGroupsCannotBeSetInRequest() {
try {
URIBuilder builder = new URIBuilder();
builder.setPath("search/");
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count())))");
+ "| all(group(a) each(output(count())))");
builder.setParameter("grouping.globalMaxGroups", "-1");
Query query = new Query(builder.toString());
execution.search(query);
@@ -382,7 +380,7 @@ public class MinimalQueryInserterTestCase {
}
@Test
- public void verifyThatWarmupIsSane() {
+ void verifyThatWarmupIsSane() {
assertTrue(MinimalQueryInserter.warmup());
}
diff --git a/container-search/src/test/java/com/yahoo/search/yql/ParameterListParserTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/ParameterListParserTestCase.java
index 44f784e96f3..8037ea097ab 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/ParameterListParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/ParameterListParserTestCase.java
@@ -2,11 +2,11 @@
package com.yahoo.search.yql;
import com.yahoo.prelude.query.WeightedSetItem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertEquals;
public class ParameterListParserTestCase {
@Test
- public void testMapParsing() {
+ void testMapParsing() {
assertParsed("{}", Map.of());
assertParsed("{a:12}", Map.of("a", 12));
assertParsed("{'a':12}", Map.of("a", 12));
@@ -27,7 +27,7 @@ public class ParameterListParserTestCase {
}
@Test
- public void testArrayParsing() {
+ void testArrayParsing() {
assertParsed("[]", Map.of());
assertParsed("[[0,12]]", Map.of(0L, 12));
assertParsed("[[0,12],[1,13]]", Map.of(0L, 12, 1L, 13));
@@ -39,9 +39,9 @@ public class ParameterListParserTestCase {
WeightedSetItem item = new WeightedSetItem("test");
ParameterListParser.addItemsFromString(string, item);
for (var entry : expected.entrySet()) {
- assertEquals("Key '" + entry.getKey() + "'", entry.getValue(), item.getTokenWeight(entry.getKey()));
+ assertEquals(entry.getValue(), item.getTokenWeight(entry.getKey()), "Key '" + entry.getKey() + "'");
}
- assertEquals("Token count is correct", expected.size(), item.getNumTokens());
+ assertEquals(expected.size(), item.getNumTokens(), "Token count is correct");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/yql/TermListTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/TermListTestCase.java
index 30254aa5738..3f04f36f64e 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/TermListTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/TermListTestCase.java
@@ -6,12 +6,12 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.searchchain.Execution;
import org.apache.http.client.utils.URIBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Tests YQL expressions where a list of terms are supplied by indirection
@@ -21,33 +21,33 @@ import static org.junit.Assert.assertNull;
public class TermListTestCase {
@Test
- public void testTermListInWeightedSet() {
+ void testTermListInWeightedSet() {
URIBuilder builder = searchUri();
builder.setParameter("myTerms", "{'1':1, '2':1, 3:1}");
builder.setParameter("yql", "select * from sources * where weightedSet(user_id, @myTerms)");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where weightedSet(user_id, {\"1\": 1, \"2\": 1, \"3\": 1})",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
@Test
- public void testTermListInWand() {
+ void testTermListInWand() {
URIBuilder builder = searchUri();
builder.setParameter("myTerms", "{'1':1, 2:1, '3':1}");
builder.setParameter("yql", "select * from sources * where wand(user_id, @myTerms)");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where wand(user_id, {\"1\": 1, \"2\": 1, \"3\": 1})",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
@Test
- public void testTermListInDotProduct() {
+ void testTermListInDotProduct() {
URIBuilder builder = searchUri();
builder.setParameter("myTerms", "{'1':1, '2':1, '3':1}");
builder.setParameter("yql", "select * from sources * where dotProduct(user_id, @myTerms)");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where dotProduct(user_id, {\"1\": 1, \"2\": 1, \"3\": 1})",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
private Query searchAndAssertNoErrors(URIBuilder builder) {
@@ -57,9 +57,9 @@ public class TermListTestCase {
var execution = new Execution(searchChain, context);
Result r = execution.search(query);
var exception = exceptionOf(r);
- assertNull(exception == null ? "No error":
- exception.getMessage() + "\n" + Arrays.toString(exception.getStackTrace()),
- r.hits().getError());
+ assertNull(r.hits().getError(),
+ exception == null ? "No error":
+ exception.getMessage() + "\n" + Arrays.toString(exception.getStackTrace()));
return query;
}
diff --git a/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
index 4af29822a26..8fe451dd095 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
@@ -1,14 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.yql;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.yahoo.search.query.QueryTree;
import org.apache.http.client.utils.URIBuilder;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.yahoo.component.chain.Chain;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
@@ -30,14 +29,14 @@ public class UserInputTestCase {
private Execution.Context context;
private Execution execution;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
searchChain = new Chain<>(new MinimalQueryInserter());
context = Execution.Context.createContextStub();
execution = new Execution(searchChain, context);
}
- @After
+ @AfterEach
public void tearDown() {
searchChain = null;
context = null;
@@ -45,7 +44,7 @@ public class UserInputTestCase {
}
@Test
- public void testSimpleUserInput() {
+ void testSimpleUserInput() {
{
URIBuilder builder = searchUri();
builder.setParameter("yql", "select * from sources * where userInput(\"nalle\")");
@@ -70,7 +69,7 @@ public class UserInputTestCase {
}
@Test
- public void testRawUserInput() {
+ void testRawUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql", "select * from sources * where {grammar: \"raw\"}userInput(\"nal le\")");
Query query = searchAndAssertNoErrors(builder);
@@ -78,7 +77,7 @@ public class UserInputTestCase {
}
@Test
- public void testSegmentedUserInput() {
+ void testSegmentedUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where {grammar: \"segment\"}userInput(\"nal le\")");
@@ -87,7 +86,7 @@ public class UserInputTestCase {
}
@Test
- public void testSegmentedNoiseUserInput() {
+ void testSegmentedNoiseUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where {grammar: \"segment\"}userInput(\"^^^^^^^^\")");
@@ -96,45 +95,45 @@ public class UserInputTestCase {
}
@Test
- public void testAnyParsedUserInput() {
+ void testAnyParsedUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql", "select * from sources * where {grammar: \"any\"}userInput('foo bar')");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where (default contains \"foo\" OR default contains \"bar\")",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
@Test
- public void testAllParsedUserInput() {
+ void testAllParsedUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql", "select * from sources * where {grammar: \"all\"}userInput('foo bar')");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where (default contains \"foo\" AND default contains \"bar\")",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
@Test
- public void testWeakAndParsedUserInput() {
+ void testWeakAndParsedUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql", "select * from sources * where {grammar: \"weakAnd\"}userInput('foo bar')");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where weakAnd(default contains \"foo\", default contains \"bar\")",
- query.yqlRepresentation());
+ query.yqlRepresentation());
}
@Test
- public void testIllegalGrammar() {
+ void testIllegalGrammar() {
URIBuilder builder = searchUri();
builder.setParameter("yql", "select * from sources * where {grammar: \"nonesuch\"}userInput('foo bar')");
Query query = new Query(builder.toString());
Result r = execution.search(query);
assertNotNull(r.hits().getError());
assertEquals("Could not create query from YQL: No query type 'nonesuch'",
- r.hits().getError().getDetailedMessage());
+ r.hits().getError().getDetailedMessage());
}
@Test
- public void testCustomDefaultIndexUserInput() {
+ void testCustomDefaultIndexUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where {defaultIndex: \"glompf\"}userInput(\"nalle\")");
@@ -143,7 +142,7 @@ public class UserInputTestCase {
}
@Test
- public void testAnnotatedUserInputStemming() {
+ void testAnnotatedUserInputStemming() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where {stem: false}userInput(\"nalle\")");
@@ -154,18 +153,18 @@ public class UserInputTestCase {
}
@Test
- public void testNegativeNumberComparison() {
+ void testNegativeNumberComparison() {
URIBuilder builder = searchUri();
builder.setParameter("myinput", "-5");
builder.setParameter("yql",
- "select * from ecitem where rank(({defaultIndex:\"myfield\"}(userInput(@myinput))))");
+ "select * from ecitem where rank(({defaultIndex:\"myfield\"}(userInput(@myinput))))");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from ecitem where rank(weakAnd(myfield = (-5)))", query.yqlRepresentation());
assertEquals("RANK (WEAKAND(100) myfield:-5)", query.getModel().getQueryTree().getRoot().toString());
}
@Test
- public void testAnnotatedUserInputUnrankedTerms() {
+ void testAnnotatedUserInputUnrankedTerms() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where {ranked: false}userInput(\"nalle\")");
@@ -176,7 +175,7 @@ public class UserInputTestCase {
}
@Test
- public void testAnnotatedUserInputFiltersTerms() {
+ void testAnnotatedUserInputFiltersTerms() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where {filter: true}userInput(\"nalle\")");
@@ -187,7 +186,7 @@ public class UserInputTestCase {
}
@Test
- public void testAnnotatedUserInputCaseNormalization() {
+ void testAnnotatedUserInputCaseNormalization() {
URIBuilder builder = searchUri();
builder.setParameter(
"yql",
@@ -199,7 +198,7 @@ public class UserInputTestCase {
}
@Test
- public void testAnnotatedUserInputAccentRemoval() {
+ void testAnnotatedUserInputAccentRemoval() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where {accentDrop: false}userInput(\"nalle\")");
@@ -210,7 +209,7 @@ public class UserInputTestCase {
}
@Test
- public void testAnnotatedUserInputPositionData() {
+ void testAnnotatedUserInputPositionData() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where {usePositionData: false}userInput(\"nalle\")");
@@ -221,7 +220,7 @@ public class UserInputTestCase {
}
@Test
- public void testQueryPropertiesAsStringArguments() {
+ void testQueryPropertiesAsStringArguments() {
URIBuilder builder = searchUri();
builder.setParameter("nalle", "bamse");
builder.setParameter("meta", "syntactic");
@@ -232,7 +231,7 @@ public class UserInputTestCase {
}
@Test
- public void testReferenceInComparison() {
+ void testReferenceInComparison() {
URIBuilder builder = searchUri();
builder.setParameter("varref", "1980");
builder.setParameter("yql", "select * from sources * where year > @varref");
@@ -241,22 +240,22 @@ public class UserInputTestCase {
}
@Test
- public void testReferenceInContinuation() {
+ void testReferenceInContinuation() {
URIBuilder builder = searchUri();
builder.setParameter("continuation", "BCBCBCBEBG");
builder.setParameter("yql",
- "select * from sources * where myfield contains 'token'" +
- "| {'continuations':[@continuation, 'BCBKCBACBKCCK'] }all(group(f) each(output(count())))");
+ "select * from sources * where myfield contains 'token'" +
+ "| {'continuations':[@continuation, 'BCBKCBACBKCCK'] }all(group(f) each(output(count())))");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where myfield contains \"token\" | { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }all(group(f) each(output(count())))", query.yqlRepresentation());
}
@Test
- public void testReferenceInEquiv() {
+ void testReferenceInEquiv() {
URIBuilder builder = searchUri();
builder.setParameter("term", "A");
builder.setParameter("yql",
- "select foo from bar where fieldName contains equiv(@term,'B')");
+ "select foo from bar where fieldName contains equiv(@term,'B')");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select foo from bar where fieldName contains equiv(\"A\", \"B\")", query.yqlRepresentation());
}
@@ -264,7 +263,7 @@ public class UserInputTestCase {
private Query searchAndAssertNoErrors(URIBuilder builder) {
Query query = new Query(builder.toString());
Result r = execution.search(query);
- assertNull(stackTraceIfAny(r), r.hits().getError());
+ assertNull(r.hits().getError(), stackTraceIfAny(r));
return query;
}
@@ -281,14 +280,14 @@ public class UserInputTestCase {
}
@Test
- public void testEmptyUserInput() {
+ void testEmptyUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql", "select * from sources * where userInput(\"\")");
assertQueryFails(builder);
}
@Test
- public void testEmptyUserInputFromQueryProperty() {
+ void testEmptyUserInputFromQueryProperty() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
builder.setParameter("yql", "select * from sources * where userInput(@foo)");
@@ -296,7 +295,7 @@ public class UserInputTestCase {
}
@Test
- public void testEmptyQueryProperty() {
+ void testEmptyQueryProperty() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains @foo)");
@@ -304,7 +303,7 @@ public class UserInputTestCase {
}
@Test
- public void testEmptyQueryPropertyInsideExpression() {
+ void testEmptyQueryPropertyInsideExpression() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
builder.setParameter("yql",
@@ -313,7 +312,7 @@ public class UserInputTestCase {
}
@Test
- public void testCompositeWithoutArguments() {
+ void testCompositeWithoutArguments() {
URIBuilder builder = searchUri();
builder.setParameter("yql", "select * from sources * where bar contains \"a\" and foo contains phrase()");
searchAndAssertNoErrors(builder);
@@ -323,7 +322,7 @@ public class UserInputTestCase {
}
@Test
- public void testAnnoyingPlacementOfNonEmpty() {
+ void testAnnoyingPlacementOfNonEmpty() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
"select * from sources * where bar contains \"a\" and foo contains nonEmpty(phrase(\"a\", \"b\"))");
@@ -336,7 +335,7 @@ public class UserInputTestCase {
}
@Test
- public void testAllowEmptyUserInput() {
+ void testAllowEmptyUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
builder.setParameter("yql", "select * from sources * where [{allowEmpty: true}]userInput(@foo)");
@@ -344,7 +343,7 @@ public class UserInputTestCase {
}
@Test
- public void testAllowEmptyNullFromQueryParsing() {
+ void testAllowEmptyNullFromQueryParsing() {
URIBuilder builder = searchUri();
builder.setParameter("foo", ",,,,,,,,");
builder.setParameter("yql", "select * from sources * where [{allowEmpty: true}]userInput(@foo)");
@@ -352,7 +351,7 @@ public class UserInputTestCase {
}
@Test
- public void testDisallowEmptyNullFromQueryParsing() {
+ void testDisallowEmptyNullFromQueryParsing() {
URIBuilder builder = searchUri();
builder.setParameter("foo", ",,,,,,,,");
builder.setParameter("yql", "select * from sources * where userInput(@foo)");
@@ -360,7 +359,7 @@ public class UserInputTestCase {
}
@Test
- public void testUserInputWithEmptyRangeStart() {
+ void testUserInputWithEmptyRangeStart() {
URIBuilder builder = searchUri();
builder.setParameter("wql", "[;boom]");
builder.setParameter("yql", "select * from sources * where ([{\"defaultIndex\": \"text_field\",\"grammar\": \"any\"}]userInput(@wql))");
diff --git a/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
index 553c3a3e583..9e5cde76c82 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
@@ -1,8 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.yql;
-import static org.junit.Assert.*;
-
import com.yahoo.prelude.query.SameElementItem;
import com.yahoo.search.Query;
import com.yahoo.search.grouping.Continuation;
@@ -12,10 +10,9 @@ import com.yahoo.search.grouping.request.AttributeFunction;
import com.yahoo.search.grouping.request.CountAggregator;
import com.yahoo.search.grouping.request.EachOperation;
import com.yahoo.search.grouping.request.GroupingOperation;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.AndSegmentItem;
import com.yahoo.prelude.query.Item;
import com.yahoo.prelude.query.MarkerWordItem;
@@ -28,73 +25,75 @@ import com.yahoo.search.query.parser.ParserEnvironment;
import java.util.Arrays;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class VespaSerializerTestCase {
private static final String SELECT = "select ignoredfield from sourceA where ";
private YqlParser parser;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
ParserEnvironment env = new ParserEnvironment();
parser = new YqlParser(env);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
parser = null;
}
@Test
- public void requireThatGroupingRequestsAreSerialized() {
+ void requireThatGroupingRequestsAreSerialized() {
Query query = new Query();
query.getModel().getQueryTree().setRoot(new WordItem("foo"));
assertEquals("default contains ({implicitTransforms: false}\"foo\")",
- VespaSerializer.serialize(query));
+ VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("a"))
- .addChild(new EachOperation().addOutput(new CountAggregator())));
+ .addChild(new EachOperation().addOutput(new CountAggregator())));
assertEquals("default contains ({implicitTransforms: false}\"foo\") " +
- "| all(group(attribute(a)) each(output(count())))",
- VespaSerializer.serialize(query));
+ "| all(group(attribute(a)) each(output(count())))",
+ VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("b"))
- .addChild(new EachOperation().addOutput(new CountAggregator())));
+ .addChild(new EachOperation().addOutput(new CountAggregator())));
assertEquals("default contains ({implicitTransforms: false}\"foo\") " +
- "| all(group(attribute(a)) each(output(count()))) " +
- "| all(group(attribute(b)) each(output(count())))",
- VespaSerializer.serialize(query));
+ "| all(group(attribute(a)) each(output(count()))) " +
+ "| all(group(attribute(b)) each(output(count())))",
+ VespaSerializer.serialize(query));
}
@Test
- public void requireThatGroupingContinuationsAreSerialized() {
+ void requireThatGroupingContinuationsAreSerialized() {
Query query = new Query();
query.getModel().getQueryTree().setRoot(new WordItem("foo"));
assertEquals("default contains ({implicitTransforms: false}\"foo\")",
- VespaSerializer.serialize(query));
+ VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("a"))
- .addChild(new EachOperation().addOutput(new CountAggregator())),
- Continuation.fromString("BCBCBCBEBG"),
- Continuation.fromString("BCBKCBACBKCCK"));
+ .addChild(new EachOperation().addOutput(new CountAggregator())),
+ Continuation.fromString("BCBCBCBEBG"),
+ Continuation.fromString("BCBKCBACBKCCK"));
assertEquals("default contains ({implicitTransforms: false}\"foo\") " +
- "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
- "all(group(attribute(a)) each(output(count())))",
- VespaSerializer.serialize(query));
+ "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
+ "all(group(attribute(a)) each(output(count())))",
+ VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("b"))
- .addChild(new EachOperation().addOutput(new CountAggregator())),
- Continuation.fromString("BCBBBBBDBF"),
- Continuation.fromString("BCBJBPCBJCCJ"));
+ .addChild(new EachOperation().addOutput(new CountAggregator())),
+ Continuation.fromString("BCBBBBBDBF"),
+ Continuation.fromString("BCBJBPCBJCCJ"));
assertEquals("default contains ({implicitTransforms: false}\"foo\") " +
- "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
- "all(group(attribute(a)) each(output(count()))) " +
- "| { continuations:['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }" +
- "all(group(attribute(b)) each(output(count())))",
- VespaSerializer.serialize(query));
+ "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
+ "all(group(attribute(a)) each(output(count()))) " +
+ "| { continuations:['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }" +
+ "all(group(attribute(b)) each(output(count())))",
+ VespaSerializer.serialize(query));
}
@Test
- public void testAnd() {
+ void testAnd() {
parseAndConfirm("(description contains \"a\" AND title contains \"that\")");
}
@@ -109,17 +108,17 @@ public class VespaSerializerTestCase {
}
@Test
- public void testAndNot() {
+ void testAndNot() {
parseAndConfirm("(description contains \"a\") AND !(title contains \"that\")");
}
@Test
- public void testEquiv() {
+ void testEquiv() {
parseAndConfirm("title contains equiv(\"a\", \"b\")");
}
@Test
- public void testGeoLocation() {
+ void testGeoLocation() {
parseAndConfirm("geoLocation(workplace, 63.418417, 10.433033, \"0.5 deg\")");
parseAndConfirm("geoLocation(headquarters, 37.41638, -122.024683, \"180.0 deg\")");
parseAndConfirm("geoLocation(home, -17.0, 42.0, \"0.0 deg\")");
@@ -127,13 +126,13 @@ public class VespaSerializerTestCase {
}
@Test
- public void testNear() {
+ void testNear() {
parseAndConfirm("title contains near(\"a\", \"b\")");
parseAndConfirm("title contains ({distance: 50}near(\"a\", \"b\"))");
}
@Test
- public void testNearestNeighbor() {
+ void testNearestNeighbor() {
parseAndConfirm("{label: \"foo\", targetNumHits: 1000}nearestNeighbor(semantic_embedding, my_property)");
parseAndConfirm("{targetNumHits: 42}nearestNeighbor(semantic_embedding, my_property)");
parseAndConfirm("{targetNumHits: 1, hnsw.exploreAdditionalHits: 76}nearestNeighbor(semantic_embedding, my_property)");
@@ -143,26 +142,26 @@ public class VespaSerializerTestCase {
}
@Test
- public void testTrueAndFalse() {
+ void testTrueAndFalse() {
parseAndConfirm("true");
parseAndConfirm("false");
}
@Test
- public void testNumbers() {
+ void testNumbers() {
parseAndConfirm("title = 500");
parseAndConfirm("title > 500");
parseAndConfirm("title < 500");
}
@Test
- public void testBoolean() {
+ void testBoolean() {
parseAndConfirm("flag = true");
parseAndConfirm("flag = false");
}
@Test
- public void testAnnotatedNumbers() {
+ void testAnnotatedNumbers() {
parseAndConfirm("title = ({filter: true}500)");
parseAndConfirm("title > ({filter: true}500)");
parseAndConfirm("title < ({filter: true}(-500))");
@@ -171,32 +170,32 @@ public class VespaSerializerTestCase {
}
@Test
- public void testRange() {
+ void testRange() {
parseAndConfirm("range(title, 1, 500)");
}
@Test
- public void testAnnotatedRange() {
+ void testAnnotatedRange() {
parseAndConfirm("{filter: true}range(title, 1, 500)");
}
@Test
- public void testOrderedNear() {
+ void testOrderedNear() {
parseAndConfirm("title contains onear(\"a\", \"b\")");
}
@Test
- public void testOr() {
+ void testOr() {
parseAndConfirm("(description contains \"a\" OR title contains \"that\")");
}
@Test
- public void testDotProduct() {
+ void testDotProduct() {
parseAndConfirm("dotProduct(description, {\"a\": 1, \"b\": 2})");
}
@Test
- public void testPredicate() {
+ void testPredicate() {
parseAndConfirm("predicate(boolean,{\"gender\":\"male\"},{\"age\":25L})");
parseAndConfirm("predicate(boolean,{\"gender\":\"male\",\"hobby\":\"music\",\"hobby\":\"hiking\"}," +
"{\"age\":25L})",
@@ -204,37 +203,37 @@ public class VespaSerializerTestCase {
parseAndConfirm("predicate(boolean,{\"0x3\":{\"gender\":\"male\"},\"0x1\":{\"hobby\":\"music\"},\"0x1\":{\"hobby\":\"hiking\"}},{\"0x80ffffffffffffff\":{\"age\":23L}})",
"predicate(boolean,{\"0x3\":{\"gender\":\"male\"},\"0x1\":{\"hobby\":[\"music\",\"hiking\"]}},{\"0x80ffffffffffffff\":{\"age\":23L}})");
parseAndConfirm("predicate(boolean,0,0)");
- parseAndConfirm("predicate(boolean,0,0)","predicate(boolean,null,void)");
- parseAndConfirm("predicate(boolean,0,0)","predicate(boolean,{},{})");
+ parseAndConfirm("predicate(boolean,0,0)", "predicate(boolean,null,void)");
+ parseAndConfirm("predicate(boolean,0,0)", "predicate(boolean,{},{})");
}
@Test
- public void testPhrase() {
+ void testPhrase() {
parseAndConfirm("description contains phrase(\"a\", \"b\")");
}
@Test
- public void testAnnotatedPhrase() {
+ void testAnnotatedPhrase() {
parseAndConfirm("description contains ({id: 1}phrase(\"a\", \"b\"))");
}
@Test
- public void testAnnotatedNear() {
+ void testAnnotatedNear() {
parseAndConfirm("description contains ({distance: 37}near(\"a\", \"b\"))");
}
@Test
- public void testAnnotatedOnear() {
+ void testAnnotatedOnear() {
parseAndConfirm("description contains ({distance: 37}onear(\"a\", \"b\"))");
}
@Test
- public void testAnnotatedEquiv() {
+ void testAnnotatedEquiv() {
parseAndConfirm("description contains ({id: 1}equiv(\"a\", \"b\"))");
}
@Test
- public void testAnnotatedPhraseSegment() {
+ void testAnnotatedPhraseSegment() {
PhraseSegmentItem phraseSegment = new PhraseSegmentItem("abc", true, false);
phraseSegment.addItem(new WordItem("a", "indexNamePlaceholder"));
phraseSegment.addItem(new WordItem("b", "indexNamePlaceholder"));
@@ -246,7 +245,7 @@ public class VespaSerializerTestCase {
}
@Test
- public void testSameElement() {
+ void testSameElement() {
SameElementItem sameElement = new SameElementItem("ss");
sameElement.addItem(new WordItem("a", "f1"));
sameElement.addItem(new WordItem("b", "f2"));
@@ -254,8 +253,9 @@ public class VespaSerializerTestCase {
assertEquals("ss contains sameElement(f1 contains ({implicitTransforms: false}\"a\"), f2 contains ({implicitTransforms: false}\"b\"))", VespaSerializer.serialize(sameElement));
}
+
@Test
- public void testAnnotatedAndSegment() {
+ void testAnnotatedAndSegment() {
AndSegmentItem andSegment = new AndSegmentItem("abc", true, false);
andSegment.addItem(new WordItem("a", "indexNamePlaceholder"));
andSegment.addItem(new WordItem("b", "indexNamePlaceholder"));
@@ -270,42 +270,42 @@ public class VespaSerializerTestCase {
}
@Test
- public void testPhraseWithAnnotations() {
+ void testPhraseWithAnnotations() {
parseAndConfirm("description contains phrase(({id: 15}\"a\"), \"b\")");
}
@Test
- public void testPhraseSegmentInPhrase() {
+ void testPhraseSegmentInPhrase() {
parseAndConfirm("description contains phrase(\"a\", \"b\", ({origin: {original: \"c d\", offset: 0, length: 3}}phrase(\"c\", \"d\")))");
}
@Test
- public void testRank() {
+ void testRank() {
parseAndConfirm("rank(a contains \"A\", b contains \"B\")");
}
@Test
- public void testWand() {
+ void testWand() {
parseAndConfirm("wand(description, {\"a\": 1, \"b\": 2})");
}
@Test
- public void testWeakAnd() {
+ void testWeakAnd() {
parseAndConfirm("weakAnd(a contains \"A\", b contains \"B\")");
}
@Test
- public void testAnnotatedWeakAnd() {
+ void testAnnotatedWeakAnd() {
parseAndConfirm("({" + YqlParser.TARGET_NUM_HITS + ": 10}weakAnd(a contains \"A\", b contains \"B\"))");
}
@Test
- public void testWeightedSet() {
+ void testWeightedSet() {
parseAndConfirm("weightedSet(description, {\"a\": 1, \"b\": 2})");
}
@Test
- public void testAnnotatedWord() {
+ void testAnnotatedWord() {
parseAndConfirm("description contains ({andSegmenting: true}\"a\")");
parseAndConfirm("description contains ({weight: 37}\"a\")");
parseAndConfirm("description contains ({id: 37}\"a\")");
@@ -317,29 +317,29 @@ public class VespaSerializerTestCase {
}
@Test
- public void testPrefix() {
+ void testPrefix() {
parseAndConfirm("description contains ({prefix: true}\"a\")");
}
@Test
- public void testSuffix() {
+ void testSuffix() {
parseAndConfirm("description contains ({suffix: true}\"a\")");
}
@Test
- public void testSubstring() {
+ void testSubstring() {
parseAndConfirm("description contains ({substring: true}\"a\")");
}
@Test
- public void testExoticItemTypes() {
+ void testExoticItemTypes() {
Item item = MarkerWordItem.createEndOfHost();
String q = VespaSerializer.serialize(item);
assertEquals("default contains ({implicitTransforms: false}\"$\")", q);
}
@Test
- public void testEmptyIndex() {
+ void testEmptyIndex() {
Item item = new WordItem("nalle", true);
String q = VespaSerializer.serialize(item);
assertEquals("default contains \"nalle\"", q);
@@ -347,7 +347,7 @@ public class VespaSerializerTestCase {
@Test
- public void testLongAndNot() {
+ void testLongAndNot() {
NotItem item = new NotItem();
item.addItem(new WordItem("a"));
item.addItem(new WordItem("b"));
@@ -358,7 +358,7 @@ public class VespaSerializerTestCase {
}
@Test
- public void testPhraseAsOperatorArgument() {
+ void testPhraseAsOperatorArgument() {
// flattening phrases is a feature, not a bug
parseAndConfirm("description contains phrase(\"a\", \"b\", \"c\")",
"description contains phrase(\"a\", phrase(\"b\", \"c\"))");
@@ -372,7 +372,7 @@ public class VespaSerializerTestCase {
}
@Test
- public void testNumberTypeInt() {
+ void testNumberTypeInt() {
parseAndConfirm("title = 500");
parseAndConfirm("title > 500");
parseAndConfirm("title < (-500)");
@@ -382,7 +382,7 @@ public class VespaSerializerTestCase {
}
@Test
- public void testNumberTypeLong() {
+ void testNumberTypeLong() {
parseAndConfirm("title = 549755813888L");
parseAndConfirm("title > 549755813888L");
parseAndConfirm("title < (-549755813888L)");
@@ -392,7 +392,7 @@ public class VespaSerializerTestCase {
}
@Test
- public void testNumberTypeFloat() {
+ void testNumberTypeFloat() {
parseAndConfirm("title = 500.0"); // silly
parseAndConfirm("title > 500.0");
parseAndConfirm("title < (-500.0)");
@@ -402,19 +402,19 @@ public class VespaSerializerTestCase {
}
@Test
- public void testAnnotatedLong() {
+ void testAnnotatedLong() {
parseAndConfirm("title >= ({id: 2014}(-549755813888L))");
}
@Test
- public void testHitLimit() {
+ void testHitLimit() {
parseAndConfirm("title <= ({hitLimit: 89}(-500))");
parseAndConfirm("title <= ({hitLimit: 89}(-500))");
parseAndConfirm("{hitLimit: 89}range(title, 1, 500)");
}
@Test
- public void testOpenIntervals() {
+ void testOpenIntervals() {
parseAndConfirm("range(title, 0.0, 500.0)");
parseAndConfirm("({bounds: \"open\"}range(title, 0.0, 500.0))");
parseAndConfirm("({bounds: \"leftOpen\"}range(title, 0.0, 500.0))");
@@ -423,18 +423,18 @@ public class VespaSerializerTestCase {
}
@Test
- public void testRegExp() {
+ void testRegExp() {
parseAndConfirm("foo matches \"a b\"");
}
@Test
- public void testWordAlternatives() {
+ void testWordAlternatives() {
parseAndConfirm("foo contains" + " ({origin: {original: \" trees \", offset: 1, length: 5}}"
+ "alternatives({\"trees\": 1.0, \"tree\": 0.7}))");
}
@Test
- public void testWordAlternativesInPhrase() {
+ void testWordAlternativesInPhrase() {
parseAndConfirm("foo contains phrase(\"forest\","
+ " ({origin: {original: \" trees \", offset: 1, length: 5}}"
+ "alternatives({\"trees\": 1.0, \"tree\": 0.7}))"
@@ -442,12 +442,12 @@ public class VespaSerializerTestCase {
}
@Test
- public void testFuzzy() {
+ void testFuzzy() {
parseAndConfirm("foo contains fuzzy(\"a\")");
}
@Test
- public void testFuzzyAnnotations() {
+ void testFuzzyAnnotations() {
parseAndConfirm("foo contains ({maxEditDistance:3,prefixLength:5}fuzzy(\"a\"))");
}
diff --git a/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java
index ee933a86578..cf3c7911d0e 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java
@@ -1,9 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.yql;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.Arrays;
import java.util.List;
@@ -12,10 +10,9 @@ import java.util.Map;
import com.yahoo.search.schema.DocumentSummary;
import com.yahoo.search.schema.Schema;
import com.yahoo.search.schema.SchemaInfo;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.yahoo.component.chain.Chain;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
@@ -41,7 +38,7 @@ public class YqlFieldAndSourceTestCase {
private Execution.Context context;
private Execution execution;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Query query = new Query("?query=test");
@@ -80,7 +77,7 @@ public class YqlFieldAndSourceTestCase {
return new SchemaInfo(List.of(schema.build()), Map.of());
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
searchChain = null;
context = null;
@@ -88,7 +85,7 @@ public class YqlFieldAndSourceTestCase {
}
@Test
- public final void testTrivial() {
+ final void testTrivial() {
final Query query = new Query("?query=test&presentation.summaryFields=" + FIELD1);
Result result = execution.search(query);
execution.fill(result);
@@ -98,7 +95,7 @@ public class YqlFieldAndSourceTestCase {
}
@Test
- public final void testWithOnlyAttribute() {
+ final void testWithOnlyAttribute() {
final Query query = new Query("?query=test&presentation.summaryFields=" + FIELD2);
Result result = execution.search(query);
execution.fill(result, THIRD_OPTION);
@@ -109,7 +106,7 @@ public class YqlFieldAndSourceTestCase {
}
@Test
- public final void testWithOnlyDiskfieldCorrectClassRequested() {
+ final void testWithOnlyDiskfieldCorrectClassRequested() {
final Query query = new Query("?query=test&presentation.summaryFields=" + FIELD3);
Result result = execution.search(query);
execution.fill(result, THIRD_OPTION);
@@ -120,7 +117,7 @@ public class YqlFieldAndSourceTestCase {
}
@Test
- public final void testTrivialCaseWithOnlyDiskfieldWrongClassRequested() {
+ final void testTrivialCaseWithOnlyDiskfieldWrongClassRequested() {
final Query query = new Query("?query=test&presentation.summaryFields=" + FIELD1);
Result result = execution.search(query);
execution.fill(result, THIRD_OPTION);
diff --git a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
index 299a7ff9d30..935b1aa62f9 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
@@ -44,19 +44,15 @@ import com.yahoo.search.query.Sorting.UcaSorter;
import com.yahoo.search.query.parser.Parsable;
import com.yahoo.search.query.parser.ParserEnvironment;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Specification for the conversion of YQL+ expressions to Vespa search queries.
@@ -68,286 +64,288 @@ public class YqlParserTestCase {
private final YqlParser parser = new YqlParser(new ParserEnvironment());
- @Test(timeout = 120_000)
- public void failsGracefullyOnMissingQuoteEscapingAndSubsequentUnicodeCharacter() {
+ @Test
+ @Timeout(120_000)
+ void failsGracefullyOnMissingQuoteEscapingAndSubsequentUnicodeCharacter() {
assertParseFail("select * from bar where rank(ids contains 'http://en.wikipedia.org/wiki/Hors_d'œuvre') limit 10",
new IllegalInputException("com.yahoo.search.yql.ProgramCompileException: query:L1:79 token recognition error at: 'œ'"));
}
@Test
- public void testParserDefaults() {
+ void testParserDefaults() {
assertTrue(parser.isQueryParser());
assertNull(parser.getDocTypes());
}
-
+
@Test
- public void testLanguageDetection() {
+ void testLanguageDetection() {
// SimpleDetector used here can detect japanese and will set that as language at the root of the user input
QueryTree tree = parse("select * from sources * where userInput(\"\u30ab\u30bf\u30ab\u30ca\")");
assertEquals(Language.JAPANESE, tree.getRoot().getLanguage());
}
@Test
- public void testGroupingStep() {
+ void testGroupingStep() {
assertParse("select foo from bar where baz contains 'cox'",
- "baz:cox");
+ "baz:cox");
assertEquals("[]",
- toString(parser.getGroupingSteps()));
+ toString(parser.getGroupingSteps()));
assertParse("select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count())))",
- "baz:cox");
+ "| all(group(a) each(output(count())))",
+ "baz:cox");
assertEquals("[[]all(group(a) each(output(count())))]",
- toString(parser.getGroupingSteps()));
+ toString(parser.getGroupingSteps()));
assertParse("select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count()))) " +
- "| all(group(b) each(output(count())))",
- "baz:cox");
+ "| all(group(a) each(output(count()))) " +
+ "| all(group(b) each(output(count())))",
+ "baz:cox");
assertEquals("[[]all(group(a) each(output(count())))," +
- " []all(group(b) each(output(count())))]",
- toString(parser.getGroupingSteps()));
+ " []all(group(b) each(output(count())))]",
+ toString(parser.getGroupingSteps()));
}
@Test
- public void testGroupingContinuation() {
+ void testGroupingContinuation() {
assertParse("select foo from bar where baz contains 'cox' " +
- "| { 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }all(group(a) each(output(count())))",
- "baz:cox");
+ "| { 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }all(group(a) each(output(count())))",
+ "baz:cox");
assertEquals("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))]",
- toString(parser.getGroupingSteps()));
+ toString(parser.getGroupingSteps()));
assertParse("select foo from bar where baz contains 'cox' " +
- "| { 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }all(group(a) each(output(count()))) " +
- "| { 'continuations': ['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }all(group(b) each(output(count())))",
- "baz:cox");
+ "| { 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }all(group(a) each(output(count()))) " +
+ "| { 'continuations': ['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }all(group(b) each(output(count())))",
+ "baz:cox");
assertEquals("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))," +
- " [BCBBBBBDBF, BCBJBPCBJCCJ]all(group(b) each(output(count())))]",
- toString(parser.getGroupingSteps()));
+ " [BCBBBBBDBF, BCBJBPCBJCCJ]all(group(b) each(output(count())))]",
+ toString(parser.getGroupingSteps()));
}
@Test
- public void testHitLimit() {
+ void testHitLimit() {
assertParse("select artist_name, track_name, track_uri from sources * where (myField contains ({prefix:true}\"m\") and ({hitLimit: 5000, descending: true}range(static_score,0,Infinity))) limit 30 offset 0",
- "AND myField:m* static_score:[0;;-5000]");
+ "AND myField:m* static_score:[0;;-5000]");
}
@Test
- public void test() {
+ void test() {
assertParse("select foo from bar where title contains \"madonna\"",
- "title:madonna");
+ "title:madonna");
}
@Test
- public void testKeywordAsFieldName() {
+ void testKeywordAsFieldName() {
assertParse("select * from sources * where cast contains sameElement(id contains '16')",
- "cast:{id:16}");
+ "cast:{id:16}");
}
@Test
- public void testComplexExpression() {
+ void testComplexExpression() {
String queryTreeYql = "rank((((filter contains ({origin: {original: \"filter:VideoAdsCappingTestCPM\", \"offset\": 7, length: 22}, normalizeCase: false, id: 1}\"videoadscappingtestcpm\") AND hasRankRestriction contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 2}\"0\") AND ((objective contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 3}\"install_app\") AND availableExtendedFields contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 4}\"cpiparams\")) OR (availableExtendedFields contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 5}\"appinstallinfo\") AND availableExtendedFields contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 6}\"appmetroplexinfo\")) OR (dummyField contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 7}\"default\")) AND !(objective contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 8}\"install_app\"))) AND advt_age = ({\"id\": 9}2147483647) AND advt_gender contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 10}\"all\") AND advt_all_segments = ({\"id\": 11}2147483647) AND advt_keywords contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 12}\"all\") AND advMobilePlatform = ({\"id\": 13}2147483647) AND advMobileDeviceType = ({\"id\": 14}2147483647) AND advMobileCon = ({\"id\": 15}2147483647) AND advMobileOSVersions = ({\"id\": 16}2147483647) AND advCarrier = ({\"id\": 17}2147483647) AND ({\"id\": 18}weightedSet(advt_supply, {\"all\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) AND (advt_day_parting contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 19, \"weight\": 1}\"adv_tuesday\") OR advt_day_parting contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 20, \"weight\": 1}\"adv_tuesday_17\") OR advt_day_parting contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 21, \"weight\": 1}\"adv_tuesday_17_forty_five\") OR advt_day_parting contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 22}\"all\")) AND isAppReengagementAd = ({\"id\": 23}0) AND dummyField contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 24}\"default\") AND serveWithPromotionOnly = ({\"id\": 26}0) AND budgetAdvertiserThrottleRateFilter = ({\"id\": 27}0) AND budgetResellerThrottleRateFilter = ({\"id\": 28}0) AND (isMystiqueRequired = ({\"id\": 29}0) OR (isMystiqueRequired = ({\"id\": 30}1) AND useBcFactorFilter = ({\"id\": 31}1))) AND (((budgetCampaignThrottleRateBits = ({\"id\": 32}55) AND dummyField contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 33}\"default\"))) AND !(useBcFactorFilter = ({\"id\": 34}1)) OR ((useBcFactorFilter = ({\"id\": 35}1) AND dummyField contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 36}\"default\") AND (bcFactorTiers = ({\"id\": 38}127) OR bcFactorTiers = ({\"id\": 39}0)) AND ((firstPriceEnforced = ({\"id\": 40}0) AND (secondPriceEnforced = ({\"id\": 41}1) OR isPrivateDeal = ({\"id\": 42}0) OR (dummyField contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 43}\"default\")) AND !(bcActiveTier = ({\"id\": 44}0)))) OR mystiqueCampaignThrottleRateBits = ({\"id\": 45}18)))) AND !(isOutOfDailyBudget = ({\"id\": 37}1))) AND testCreative = ({\"id\": 46}0) AND advt_geo = ({\"id\": 47}2147483647) AND ((adType contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 48}\"strm_video\") AND isPortraitVideo = ({\"id\": 49}0)) OR adType contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 50}\"stream_ad\")) AND ((isCPM = ({\"id\": 51}0) AND isOCPC = ({\"id\": 52}0) AND isECPC = ({\"id\": 53}0) AND ((priceType contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 54}\"cpcv\") AND bid >= ({\"id\": 55}0.005)) OR (priceType contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 56}\"cpv\") AND bid >= ({\"id\": 57}0.01)) OR (priceType contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 58}\"cpc\") AND bid >= ({\"id\": 59}0.05)) OR (objective contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 60}\"promote_content\") AND bid >= ({\"id\": 61}0.01)) OR hasFloorPriceUsd = ({\"id\": 62}1))) OR isECPC = ({\"id\": 63}1) OR (isCPM = ({\"id\": 64}1) AND isOCPM = ({\"id\": 65}0) AND (({\"id\": 66}range(bid, 0.25, Infinity)) OR hasFloorPriceUsd = ({\"id\": 67}1)))) AND start_date <= ({\"id\": 68}1572976776299L) AND end_date >= ({\"id\": 69}1572976776299L))) AND !(isHoldoutAd = ({\"id\": 25}1))) AND !((disclaimerExtensionsTypes contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 70}\"pharma\") OR ({\"id\": 71}weightedSet(exclusion_advt_supply, {\"extsite223\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) OR isPersonalized = ({\"id\": 72}1) OR blocked_section_ids contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 73}\"223\") OR blocked_publisher_ids contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 74}\"223\") OR blocked_site_ids contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 75}\"223\"))), {\"id\": 76, \"label\": \"ad_ocpc_max_cpc\"}dotProduct(ocpc_max_cpc, {\"0\": 1}), {\"id\": 77, \"label\": \"ad_ocpc_min_cpc\"}dotProduct(ocpc_min_cpc, {\"0\": 1}), {\"id\": 78, \"label\": \"ad_ocpc_max_alpha\"}dotProduct(ocpc_max_alpha, {\"0\": 1}), {\"id\": 79, \"label\": \"ad_ocpc_min_alpha\"}dotProduct(ocpc_min_alpha, {\"0\": 1}), {\"id\": 80, \"label\": \"ad_ocpc_alpha_0\"}dotProduct(ocpc_alpha_0, {\"0\": 1}), {\"id\": 81, \"label\": \"ad_ocpc_alpha_1\"}dotProduct(ocpc_alpha_1, {\"0\": 1}), (bidAdjustmentDayParting contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 82, \"weight\": 1}\"adv_tuesday\") OR bidAdjustmentDayParting contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 83, \"weight\": 1}\"adv_tuesday_17\") OR bidAdjustmentDayParting contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 84, \"weight\": 1}\"adv_tuesday_17_forty_five\") OR bidAdjustmentDayPartingForCostCap contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 85, \"weight\": 1}\"adv_tuesday\") OR bidAdjustmentDayPartingForCostCap contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 86, \"weight\": 1}\"adv_tuesday_17\") OR bidAdjustmentDayPartingForCostCap contains ({\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 87, \"weight\": 1}\"adv_tuesday_17_forty_five\")), bidAdjustmentForCpi = ({\"id\": 88, \"weight\": 1}223), {\"id\": 89, \"label\": \"boostingForBackfill\"}dotProduct(boostingForBackfill, {\"priority\": 1000})) limit 0 timeout 3980 | all(group(adTypeForGrouping) each(group(advertiser_id) max(11) output(count() as(groupingCounter)) each(max(1) each(output(summary())))))";
QueryTree parsed = assertParse("select * from sources * where " + queryTreeYql + ";",
- "RANK (+(+(AND filter:VideoAdsCappingTestCPM hasRankRestriction:0 (OR (AND objective:install_app availableExtendedFields:cpiparams) (AND availableExtendedFields:appinstallinfo availableExtendedFields:appmetroplexinfo) (+dummyField:default -objective:install_app)) advt_age:2147483647 advt_gender:all advt_all_segments:2147483647 advt_keywords:all advMobilePlatform:2147483647 advMobileDeviceType:2147483647 advMobileCon:2147483647 advMobileOSVersions:2147483647 advCarrier:2147483647 WEIGHTEDSET advt_supply{[1]:\"site223\",[1]:\"pub223\",[1]:\"all\",[1]:\"sec223\"} (OR advt_day_parting:adv_tuesday!1 advt_day_parting:adv_tuesday_17!1 advt_day_parting:adv_tuesday_17_forty_five!1 advt_day_parting:all) isAppReengagementAd:0 dummyField:default serveWithPromotionOnly:0 budgetAdvertiserThrottleRateFilter:0 budgetResellerThrottleRateFilter:0 (OR isMystiqueRequired:0 (AND isMystiqueRequired:1 useBcFactorFilter:1)) (OR (+(AND budgetCampaignThrottleRateBits:55 dummyField:default) -useBcFactorFilter:1) (+(AND useBcFactorFilter:1 dummyField:default (OR bcFactorTiers:127 bcFactorTiers:0) (OR (AND firstPriceEnforced:0 (OR secondPriceEnforced:1 isPrivateDeal:0 (+dummyField:default -bcActiveTier:0))) mystiqueCampaignThrottleRateBits:18)) -isOutOfDailyBudget:1)) testCreative:0 advt_geo:2147483647 (OR (AND adType:strm_video isPortraitVideo:0) adType:stream_ad) (OR (AND isCPM:0 isOCPC:0 isECPC:0 (OR (AND priceType:cpcv bid:[0.005;]) (AND priceType:cpv bid:[0.01;]) (AND priceType:cpc bid:[0.05;]) (AND objective:promote_content bid:[0.01;]) hasFloorPriceUsd:1)) isECPC:1 (AND isCPM:1 isOCPM:0 (OR bid:[0.25;] hasFloorPriceUsd:1))) start_date:[;1572976776299] end_date:[1572976776299;]) -isHoldoutAd:1) -(OR disclaimerExtensionsTypes:pharma WEIGHTEDSET exclusion_advt_supply{[1]:\"extsite223\",[1]:\"site223\",[1]:\"pub223\",[1]:\"sec223\"} isPersonalized:1 blocked_section_ids:223 blocked_publisher_ids:223 blocked_site_ids:223)) DOTPRODUCT ocpc_max_cpc{[1]:\"0\"} DOTPRODUCT ocpc_min_cpc{[1]:\"0\"} DOTPRODUCT ocpc_max_alpha{[1]:\"0\"} DOTPRODUCT ocpc_min_alpha{[1]:\"0\"} DOTPRODUCT ocpc_alpha_0{[1]:\"0\"} DOTPRODUCT ocpc_alpha_1{[1]:\"0\"} (OR bidAdjustmentDayParting:adv_tuesday!1 bidAdjustmentDayParting:adv_tuesday_17!1 bidAdjustmentDayParting:adv_tuesday_17_forty_five!1 bidAdjustmentDayPartingForCostCap:adv_tuesday!1 bidAdjustmentDayPartingForCostCap:adv_tuesday_17!1 bidAdjustmentDayPartingForCostCap:adv_tuesday_17_forty_five!1) bidAdjustmentForCpi:223!1 DOTPRODUCT boostingForBackfill{[1000]:\"priority\"}");
+ "RANK (+(+(AND filter:VideoAdsCappingTestCPM hasRankRestriction:0 (OR (AND objective:install_app availableExtendedFields:cpiparams) (AND availableExtendedFields:appinstallinfo availableExtendedFields:appmetroplexinfo) (+dummyField:default -objective:install_app)) advt_age:2147483647 advt_gender:all advt_all_segments:2147483647 advt_keywords:all advMobilePlatform:2147483647 advMobileDeviceType:2147483647 advMobileCon:2147483647 advMobileOSVersions:2147483647 advCarrier:2147483647 WEIGHTEDSET advt_supply{[1]:\"site223\",[1]:\"pub223\",[1]:\"all\",[1]:\"sec223\"} (OR advt_day_parting:adv_tuesday!1 advt_day_parting:adv_tuesday_17!1 advt_day_parting:adv_tuesday_17_forty_five!1 advt_day_parting:all) isAppReengagementAd:0 dummyField:default serveWithPromotionOnly:0 budgetAdvertiserThrottleRateFilter:0 budgetResellerThrottleRateFilter:0 (OR isMystiqueRequired:0 (AND isMystiqueRequired:1 useBcFactorFilter:1)) (OR (+(AND budgetCampaignThrottleRateBits:55 dummyField:default) -useBcFactorFilter:1) (+(AND useBcFactorFilter:1 dummyField:default (OR bcFactorTiers:127 bcFactorTiers:0) (OR (AND firstPriceEnforced:0 (OR secondPriceEnforced:1 isPrivateDeal:0 (+dummyField:default -bcActiveTier:0))) mystiqueCampaignThrottleRateBits:18)) -isOutOfDailyBudget:1)) testCreative:0 advt_geo:2147483647 (OR (AND adType:strm_video isPortraitVideo:0) adType:stream_ad) (OR (AND isCPM:0 isOCPC:0 isECPC:0 (OR (AND priceType:cpcv bid:[0.005;]) (AND priceType:cpv bid:[0.01;]) (AND priceType:cpc bid:[0.05;]) (AND objective:promote_content bid:[0.01;]) hasFloorPriceUsd:1)) isECPC:1 (AND isCPM:1 isOCPM:0 (OR bid:[0.25;] hasFloorPriceUsd:1))) start_date:[;1572976776299] end_date:[1572976776299;]) -isHoldoutAd:1) -(OR disclaimerExtensionsTypes:pharma WEIGHTEDSET exclusion_advt_supply{[1]:\"extsite223\",[1]:\"site223\",[1]:\"pub223\",[1]:\"sec223\"} isPersonalized:1 blocked_section_ids:223 blocked_publisher_ids:223 blocked_site_ids:223)) DOTPRODUCT ocpc_max_cpc{[1]:\"0\"} DOTPRODUCT ocpc_min_cpc{[1]:\"0\"} DOTPRODUCT ocpc_max_alpha{[1]:\"0\"} DOTPRODUCT ocpc_min_alpha{[1]:\"0\"} DOTPRODUCT ocpc_alpha_0{[1]:\"0\"} DOTPRODUCT ocpc_alpha_1{[1]:\"0\"} (OR bidAdjustmentDayParting:adv_tuesday!1 bidAdjustmentDayParting:adv_tuesday_17!1 bidAdjustmentDayParting:adv_tuesday_17_forty_five!1 bidAdjustmentDayPartingForCostCap:adv_tuesday!1 bidAdjustmentDayPartingForCostCap:adv_tuesday_17!1 bidAdjustmentDayPartingForCostCap:adv_tuesday_17_forty_five!1) bidAdjustmentForCpi:223!1 DOTPRODUCT boostingForBackfill{[1000]:\"priority\"}");
String serializedQueryTreeYql = VespaSerializer.serialize(parsed);
// Note: All the details here are not verified
assertEquals("rank((((filter contains ({normalizeCase: false, id: 1}\"VideoAdsCappingTestCPM\") AND hasRankRestriction contains ({normalizeCase: false, implicitTransforms: false, id: 2}\"0\") AND ((objective contains ({normalizeCase: false, implicitTransforms: false, id: 3}\"install_app\") AND availableExtendedFields contains ({normalizeCase: false, implicitTransforms: false, id: 4}\"cpiparams\")) OR (availableExtendedFields contains ({normalizeCase: false, implicitTransforms: false, id: 5}\"appinstallinfo\") AND availableExtendedFields contains ({normalizeCase: false, implicitTransforms: false, id: 6}\"appmetroplexinfo\")) OR (dummyField contains ({normalizeCase: false, implicitTransforms: false, id: 7}\"default\")) AND !(objective contains ({normalizeCase: false, implicitTransforms: false, id: 8}\"install_app\"))) AND advt_age = ({id: 9}2147483647) AND advt_gender contains ({normalizeCase: false, implicitTransforms: false, id: 10}\"all\") AND advt_all_segments = ({id: 11}2147483647) AND advt_keywords contains ({normalizeCase: false, implicitTransforms: false, id: 12}\"all\") AND advMobilePlatform = ({id: 13}2147483647) AND advMobileDeviceType = ({id: 14}2147483647) AND advMobileCon = ({id: 15}2147483647) AND advMobileOSVersions = ({id: 16}2147483647) AND advCarrier = ({id: 17}2147483647) AND ({id: 18}weightedSet(advt_supply, {\"all\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) AND (advt_day_parting contains ({normalizeCase: false, implicitTransforms: false, id: 19, weight: 1}\"adv_tuesday\") OR advt_day_parting contains ({normalizeCase: false, implicitTransforms: false, id: 20, weight: 1}\"adv_tuesday_17\") OR advt_day_parting contains ({normalizeCase: false, implicitTransforms: false, id: 21, weight: 1}\"adv_tuesday_17_forty_five\") OR advt_day_parting contains ({normalizeCase: false, implicitTransforms: false, id: 22}\"all\")) AND isAppReengagementAd = ({id: 23}0) AND dummyField contains ({normalizeCase: false, implicitTransforms: false, id: 24}\"default\") AND serveWithPromotionOnly = ({id: 26}0) AND budgetAdvertiserThrottleRateFilter = ({id: 27}0) AND budgetResellerThrottleRateFilter = ({id: 28}0) AND (isMystiqueRequired = ({id: 29}0) OR (isMystiqueRequired = ({id: 30}1) AND useBcFactorFilter = ({id: 31}1))) AND (((budgetCampaignThrottleRateBits = ({id: 32}55) AND dummyField contains ({normalizeCase: false, implicitTransforms: false, id: 33}\"default\"))) AND !(useBcFactorFilter = ({id: 34}1)) OR ((useBcFactorFilter = ({id: 35}1) AND dummyField contains ({normalizeCase: false, implicitTransforms: false, id: 36}\"default\") AND (bcFactorTiers = ({id: 38}127) OR bcFactorTiers = ({id: 39}0)) AND ((firstPriceEnforced = ({id: 40}0) AND (secondPriceEnforced = ({id: 41}1) OR isPrivateDeal = ({id: 42}0) OR (dummyField contains ({normalizeCase: false, implicitTransforms: false, id: 43}\"default\")) AND !(bcActiveTier = ({id: 44}0)))) OR mystiqueCampaignThrottleRateBits = ({id: 45}18)))) AND !(isOutOfDailyBudget = ({id: 37}1))) AND testCreative = ({id: 46}0) AND advt_geo = ({id: 47}2147483647) AND ((adType contains ({normalizeCase: false, implicitTransforms: false, id: 48}\"strm_video\") AND isPortraitVideo = ({id: 49}0)) OR adType contains ({normalizeCase: false, implicitTransforms: false, id: 50}\"stream_ad\")) AND ((isCPM = ({id: 51}0) AND isOCPC = ({id: 52}0) AND isECPC = ({id: 53}0) AND ((priceType contains ({normalizeCase: false, implicitTransforms: false, id: 54}\"cpcv\") AND bid >= ({id: 55}0.005)) OR (priceType contains ({normalizeCase: false, implicitTransforms: false, id: 56}\"cpv\") AND bid >= ({id: 57}0.01)) OR (priceType contains ({normalizeCase: false, implicitTransforms: false, id: 58}\"cpc\") AND bid >= ({id: 59}0.05)) OR (objective contains ({normalizeCase: false, implicitTransforms: false, id: 60}\"promote_content\") AND bid >= ({id: 61}0.01)) OR hasFloorPriceUsd = ({id: 62}1))) OR isECPC = ({id: 63}1) OR (isCPM = ({id: 64}1) AND isOCPM = ({id: 65}0) AND ({id: 66}range(bid, 0.25, Infinity) OR hasFloorPriceUsd = ({id: 67}1)))) AND start_date <= ({id: 68}1572976776299L) AND end_date >= ({id: 69}1572976776299L))) AND !(isHoldoutAd = ({id: 25}1))) AND !((disclaimerExtensionsTypes contains ({normalizeCase: false, implicitTransforms: false, id: 70}\"pharma\") OR ({id: 71}weightedSet(exclusion_advt_supply, {\"extsite223\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) OR isPersonalized = ({id: 72}1) OR blocked_section_ids contains ({normalizeCase: false, implicitTransforms: false, id: 73}\"223\") OR blocked_publisher_ids contains ({normalizeCase: false, implicitTransforms: false, id: 74}\"223\") OR blocked_site_ids contains ({normalizeCase: false, implicitTransforms: false, id: 75}\"223\"))), ({id: 76, label: \"ad_ocpc_max_cpc\"}dotProduct(ocpc_max_cpc, {\"0\": 1})), ({id: 77, label: \"ad_ocpc_min_cpc\"}dotProduct(ocpc_min_cpc, {\"0\": 1})), ({id: 78, label: \"ad_ocpc_max_alpha\"}dotProduct(ocpc_max_alpha, {\"0\": 1})), ({id: 79, label: \"ad_ocpc_min_alpha\"}dotProduct(ocpc_min_alpha, {\"0\": 1})), ({id: 80, label: \"ad_ocpc_alpha_0\"}dotProduct(ocpc_alpha_0, {\"0\": 1})), ({id: 81, label: \"ad_ocpc_alpha_1\"}dotProduct(ocpc_alpha_1, {\"0\": 1})), (bidAdjustmentDayParting contains ({normalizeCase: false, implicitTransforms: false, id: 82, weight: 1}\"adv_tuesday\") OR bidAdjustmentDayParting contains ({normalizeCase: false, implicitTransforms: false, id: 83, weight: 1}\"adv_tuesday_17\") OR bidAdjustmentDayParting contains ({normalizeCase: false, implicitTransforms: false, id: 84, weight: 1}\"adv_tuesday_17_forty_five\") OR bidAdjustmentDayPartingForCostCap contains ({normalizeCase: false, implicitTransforms: false, id: 85, weight: 1}\"adv_tuesday\") OR bidAdjustmentDayPartingForCostCap contains ({normalizeCase: false, implicitTransforms: false, id: 86, weight: 1}\"adv_tuesday_17\") OR bidAdjustmentDayPartingForCostCap contains ({normalizeCase: false, implicitTransforms: false, id: 87, weight: 1}\"adv_tuesday_17_forty_five\")), bidAdjustmentForCpi = ({id: 88, weight: 1}223), ({id: 89, label: \"boostingForBackfill\"}dotProduct(boostingForBackfill, {\"priority\": 1000})))",
- serializedQueryTreeYql);
+ serializedQueryTreeYql);
}
@Test
- public void testDottedFieldNames() {
+ void testDottedFieldNames() {
assertParse("select foo from bar where my.nested.title contains \"madonna\"",
"my.nested.title:madonna");
}
+
@Test
- public void testDottedNestedFieldNames() {
+ void testDottedNestedFieldNames() {
assertParse("select foo from bar where my.title contains \"madonna\"",
"my.title:madonna");
}
@Test
- public void testOr() {
+ void testOr() {
assertParse("select foo from bar where title contains \"madonna\" or title contains \"saint\"",
- "OR title:madonna title:saint");
+ "OR title:madonna title:saint");
assertParse("select foo from bar where title contains \"madonna\" or title contains \"saint\" or title " +
- "contains \"angel\"",
- "OR title:madonna title:saint title:angel");
+ "contains \"angel\"",
+ "OR title:madonna title:saint title:angel");
}
@Test
- public void testAnd() {
+ void testAnd() {
assertParse("select foo from bar where title contains \"madonna\" and title contains \"saint\"",
- "AND title:madonna title:saint");
+ "AND title:madonna title:saint");
assertParse("select foo from bar where title contains \"madonna\" and title contains \"saint\" and title " +
- "contains \"angel\"",
- "AND title:madonna title:saint title:angel");
+ "contains \"angel\"",
+ "AND title:madonna title:saint title:angel");
}
@Test
- public void testAndNot() {
+ void testAndNot() {
assertParse("select foo from bar where title contains \"madonna\" and !(title contains \"saint\")",
- "+title:madonna -title:saint");
+ "+title:madonna -title:saint");
}
@Test
- public void testSingleNot() {
+ void testSingleNot() {
assertParse("select foo from bar where !(title contains \"saint\")",
- "-title:saint");
+ "-title:saint");
}
@Test
- public void testMultipleNot() {
+ void testMultipleNot() {
assertParse("select foo from bar where !(title contains \"saint\") AND !(title contains \"etienne\")",
- "-title:saint -title:etienne");
+ "-title:saint -title:etienne");
}
@Test
- public void testLessThan() {
+ void testLessThan() {
assertParse("select foo from bar where price < 500", "price:<500");
assertParse("select foo from bar where 500 < price", "price:>500");
}
@Test
- public void testGreaterThan() {
+ void testGreaterThan() {
assertParse("select foo from bar where price > 500", "price:>500");
assertParse("select foo from bar where 500 > price", "price:<500");
}
@Test
- public void testLessThanOrEqual() {
+ void testLessThanOrEqual() {
assertParse("select foo from bar where price <= 500", "price:[;500]");
assertParse("select foo from bar where 500 <= price", "price:[500;]");
}
@Test
- public void testGreaterThanOrEqual() {
+ void testGreaterThanOrEqual() {
assertParse("select foo from bar where price >= 500", "price:[500;]");
assertParse("select foo from bar where 500 >= price", "price:[;500]");
}
@Test
- public void testEquality() {
+ void testEquality() {
assertParse("select foo from bar where price = 500", "price:500");
assertParse("select foo from bar where 500 = price", "price:500");
}
@Test
- public void testNegativeLessThan() {
+ void testNegativeLessThan() {
assertParse("select foo from bar where price < -500", "price:<-500");
assertParse("select foo from bar where -500 < price", "price:>-500");
}
@Test
- public void testNegativeGreaterThan() {
+ void testNegativeGreaterThan() {
assertParse("select foo from bar where price > -500", "price:>-500");
assertParse("select foo from bar where -500 > price", "price:<-500");
}
@Test
- public void testNegativeLessThanOrEqual() {
+ void testNegativeLessThanOrEqual() {
assertParse("select foo from bar where price <= -500", "price:[;-500]");
assertParse("select foo from bar where -500 <= price", "price:[-500;]");
}
@Test
- public void testNegativeGreaterThanOrEqual() {
+ void testNegativeGreaterThanOrEqual() {
assertParse("select foo from bar where price >= -500", "price:[-500;]");
assertParse("select foo from bar where -500 >= price", "price:[;-500]");
}
@Test
- public void testNegativeEquality() {
+ void testNegativeEquality() {
assertParse("select foo from bar where price = -500", "price:-500");
assertParse("select foo from bar where -500 = price", "price:-500");
}
@Test
- public void testAnnotatedLessThan() {
+ void testAnnotatedLessThan() {
assertParse("select foo from bar where price < ({filter: true}(-500))", "|price:<-500");
assertParse("select foo from bar where ({filter: true}500) < price", "|price:>500");
}
@Test
- public void testAnnotatedGreaterThan() {
+ void testAnnotatedGreaterThan() {
assertParse("select foo from bar where price > ({filter: true}500)", "|price:>500");
assertParse("select foo from bar where ({filter: true}(-500)) > price", "|price:<-500");
}
@Test
- public void testAnnotatedLessThanOrEqual() {
+ void testAnnotatedLessThanOrEqual() {
assertParse("select foo from bar where price <= ({filter: true}(-500))", "|price:[;-500]");
assertParse("select foo from bar where ({filter: true}500) <= price", "|price:[500;]");
}
@Test
- public void testAnnotatedGreaterThanOrEqual() {
+ void testAnnotatedGreaterThanOrEqual() {
assertParse("select foo from bar where price >= ({filter: true}500)", "|price:[500;]");
assertParse("select foo from bar where ({filter: true}(-500)) >= price", "|price:[;-500]");
}
@Test
- public void testAnnotatedEquality() {
+ void testAnnotatedEquality() {
assertParse("select foo from bar where price = ({filter: true}(-500))", "|price:-500");
assertParse("select foo from bar where ({filter: true}500) = price", "|price:500");
}
@Test
- public void testBoolean() {
+ void testBoolean() {
assertParse("select foo from bar where flag = true;", "flag:true");
QueryTree query = assertParse("select foo from bar where flag = false;", "flag:false");
assertEquals(BoolItem.class, query.getRoot().getClass());
- BoolItem item = (BoolItem)query.getRoot();
+ BoolItem item = (BoolItem) query.getRoot();
assertEquals("flag", item.getIndexName());
assertEquals(false, item.value());
}
@Test
- public void testTermAnnotations() {
+ void testTermAnnotations() {
assertEquals("merkelapp",
- getRootWord("select foo from bar where baz contains " +
- "({label: \"merkelapp\"}\"colors\")").getLabel());
+ getRootWord("select foo from bar where baz contains " +
+ "({label: \"merkelapp\"}\"colors\")").getLabel());
assertEquals("another",
- getRootWord("select foo from bar where baz contains " +
- "({annotations: {cox: \"another\"}}\"colors\")").getAnnotation("cox"));
+ getRootWord("select foo from bar where baz contains " +
+ "({annotations: {cox: \"another\"}}\"colors\")").getAnnotation("cox"));
assertEquals(23.0, getRootWord("select foo from bar where baz contains " +
- "({significance: 23.0}\"colors\")").getSignificance(), 1E-6);
+ "({significance: 23.0}\"colors\")").getSignificance(), 1E-6);
assertEquals(23, getRootWord("select foo from bar where baz contains " +
- "({id: 23}\"colors\")").getUniqueID());
+ "({id: 23}\"colors\")").getUniqueID());
assertEquals(150, getRootWord("select foo from bar where baz contains " +
- "({weight: 150}\"colors\")").getWeight());
+ "({weight: 150}\"colors\")").getWeight());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "({usePositionData: false}\"colors\")").usePositionData());
+ "({usePositionData: false}\"colors\")").usePositionData());
assertTrue(getRootWord("select foo from bar where baz contains " +
- "({filter: true}\"colors\")").isFilter());
+ "({filter: true}\"colors\")").isFilter());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "({ranked: false}\"colors\")").isRanked());
+ "({ranked: false}\"colors\")").isRanked());
Substring origin = getRootWord("select foo from bar where baz contains " +
- "({origin: {original: \"abc\", offset: 1, length: 2}}" +
- "\"colors\")").getOrigin();
+ "({origin: {original: \"abc\", offset: 1, length: 2}}" +
+ "\"colors\")").getOrigin();
assertEquals("abc", origin.string);
assertEquals(1, origin.start);
assertEquals(3, origin.end);
}
@Test
- public void testAnnotationsCanBeInBrackets() {
+ void testAnnotationsCanBeInBrackets() {
assertEquals("merkelapp",
- getRootWord("select foo from bar where baz contains " +
- "([ {label: \"merkelapp\"} ]\"colors\")").getLabel());
+ getRootWord("select foo from bar where baz contains " +
+ "([ {label: \"merkelapp\"} ]\"colors\")").getLabel());
}
@Test
- public void testValuesCanBeQuoted() {
+ void testValuesCanBeQuoted() {
assertEquals("merkelapp",
- getRootWord("select foo from bar where baz contains " +
- "( {label: \"merkelapp\"} \"colors\")").getLabel());
+ getRootWord("select foo from bar where baz contains " +
+ "( {label: \"merkelapp\"} \"colors\")").getLabel());
}
@Test
- public void testSameElement() {
+ void testSameElement() {
assertParse("select foo from bar where baz contains sameElement(f1 contains \"a\", f2 contains \"b\")",
"baz:{f1:a f2:b}");
assertParse("select foo from bar where baz contains sameElement(f1 contains \"a\", f2 = 10)",
@@ -361,27 +359,27 @@ public class YqlParserTestCase {
}
@Test
- public void testPhrase() {
+ void testPhrase() {
assertParse("select foo from bar where baz contains phrase(\"a\", \"b\")",
- "baz:\"a b\"");
+ "baz:\"a b\"");
}
@Test
- public void testNestedPhrase() {
+ void testNestedPhrase() {
assertParse("select foo from bar where baz contains phrase(\"a\", \"b\", phrase(\"c\", \"d\"))",
- "baz:\"a b c d\"");
+ "baz:\"a b c d\"");
}
@Test
- public void testNestedPhraseSegment() {
+ void testNestedPhraseSegment() {
assertParse("select foo from bar where baz contains " +
- "phrase(\"a\", \"b\", [ {origin: {original: \"c d\", offset: 0, length: 3}} ]" +
- "phrase(\"c\", \"d\"));",
- "baz:\"a b 'c d'\"");
+ "phrase(\"a\", \"b\", [ {origin: {original: \"c d\", offset: 0, length: 3}} ]" +
+ "phrase(\"c\", \"d\"));",
+ "baz:\"a b 'c d'\"");
}
@Test
- public void testFuzzy() {
+ void testFuzzy() {
QueryTree x = parse("select foo from bar where baz contains fuzzy(\"a b\")");
Item root = x.getRoot();
assertSame(FuzzyItem.class, root.getClass());
@@ -392,7 +390,7 @@ public class YqlParserTestCase {
}
@Test
- public void testFuzzyAnnotations() {
+ void testFuzzyAnnotations() {
QueryTree x = parse(
"select foo from bar where baz contains ({maxEditDistance: 3, prefixLength: 10}fuzzy(\"a b\"))"
);
@@ -405,17 +403,17 @@ public class YqlParserTestCase {
}
@Test
- public void testStemming() {
+ void testStemming() {
assertTrue(getRootWord("select foo from bar where baz contains " +
- "([ {stem: false} ]\"colors\")").isStemmed());
+ "([ {stem: false} ]\"colors\")").isStemmed());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "([ {stem: true} ]\"colors\")").isStemmed());
+ "([ {stem: true} ]\"colors\")").isStemmed());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "\"colors\"").isStemmed());
+ "\"colors\"").isStemmed());
}
@Test
- public void testRaw() {
+ void testRaw() {
// Default: Not raw, for comparison
Item root = parse("select foo from bar where baz contains (\"yoni jo dima\")").getRoot();
assertEquals("baz:'yoni jo dima'", root.toString());
@@ -426,7 +424,7 @@ public class YqlParserTestCase {
assertEquals("baz:yoni jo dima", root.toString());
assertTrue(root instanceof WordItem);
assertFalse(root instanceof ExactStringItem);
- assertEquals("yoni jo dima", ((WordItem)root).getWord());
+ assertEquals("yoni jo dima", ((WordItem) root).getWord());
root = parse("select foo from bar where {grammar:\"all\"}userInput(\"yoni jo dima\")").getRoot();
assertTrue(root instanceof AndItem);
@@ -436,232 +434,232 @@ public class YqlParserTestCase {
root = parse("select foo from bar where {grammar:\"raw\"}userInput(\"yoni jo dima\")").getRoot();
assertTrue(root instanceof WordItem);
assertTrue(root instanceof ExactStringItem);
- assertEquals("yoni jo dima", ((WordItem)root).getWord());
+ assertEquals("yoni jo dima", ((WordItem) root).getWord());
}
@Test
- public void testAccentDropping() {
+ void testAccentDropping() {
assertFalse(getRootWord("select foo from bar where baz contains " +
- "( {accentDrop: false} \"colors\")").isNormalizable());
+ "( {accentDrop: false} \"colors\")").isNormalizable());
assertTrue(getRootWord("select foo from bar where baz contains " +
- "( {accentDrop: true} \"colors\")").isNormalizable());
+ "( {accentDrop: true} \"colors\")").isNormalizable());
assertTrue(getRootWord("select foo from bar where baz contains " +
- "\"colors\"").isNormalizable());
+ "\"colors\"").isNormalizable());
}
@Test
- public void testCaseNormalization() {
+ void testCaseNormalization() {
assertTrue(getRootWord("select foo from bar where baz contains " +
- "( {normalizeCase: false} \"colors\")").isLowercased());
+ "( {normalizeCase: false} \"colors\")").isLowercased());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "( {normalizeCase: true} \"colors\")").isLowercased());
+ "( {normalizeCase: true} \"colors\")").isLowercased());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "\"colors\"").isLowercased());
+ "\"colors\"").isLowercased());
}
@Test
- public void testSegmentingRule() {
+ void testSegmentingRule() {
assertEquals(SegmentingRule.PHRASE,
- getRootWord("select foo from bar where baz contains " +
- "( {andSegmenting: false} \"colors\")").getSegmentingRule());
+ getRootWord("select foo from bar where baz contains " +
+ "( {andSegmenting: false} \"colors\")").getSegmentingRule());
assertEquals(SegmentingRule.BOOLEAN_AND,
- getRootWord("select foo from bar where baz contains " +
- "( {andSegmenting: true} \"colors\")").getSegmentingRule());
+ getRootWord("select foo from bar where baz contains " +
+ "( {andSegmenting: true} \"colors\")").getSegmentingRule());
assertEquals(SegmentingRule.LANGUAGE_DEFAULT,
- getRootWord("select foo from bar where baz contains " +
- "\"colors\"").getSegmentingRule());
+ getRootWord("select foo from bar where baz contains " +
+ "\"colors\"").getSegmentingRule());
}
@Test
- public void testNfkc() {
+ void testNfkc() {
assertEquals("a\u030a",
- getRootWord("select foo from bar where baz contains " +
- "( {nfkc: false} \"a\\u030a\")").getWord());
+ getRootWord("select foo from bar where baz contains " +
+ "( {nfkc: false} \"a\\u030a\")").getWord());
assertEquals("\u00e5",
- getRootWord("select foo from bar where baz contains " +
- "( {nfkc: true} \"a\\u030a\")").getWord());
- assertEquals("No NKFC by default",
- "a\u030a",
- getRootWord("select foo from bar where baz contains " +
- "(\"a\\u030a\")").getWord());
+ getRootWord("select foo from bar where baz contains " +
+ "( {nfkc: true} \"a\\u030a\")").getWord());
+ assertEquals("a\u030a",
+ getRootWord("select foo from bar where baz contains " +
+ "(\"a\\u030a\")").getWord(),
+ "No NKFC by default");
}
@Test
- public void testImplicitTransforms() {
+ void testImplicitTransforms() {
assertFalse(getRootWord("select foo from bar where baz contains ({implicitTransforms: " +
- "false} \"cox\")").isFromQuery());
+ "false} \"cox\")").isFromQuery());
assertTrue(getRootWord("select foo from bar where baz contains ({implicitTransforms: " +
- "true} \"cox\")").isFromQuery());
+ "true} \"cox\")").isFromQuery());
assertTrue(getRootWord("select foo from bar where baz contains \"cox\"").isFromQuery());
}
@Test
- public void testConnectivity() {
+ void testConnectivity() {
QueryTree parsed = parse("select foo from bar where " +
- "title contains ({id: 1, connectivity: {\"id\": 3, weight: 7.0}}\"madonna\") " +
- "and title contains ({id: 2}\"saint\") " +
- "and title contains ({id: 3}\"angel\")");
+ "title contains ({id: 1, connectivity: {\"id\": 3, weight: 7.0}}\"madonna\") " +
+ "and title contains ({id: 2}\"saint\") " +
+ "and title contains ({id: 3}\"angel\")");
assertEquals("AND title:madonna title:saint title:angel",
- parsed.toString());
- AndItem root = (AndItem)parsed.getRoot();
- WordItem first = (WordItem)root.getItem(0);
- WordItem second = (WordItem)root.getItem(1);
- WordItem third = (WordItem)root.getItem(2);
- assertTrue(first.getConnectedItem() == third);
+ parsed.toString());
+ AndItem root = (AndItem) parsed.getRoot();
+ WordItem first = (WordItem) root.getItem(0);
+ WordItem second = (WordItem) root.getItem(1);
+ WordItem third = (WordItem) root.getItem(2);
+ assertEquals(first.getConnectedItem(), third);
assertEquals(first.getConnectivity(), 7.0d, 1E-6);
assertNull(second.getConnectedItem());
assertParseFail("select foo from bar where " +
- "title contains ({id: 1, connectivity: {id: 4, weight: 7.0}}\"madonna\") " +
- "and title contains ({id: 2}\"saint\") " +
- "and title contains ({id: 3}\"angel\")",
- new IllegalArgumentException("Item 'title:madonna' was specified to connect to item with ID 4, " +
- "which does not exist in the query."));
+ "title contains ({id: 1, connectivity: {id: 4, weight: 7.0}}\"madonna\") " +
+ "and title contains ({id: 2}\"saint\") " +
+ "and title contains ({id: 3}\"angel\")",
+ new IllegalArgumentException("Item 'title:madonna' was specified to connect to item with ID 4, " +
+ "which does not exist in the query."));
}
@Test
- public void testAnnotatedPhrase() {
+ void testAnnotatedPhrase() {
QueryTree parsed =
parse("select foo from bar where baz contains ({label: \"hello world\"}phrase(\"a\", \"b\"))");
assertEquals("baz:\"a b\"", parsed.toString());
- PhraseItem phrase = (PhraseItem)parsed.getRoot();
+ PhraseItem phrase = (PhraseItem) parsed.getRoot();
assertEquals("hello world", phrase.getLabel());
}
@Test
- public void testRange() {
+ void testRange() {
QueryTree parsed = parse("select foo from bar where range(baz,1,8)");
assertEquals("baz:[1;8]", parsed.toString());
}
@Test
- public void testRangeWithEndInfinity() {
+ void testRangeWithEndInfinity() {
QueryTree parsed = parse("select foo from bar where range(baz,1,Infinity)");
assertEquals("baz:[1;]", parsed.toString());
}
@Test
- public void testRangeWithStartInfinity() {
+ void testRangeWithStartInfinity() {
QueryTree parsed = parse("select foo from bar where range(baz,-Infinity,8)");
assertEquals("baz:[;8]", parsed.toString());
}
@Test
- public void testNegativeRange() {
+ void testNegativeRange() {
QueryTree parsed = parse("select foo from bar where range(baz,-8,-1)");
assertEquals("baz:[-8;-1]", parsed.toString());
}
@Test
- public void testRangeIllegalArguments() {
+ void testRangeIllegalArguments() {
assertParseFail("select foo from bar where range(baz,cox,8)",
- new IllegalArgumentException("Expected a numerical argument (or 'Infinity') to range but got 'cox'"));
+ new IllegalArgumentException("Expected a numerical argument (or 'Infinity') to range but got 'cox'"));
}
@Test
- public void testNear() {
+ void testNear() {
assertParse("select foo from bar where description contains near(\"a\", \"b\")",
- "NEAR(2) description:a description:b");
+ "NEAR(2) description:a description:b");
assertParse("select foo from bar where description contains ({distance: 100} near(\"a\", \"b\"))",
- "NEAR(100) description:a description:b");
+ "NEAR(100) description:a description:b");
}
@Test
- public void testOrderedNear() {
+ void testOrderedNear() {
assertParse("select foo from bar where description contains onear(\"a\", \"b\");",
- "ONEAR(2) description:a description:b");
+ "ONEAR(2) description:a description:b");
assertParse("select foo from bar where description contains ({distance: 100} onear(\"a\", \"b\"))",
- "ONEAR(100) description:a description:b");
+ "ONEAR(100) description:a description:b");
}
@Test
- public void testWand() {
+ void testWand() {
assertParse("select foo from bar where wand(description, {\"a\":1, \"b\":2});",
"WAND(10,0.0,1.0) description{[1]:\"a\",[2]:\"b\"}");
assertParse("select foo from bar where {scoreThreshold : 13.3, targetHits: 7, " +
- "thresholdBoostFactor: 2.3} wand(description, {\"a\":1, \"b\":2})",
- "WAND(7,13.3,2.3) description{[1]:\"a\",[2]:\"b\"}");
+ "thresholdBoostFactor: 2.3} wand(description, {\"a\":1, \"b\":2})",
+ "WAND(7,13.3,2.3) description{[1]:\"a\",[2]:\"b\"}");
}
@Test
- public void testQuotedAnnotations() {
+ void testQuotedAnnotations() {
assertParse("select foo from bar where {\"scoreThreshold\": 13.3, \"targetHits\": 7, " +
- "'thresholdBoostFactor': 2.3} wand(description, {\"a\":1})",
- "WAND(7,13.3,2.3) description{[1]:\"a\"}");
+ "'thresholdBoostFactor': 2.3} wand(description, {\"a\":1})",
+ "WAND(7,13.3,2.3) description{[1]:\"a\"}");
}
@Test
- public void testNumericWand() {
+ void testNumericWand() {
String numWand = "WAND(10,0.0,1.0) description{[1]:\"11\",[2]:\"37\"}";
assertParse("select foo from bar where wand(description, [[11,1], [37,2]])", numWand);
assertParse("select foo from bar where wand(description, [[11L,1], [37L,2]])", numWand);
assertParseFail("select foo from bar where wand(description, 12);",
- new IllegalArgumentException("Expected ARRAY or MAP, got LITERAL."));
+ new IllegalArgumentException("Expected ARRAY or MAP, got LITERAL."));
}
- @Test
//This test is order dependent. Fix it!
- public void testWeightedSet() {
+ @Test
+ void testWeightedSet() {
assertParse("select foo from bar where weightedSet(description, {\"a\":1, \"b\":2})",
- "WEIGHTEDSET description{[1]:\"a\",[2]:\"b\"}");
+ "WEIGHTEDSET description{[1]:\"a\",[2]:\"b\"}");
assertParseFail("select foo from bar where weightedSet(description, {\"a\":g, \"b\":2})",
- new IllegalInputException("com.yahoo.search.yql.ProgramCompileException: " +
- "query:L1:56 no viable alternative at input 'weightedSet(description, {\"a\":g'"));
+ new IllegalInputException("com.yahoo.search.yql.ProgramCompileException: " +
+ "query:L1:56 no viable alternative at input 'weightedSet(description, {\"a\":g'"));
assertParseFail("select foo from bar where weightedSet(description);",
- new IllegalArgumentException("Expected 2 arguments, got 1."));
+ new IllegalArgumentException("Expected 2 arguments, got 1."));
}
//This test is order dependent. Fix it!
@Test
- public void testDotProduct() {
+ void testDotProduct() {
assertParse("select foo from bar where dotProduct(description, {\"a\":1, \"b\":2})",
- "DOTPRODUCT description{[1]:\"a\",[2]:\"b\"}");
+ "DOTPRODUCT description{[1]:\"a\",[2]:\"b\"}");
assertParse("select foo from bar where dotProduct(description, {\"a\":2})",
- "DOTPRODUCT description{[2]:\"a\"}");
+ "DOTPRODUCT description{[2]:\"a\"}");
}
@Test
- public void testGeoLocation() {
+ void testGeoLocation() {
assertParse("select foo from bar where geoLocation(workplace, 63.418417, 10.433033, \"0.5 deg\")",
- "GEO_LOCATION workplace:(2,10433033,63418417,500000,0,1,0,1921876103)");
+ "GEO_LOCATION workplace:(2,10433033,63418417,500000,0,1,0,1921876103)");
assertParse("select foo from bar where geoLocation(headquarters, \"37.416383\", \"-122.024683\", \"100 miles\")",
- "GEO_LOCATION headquarters:(2,-122024683,37416383,1450561,0,1,0,3411238761)");
+ "GEO_LOCATION headquarters:(2,-122024683,37416383,1450561,0,1,0,3411238761)");
assertParse("select foo from bar where geoLocation(home, \"E10.433033\", \"N63.418417\", \"5km\")",
- "GEO_LOCATION home:(2,10433033,63418417,45066,0,1,0,1921876103)");
+ "GEO_LOCATION home:(2,10433033,63418417,45066,0,1,0,1921876103)");
assertParseFail("select foo from bar where geoLocation(qux, 1, 2)",
- new IllegalArgumentException("Expected 4 arguments, got 3."));
+ new IllegalArgumentException("Expected 4 arguments, got 3."));
assertParseFail("select foo from bar where geoLocation(qux, 2.0, \"N5.0\", \"0.5 deg\");",
- new IllegalArgumentException(
- "Invalid geoLocation coordinates 'Latitude: 2.0 degrees' and 'Latitude: 5.0 degrees'"));
+ new IllegalArgumentException(
+ "Invalid geoLocation coordinates 'Latitude: 2.0 degrees' and 'Latitude: 5.0 degrees'"));
assertParse("select foo from bar where geoLocation(workplace, -12, -34, \"-77 d\")",
- "GEO_LOCATION workplace:(2,-34000000,-12000000,-1,0,1,0,4201111954)");
+ "GEO_LOCATION workplace:(2,-34000000,-12000000,-1,0,1,0,4201111954)");
}
@Test
- public void testNearestNeighbor() {
+ void testNearestNeighbor() {
assertParse("select foo from bar where nearestNeighbor(semantic_embedding, my_vector);",
- "NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=Infinity,approximate=true,targetHits=0}");
+ "NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=Infinity,approximate=true,targetHits=0}");
assertParse("select foo from bar where {targetHits: 37} nearestNeighbor(semantic_embedding, my_vector)",
- "NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=Infinity,approximate=true,targetHits=37}");
+ "NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=Infinity,approximate=true,targetHits=37}");
assertParse("select foo from bar where {approximate: false, hnsw.exploreAdditionalHits: 8, targetHits: 3} nearestNeighbor(semantic_embedding, my_vector)",
- "NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=8,distanceThreshold=Infinity,approximate=false,targetHits=3}");
+ "NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=8,distanceThreshold=Infinity,approximate=false,targetHits=3}");
assertParse("select foo from bar where {targetHits: 7, distanceThreshold: 100100.25} nearestNeighbor(semantic_embedding, my_vector)",
- "NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=100100.25,approximate=true,targetHits=7}");
+ "NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=100100.25,approximate=true,targetHits=7}");
}
@Test
- public void testTrueAndFalse() {
+ void testTrueAndFalse() {
assertParse("select foo from bar where true", "TRUE");
assertParse("select foo from bar where false", "FALSE");
assertParse("select foo from bar where ((title contains \"foo\") AND true) AND !((title contains \"bar\") or false)",
- "+(AND title:foo TRUE) -(OR title:bar FALSE)");
+ "+(AND title:foo TRUE) -(OR title:bar FALSE)");
}
@Test
- public void testPredicate() {
+ void testPredicate() {
assertParse("select foo from bar where predicate(predicate_field, " +
"{\"gender\":\"male\", \"hobby\":[\"music\", \"hiking\"]}, {\"age\":23L})",
"PREDICATE_QUERY_ITEM gender=male, hobby=music, hobby=hiking, age:23");
@@ -673,113 +671,113 @@ public class YqlParserTestCase {
}
@Test
- public void testPredicateWithSubQueries() {
+ void testPredicateWithSubQueries() {
assertParse("select foo from bar where predicate(predicate_field, " +
"{\"0x03\":{\"gender\":\"male\"},\"0x01\":{\"hobby\":[\"music\", \"hiking\"]}}, {\"0x80ffffffffffffff\":{\"age\":23L}})",
"PREDICATE_QUERY_ITEM gender=male[0x3], hobby=music[0x1], hobby=hiking[0x1], age:23[0x80ffffffffffffff]");
assertParseFail("select foo from bar where predicate(foo, null, {\"0x80000000000000000\":{\"age\":23}})",
new NumberFormatException("Too long subquery string: 0x80000000000000000"));
assertParse("select foo from bar where predicate(predicate_field, " +
- "{\"[0,1]\":{\"gender\":\"male\"},\"[0]\":{\"hobby\":[\"music\", \"hiking\"]}}, {\"[62, 63]\":{\"age\":23L}})",
+ "{\"[0,1]\":{\"gender\":\"male\"},\"[0]\":{\"hobby\":[\"music\", \"hiking\"]}}, {\"[62, 63]\":{\"age\":23L}})",
"PREDICATE_QUERY_ITEM gender=male[0x3], hobby=music[0x1], hobby=hiking[0x1], age:23[0xc000000000000000]");
}
@Test
- public void testRank() {
+ void testRank() {
assertParse("select foo from bar where rank(a contains \"A\", b contains \"B\")",
- "RANK a:A b:B");
+ "RANK a:A b:B");
assertParse("select foo from bar where rank(a contains \"A\", b contains \"B\", c " +
- "contains \"C\")",
- "RANK a:A b:B c:C");
+ "contains \"C\")",
+ "RANK a:A b:B c:C");
assertParse("select foo from bar where rank(a contains \"A\", b contains \"B\" or c " +
- "contains \"C\")",
- "RANK a:A (OR b:B c:C)");
+ "contains \"C\")",
+ "RANK a:A (OR b:B c:C)");
}
@Test
@SuppressWarnings("deprecation")
- public void testWeakAnd() {
+ void testWeakAnd() {
assertParse("select foo from bar where weakAnd(a contains \"A\", b contains \"B\")",
- "WEAKAND(100) a:A b:B");
+ "WEAKAND(100) a:A b:B");
assertParse("select foo from bar where {targetHits: 37}weakAnd(a contains \"A\", " +
- "b contains \"B\")",
- "WEAKAND(37) a:A b:B");
+ "b contains \"B\")",
+ "WEAKAND(37) a:A b:B");
QueryTree tree = parse("select foo from bar where weakAnd(a " +
- "contains \"A\", b contains \"B\")");
+ "contains \"A\", b contains \"B\")");
assertEquals("WEAKAND(100) a:A b:B", tree.toString());
assertEquals(WeakAndItem.class, tree.getRoot().getClass());
}
@Test
- public void testEquiv() {
+ void testEquiv() {
assertParse("select foo from bar where fieldName contains equiv(\"A\",\"B\")",
- "EQUIV fieldName:A fieldName:B");
+ "EQUIV fieldName:A fieldName:B");
assertParse("select foo from bar where fieldName contains " +
- "equiv(\"ny\",phrase(\"new\",\"york\"));",
- "EQUIV fieldName:ny fieldName:\"new york\"");
+ "equiv(\"ny\",phrase(\"new\",\"york\"));",
+ "EQUIV fieldName:ny fieldName:\"new york\"");
assertParseFail("select foo from bar where fieldName contains equiv(\"ny\")",
- new IllegalArgumentException("Expected 2 or more arguments, got 1."));
+ new IllegalArgumentException("Expected 2 or more arguments, got 1."));
assertParseFail("select foo from bar where fieldName contains equiv(\"ny\", nalle(void))",
- new IllegalArgumentException("Expected function 'phrase', got 'nalle'."));
+ new IllegalArgumentException("Expected function 'phrase', got 'nalle'."));
assertParseFail("select foo from bar where fieldName contains equiv(\"ny\", 42)",
- new ClassCastException("Cannot cast java.lang.Integer to java.lang.String"));
+ new ClassCastException("Cannot cast java.lang.Integer to java.lang.String"));
}
@Test
- public void testAffixItems() {
+ void testAffixItems() {
assertRootClass("select foo from bar where baz contains ({suffix: true}\"colors\")",
- SuffixItem.class);
+ SuffixItem.class);
assertRootClass("select foo from bar where baz contains ({prefix: true}\"colors\")",
- PrefixItem.class);
+ PrefixItem.class);
assertRootClass("select foo from bar where baz contains ({substring: true}\"colors\")",
- SubstringItem.class);
+ SubstringItem.class);
assertParseFail("select foo from bar where description contains ({suffix: true, " +
- "prefix: true}\"colors\")",
- new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
+ "prefix: true}\"colors\")",
+ new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
assertParseFail("select foo from bar where description contains ({suffix: true, " +
- "substring: true}\"colors\")",
- new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
+ "substring: true}\"colors\")",
+ new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
}
@Test
- public void testLongNumberInSimpleExpression() {
+ void testLongNumberInSimpleExpression() {
assertParse("select foo from bar where price = 8589934592L", "price:8589934592");
assertParse("select foo from bar where price = 8589934592", "price:8589934592");
}
@Test
- public void testNegativeLongNumberInSimpleExpression() {
+ void testNegativeLongNumberInSimpleExpression() {
assertParse("select foo from bar where price = -8589934592L", "price:-8589934592");
}
@Test
- public void testSources() {
+ void testSources() {
assertSources("select foo from sourceA where price <= 500", List.of("sourceA"));
}
@Test
- public void testQueryWithSemicolon() {
+ void testQueryWithSemicolon() {
assertParse("select foo from bar where price = 1", "price:1");
}
@Test
- public void testSourcesWithDash() {
+ void testSourcesWithDash() {
assertSources("select foo from source-a where price <= 500", List.of("source-a"));
}
@Test
- public void testWildCardSources() {
+ void testWildCardSources() {
assertSources("select foo from sources * where price <= 500", List.of());
}
@Test
- public void testMultiSources() {
+ void testMultiSources() {
assertSources("select foo from sources sourceA, sourceB where price <= 500", List.of("sourceA", "sourceB"));
}
@Test
- public void testFields() {
+ void testFields() {
assertSummaryFields("select fieldA from bar where price <= 500", List.of("fieldA"));
assertSummaryFields("select fieldA, fieldB from bar where price <= 500", List.of("fieldA", "fieldB"));
assertSummaryFields("select fieldA, fieldB, fieldC from bar where price <= 500", List.of("fieldA", "fieldB", "fieldC"));
@@ -787,37 +785,37 @@ public class YqlParserTestCase {
}
@Test
- public void testFieldsRoot() {
+ void testFieldsRoot() {
assertParse("select * from bar where price <= 500", "price:[;500]");
}
@Test
- public void testOffset() {
+ void testOffset() {
assertParse("select foo from bar where title contains \"madonna\" offset 37", "title:madonna");
assertEquals(Integer.valueOf(37), parser.getOffset());
}
@Test
- public void testLimit() {
+ void testLimit() {
assertParse("select foo from bar where title contains \"madonna\" limit 29", "title:madonna");
assertEquals(Integer.valueOf(29), parser.getHits());
}
@Test
- public void testOffsetAndLimit() {
+ void testOffsetAndLimit() {
assertParse("select foo from bar where title contains \"madonna\" limit 31 offset 29",
- "title:madonna");
+ "title:madonna");
assertEquals(Integer.valueOf(29), parser.getOffset());
assertEquals(Integer.valueOf(2), parser.getHits());
assertParse("select * from bar where title contains \"madonna\" limit 41 offset 37",
- "title:madonna");
+ "title:madonna");
assertEquals(Integer.valueOf(37), parser.getOffset());
assertEquals(Integer.valueOf(4), parser.getHits());
}
@Test
- public void testTimeout() {
+ void testTimeout() {
assertParse("select * from bar where title contains \"madonna\" timeout 7", "title:madonna");
assertEquals(Integer.valueOf(7), parser.getTimeout());
@@ -826,10 +824,10 @@ public class YqlParserTestCase {
}
@Test
- public void testOrdering() {
+ void testOrdering() {
assertParse("select foo from bar where title contains \"madonna\" order by something asc, " +
- "shoesize desc limit 600 timeout 3",
- "title:madonna");
+ "shoesize desc limit 600 timeout 3",
+ "title:madonna");
assertEquals(2, parser.getSorting().fieldOrders().size());
assertEquals("something", parser.getSorting().fieldOrders().get(0).getFieldName());
assertEquals(Order.ASCENDING, parser.getSorting().fieldOrders().get(0).getSortOrder());
@@ -837,14 +835,14 @@ public class YqlParserTestCase {
assertEquals(Order.DESCENDING, parser.getSorting().fieldOrders().get(1).getSortOrder());
assertParse("select foo from bar where title contains \"madonna\" order by other limit 600 " +
- "timeout 3",
- "title:madonna");
+ "timeout 3",
+ "title:madonna");
assertEquals("other", parser.getSorting().fieldOrders().get(0).getFieldName());
assertEquals(Order.ASCENDING, parser.getSorting().fieldOrders().get(0).getSortOrder());
}
@Test
- public void testAnnotatedOrdering() {
+ void testAnnotatedOrdering() {
assertParse(
"select foo from bar where title contains \"madonna\""
+ " order by {function: \"uca\", locale: \"en_US\", strength: \"IDENTICAL\"}other desc"
@@ -860,7 +858,7 @@ public class YqlParserTestCase {
}
@Test
- public void testMultipleAnnotatedOrdering() {
+ void testMultipleAnnotatedOrdering() {
assertParse(
"select foo from bar where title contains \"madonna\""
+ " order by {\"function\": \"uca\", \"locale\": \"en_US\", \"strength\": \"IDENTICAL\"}other desc,"
@@ -886,40 +884,40 @@ public class YqlParserTestCase {
}
@Test
- public void testSegmenting() {
+ void testSegmenting() {
assertParse("select * from bar where title contains 'foo.bar'", "title:'foo bar'");
assertParse("select * from bar where title contains 'foo&123'", "title:'foo 123'");
}
@Test
- public void testNegativeHitLimit() {
+ void testNegativeHitLimit() {
assertParse("select * from sources * where {hitLimit: -38}range(foo, 0, 1)", "foo:[0;1;-38]");
}
@Test
- public void testRangeSearchHitPopulationOrdering() {
+ void testRangeSearchHitPopulationOrdering() {
assertParse("select * from sources * where {hitLimit: 38, ascending: true}range(foo, 0, 1)",
- "foo:[0;1;38]");
+ "foo:[0;1;38]");
assertParse("select * from sources * where {hitLimit: 38, ascending: false}range(foo, 0, 1)",
- "foo:[0;1;-38]");
+ "foo:[0;1;-38]");
assertParse("select * from sources * where {hitLimit: 38, descending: true}range(foo, 0, 1)",
- "foo:[0;1;-38]");
+ "foo:[0;1;-38]");
assertParse("select * from sources * where {hitLimit: 38, descending: false}range(foo, 0, 1)",
- "foo:[0;1;38]");
+ "foo:[0;1;38]");
boolean gotExceptionFromParse = false;
try {
parse("select * from sources * where {hitLimit: 38, ascending: true, descending: false}range(foo, 0, 1)");
} catch (IllegalArgumentException e) {
- assertTrue("Expected information about abuse of settings.",
- e.getMessage().contains("both ascending and descending ordering set"));
+ assertTrue(e.getMessage().contains("both ascending and descending ordering set"),
+ "Expected information about abuse of settings.");
gotExceptionFromParse = true;
}
assertTrue(gotExceptionFromParse);
}
@Test
- public void testOpenIntervals() {
+ void testOpenIntervals() {
assertParse("select * from sources * where range(title, 0.0, 500.0)",
"title:[0.0;500.0]");
assertParse(
@@ -934,7 +932,7 @@ public class YqlParserTestCase {
}
@Test
- public void testInheritedAnnotations() {
+ void testInheritedAnnotations() {
{
QueryTree x = parse("select * from sources * where ({ranked: false}(foo contains \"a\" and bar contains \"b\")) or foor contains ({ranked: false}\"c\")");
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
@@ -954,12 +952,12 @@ public class YqlParserTestCase {
}
@Test
- public void testMoreInheritedAnnotations() {
+ void testMoreInheritedAnnotations() {
String yqlQuery = "select * from sources * where " +
- "({ranked: false}(foo contains \"a\" " +
- "and ({ranked: true}(bar contains \"b\" " +
- "or ({ranked: false}(foo contains \"c\" " +
- "and foo contains ({ranked: true}\"d\")))))))";
+ "({ranked: false}(foo contains \"a\" " +
+ "and ({ranked: true}(bar contains \"b\" " +
+ "or ({ranked: false}(foo contains \"c\" " +
+ "and foo contains ({ranked: true}\"d\")))))))";
QueryTree x = parse(yqlQuery);
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(4, terms.size());
@@ -980,11 +978,11 @@ public class YqlParserTestCase {
}
@Test
- public void testFieldAliases() {
+ void testFieldAliases() {
IndexInfoConfig modelConfig = new IndexInfoConfig(new IndexInfoConfig.Builder().indexinfo(new Indexinfo.Builder()
.name("music").command(new Command.Builder().indexname("title").command("index"))
.alias(new Alias.Builder().alias("song").indexname("title"))));
- IndexModel model = new IndexModel(modelConfig, (QrSearchersConfig)null);
+ IndexModel model = new IndexModel(modelConfig, (QrSearchersConfig) null);
IndexFacts indexFacts = new IndexFacts(model);
ParserEnvironment parserEnvironment = new ParserEnvironment().setIndexFacts(indexFacts);
@@ -999,7 +997,7 @@ public class YqlParserTestCase {
}
@Test
- public void testRegexp() {
+ void testRegexp() {
QueryTree x = parse("select * from sources * where foo matches \"a b\"");
Item root = x.getRoot();
assertSame(RegExpItem.class, root.getClass());
@@ -1007,7 +1005,7 @@ public class YqlParserTestCase {
}
@Test
- public void testWordAlternatives() {
+ void testWordAlternatives() {
QueryTree x = parse("select * from sources * where foo contains alternatives({trees: 1.0, \"tree\": 0.7})");
Item root = x.getRoot();
assertSame(WordAlternativesItem.class, root.getClass());
@@ -1016,10 +1014,10 @@ public class YqlParserTestCase {
}
@Test
- public void testWordAlternativesWithOrigin() {
+ void testWordAlternativesWithOrigin() {
QueryTree q = parse("select * from sources * where foo contains" +
- " ({origin: {original: \" trees \", offset: 1, length: 5}}" +
- "alternatives({trees: 1.0, tree: 0.7}))");
+ " ({origin: {original: \" trees \", offset: 1, length: 5}}" +
+ "alternatives({trees: 1.0, tree: 0.7}))");
Item root = q.getRoot();
assertSame(WordAlternativesItem.class, root.getClass());
WordAlternativesItem alternatives = (WordAlternativesItem) root;
@@ -1032,9 +1030,9 @@ public class YqlParserTestCase {
}
@Test
- public void testWordAlternativesInPhrase() {
+ void testWordAlternativesInPhrase() {
QueryTree q = parse("select * from sources * where" +
- " foo contains phrase(\"forest\", alternatives({trees: 1.0, tree: 0.7}))");
+ " foo contains phrase(\"forest\", alternatives({trees: 1.0, tree: 0.7}))");
Item root = q.getRoot();
assertSame(PhraseItem.class, root.getClass());
PhraseItem phrase = (PhraseItem) root;
@@ -1046,7 +1044,7 @@ public class YqlParserTestCase {
/** Verifies that we can search for a backslash */
@Test
- public void testBackslash() {
+ void testBackslash() {
{
String queryString = "select * from testtype where title contains \"\\\\\""; // Java escaping * YQL escaping
@@ -1063,7 +1061,7 @@ public class YqlParserTestCase {
}
@Test
- public void testUrlHostSearchingDefaultAnchors() {
+ void testUrlHostSearchingDefaultAnchors() {
// Simple query syntax, for reference
assertUrlQuery("urlfield.hostname", new Query("?query=urlfield.hostname:google.com&type=all"), false, true, true);
@@ -1074,7 +1072,7 @@ public class YqlParserTestCase {
}
@Test
- public void testUrlHostSearchingNoAnchors() {
+ void testUrlHostSearchingNoAnchors() {
// Simple query syntax, for reference
assertUrlQuery("urlfield.hostname", new Query("?query=urlfield.hostname:google.com*&type=all"), false, false, true);
@@ -1085,7 +1083,7 @@ public class YqlParserTestCase {
}
@Test
- public void testUrlHostSearchingBothAnchors() {
+ void testUrlHostSearchingBothAnchors() {
// Simple query syntax, for reference
assertUrlQuery("urlfield.hostname", new Query("?query=urlfield.hostname:%5Egoogle.com&type=all"), true, true, true); // %5E = ^
@@ -1096,7 +1094,7 @@ public class YqlParserTestCase {
}
@Test
- public void testUriNonHostDoesNotCreateAnchors() {
+ void testUriNonHostDoesNotCreateAnchors() {
// Simple query syntax, for reference
assertUrlQuery("urlfield", new Query("?query=urlfield:google.com&type=all"), false, false, false);
@@ -1107,13 +1105,13 @@ public class YqlParserTestCase {
}
@Test
- public void testReservedWordInSource() {
+ void testReservedWordInSource() {
parse("select * from sources like where text contains \"test\"");
// success: parsed without exception
}
@Test
- public void testAndSegmenting() {
+ void testAndSegmenting() {
parse("select * from sources * where (default contains ({stem: false}\"m\") AND default contains ({origin: {original: \"m\'s\", offset: 0, length: 3}, andSegmenting: true}phrase(\"m\", \"s\"))) timeout 472");
}
@@ -1198,11 +1196,11 @@ public class YqlParserTestCase {
assertEquals(2, alternatives.getAlternatives().size());
for (WordAlternativesItem.Alternative alternative : alternatives.getAlternatives()) {
if (tree.equals(alternative.word)) {
- assertFalse("Duplicate term introduced", seenTree);
+ assertFalse(seenTree, "Duplicate term introduced");
seenTree = true;
assertEquals(.7d, alternative.exactness, 1e-15d);
} else if (forest.equals(alternative.word)) {
- assertFalse("Duplicate term introduced", seenForest);
+ assertFalse(seenForest, "Duplicate term introduced");
seenForest = true;
assertEquals(1.0d, alternative.exactness, 1e-15d);
} else {