aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/test/java/com/yahoo')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java37
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java38
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java9
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java83
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/PartialFillTestCase.java29
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/hitfield/XmlRendererTestCase.java96
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/hitfield/test/HitFieldTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java500
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/hitfield/test/TokenFieldIteratorTestCase.java30
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/ItemLabelTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/ItemsCommonStuffTestCase.java73
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/TaggableItemsTestCase.java23
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/WordAlternativesItemTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java1191
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParsingTester.java10
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/SubstringTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java50
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/parser/test/WashPhrasesTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/DotProductItemTestCase.java13
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/IntItemTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/ItemEncodingTestCase.java149
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/PhraseItemTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/PredicateQueryItemTestCase.java50
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/QueryCanonicalizerTestCase.java85
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/QueryLanguageTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/QueryTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/SameElementItemTestCase.java30
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/SegmentItemTestCase.java9
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/WandItemTestCase.java39
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/test/WeightedSetItemTestCase.java23
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/query/textualrepresentation/test/TextualQueryRepresentationTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/CJKSearcherTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/CollapsePhraseSearcherTestCase.java24
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java42
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/NoRankingSearcherTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/NonPhrasingSearcherTestCase.java64
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java24
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhraseMatcherTestCase.java289
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhrasingSearcherTestCase.java156
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/QueryRewriteTestCase.java30
-rwxr-xr-xcontainer-search/src/test/java/com/yahoo/prelude/querytransform/test/RecallSearcherTestCase.java13
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/StemmingSearcherTestCase.java60
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java141
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/FieldCollapsingSearcherTestCase.java108
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/JSONDebugSearcherTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/MultipleResultsTestCase.java50
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/PosSearcherTestCase.java34
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java23
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidateSortingSearcherTestCase.java15
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/parser/test/SemanticsParserTestCase.java28
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/AlibabaTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/AnchorTestCase.java38
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataNotTestCase.java9
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataTestCase.java69
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/BacktrackingTestCase.java38
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/BlendingTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/CJKTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonTestCase.java26
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonsTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ConditionTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ConfigurationTestCase.java29
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/DuplicateRuleTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/Ellipsis2TestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/EllipsisTestCase.java38
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTrickTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/InheritanceTestCase.java61
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/LabelMatchingTestCase.java36
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchAllTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchOnlyIfNotOnlyTermTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/MusicTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/NoStemmingTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/NotTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/NumbersTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/NumericTermsTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/Parameter2TestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ParameterTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.java13
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ProductionRuleTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseAbstractTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseTester.java2
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/SegmentSubstitutionTestCase.java11
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/SemanticSearcherTestCase.java92
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/StemmingTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/StopwordTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/SynonymTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/UrlTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/WeightingTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/GetRawWordTestCase.java17
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java46
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/IntegrationTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/LocationTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java114
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/ResultTestCase.java74
-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
-rw-r--r--container-search/src/test/java/com/yahoo/select/SelectTestCase.java205
-rw-r--r--container-search/src/test/java/com/yahoo/text/interpretation/test/AnnotationTestCase.java77
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/ListMergerTestCase.java28
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java30
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java40
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsVisitorTestCase.java24
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/MaxSamplesPerPeriodTest.java12
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/ProbabilisticSampleRateTest.java10
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/SamplingTraceExporterTest.java4
282 files changed, 8614 insertions, 8644 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
index ac860faffa5..2b560713c57 100644
--- a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
@@ -26,7 +26,7 @@ import com.yahoo.search.schema.Schema;
import com.yahoo.search.schema.SchemaInfo;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.vespa.config.search.DispatchConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,10 +38,7 @@ import java.util.List;
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.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests cluster monitoring
@@ -53,7 +50,7 @@ public class ClusterSearcherTestCase {
private static final double DELTA = 0.0000000000000001;
@Test
- public void testNoBackends() {
+ void testNoBackends() {
ClusterSearcher cluster = new ClusterSearcher(new LinkedHashSet<>(Arrays.asList("dummy")));
try {
Execution execution = new Execution(cluster, Execution.Context.createContextStub());
@@ -87,7 +84,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatDocumentTypesAreResolved() {
+ void testThatDocumentTypesAreResolved() {
ClusterSearcher cluster1 = new ClusterSearcher(new LinkedHashSet<>(Arrays.asList("type1", "type2", "type3")));
try {
ClusterSearcher type1 = new ClusterSearcher(new LinkedHashSet<>(Arrays.asList("type6")));
@@ -126,7 +123,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatDocumentTypesAreResolvedTODO_REMOVE() {
+ void testThatDocumentTypesAreResolvedTODO_REMOVE() {
ClusterSearcher cluster1 = new ClusterSearcher(new LinkedHashSet<>(List.of("type1", "type2", "type3")));
try {
ClusterSearcher type1 = new ClusterSearcher(new LinkedHashSet<>(List.of("type6")));
@@ -284,7 +281,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatSingleDocumentTypeCanBeSearched() {
+ void testThatSingleDocumentTypeCanBeSearched() {
{ // Explicit 1 type in restrict set
Execution execution = createExecution();
Query query = new Query("?query=hello&restrict=type1");
@@ -311,7 +308,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatSubsetOfDocumentTypesCanBeSearched() {
+ void testThatSubsetOfDocumentTypesCanBeSearched() {
Execution execution = createExecution();
Query query = new Query("?query=hello&restrict=type1,type3");
@@ -328,7 +325,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatMultipleDocumentTypesCanBeSearchedAndFilled() {
+ void testThatMultipleDocumentTypesCanBeSearchedAndFilled() {
Execution execution = createExecution();
Query query = new Query("?query=hello");
@@ -386,7 +383,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatWeCanSpecifyNumHitsAndHitOffset() {
+ void testThatWeCanSpecifyNumHitsAndHitOffset() {
Execution ex = createExecution();
// all types
@@ -411,7 +408,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatWeCanSpecifyNumHitsAndHitOffsetWhenSorting() {
+ void testThatWeCanSpecifyNumHitsAndHitOffsetWhenSorting() {
Execution ex = createExecution(true);
String extra = "&restrict=type1,type2&sorting=%2Basc-score";
@@ -485,7 +482,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatVipStatusIsSetUpForStreamingSearch() {
+ void testThatVipStatusIsSetUpForStreamingSearch() {
String clusterName = "test-cluster";
VipStatus vipStatus = new VipStatus(new QrSearchersConfig.Builder().searchcluster(new QrSearchersConfig.Searchcluster.Builder().name(clusterName)).build(), new ClustersStatus());
assertFalse(vipStatus.isInRotation());
@@ -494,7 +491,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatQueryTimeoutIsCappedWithDefaultMax() {
+ void testThatQueryTimeoutIsCappedWithDefaultMax() {
QueryTimeoutFixture f = new QueryTimeoutFixture(null, null);
f.query.setTimeout(600001);
f.search();
@@ -502,7 +499,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatQueryTimeoutIsNotCapped() {
+ void testThatQueryTimeoutIsNotCapped() {
QueryTimeoutFixture f = new QueryTimeoutFixture(null, null);
f.query.setTimeout(599999);
f.search();
@@ -510,7 +507,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatQueryTimeoutIsCappedWithSpecifiedMax() {
+ void testThatQueryTimeoutIsCappedWithSpecifiedMax() {
QueryTimeoutFixture f = new QueryTimeoutFixture(70.0, null);
f.query.setTimeout(70001);
f.search();
@@ -518,7 +515,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatQueryCacheIsDisabledIfTimeoutIsLargerThanMax() {
+ void testThatQueryCacheIsDisabledIfTimeoutIsLargerThanMax() {
QueryTimeoutFixture f = new QueryTimeoutFixture(null, null);
f.query.setTimeout(10001);
f.query.getRanking().setQueryCache(true);
@@ -527,7 +524,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatQueryCacheIsNotDisabledIfTimeoutIsOk() {
+ void testThatQueryCacheIsNotDisabledIfTimeoutIsOk() {
QueryTimeoutFixture f = new QueryTimeoutFixture(null, null);
f.query.setTimeout(10000);
f.query.getRanking().setQueryCache(true);
@@ -536,7 +533,7 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testThatQueryCacheIsDisabledIfTimeoutIsLargerThanConfiguredMax() {
+ void testThatQueryCacheIsDisabledIfTimeoutIsLargerThanConfiguredMax() {
QueryTimeoutFixture f = new QueryTimeoutFixture(null, 5.0);
f.query.setTimeout(5001);
f.query.getRanking().setQueryCache(true);
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java
index c39efe21e70..74874c28452 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java
@@ -16,7 +16,7 @@ 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.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -27,12 +27,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.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.*;
public class SlimeSummaryTestCase {
@@ -43,7 +38,7 @@ public class SlimeSummaryTestCase {
private static final String partial_summary3_cf = cf_pre + "partial-summary3.cfg";
@Test
- public void testDecodingEmpty() {
+ void testDecodingEmpty() {
DocsumDefinitionSet docsum = createDocsumDefinitionSet();
FastHit hit = new FastHit();
assertNull(docsum.lazyDecode("default", emptySummary(), hit));
@@ -69,23 +64,23 @@ public class SlimeSummaryTestCase {
}
@Test
- public void testTimeout() {
+ void testTimeout() {
DocsumDefinitionSet docsum = createDocsumDefinitionSet();
FastHit hit = new FastHit();
assertEquals("Hit hit index:null/0/000000000000000000000000 (relevance 0.0) [fasthit, globalid: 0 0 0 0 0 0 0 0 0 0 0 0, partId: 0, distributionkey: 0] failed: Timed out....",
- docsum.lazyDecode("default", timeoutSummary(), hit));
+ docsum.lazyDecode("default", timeoutSummary(), hit));
}
@Test
- public void testDecoding() {
+ void testDecoding() {
Tensor tensor1 = Tensor.from("tensor(x{},y{}):{{x:foo,y:bar}:0.1}");
Tensor tensor2 = Tensor.from("tensor(x[1],y[1]):{{x:0,y:0}:-0.3}");
DocsumDefinitionSet docsum = createDocsumDefinitionSet();
FastHit hit = new FastHit();
assertNull(docsum.lazyDecode("default", fullSummary(tensor1, tensor2), hit));
assertEquals(4, hit.getField("integer_field"));
- assertEquals((short)2, hit.getField("short_field"));
- assertEquals((byte)1, hit.getField("byte_field"));
+ assertEquals((short) 2, hit.getField("short_field"));
+ assertEquals((byte) 1, hit.getField("byte_field"));
assertEquals(4.5F, hit.getField("float_field"));
assertEquals(8.75, hit.getField("double_field"));
assertEquals(8L, hit.getField("int64_field"));
@@ -117,7 +112,7 @@ public class SlimeSummaryTestCase {
assertEquals(tensor2, hit.getField("tensor_field2"));
FeatureData featureData = hit.features();
assertEquals("double_feature,rankingExpression(tensor1_feature),tensor2_feature",
- featureData.featureNames().stream().sorted().collect(Collectors.joining(",")));
+ featureData.featureNames().stream().sorted().collect(Collectors.joining(",")));
assertEquals(0.5, featureData.getDouble("double_feature"), 0.00000001);
assertEquals(tensor1, featureData.getTensor("tensor1_feature"));
assertEquals(tensor1, featureData.getTensor("rankingExpression(tensor1_feature)"));
@@ -125,7 +120,7 @@ public class SlimeSummaryTestCase {
}
@Test
- public void testFieldAccessAPI() {
+ void testFieldAccessAPI() {
DocsumDefinitionSet partialDocsum1 = createPartialDocsumDefinitionSet1();
DocsumDefinitionSet partialDocsum2 = createPartialDocsumDefinitionSet2();
DocsumDefinitionSet partialDocsum3 = createPartialDocsumDefinitionSet3();
@@ -253,8 +248,8 @@ public class SlimeSummaryTestCase {
Tensor tensor2 = Tensor.from("tensor(x[1],y[1]):{{x:0,y:0}:-0.3}");
assertNull(fullDocsum.lazyDecode("default", fullishSummary(tensor1, tensor2), hit));
expected.put("integer_field", 4);
- expected.put("short_field", (short)2);
- expected.put("byte_field", (byte)1);
+ expected.put("short_field", (short) 2);
+ expected.put("byte_field", (byte) 1);
expected.put("float_field", 4.5f);
expected.put("double_field", 8.75d);
expected.put("int64_field", 8L);
@@ -303,7 +298,7 @@ public class SlimeSummaryTestCase {
for (Iterator<String> i = hit.fieldKeys().iterator(); i.hasNext(); ) {
fieldNameIteratorFieldCount++;
String name = i.next();
- assertTrue("Expected field " + name, expected.containsKey(name));
+ assertTrue(expected.containsKey(name), "Expected field " + name);
}
assertEquals(expected.size(), fieldNameIteratorFieldCount);
// fieldKeys
@@ -324,11 +319,10 @@ public class SlimeSummaryTestCase {
}
private void assertEqualMaps(Map<String, Object> expected, Map<String, Object> actual) {
- assertEquals("Map sizes", expected.size(), actual.size());
- assertEquals("Keys", expected.keySet(), actual.keySet());
+ assertEquals(expected.size(), actual.size(), "Map sizes");
+ assertEquals(expected.keySet(), actual.keySet(), "Keys");
for (var expectedEntry : expected.entrySet()) {
- assertEquals("Key '" + expectedEntry.getKey() + "'",
- expectedEntry.getValue(), actual.get(expectedEntry.getKey()));
+ assertEquals(expectedEntry.getValue(), actual.get(expectedEntry.getKey()), "Key '" + expectedEntry.getKey() + "'");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
index da9d849db90..f07ef0f733b 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java
@@ -15,15 +15,12 @@ import com.yahoo.search.schema.Schema;
import com.yahoo.slime.BinaryFormat;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.Slime;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests docsum class functionality
@@ -33,7 +30,7 @@ import static org.junit.Assert.assertTrue;
public class DocsumDefinitionTestCase {
@Test
- public void testDecoding() {
+ void testDecoding() {
DocsumDefinitionSet set = createDocsumDefinitionSet();
FastHit hit = new FastHit();
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
index d5630063f4b..dbc827ea5c2 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
@@ -30,7 +30,7 @@ import com.yahoo.search.schema.RankProfile;
import com.yahoo.search.schema.Schema;
import com.yahoo.search.schema.SchemaInfo;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
@@ -39,11 +39,7 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-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.*;
/**
@@ -54,20 +50,20 @@ import static org.junit.Assert.assertTrue;
public class FastSearcherTestCase {
@Test
- public void testNullQuery() {
+ void testNullQuery() {
Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
FastSearcher fastSearcher = new FastSearcher("container.0",
- MockDispatcher.create(Collections.emptyList()),
- new SummaryParameters(null),
- new ClusterParams("testhittype"),
- documentdbInfoConfig("test"),
- schemaInfo("test"));
+ MockDispatcher.create(Collections.emptyList()),
+ new SummaryParameters(null),
+ new ClusterParams("testhittype"),
+ documentdbInfoConfig("test"),
+ schemaInfo("test"));
String query = "?junkparam=ignored";
Result result = doSearch(fastSearcher, new Query(query), 0, 10);
ErrorMessage message = result.hits().getError();
- assertNotNull("Got error", message);
+ assertNotNull(message, "Got error");
assertEquals("Null query", message.getMessage());
assertEquals(query, message.getDetailedMessage());
assertEquals(Error.NULL_QUERY.code, message.getCode());
@@ -90,13 +86,13 @@ public class FastSearcherTestCase {
}
@Test
- public void testSinglePassGroupingIsForcedWithSingleNodeGroups() {
+ void testSinglePassGroupingIsForcedWithSingleNodeGroups() {
FastSearcher fastSearcher = new FastSearcher("container.0",
- MockDispatcher.create(List.of(new Node(0, "host0", 0))),
- new SummaryParameters(null),
- new ClusterParams("testhittype"),
- documentdbInfoConfig("test"),
- schemaInfo("test"));
+ MockDispatcher.create(List.of(new Node(0, "host0", 0))),
+ new SummaryParameters(null),
+ new ClusterParams("testhittype"),
+ documentdbInfoConfig("test"),
+ schemaInfo("test"));
Query q = new Query("?query=foo");
GroupingRequest request1 = GroupingRequest.newInstance(q);
request1.setRootOperation(new AllOperation());
@@ -113,32 +109,32 @@ public class FastSearcherTestCase {
}
@Test
- public void testRankProfileValidation() {
+ void testRankProfileValidation() {
FastSearcher fastSearcher = new FastSearcher("container.0",
- MockDispatcher.create(List.of(new Node(0, "host0", 0))),
- new SummaryParameters(null),
- new ClusterParams("testhittype"),
- documentdbInfoConfig("test"),
- schemaInfo("test"));
+ MockDispatcher.create(List.of(new Node(0, "host0", 0))),
+ new SummaryParameters(null),
+ new ClusterParams("testhittype"),
+ documentdbInfoConfig("test"),
+ schemaInfo("test"));
assertFalse(searchError("?query=q", fastSearcher).contains("does not contain requested rank profile"));
assertFalse(searchError("?query=q&ranking.profile=default", fastSearcher).contains("does not contain requested rank profile"));
assertTrue(searchError("?query=q&ranking.profile=nosuch", fastSearcher).contains("does not contain requested rank profile"));
}
@Test
- public void testSummaryNeedsQuery() {
+ void testSummaryNeedsQuery() {
var documentDb = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("test")));
var schema = new Schema.Builder("test")
- .add(new DocumentSummary.Builder("default").build())
- .add(new RankProfile.Builder("default").setHasRankFeatures(false)
- .setHasSummaryFeatures(false)
- .build());
+ .add(new DocumentSummary.Builder("default").build())
+ .add(new RankProfile.Builder("default").setHasRankFeatures(false)
+ .setHasSummaryFeatures(false)
+ .build());
FastSearcher backend = new FastSearcher("container.0",
- MockDispatcher.create(Collections.singletonList(new Node(0, "host0", 0))),
- new SummaryParameters(null),
- new ClusterParams("testhittype"),
- documentDb,
- new SchemaInfo(List.of(schema.build()), Map.of()));
+ MockDispatcher.create(Collections.singletonList(new Node(0, "host0", 0))),
+ new SummaryParameters(null),
+ new ClusterParams("testhittype"),
+ documentDb,
+ new SchemaInfo(List.of(schema.build()), Map.of()));
Query q = new Query("?query=foo");
Result result = doSearch(backend, q, 0, 10);
assertFalse(backend.summaryNeedsQuery(q));
@@ -150,15 +146,15 @@ public class FastSearcherTestCase {
}
@Test
- public void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
+ void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
MockDispatcher dispatcher = MockDispatcher.create(ImmutableList.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
FastSearcher fastSearcher = new FastSearcher("container.0",
- dispatcher,
- new SummaryParameters(null),
- new ClusterParams("testhittype"),
- documentdbInfoConfig("test"),
- schemaInfo("test"));
+ dispatcher,
+ new SummaryParameters(null),
+ new ClusterParams("testhittype"),
+ documentdbInfoConfig("test"),
+ schemaInfo("test"));
Query q = new Query("?query=foo");
GroupingRequest request1 = GroupingRequest.newInstance(q);
request1.setRootOperation(new AllOperation());
@@ -180,14 +176,13 @@ public class FastSearcherTestCase {
}
private void assertForceSinglePassIs(boolean expected, GroupingOperation operation) {
- assertEquals("Force single pass is " + expected + " in " + operation,
- expected, operation.getForceSinglePass());
+ assertEquals(expected, operation.getForceSinglePass(), "Force single pass is " + expected + " in " + operation);
for (GroupingOperation child : operation.getChildren())
assertForceSinglePassIs(expected, child);
}
@Test
- public void testDispatchReconfig() {
+ void testDispatchReconfig() {
String clusterName = "a";
var b = new QrSearchersConfig.Builder();
var searchClusterB = new QrSearchersConfig.Searchcluster.Builder();
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/PartialFillTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/PartialFillTestCase.java
index 45ae8241696..f73edfec4c5 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/PartialFillTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/PartialFillTestCase.java
@@ -12,16 +12,13 @@ import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.search.result.ErrorHit;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
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 havardpe
@@ -50,7 +47,7 @@ public class PartialFillTestCase {
}
@Test
- public void testPartitioning() {
+ void testPartitioning() {
FS4 fs4 = new FS4();
Query a = new Query("/?query=foo");
Query b = new Query("/?query=bar");
@@ -107,7 +104,7 @@ public class PartialFillTestCase {
}
@Test
- public void testMergeErrors() {
+ void testMergeErrors() {
BadFS4 fs4 = new BadFS4();
Query a = new Query("/?query=foo");
Query b = new Query("/?query=bar");
@@ -129,17 +126,17 @@ public class PartialFillTestCase {
assertNotNull(eh);
ErrorMessage exp_sub = ErrorMessage.createUnspecifiedError("error");
int n = 0;
- for (Iterator<? extends com.yahoo.search.result.ErrorMessage> i = eh.errorIterator(); i.hasNext();) {
+ for (Iterator<? extends com.yahoo.search.result.ErrorMessage> i = eh.errorIterator(); i.hasNext(); ) {
com.yahoo.search.result.ErrorMessage error = i.next();
switch (n) {
- case 0:
- assertEquals(exp_sub, error);
- break;
- case 1:
- assertEquals(exp_sub, error);
- break;
- default:
- assertTrue(false);
+ case 0:
+ assertEquals(exp_sub, error);
+ break;
+ case 1:
+ assertEquals(exp_sub, error);
+ break;
+ default:
+ assertTrue(false);
}
n++;
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/hitfield/XmlRendererTestCase.java b/container-search/src/test/java/com/yahoo/prelude/hitfield/XmlRendererTestCase.java
index f35c45e7ad6..bf020b5ca84 100644
--- a/container-search/src/test/java/com/yahoo/prelude/hitfield/XmlRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/hitfield/XmlRendererTestCase.java
@@ -2,71 +2,71 @@
package com.yahoo.prelude.hitfield;
import com.yahoo.data.access.simple.Value;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class XmlRendererTestCase {
@Test
- public void testWeightedSet1() {
+ void testWeightedSet1() {
Value.ArrayValue top = new Value.ArrayValue();
top
- .add(new Value.ArrayValue()
- .add(new Value.StringValue("per"))
- .add(new Value.LongValue(10)))
- .add(new Value.ArrayValue()
- .add(new Value.StringValue("paal"))
- .add(new Value.LongValue(20)))
- .add(new Value.ArrayValue()
- .add(new Value.StringValue("espen"))
- .add(new Value.LongValue(30)));
+ .add(new Value.ArrayValue()
+ .add(new Value.StringValue("per"))
+ .add(new Value.LongValue(10)))
+ .add(new Value.ArrayValue()
+ .add(new Value.StringValue("paal"))
+ .add(new Value.LongValue(20)))
+ .add(new Value.ArrayValue()
+ .add(new Value.StringValue("espen"))
+ .add(new Value.LongValue(30)));
String rendered = XmlRenderer.render(new StringBuilder(), top).toString();
String correct = "\n"
- + " <item weight=\"10\">per</item>\n"
- + " <item weight=\"20\">paal</item>\n"
- + " <item weight=\"30\">espen</item>\n"
- + " ";
+ + " <item weight=\"10\">per</item>\n"
+ + " <item weight=\"20\">paal</item>\n"
+ + " <item weight=\"30\">espen</item>\n"
+ + " ";
assertEquals(correct, rendered);
}
@Test
- public void testWeightedSet2() {
+ void testWeightedSet2() {
Value.ObjectValue top = new Value.ObjectValue();
top
- .put("foo", new Value.ArrayValue()
- .add(new Value.ArrayValue()
- .add(new Value.StringValue("per"))
- .add(new Value.LongValue(10)))
- .add(new Value.ArrayValue()
- .add(new Value.StringValue("paal"))
- .add(new Value.LongValue(20)))
- .add(new Value.ArrayValue()
- .add(new Value.StringValue("espen"))
- .add(new Value.LongValue(30))))
- .put("bar", new Value.ArrayValue()
- .add(new Value.ObjectValue()
- .put("item",new Value.StringValue("per"))
- .put("weight",new Value.LongValue(10)))
- .add(new Value.ObjectValue()
- .put("item",new Value.StringValue("paal"))
- .put("weight",new Value.LongValue(20)))
- .add(new Value.ObjectValue()
- .put("weight",new Value.LongValue(30))
- .put("item",new Value.StringValue("espen"))));
+ .put("foo", new Value.ArrayValue()
+ .add(new Value.ArrayValue()
+ .add(new Value.StringValue("per"))
+ .add(new Value.LongValue(10)))
+ .add(new Value.ArrayValue()
+ .add(new Value.StringValue("paal"))
+ .add(new Value.LongValue(20)))
+ .add(new Value.ArrayValue()
+ .add(new Value.StringValue("espen"))
+ .add(new Value.LongValue(30))))
+ .put("bar", new Value.ArrayValue()
+ .add(new Value.ObjectValue()
+ .put("item", new Value.StringValue("per"))
+ .put("weight", new Value.LongValue(10)))
+ .add(new Value.ObjectValue()
+ .put("item", new Value.StringValue("paal"))
+ .put("weight", new Value.LongValue(20)))
+ .add(new Value.ObjectValue()
+ .put("weight", new Value.LongValue(30))
+ .put("item", new Value.StringValue("espen"))));
String rendered = XmlRenderer.render(new StringBuilder(), top).toString();
String correct = "\n"
- + " <struct-field name=\"foo\">\n"
- + " <item weight=\"10\">per</item>\n"
- + " <item weight=\"20\">paal</item>\n"
- + " <item weight=\"30\">espen</item>\n"
- + " </struct-field>\n"
- + " <struct-field name=\"bar\">\n"
- + " <item weight=\"10\">per</item>\n"
- + " <item weight=\"20\">paal</item>\n"
- + " <item weight=\"30\">espen</item>\n"
- + " </struct-field>\n"
- + " ";
+ + " <struct-field name=\"foo\">\n"
+ + " <item weight=\"10\">per</item>\n"
+ + " <item weight=\"20\">paal</item>\n"
+ + " <item weight=\"30\">espen</item>\n"
+ + " </struct-field>\n"
+ + " <struct-field name=\"bar\">\n"
+ + " <item weight=\"10\">per</item>\n"
+ + " <item weight=\"20\">paal</item>\n"
+ + " <item weight=\"30\">espen</item>\n"
+ + " </struct-field>\n"
+ + " ";
assertEquals(correct, rendered);
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/hitfield/test/HitFieldTestCase.java b/container-search/src/test/java/com/yahoo/prelude/hitfield/test/HitFieldTestCase.java
index 7c264f40388..f6b3ee65d12 100644
--- a/container-search/src/test/java/com/yahoo/prelude/hitfield/test/HitFieldTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/hitfield/test/HitFieldTestCase.java
@@ -5,10 +5,10 @@ import java.util.ArrayList;
import java.util.List;
import com.yahoo.prelude.hitfield.HitField;
-import com.yahoo.prelude.hitfield.StringFieldPart;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import com.yahoo.prelude.hitfield.StringFieldPart;
+import org.junit.jupiter.api.Test;
/**
* Tests the HitField class
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals;
public class HitFieldTestCase {
@Test
- public void testHitField() {
+ void testHitField() {
HitField hf = new HitField("boo", "hei paa deg");
assertEquals(3, hf.getTokenizedContent().size());
List l = new ArrayList();
@@ -32,7 +32,7 @@ public class HitFieldTestCase {
}
@Test
- public void testCjk() {
+ void testCjk() {
HitField hf = new HitField("boo", "hmm\u001fgr");
assertEquals(2, hf.getTokenizedContent().size());
assertEquals("hmmgr", hf.getContent());
@@ -44,7 +44,7 @@ public class HitFieldTestCase {
}
@Test
- public void testAnnotateField() {
+ void testAnnotateField() {
HitField hf = new HitField("boo", "The <hi>Eclipse</hi> SDK \uFFF9include\uFFFAincludes\uFFFB the <hi>Eclipse</hi> Platform");
assertEquals(11, hf.getTokenizedContent().size());
hf = new HitField("boo", "\uFFF9include\uFFFAincludes\uFFFB the <hi>Eclipse</hi> Platform");
@@ -72,7 +72,7 @@ public class HitFieldTestCase {
}
@Test
- public void testEmptyField() {
+ void testEmptyField() {
HitField hf = new HitField("boo", "");
assertEquals(0, hf.getTokenizedContent().size());
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java b/container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java
index 256014b7df4..944e1e0a02f 100644
--- a/container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java
@@ -8,10 +8,10 @@ import com.yahoo.data.access.Inspector;
import com.yahoo.data.access.Type;
import com.yahoo.slime.Slime;
import com.yahoo.slime.Cursor;
-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;
/**
* Tests the JSONString XML rendering.
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue;
public class JSONStringTestCase {
@Test
- public void testWeightedSet() {
+ void testWeightedSet() {
String json = "[[{\"as1\":[\"per\",\"paal\"],\"l1\":1122334455667788997,\"d1\":87.790001,\"i1\":7,\"al1\":[11223344556677881,11223344556677883],\"s1\":\"string\\n"
+ "espa\u00F1a\\n"
+ "wssf1.s1[0]\"},10],"
@@ -44,7 +44,7 @@ public class JSONStringTestCase {
+ " <item>paal</item>\n"
+ " </struct-field>\n",
" <struct-field name=\"s1\">string\n" + "españa\n"
- + "wssf1.s1[0]</struct-field>\n" };
+ + "wssf1.s1[0]</struct-field>\n"};
String o2 = " <item weight=\"20\">\n";
String[] o2Fields = {
" <struct-field name=\"l1\">1122334455667788998</struct-field>\n",
@@ -59,7 +59,7 @@ public class JSONStringTestCase {
+ " <item>paal</item>\n"
+ " </struct-field>\n",
" <struct-field name=\"s1\">string\n"
- + "españa wssf1.s1[1]</struct-field>\n" };
+ + "españa wssf1.s1[1]</struct-field>\n"};
String rendered = js.toString();
int o1Offset = rendered.indexOf(o1);
assertTrue(-1 < o1Offset);
@@ -72,88 +72,88 @@ public class JSONStringTestCase {
}
@Test
- public void testWeightedSetFromInspector() {
+ void testWeightedSetFromInspector() {
Value.ArrayValue top = new Value.ArrayValue();
top.add(new Value.ArrayValue()
.add(new Value.ObjectValue()
- .put("d1", new Value.DoubleValue(87.790001))
- .put("s1", new Value.StringValue("string\n" + "espa\u00F1a\n" + "wssf1.s1[0]"))
- .put("al1", new Value.ArrayValue()
- .add(new Value.LongValue(11223344556677881L))
- .add(new Value.LongValue(11223344556677883L)))
- .put("l1", new Value.LongValue(1122334455667788997L))
- .put("as1", new Value.ArrayValue()
- .add(new Value.StringValue("per"))
- .add(new Value.StringValue("paal")))
- .put("i1", new Value.LongValue(7)))
+ .put("d1", new Value.DoubleValue(87.790001))
+ .put("s1", new Value.StringValue("string\n" + "espa\u00F1a\n" + "wssf1.s1[0]"))
+ .put("al1", new Value.ArrayValue()
+ .add(new Value.LongValue(11223344556677881L))
+ .add(new Value.LongValue(11223344556677883L)))
+ .put("l1", new Value.LongValue(1122334455667788997L))
+ .put("as1", new Value.ArrayValue()
+ .add(new Value.StringValue("per"))
+ .add(new Value.StringValue("paal")))
+ .put("i1", new Value.LongValue(7)))
.add(new Value.LongValue(10)))
- .add(new Value.ArrayValue()
- .add(new Value.ObjectValue()
- .put("d1", new Value.DoubleValue(88.790001))
- .put("s1", new Value.StringValue("string\n" + "espa\u00F1a wssf1.s1[1]"))
- .put("al1", new Value.ArrayValue()
- .add(new Value.LongValue(11223344556677881L))
- .add(new Value.LongValue(11223344556677883L)))
- .put("l1", new Value.LongValue(1122334455667788998L))
- .put("as1", new Value.ArrayValue()
- .add(new Value.StringValue("per"))
- .add(new Value.StringValue("paal")))
- .put("i1", new Value.LongValue(8)))
- .add(new Value.LongValue(20)));
+ .add(new Value.ArrayValue()
+ .add(new Value.ObjectValue()
+ .put("d1", new Value.DoubleValue(88.790001))
+ .put("s1", new Value.StringValue("string\n" + "espa\u00F1a wssf1.s1[1]"))
+ .put("al1", new Value.ArrayValue()
+ .add(new Value.LongValue(11223344556677881L))
+ .add(new Value.LongValue(11223344556677883L)))
+ .put("l1", new Value.LongValue(1122334455667788998L))
+ .put("as1", new Value.ArrayValue()
+ .add(new Value.StringValue("per"))
+ .add(new Value.StringValue("paal")))
+ .put("i1", new Value.LongValue(8)))
+ .add(new Value.LongValue(20)));
JSONString js = new JSONString(top);
String correct = "\n"
- + " <item weight=\"10\">\n"
- + " <struct-field name=\"d1\">87.790001</struct-field>\n"
- + " <struct-field name=\"s1\">string\n"
- + "espa\u00F1a\n"
- + "wssf1.s1[0]</struct-field>\n"
- + " <struct-field name=\"al1\">\n"
- + " <item>11223344556677881</item>\n"
- + " <item>11223344556677883</item>\n"
- + " </struct-field>\n"
- + " <struct-field name=\"l1\">1122334455667788997</struct-field>\n"
- + " <struct-field name=\"as1\">\n"
- + " <item>per</item>\n"
- + " <item>paal</item>\n"
- + " </struct-field>\n"
- + " <struct-field name=\"i1\">7</struct-field>\n"
- + " </item>\n"
- + " <item weight=\"20\">\n"
- + " <struct-field name=\"d1\">88.790001</struct-field>\n"
- + " <struct-field name=\"s1\">string\n"
- + "espa\u00F1a wssf1.s1[1]</struct-field>\n"
- + " <struct-field name=\"al1\">\n"
- + " <item>11223344556677881</item>\n"
- + " <item>11223344556677883</item>\n"
- + " </struct-field>\n"
- + " <struct-field name=\"l1\">1122334455667788998</struct-field>\n"
- + " <struct-field name=\"as1\">\n"
- + " <item>per</item>\n"
- + " <item>paal</item>\n"
- + " </struct-field>\n"
- + " <struct-field name=\"i1\">8</struct-field>\n"
- + " </item>\n"
- + " ";
+ + " <item weight=\"10\">\n"
+ + " <struct-field name=\"d1\">87.790001</struct-field>\n"
+ + " <struct-field name=\"s1\">string\n"
+ + "espa\u00F1a\n"
+ + "wssf1.s1[0]</struct-field>\n"
+ + " <struct-field name=\"al1\">\n"
+ + " <item>11223344556677881</item>\n"
+ + " <item>11223344556677883</item>\n"
+ + " </struct-field>\n"
+ + " <struct-field name=\"l1\">1122334455667788997</struct-field>\n"
+ + " <struct-field name=\"as1\">\n"
+ + " <item>per</item>\n"
+ + " <item>paal</item>\n"
+ + " </struct-field>\n"
+ + " <struct-field name=\"i1\">7</struct-field>\n"
+ + " </item>\n"
+ + " <item weight=\"20\">\n"
+ + " <struct-field name=\"d1\">88.790001</struct-field>\n"
+ + " <struct-field name=\"s1\">string\n"
+ + "espa\u00F1a wssf1.s1[1]</struct-field>\n"
+ + " <struct-field name=\"al1\">\n"
+ + " <item>11223344556677881</item>\n"
+ + " <item>11223344556677883</item>\n"
+ + " </struct-field>\n"
+ + " <struct-field name=\"l1\">1122334455667788998</struct-field>\n"
+ + " <struct-field name=\"as1\">\n"
+ + " <item>per</item>\n"
+ + " <item>paal</item>\n"
+ + " </struct-field>\n"
+ + " <struct-field name=\"i1\">8</struct-field>\n"
+ + " </item>\n"
+ + " ";
assertEquals(correct, js.renderFromInspector());
top = new Value.ArrayValue();
top.add(new Value.ArrayValue()
.add(new Value.StringValue("s1"))
.add(new Value.LongValue(10)))
- .add(new Value.ArrayValue()
- .add(new Value.StringValue("s2"))
- .add(new Value.LongValue(20)));
+ .add(new Value.ArrayValue()
+ .add(new Value.StringValue("s2"))
+ .add(new Value.LongValue(20)));
js = new JSONString(top);
correct = "\n" +
- " <item weight=\"10\">s1</item>\n" +
- " <item weight=\"20\">s2</item>\n" +
- " ";
+ " <item weight=\"10\">s1</item>\n" +
+ " <item weight=\"20\">s2</item>\n" +
+ " ";
assertEquals(correct, js.renderFromInspector());
}
@Test
- public void testStruct() {
+ void testStruct() {
{
Value.ObjectValue top = new Value.ObjectValue();
top.put("d1", new Value.DoubleValue(81.790001))
@@ -184,7 +184,7 @@ public class JSONStringTestCase {
+ " <item>per</item>\n"
+ " <item>paal</item>\n"
+ " </struct-field>\n",
- " <struct-field name=\"i1\">1</struct-field>\n" };
+ " <struct-field name=\"i1\">1</struct-field>\n"};
String rendered = js.renderFromInspector();
checkSubstrings(renderedFields, rendered);
@@ -213,7 +213,7 @@ public class JSONStringTestCase {
+ " <item>per</item>\n"
+ " <item>paal</item>\n"
+ " </struct-field>\n",
- " <struct-field name=\"i1\">4</struct-field>\n " };
+ " <struct-field name=\"i1\">4</struct-field>\n "};
String rendered = js.renderFromInspector();
checkSubstrings(renderedFields, rendered);
@@ -299,7 +299,7 @@ public class JSONStringTestCase {
String[] renderedFields = {
" <struct-field name=\"nss1\">\n",
" <struct-field name=\"s2\">string españa\n"
- + "ssf8.s2</struct-field>\n " };
+ + "ssf8.s2</struct-field>\n "};
String nss1Fields[] = {
" <struct-field name=\"al1\">\n"
+ " <item>11223344556677881</item>\n"
@@ -310,7 +310,7 @@ public class JSONStringTestCase {
" <struct-field name=\"as1\">\n"
+ " <item>per</item>\n"
+ " <item>paal</item>\n"
- + " </struct-field>\n" };
+ + " </struct-field>\n"};
checkSubstrings(renderedFields, rendered);
int nss1Offset = rendered.indexOf(renderedFields[0])
@@ -321,58 +321,58 @@ public class JSONStringTestCase {
}
@Test
- public void testMap() {
+ void testMap() {
String json = "[{\"key\":\"k1\",\"value\":\"v1\"},{\"key\":\"k2\",\"value\":\"v2\"}]";
JSONString js = new JSONString(json);
String correct = "\n"
- + " <item><key>k1</key><value>v1</value></item>\n"
- + " <item><key>k2</key><value>v2</value></item>\n ";
- assertEquals(correct,js.toString());
+ + " <item><key>k1</key><value>v1</value></item>\n"
+ + " <item><key>k2</key><value>v2</value></item>\n ";
+ assertEquals(correct, js.toString());
Inspector top = new Value.ArrayValue()
- .add(new Value.ObjectValue()
- .put("key", "k1")
- .put("value", "v1"))
- .add(new Value.ObjectValue()
- .put("key", "k2")
- .put("value", "v2"));
+ .add(new Value.ObjectValue()
+ .put("key", "k1")
+ .put("value", "v1"))
+ .add(new Value.ObjectValue()
+ .put("key", "k2")
+ .put("value", "v2"));
js = new JSONString(top);
assertEquals(correct, js.renderFromInspector());
}
@Test
- public void testWithData() {
- byte[] d1 = { (byte)0x41, (byte)0x42, (byte)0x43 };
- byte[] d2 = { (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x02 };
- byte[] d3 = { (byte)0x12, (byte)0x34 };
- byte[] d4 = { (byte)0xff, (byte)0x80, (byte)0x7f };
+ void testWithData() {
+ byte[] d1 = {(byte) 0x41, (byte) 0x42, (byte) 0x43};
+ byte[] d2 = {(byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x02};
+ byte[] d3 = {(byte) 0x12, (byte) 0x34};
+ byte[] d4 = {(byte) 0xff, (byte) 0x80, (byte) 0x7f};
Inspector top = new Value.ObjectValue()
- .put("simple", new Value.DataValue(d1))
- .put("array", new Value.ArrayValue()
- .add(new Value.DataValue(d2))
- .add(new Value.DataValue(d3))
- .add(new Value.DataValue(d4)));
+ .put("simple", new Value.DataValue(d1))
+ .put("array", new Value.ArrayValue()
+ .add(new Value.DataValue(d2))
+ .add(new Value.DataValue(d3))
+ .add(new Value.DataValue(d4)));
JSONString js = new JSONString(top);
String correct = "\n"
- + " <struct-field name=\"simple\">"
- + "<data length=\"3\" encoding=\"hex\">414243</data>"
- + "</struct-field>\n"
- + " <struct-field name=\"array\">\n"
- + " <item>"
- + "<data length=\"4\" encoding=\"hex\">00010002</data>"
- + "</item>\n"
- + " <item>"
- + "<data length=\"2\" encoding=\"hex\">1234</data>"
- + "</item>\n"
- + " <item>"
- + "<data length=\"3\" encoding=\"hex\">FF807F</data>"
- + "</item>\n"
- + " </struct-field>\n ";
+ + " <struct-field name=\"simple\">"
+ + "<data length=\"3\" encoding=\"hex\">414243</data>"
+ + "</struct-field>\n"
+ + " <struct-field name=\"array\">\n"
+ + " <item>"
+ + "<data length=\"4\" encoding=\"hex\">00010002</data>"
+ + "</item>\n"
+ + " <item>"
+ + "<data length=\"2\" encoding=\"hex\">1234</data>"
+ + "</item>\n"
+ + " <item>"
+ + "<data length=\"3\" encoding=\"hex\">FF807F</data>"
+ + "</item>\n"
+ + " </struct-field>\n ";
assertEquals(correct, js.renderFromInspector());
}
@Test
- public void testArrayOfArray() {
+ void testArrayOfArray() {
String json = "[[\"c1\", 0], [\"c2\", 2, 3], [\"c3\", 3, 4, 5], [\"c4\", 4,5,6,7]]";
JSONString js = new JSONString(json);
Inspector outer = js.inspect();
@@ -402,48 +402,48 @@ public class JSONStringTestCase {
}
@Test
- public void testSimpleArrays() {
+ void testSimpleArrays() {
String json = "[1, 2, 3]";
JSONString js = new JSONString(json);
String correct = "\n"
- + " <item>1</item>\n"
- + " <item>2</item>\n"
- + " <item>3</item>\n ";
+ + " <item>1</item>\n"
+ + " <item>2</item>\n"
+ + " <item>3</item>\n ";
assertEquals(correct, js.toString());
Inspector top = new Value.ArrayValue()
- .add(1).add(2).add(3);
+ .add(1).add(2).add(3);
js = new JSONString(top);
assertEquals(correct, js.renderFromInspector());
json = "[1.0, 2.0, 3.0]";
js = new JSONString(json);
correct = "\n"
- + " <item>1.0</item>\n"
- + " <item>2.0</item>\n"
- + " <item>3.0</item>\n ";
+ + " <item>1.0</item>\n"
+ + " <item>2.0</item>\n"
+ + " <item>3.0</item>\n ";
assertEquals(correct, js.toString());
top = new Value.ArrayValue()
- .add(1.0).add(2.0).add(3.0);
+ .add(1.0).add(2.0).add(3.0);
js = new JSONString(top);
assertEquals(correct, js.renderFromInspector());
json = "[\"a\", \"b\", \"c\"]";
correct = "\n"
- + " <item>a</item>\n"
- + " <item>b</item>\n"
- + " <item>c</item>\n ";
+ + " <item>a</item>\n"
+ + " <item>b</item>\n"
+ + " <item>c</item>\n ";
js = new JSONString(json);
assertEquals(correct, js.toString());
top = new Value.ArrayValue()
- .add("a").add("b").add("c");
+ .add("a").add("b").add("c");
js = new JSONString(top);
assertEquals(correct, js.renderFromInspector());
}
@Test
- public void testArrayOfStruct() {
+ void testArrayOfStruct() {
String json = "[{\"as1\":[\"per\",\"paal\"],"
+ "\"l1\":1122334455667788994,\"d1\":74.790001,"
+ "\"i1\":14,\"al1\":[11223344556677881,11223344556677883],\"s1\":\"string\\n"
@@ -465,7 +465,7 @@ public class JSONStringTestCase {
+ " <item>paal</item>\n"
+ " </struct-field>\n",
" <struct-field name=\"s1\">string\n" + "españa\n"
- + "asf1[0].s1</struct-field>\n" };
+ + "asf1[0].s1</struct-field>\n"};
String separator = " </item>\n" + " <item>\n";
String[] o2Fields = {
" <struct-field name=\"l1\">1122334455667788995</struct-field>\n",
@@ -480,7 +480,7 @@ public class JSONStringTestCase {
+ " <item>paal</item>\n"
+ " </struct-field>\n",
" <struct-field name=\"s1\">string\n"
- + "españa asf1[1].s1</struct-field>\n" };
+ + "españa asf1[1].s1</struct-field>\n"};
String rendered = js.toString();
int o2Offset = rendered.indexOf(separator);
@@ -535,153 +535,153 @@ public class JSONStringTestCase {
}
}
-/*** here is some json for you
-
- [{"asf":"here is 1st simple string field",
- "map":[{"key":"one key string","value":["one value string","embedded array"]},
- {"key":"two key string","value":["two value string","embedded array"]}],
- "sf2":"here is 2nd simple string field"},
- {"asf":"here is 3rd simple string field",
- "map":[{"key":"three key string","value":["three value string","embedded array"]},
- {"key":"four key string","value":["four value string","embedded array"]}],
- "sf2":"here is 4th simple string field"},
- ]
-
-***/
-
-/*** and here is some corresponding XML
-
- <item>
- <struct-field name="asf">here is 1st simple string field</struct-field>
- <struct-field name="map">
- <item><key>one key string</key><value>
- <item>one value string</item>
- <item>embedded array</item>
- </value></item>
- <item><key>two key string</key><value>
- <item>two value string</item>
- <item>embedded array</item>
- </value></item>
- </struct-field>
- <struct-field name="sf2">here is 2nd simple string field</struct-field>
- </item>
- <item>
- <struct-field name="asf">here is 3rd simple string field</struct-field>
- <struct-field name="map">
- <item><key>three key string</key><value>
- <item>three value string</item>
- <item>embedded array</item>
- </value></item>
- <item><key>four key string</key><value>
- <item>four value string</item>
- <item>embedded array</item>
- </value></item>
- </struct-field>
- <struct-field name="sf2">here is 4th simple string field</struct-field>
- </item>
-
-***/
+ /*** here is some json for you
+
+ [{"asf":"here is 1st simple string field",
+ "map":[{"key":"one key string","value":["one value string","embedded array"]},
+ {"key":"two key string","value":["two value string","embedded array"]}],
+ "sf2":"here is 2nd simple string field"},
+ {"asf":"here is 3rd simple string field",
+ "map":[{"key":"three key string","value":["three value string","embedded array"]},
+ {"key":"four key string","value":["four value string","embedded array"]}],
+ "sf2":"here is 4th simple string field"},
+ ]
+
+ ***/
+
+ /*** and here is some corresponding XML
+
+ <item>
+ <struct-field name="asf">here is 1st simple string field</struct-field>
+ <struct-field name="map">
+ <item><key>one key string</key><value>
+ <item>one value string</item>
+ <item>embedded array</item>
+ </value></item>
+ <item><key>two key string</key><value>
+ <item>two value string</item>
+ <item>embedded array</item>
+ </value></item>
+ </struct-field>
+ <struct-field name="sf2">here is 2nd simple string field</struct-field>
+ </item>
+ <item>
+ <struct-field name="asf">here is 3rd simple string field</struct-field>
+ <struct-field name="map">
+ <item><key>three key string</key><value>
+ <item>three value string</item>
+ <item>embedded array</item>
+ </value></item>
+ <item><key>four key string</key><value>
+ <item>four value string</item>
+ <item>embedded array</item>
+ </value></item>
+ </struct-field>
+ <struct-field name="sf2">here is 4th simple string field</struct-field>
+ </item>
+
+ ***/
@Test
- public void testArrayOfStructWithMap() {
+ void testArrayOfStructWithMap() {
String json = "[{\"asf\":\"here is 1st simple string field\",\"map\":[{\"key\":\"one key string\",\"value\":[\"one value string\",\"embedded array\"]},{\"key\":\"two key string\",\"value\":[\"two value string\",\"embedded array\"]}],\"sf2\":\"here is 2nd simple string field\"},{\"asf\":\"here is 3rd simple string field\",\"map\":[{\"key\":\"three key string\",\"value\":[\"three value string\",\"embedded array\"]},{\"key\":\"four key string\",\"value\":[\"four value string\",\"embedded array\"]}],\"sf2\":\"here is 4th simple string field\"}]";
JSONString js = new JSONString(json);
String correct = "\n"
- + " <item>\n"
- + " <struct-field name=\"asf\">here is 1st simple string field</struct-field>\n"
- + " <struct-field name=\"map\">\n"
- + " <item><key>one key string</key><value>\n"
- + " <item>one value string</item>\n"
- + " <item>embedded array</item>\n"
- + " </value></item>\n"
- + " <item><key>two key string</key><value>\n"
- + " <item>two value string</item>\n"
- + " <item>embedded array</item>\n"
- + " </value></item>\n"
- + " </struct-field>\n"
- + " <struct-field name=\"sf2\">here is 2nd simple string field</struct-field>\n"
- + " </item>\n"
- + " <item>\n"
- + " <struct-field name=\"asf\">here is 3rd simple string field</struct-field>\n"
- + " <struct-field name=\"map\">\n"
- + " <item><key>three key string</key><value>\n"
- + " <item>three value string</item>\n"
- + " <item>embedded array</item>\n"
- + " </value></item>\n"
- + " <item><key>four key string</key><value>\n"
- + " <item>four value string</item>\n"
- + " <item>embedded array</item>\n"
- + " </value></item>\n"
- + " </struct-field>\n"
- + " <struct-field name=\"sf2\">here is 4th simple string field</struct-field>\n"
- + " </item>\n"
- + " ";
+ + " <item>\n"
+ + " <struct-field name=\"asf\">here is 1st simple string field</struct-field>\n"
+ + " <struct-field name=\"map\">\n"
+ + " <item><key>one key string</key><value>\n"
+ + " <item>one value string</item>\n"
+ + " <item>embedded array</item>\n"
+ + " </value></item>\n"
+ + " <item><key>two key string</key><value>\n"
+ + " <item>two value string</item>\n"
+ + " <item>embedded array</item>\n"
+ + " </value></item>\n"
+ + " </struct-field>\n"
+ + " <struct-field name=\"sf2\">here is 2nd simple string field</struct-field>\n"
+ + " </item>\n"
+ + " <item>\n"
+ + " <struct-field name=\"asf\">here is 3rd simple string field</struct-field>\n"
+ + " <struct-field name=\"map\">\n"
+ + " <item><key>three key string</key><value>\n"
+ + " <item>three value string</item>\n"
+ + " <item>embedded array</item>\n"
+ + " </value></item>\n"
+ + " <item><key>four key string</key><value>\n"
+ + " <item>four value string</item>\n"
+ + " <item>embedded array</item>\n"
+ + " </value></item>\n"
+ + " </struct-field>\n"
+ + " <struct-field name=\"sf2\">here is 4th simple string field</struct-field>\n"
+ + " </item>\n"
+ + " ";
assertEquals(correct, js.toString());
Inspector top = new Value.ArrayValue()
- .add(new Value.ObjectValue()
- .put("asf", "here is 1st simple string field")
- .put("map", new Value.ArrayValue()
- .add(new Value.ObjectValue()
- .put("key", "one key string")
- .put("value", new Value.ArrayValue()
- .add("one value string")
- .add("embedded array")))
- .add(new Value.ObjectValue()
- .put("key", "two key string")
- .put("value", new Value.ArrayValue()
- .add("two value string")
- .add("embedded array"))))
- .put("sf2", "here is 2nd simple string field"))
- .add(new Value.ObjectValue()
- .put("asf", "here is 3rd simple string field")
- .put("map", new Value.ArrayValue()
- .add(new Value.ObjectValue()
- .put("key", "three key string")
- .put("value", new Value.ArrayValue()
- .add("three value string")
- .add("embedded array")))
- .add(new Value.ObjectValue()
- .put("key", "four key string")
- .put("value", new Value.ArrayValue()
- .add("four value string")
- .add("embedded array"))))
- .put("sf2", "here is 4th simple string field"));
+ .add(new Value.ObjectValue()
+ .put("asf", "here is 1st simple string field")
+ .put("map", new Value.ArrayValue()
+ .add(new Value.ObjectValue()
+ .put("key", "one key string")
+ .put("value", new Value.ArrayValue()
+ .add("one value string")
+ .add("embedded array")))
+ .add(new Value.ObjectValue()
+ .put("key", "two key string")
+ .put("value", new Value.ArrayValue()
+ .add("two value string")
+ .add("embedded array"))))
+ .put("sf2", "here is 2nd simple string field"))
+ .add(new Value.ObjectValue()
+ .put("asf", "here is 3rd simple string field")
+ .put("map", new Value.ArrayValue()
+ .add(new Value.ObjectValue()
+ .put("key", "three key string")
+ .put("value", new Value.ArrayValue()
+ .add("three value string")
+ .add("embedded array")))
+ .add(new Value.ObjectValue()
+ .put("key", "four key string")
+ .put("value", new Value.ArrayValue()
+ .add("four value string")
+ .add("embedded array"))))
+ .put("sf2", "here is 4th simple string field"));
js = new JSONString(top);
assertEquals(correct, js.renderFromInspector());
}
@Test
- public void testArrayOfStructWithEmptyMap() {
+ void testArrayOfStructWithEmptyMap() {
String json = "[{\"asf\":\"here is 1st simple string field\",\"map\":[],\"sf2\":\"here is 2nd simple string field\"},{\"asf\":\"here is 3rd simple string field\",\"map\":[],\"sf2\":\"here is 4th simple string field\"}]";
JSONString js = new JSONString(json);
String correct = "\n"
- + " <item>\n"
- + " <struct-field name=\"asf\">here is 1st simple string field</struct-field>\n"
- + " <struct-field name=\"map\"></struct-field>\n"
- + " <struct-field name=\"sf2\">here is 2nd simple string field</struct-field>\n"
- + " </item>\n"
- + " <item>\n"
- + " <struct-field name=\"asf\">here is 3rd simple string field</struct-field>\n"
- + " <struct-field name=\"map\"></struct-field>\n"
- + " <struct-field name=\"sf2\">here is 4th simple string field</struct-field>\n"
- + " </item>\n"
- + " ";
+ + " <item>\n"
+ + " <struct-field name=\"asf\">here is 1st simple string field</struct-field>\n"
+ + " <struct-field name=\"map\"></struct-field>\n"
+ + " <struct-field name=\"sf2\">here is 2nd simple string field</struct-field>\n"
+ + " </item>\n"
+ + " <item>\n"
+ + " <struct-field name=\"asf\">here is 3rd simple string field</struct-field>\n"
+ + " <struct-field name=\"map\"></struct-field>\n"
+ + " <struct-field name=\"sf2\">here is 4th simple string field</struct-field>\n"
+ + " </item>\n"
+ + " ";
assertEquals(correct, js.toString());
Inspector top = new Value.ArrayValue()
- .add(new Value.ObjectValue()
- .put("asf", "here is 1st simple string field")
- .put("map", new Value.ArrayValue())
- .put("sf2", "here is 2nd simple string field"))
- .add(new Value.ObjectValue()
- .put("asf", "here is 3rd simple string field")
- .put("map", new Value.ArrayValue())
- .put("sf2", "here is 4th simple string field"));
+ .add(new Value.ObjectValue()
+ .put("asf", "here is 1st simple string field")
+ .put("map", new Value.ArrayValue())
+ .put("sf2", "here is 2nd simple string field"))
+ .add(new Value.ObjectValue()
+ .put("asf", "here is 3rd simple string field")
+ .put("map", new Value.ArrayValue())
+ .put("sf2", "here is 4th simple string field"));
js = new JSONString(top);
assertEquals(correct, js.renderFromInspector());
@@ -718,7 +718,7 @@ public class JSONStringTestCase {
}
@Test
- public void testInspectorToContentMapping() {
+ void testInspectorToContentMapping() {
String content1 = new JSONString(getSlime1()).getContent();
String content2 = new JSONString(getSlime2()).getContent();
String content3 = new JSONString(getSlime3()).getContent();
@@ -732,7 +732,7 @@ public class JSONStringTestCase {
}
@Test
- public void testContentToInspectorMapping() {
+ void testContentToInspectorMapping() {
Inspector value1 = new JSONString("").inspect();
Inspector value2 = new JSONString("foo").inspect();
Inspector value3 = new JSONString("\"foo\"").inspect();
diff --git a/container-search/src/test/java/com/yahoo/prelude/hitfield/test/TokenFieldIteratorTestCase.java b/container-search/src/test/java/com/yahoo/prelude/hitfield/test/TokenFieldIteratorTestCase.java
index 4b59a31785a..1e689d95cee 100644
--- a/container-search/src/test/java/com/yahoo/prelude/hitfield/test/TokenFieldIteratorTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/hitfield/test/TokenFieldIteratorTestCase.java
@@ -4,11 +4,11 @@ package com.yahoo.prelude.hitfield.test;
import java.util.ListIterator;
import com.yahoo.prelude.hitfield.FieldPart;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.hitfield.HitField;
import com.yahoo.prelude.hitfield.StringFieldPart;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
/**
* Tests the FieldTokenIterator class
@@ -18,35 +18,35 @@ import static org.junit.Assert.assertEquals;
public class TokenFieldIteratorTestCase {
@Test
- public void testTokenIteratorNext() {
+ void testTokenIteratorNext() {
HitField hf = new HitField("boo", "hei paa deg");
assertEquals(3, hf.getTokenizedContent().size());
ListIterator<?> l = hf.tokenIterator();
- FieldPart p = (FieldPart)l.next();
+ FieldPart p = (FieldPart) l.next();
assertEquals("hei", p.getContent());
- p = (FieldPart)l.next();
+ p = (FieldPart) l.next();
assertEquals("paa", p.getContent());
- p = (FieldPart)l.next();
+ p = (FieldPart) l.next();
assertEquals("deg", p.getContent());
assertEquals(false, l.hasNext());
}
@Test
- public void testTokenIteratorPrevious() {
+ void testTokenIteratorPrevious() {
HitField hf = new HitField("boo", "hei paa");
ListIterator<?> l = hf.tokenIterator();
- FieldPart p = (FieldPart)l.next();
+ FieldPart p = (FieldPart) l.next();
assertEquals("hei", p.getContent());
- p = (FieldPart)l.next();
+ p = (FieldPart) l.next();
assertEquals("paa", p.getContent());
- p = (FieldPart)l.previous();
+ p = (FieldPart) l.previous();
assertEquals("paa", p.getContent());
- p = (FieldPart)l.previous();
+ p = (FieldPart) l.previous();
assertEquals("hei", p.getContent());
}
@Test
- public void testTokenIteratorSet() {
+ void testTokenIteratorSet() {
HitField hf = new HitField("boo", "hei paa deg");
assertEquals(3, hf.getTokenizedContent().size());
ListIterator<FieldPart> l = hf.tokenIterator();
@@ -61,7 +61,7 @@ public class TokenFieldIteratorTestCase {
}
@Test
- public void testTokenIteratorAdd() {
+ void testTokenIteratorAdd() {
HitField hf = new HitField("boo", "hei paa deg");
assertEquals(3, hf.getTokenizedContent().size());
ListIterator<FieldPart> l = hf.tokenIterator();
@@ -76,7 +76,7 @@ public class TokenFieldIteratorTestCase {
}
@Test
- public void testTokenIteratorRemove() {
+ void testTokenIteratorRemove() {
HitField hf = new HitField("boo", "hei paa deg");
ListIterator<FieldPart> l = hf.tokenIterator();
l.next();
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java
index 657d7fb30bc..dccf471fb04 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java
@@ -1,7 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@@ -9,8 +10,7 @@ import java.util.ArrayList;
import java.util.List;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.search.Query;
@@ -23,14 +23,14 @@ import com.yahoo.search.Query;
public class ItemHelperTestCase {
@Test
- public final void testGetNumTerms() {
+ final void testGetNumTerms() {
ItemHelper helper = new ItemHelper();
Query q = new Query("/?query=" + enc("a b c"));
assertEquals(3, helper.getNumTerms(q.getModel().getQueryTree().getRoot()));
}
@Test
- public final void testGetPositiveTerms() {
+ final void testGetPositiveTerms() {
ItemHelper helper = new ItemHelper();
Query q = new Query("/?query=" + enc("a b c \"d e\" -f"));
List<IndexedItem> l = new ArrayList<>();
@@ -52,7 +52,7 @@ public class ItemHelperTestCase {
c = true;
}
}
- assertFalse("An item is missing.", (a & b & c & d) == false);
+ assertNotNull(false);
}
private String enc(String s) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/ItemLabelTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/ItemLabelTestCase.java
index 06808d2c8d5..17a4ce400ff 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/ItemLabelTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/ItemLabelTestCase.java
@@ -3,9 +3,9 @@ package com.yahoo.prelude.query;
import java.lang.reflect.Modifier;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.Test;
import com.yahoo.search.Query;
import com.yahoo.prelude.query.textualrepresentation.Discloser;
@@ -27,13 +27,13 @@ public class ItemLabelTestCase {
}
@Test
- public final void testLabelVisibility() throws Exception {
+ final void testLabelVisibility() throws Exception {
assertTrue(Modifier.isPublic(Item.class.getMethod("setLabel", String.class).getModifiers()));
assertTrue(Modifier.isPublic(Item.class.getMethod("getLabel").getModifiers()));
}
@Test
- public final void testLabelAccess() {
+ final void testLabelAccess() {
Item item = new WordItem("word");
assertFalse(item.hasUniqueID());
assertNull(item.getLabel());
@@ -43,7 +43,7 @@ public class ItemLabelTestCase {
}
@Test
- public final void testLabelDisclose() {
+ final void testLabelDisclose() {
LabelCatcher catcher = new LabelCatcher();
Item item = new WordItem("word");
item.disclose(catcher);
@@ -54,7 +54,7 @@ public class ItemLabelTestCase {
}
@Test
- public final void testLabelEncode() {
+ final void testLabelEncode() {
Item w1 = new WordItem("w1");
Item w2 = new WordItem("w2");
Item w3 = new WordItem("w3");
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/ItemsCommonStuffTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/ItemsCommonStuffTestCase.java
index 418d7121769..f25c858a6a4 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/ItemsCommonStuffTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/ItemsCommonStuffTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -9,8 +9,7 @@ import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.regex.PatternSyntaxException;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.Item.ItemType;
/**
@@ -21,7 +20,7 @@ import com.yahoo.prelude.query.Item.ItemType;
public class ItemsCommonStuffTestCase {
@Test
- public void testLoops() {
+ void testLoops() {
AndSegmentItem as = new AndSegmentItem("farmyards", false, false);
boolean caught = false;
try {
@@ -58,7 +57,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testIndexName() {
+ void testIndexName() {
WordItem w = new WordItem("nalle");
AndItem a = new AndItem();
a.addItem(w);
@@ -68,7 +67,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testBoundaries() {
+ void testBoundaries() {
WordItem w = new WordItem("nalle");
AndItem a = new AndItem();
boolean caught = false;
@@ -102,7 +101,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testRemoving() {
+ void testRemoving() {
AndItem other = new AndItem();
WordItem w = new WordItem("nalle");
AndItem a = new AndItem();
@@ -117,7 +116,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testGeneralMutability() {
+ void testGeneralMutability() {
AndItem a = new AndItem();
assertFalse(a.isLocked());
a.lock();
@@ -125,7 +124,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testCounting() {
+ void testCounting() {
WordItem w = new WordItem("nalle");
AndItem a = new AndItem();
WordItem v = new WordItem("bamse");
@@ -139,7 +138,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testIteratorJuggling() {
+ void testIteratorJuggling() {
AndItem a = new AndItem();
WordItem w0 = new WordItem("nalle");
WordItem w1 = new WordItem("bamse");
@@ -168,7 +167,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testIdStuff() {
+ void testIdStuff() {
Item i;
String expected = "i";
i = new ExactStringItem(expected);
@@ -187,7 +186,7 @@ public class ItemsCommonStuffTestCase {
i = new WeightedSetItem("nalle");
assertEquals(ItemType.WEIGHTEDSET, i.getItemType());
assertEquals("WEIGHTEDSET", i.getName());
- i = new AndSegmentItem("",false, false);
+ i = new AndSegmentItem("", false, false);
assertEquals(ItemType.AND, i.getItemType());
assertEquals("SAND", i.getName());
i = new WeakAndItem();
@@ -196,7 +195,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testEquivBuilding() {
+ void testEquivBuilding() {
WordItem w = new WordItem("nalle");
WordItem v = new WordItem("bamse");
w.setConnectivity(v, 1.0);
@@ -206,7 +205,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public final void testEquivBuildingFromCollection() {
+ final void testEquivBuildingFromCollection() {
WordItem w = new WordItem("nalle");
WordItem v = new WordItem("bamse");
w.setConnectivity(v, 1.0);
@@ -220,7 +219,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testSegment() {
+ void testSegment() {
AndSegmentItem as = new AndSegmentItem("farmyards", false, false);
assertFalse(as.isLocked());
WordItem firstItem = new WordItem("nalle");
@@ -253,20 +252,20 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testMarkersVsWords() {
+ void testMarkersVsWords() {
WordItem mw0 = MarkerWordItem.createEndOfHost();
WordItem mw1 = MarkerWordItem.createStartOfHost();
WordItem w0 = new WordItem("$");
WordItem w1 = new WordItem("^");
assertEquals(w0.getWord(), mw0.getWord());
assertEquals(w1.getWord(), mw1.getWord());
- assertFalse(mw0.equals(w0));
- assertTrue(mw0.equals(MarkerWordItem.createEndOfHost()));
- assertFalse(w1.hashCode() == mw1.hashCode());
+ assertNotEquals(mw0, w0);
+ assertEquals(mw0, MarkerWordItem.createEndOfHost());
+ assertNotNull(mw1.hashCode());
}
@Test
- public void testNumberBasics() {
+ void testNumberBasics() {
String expected = "12";
IntItem i = new IntItem(expected, "num");
assertEquals(expected, i.stringValue());
@@ -279,12 +278,12 @@ public class ItemsCommonStuffTestCase {
assertTrue(i.isStemmed());
assertFalse(i.isWords());
assertEquals(1, i.getNumWords());
- assertFalse(i.equals(new IntItem(expected3)));
- assertTrue(i.equals(new IntItem(expected3, "num")));
+ assertNotEquals(i, new IntItem(expected3));
+ assertEquals(i, new IntItem(expected3, "num"));
}
@Test
- public void testNullItemFailsProperly() {
+ void testNullItemFailsProperly() {
NullItem n = new NullItem();
n.setIndexName("nalle");
boolean caught = false;
@@ -311,7 +310,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testNearisNotAnd() {
+ void testNearisNotAnd() {
AndItem a = new AndItem();
NearItem n = new NearItem();
n.setDistance(2);
@@ -323,14 +322,14 @@ public class ItemsCommonStuffTestCase {
fill(n);
fill(n2);
fill(n3);
- assertFalse(a.hashCode() == n.hashCode());
- assertFalse(n.equals(a));
- assertTrue(n.equals(n2));
- assertFalse(n.equals(n3));
+ assertNotNull(n.hashCode());
+ assertNotEquals(n, a);
+ assertEquals(n, n2);
+ assertNotEquals(n, n3);
}
@Test
- public void testPhraseSegmentBasics() {
+ void testPhraseSegmentBasics() {
AndSegmentItem a = new AndSegmentItem("gnurk", "gurk", false, false);
fill(a);
a.lock();
@@ -352,7 +351,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testPhraseConnectivity() {
+ void testPhraseConnectivity() {
WordItem w = new WordItem("a");
PhraseItem p = new PhraseItem();
fill(p);
@@ -362,7 +361,7 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testBaseClassPhraseSegments() {
+ void testBaseClassPhraseSegments() {
PhraseSegmentItem p = new PhraseSegmentItem("g", false, true);
fill(p);
assertEquals(4, p.encode(ByteBuffer.allocate(5000)));
@@ -373,18 +372,18 @@ public class ItemsCommonStuffTestCase {
}
@Test
- public void testTermTypeBasic() {
- assertFalse(TermType.AND.equals(TermType.DEFAULT));
- assertFalse(TermType.AND.equals(Integer.valueOf(10)));
- assertTrue(TermType.AND.equals(TermType.AND));
+ void testTermTypeBasic() {
+ assertNotEquals(TermType.AND, TermType.DEFAULT);
+ assertNotEquals(TermType.AND, Integer.valueOf(10));
+ assertEquals(TermType.AND, TermType.AND);
assertSame(AndItem.class, TermType.DEFAULT.createItemClass().getClass());
assertSame(CompositeItem.class, TermType.DEFAULT.getItemClass());
- assertFalse(TermType.AND.hashCode() == TermType.PHRASE.hashCode());
+ assertNotNull(TermType.PHRASE.hashCode());
assertEquals("term type 'not'", TermType.NOT.toString());
}
@Test
- public void testRegexp() {
+ void testRegexp() {
RegExpItem empty = new RegExpItem("a", true, "");
assertTrue(empty.isFromQuery());
assertTrue(empty.isStemmed());
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/TaggableItemsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/TaggableItemsTestCase.java
index 3d16859a79d..ec2a69fb9b0 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/TaggableItemsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/TaggableItemsTestCase.java
@@ -1,18 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
-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;
/**
* Keep CompositeTaggableItem, SimpleTaggableItem and TaggableSegmentItem in
@@ -22,11 +19,11 @@ import org.junit.Test;
*/
public class TaggableItemsTestCase {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
}
@@ -97,7 +94,7 @@ public class TaggableItemsTestCase {
}
@Test
- public void requireSimilarAPIs() {
+ void requireSimilarAPIs() {
final Method[] composite = CompositeTaggableItem.class
.getDeclaredMethods();
final Method[] simple = SimpleTaggableItem.class.getDeclaredMethods();
@@ -123,7 +120,7 @@ public class TaggableItemsTestCase {
}
@Test
- public final void testSetUniqueID() {
+ final void testSetUniqueID() {
final PhraseSegmentItem p = new PhraseSegmentItem("farmyards", false,
false);
assertFalse(p.hasUniqueID());
@@ -133,7 +130,7 @@ public class TaggableItemsTestCase {
}
@Test
- public final void testSetConnectivity() {
+ final void testSetConnectivity() {
final PhraseSegmentItem p = new PhraseSegmentItem("farmyards", false,
false);
assertEquals(0.0d, p.getConnectivity(), 1e-9);
@@ -145,7 +142,7 @@ public class TaggableItemsTestCase {
}
@Test
- public final void testSetSignificance() {
+ final void testSetSignificance() {
final PhraseSegmentItem p = new PhraseSegmentItem("farmyards", false,
false);
// unset
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/WordAlternativesItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/WordAlternativesItemTestCase.java
index 4f39e07f6d3..c246abb14da 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/WordAlternativesItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/WordAlternativesItemTestCase.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.prelude.query;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.WordAlternativesItem.Alternative;
/**
@@ -18,7 +18,7 @@ import com.yahoo.prelude.query.WordAlternativesItem.Alternative;
public class WordAlternativesItemTestCase {
@Test
- public final void testWordAlternativesItem() {
+ final void testWordAlternativesItem() {
List<Alternative> terms = new ArrayList<>();
List<Alternative> expected;
terms.add(new Alternative("1", 1.0));
@@ -35,7 +35,7 @@ public class WordAlternativesItemTestCase {
}
@Test
- public final void testSetAlternatives() {
+ final void testSetAlternatives() {
List<Alternative> terms = new ArrayList<>();
terms.add(new Alternative("1", 1.0));
terms.add(new Alternative("2", 1.0));
@@ -43,19 +43,19 @@ public class WordAlternativesItemTestCase {
terms.add(new Alternative("1", 1.5));
terms.add(new Alternative("2", 0.5));
w.setAlternatives(terms);
- assertTrue("Could not overwrite alternative",
- w.getAlternatives().stream().anyMatch((a) -> a.word.equals("1") && a.exactness == 1.5));
- assertTrue("Old alternative unexpectedly removed",
- w.getAlternatives().stream().anyMatch((a) -> a.word.equals("2") && a.exactness == 1.0));
+ assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("1") && a.exactness == 1.5),
+ "Could not overwrite alternative");
+ assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("2") && a.exactness == 1.0),
+ "Old alternative unexpectedly removed");
assertEquals(2, w.getAlternatives().size());
terms.add(new Alternative("3", 0.5));
w.setAlternatives(terms);
- assertTrue("Could not add new term",
- w.getAlternatives().stream().anyMatch((a) -> a.word.equals("3") && a.exactness == 0.5));
+ assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("3") && a.exactness == 0.5),
+ "Could not add new term");
}
@Test
- public final void testAddTerm() {
+ final void testAddTerm() {
List<Alternative> terms = new ArrayList<>();
terms.add(new Alternative("1", 1.0));
terms.add(new Alternative("2", 1.0));
@@ -63,12 +63,12 @@ public class WordAlternativesItemTestCase {
w.addTerm("1", 0.1);
assertEquals(terms, w.getAlternatives());
w.addTerm("1", 2.0);
- assertTrue("Could not add new alternative",
- w.getAlternatives().stream().anyMatch((a) -> a.word.equals("1") && a.exactness == 2.0));
+ assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("1") && a.exactness == 2.0),
+ "Could not add new alternative");
assertEquals(2, w.getAlternatives().size());
w.addTerm("3", 0.5);
- assertTrue("Could not add new term",
- w.getAlternatives().stream().anyMatch((a) -> a.word.equals("3") && a.exactness == 0.5));
+ assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("3") && a.exactness == 0.5),
+ "Could not add new term");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.java
index 5e19f2e2ae6..40911fd6e11 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.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.prelude.query.parser;
-import static org.junit.Assert.assertEquals;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test UnicodePropertyDump gives expected data.
@@ -17,7 +17,7 @@ import org.junit.Test;
public class UnicodePropertyDumpTestCase {
@Test
- public final void testMain() throws IOException {
+ final void testMain() throws IOException {
ByteArrayOutputStream toCheck;
PrintStream out;
toCheck = new ByteArrayOutputStream();
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java
index a662afcd51c..cda966f714f 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ExactMatchAndDefaultIndexTestCase.java
@@ -7,14 +7,14 @@ import com.yahoo.prelude.IndexModel;
import com.yahoo.prelude.SearchDefinition;
import com.yahoo.search.Query;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Check default index propagates correctly to the tokenizer.
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertEquals;
public class ExactMatchAndDefaultIndexTestCase {
@Test
- public void testExactMatchTokenization() {
+ void testExactMatchTokenization() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index = new Index("testexact");
index.setExact(true, null);
@@ -39,7 +39,7 @@ public class ExactMatchAndDefaultIndexTestCase {
}
@Test
- public void testDefaultIndexSpecialChars() {
+ void testDefaultIndexSpecialChars() {
Query q = new Query("?query=" + enc("dog & cat") + "&default-index=textsearch");
assertEquals("WEAKAND(100) textsearch:dog textsearch:cat", q.getModel().getQueryTree().getRoot().toString());
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java
index 77d8b2b973e..bd6b2f1f21d 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java
@@ -24,14 +24,11 @@ import com.yahoo.prelude.query.WordItem;
import com.yahoo.language.process.SpecialTokens;
import com.yahoo.prelude.query.parser.TestLinguistics;
import com.yahoo.search.Query;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Iterator;
-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.jupiter.api.Assertions.*;
/**
* Tests query parsing.
@@ -41,562 +38,562 @@ import static org.junit.Assert.assertTrue;
public class ParseTestCase {
private final ParsingTester tester = new ParsingTester();
-
+
@Test
- public void testSimpleTermQuery() {
+ void testSimpleTermQuery() {
tester.assertParsed("foobar", "foobar", Query.Type.ANY);
}
@Test
- public void testTermWithIndexPrefix() {
+ void testTermWithIndexPrefix() {
tester.assertParsed("url:foobar",
- "url:foobar",
- Query.Type.ANY);
+ "url:foobar",
+ Query.Type.ANY);
}
@Test
- public void testTermWithCatalogAndIndexPrefix() {
+ void testTermWithCatalogAndIndexPrefix() {
tester.assertParsed("normal.title:foobar", "normal.title:foobar", Query.Type.ANY);
}
@Test
- public void testMultipleTermsWithUTF8EncodingOred() {
+ void testMultipleTermsWithUTF8EncodingOred() {
tester.assertParsed("OR l\u00e5gen delta M\u00dcNICH M\u00fcnchen",
- "l\u00e5gen delta M\u00dcNICH M\u00fcnchen",
- Query.Type.ANY);
+ "l\u00e5gen delta M\u00dcNICH M\u00fcnchen",
+ Query.Type.ANY);
}
@Test
- public void testMultipleTermsWithMultiplePrefixes() {
+ void testMultipleTermsWithMultiplePrefixes() {
tester.assertParsed("RANK (+bar -normal.title:foo -baz) url:foobar",
- "url:foobar +bar -normal.title:foo -baz", Query.Type.ANY);
+ "url:foobar +bar -normal.title:foo -baz", Query.Type.ANY);
}
@Test
- public void testSimpleQueryDefaultOr() {
+ void testSimpleQueryDefaultOr() {
tester.assertParsed("OR foobar foo bar baz", "foobar foo bar baz", Query.Type.ANY);
}
@Test
- public void testOrAndNot() {
+ void testOrAndNot() {
tester.assertParsed("RANK (+(AND baz bar) -xyzzy -foobaz) foobar foo",
- "foobar +baz foo -xyzzy -foobaz +bar", Query.Type.ANY);
+ "foobar +baz foo -xyzzy -foobaz +bar", Query.Type.ANY);
}
@Test
- public void testSimpleOrNestedAnd() {
+ void testSimpleOrNestedAnd() {
tester.assertParsed("RANK (OR foo bar baz) foobar xyzzy",
- "foobar +(foo bar baz) xyzzy", Query.Type.ANY);
+ "foobar +(foo bar baz) xyzzy", Query.Type.ANY);
}
@Test
- public void testSimpleOrNestedNot() {
+ void testSimpleOrNestedNot() {
tester.assertParsed("+(OR foobar xyzzy) -(AND foo bar baz)",
- "foobar -(foo bar baz) xyzzy", Query.Type.ANY);
+ "foobar -(foo bar baz) xyzzy", Query.Type.ANY);
}
@Test
- public void testOrNotNestedAnd() {
+ void testOrNotNestedAnd() {
tester.assertParsed("RANK (+(AND baz (OR foo bar baz) bar) -xyzzy -foobaz) foobar foo",
- "foobar +baz foo -xyzzy +(foo bar baz) -foobaz +bar",
- Query.Type.ANY);
+ "foobar +baz foo -xyzzy +(foo bar baz) -foobaz +bar",
+ Query.Type.ANY);
}
@Test
- public void testOrAndNotNestedNot() {
+ void testOrAndNotNestedNot() {
tester.assertParsed("RANK (+(AND baz bar) -xyzzy -(AND foo bar baz) -foobaz) foobar foo",
- "foobar +baz foo -xyzzy -(foo bar baz) -foobaz +bar",
- Query.Type.ANY);
+ "foobar +baz foo -xyzzy -(foo bar baz) -foobaz +bar",
+ Query.Type.ANY);
}
@Test
- public void testOrMultipleNestedAnd() {
+ void testOrMultipleNestedAnd() {
tester.assertParsed("RANK (AND (OR fo ba foba) (OR foz baraz)) foobar foo bar baz",
- "foobar +(fo ba foba) foo bar +(foz baraz) baz",
- Query.Type.ANY);
+ "foobar +(fo ba foba) foo bar +(foz baraz) baz",
+ Query.Type.ANY);
}
@Test
- public void testOrMultipleNestedNot() {
+ void testOrMultipleNestedNot() {
tester.assertParsed("+(OR foobar foo bar baz) -(AND fo ba foba) -(AND foz baraz)",
- "foobar -(fo ba foba) foo bar -(foz baraz) baz",
- Query.Type.ANY);
+ "foobar -(fo ba foba) foo bar -(foz baraz) baz",
+ Query.Type.ANY);
}
@Test
- public void testOrAndNotMultipleNestedAnd() {
+ void testOrAndNotMultipleNestedAnd() {
tester.assertParsed("RANK (+(AND baz (OR foo bar baz) (OR foz bazaz) bar) -xyzzy -foobaz) foobar foo",
- "foobar +baz foo -xyzzy +(foo bar baz) -foobaz +(foz bazaz) +bar",
- Query.Type.ANY);
+ "foobar +baz foo -xyzzy +(foo bar baz) -foobaz +(foz bazaz) +bar",
+ Query.Type.ANY);
}
@Test
- public void testOrAndNotMultipleNestedNot() {
+ void testOrAndNotMultipleNestedNot() {
tester.assertParsed("RANK (+(AND baz bar) -xyzzy -(AND foo bar baz) -foobaz -(AND foz bazaz)) foobar foo",
- "foobar +baz foo -xyzzy -(foo bar baz) -foobaz -(foz bazaz) +bar",
- Query.Type.ANY);
+ "foobar +baz foo -xyzzy -(foo bar baz) -foobaz -(foz bazaz) +bar",
+ Query.Type.ANY);
}
@Test
- public void testOrMultipleNestedAndNot() {
+ void testOrMultipleNestedAndNot() {
tester.assertParsed("RANK (+(AND (OR ffoooo bbaarr) (OR oof rab raboof)) -(AND fo ba foba) -(AND foz baraz)) foobar foo bar baz",
- "foobar -(fo ba foba) foo +(ffoooo bbaarr) bar +(oof rab raboof) -(foz baraz) baz",
- Query.Type.ANY);
+ "foobar -(fo ba foba) foo +(ffoooo bbaarr) bar +(oof rab raboof) -(foz baraz) baz",
+ Query.Type.ANY);
}
@Test
- public void testOrAndNotMultipleNestedAndNot() {
+ void testOrAndNotMultipleNestedAndNot() {
tester.assertParsed("RANK (+(AND (OR ffoooo bbaarr) (OR oof rab raboof) baz xyxyzzy) -(AND fo ba foba) -foo -bar -(AND foz baraz)) foobar",
- "foobar -(fo ba foba) -foo +(ffoooo bbaarr) -bar +(oof rab raboof) -(foz baraz) +baz +xyxyzzy",
- Query.Type.ANY);
+ "foobar -(fo ba foba) -foo +(ffoooo bbaarr) -bar +(oof rab raboof) -(foz baraz) +baz +xyxyzzy",
+ Query.Type.ANY);
}
@Test
- public void testExplicitPhrase() {
+ void testExplicitPhrase() {
Item root = tester.assertParsed("\"foo bar foobar\"", "\"foo bar foobar\"", Query.Type.ANY);
assertTrue(root instanceof PhraseItem);
- assertTrue(((PhraseItem)root).isExplicit());
+ assertTrue(((PhraseItem) root).isExplicit());
}
@Test
- public void testPhraseWithIndex() {
+ void testPhraseWithIndex() {
tester.assertParsed("normal.title:\"foo bar foobar\"",
- "normal.title:\"foo bar foobar\"", Query.Type.ANY);
+ "normal.title:\"foo bar foobar\"", Query.Type.ANY);
}
@Test
- public void testPhrasesAndTerms() {
+ void testPhrasesAndTerms() {
tester.assertParsed("OR \"foo bar foobar\" xyzzy \"baz gaz faz\"",
- "\"foo bar foobar\" xyzzy \"baz gaz faz\"", Query.Type.ANY);
+ "\"foo bar foobar\" xyzzy \"baz gaz faz\"", Query.Type.ANY);
}
@Test
- public void testPhrasesAndTermsWithOperators() {
+ void testPhrasesAndTermsWithOperators() {
tester.assertParsed("RANK (+(AND \"baz gaz faz\" bazar) -\"foo bar foobar\") foofoo xyzzy",
- "foofoo -\"foo bar foobar\" xyzzy +\"baz gaz faz\" +bazar",
- Query.Type.ANY);
+ "foofoo -\"foo bar foobar\" xyzzy +\"baz gaz faz\" +bazar",
+ Query.Type.ANY);
}
@Test
- public void testSimpleTermQueryDefaultAnd() {
+ void testSimpleTermQueryDefaultAnd() {
tester.assertParsed("foobar", "foobar", Query.Type.ALL);
}
@Test
- public void testTermWithCatalogAndIndexPrefixDefaultAnd() {
+ void testTermWithCatalogAndIndexPrefixDefaultAnd() {
tester.assertParsed("normal.title:foobar", "normal.title:foobar", Query.Type.ALL);
}
@Test
- public void testMultipleTermsWithMultiplePrefixesDefaultAnd() {
+ void testMultipleTermsWithMultiplePrefixesDefaultAnd() {
tester.assertParsed("+(AND url:foobar bar) -normal.title:foo -baz",
- "url:foobar +bar -normal.title:foo -baz",
- Query.Type.ALL);
+ "url:foobar +bar -normal.title:foo -baz",
+ Query.Type.ALL);
}
@Test
- public void testSimpleQueryDefaultAnd() {
+ void testSimpleQueryDefaultAnd() {
tester.assertParsed("AND foobar foo bar baz", "foobar foo bar baz", Query.Type.ALL);
}
@Test
- public void testNotDefaultAnd() {
+ void testNotDefaultAnd() {
tester.assertParsed("+(AND foobar (OR foo bar baz) xyzzy) -(AND foz baraz bazar)",
- "foobar +(foo bar baz) xyzzy -(foz baraz bazar)",
- Query.Type.ALL);
+ "foobar +(foo bar baz) xyzzy -(foz baraz bazar)",
+ Query.Type.ALL);
}
@Test
- public void testSimpleTermQueryDefaultPhrase() {
+ void testSimpleTermQueryDefaultPhrase() {
tester.assertParsed("foobar",
- "foobar",
- Query.Type.PHRASE);
+ "foobar",
+ Query.Type.PHRASE);
}
@Test
- public void testSimpleQueryDefaultPhrase() {
+ void testSimpleQueryDefaultPhrase() {
Item root = tester.assertParsed("\"foobar foo bar baz\"",
- "foobar foo bar baz",
- Query.Type.PHRASE);
+ "foobar foo bar baz",
+ Query.Type.PHRASE);
assertTrue(root instanceof PhraseItem);
- assertFalse(((PhraseItem)root).isExplicit());
+ assertFalse(((PhraseItem) root).isExplicit());
}
@Test
- public void testMultipleTermsWithMultiplePrefixesDefaultPhrase() {
+ void testMultipleTermsWithMultiplePrefixesDefaultPhrase() {
tester.assertParsed("\"url foobar bar normal title foo baz\"",
- "url:foobar +bar -normal.title:foo -baz",
- Query.Type.PHRASE);
+ "url:foobar +bar -normal.title:foo -baz",
+ Query.Type.PHRASE);
}
@Test
- public void testOdd1() {
+ void testOdd1() {
tester.assertParsed("AND window print error", "+window.print() +error",
- Query.Type.ALL);
+ Query.Type.ALL);
}
@Test
- public void testOdd2() {
+ void testOdd2() {
tester.assertParsed("normal.title:kaboom", "normal.title:\"kaboom\"",
- Query.Type.ALL);
+ Query.Type.ALL);
}
@Test
- public void testOdd2Uppercase() {
+ void testOdd2Uppercase() {
tester.assertParsed("normal.title:KABOOM", "NORMAL.TITLE:\"KABOOM\"", Query.Type.ALL);
}
@Test
- public void testOdd3() {
+ void testOdd3() {
tester.assertParsed("AND foo (OR size.all:[200;300] date.all:512)",
"foo +(size.all:[200;300] date.all:512)", Query.Type.ALL);
}
@Test
- public void testNullQuery() {
+ void testNullQuery() {
tester.assertParsed(null, null, Query.Type.ALL);
}
@Test
- public void testEmptyQuery() {
+ void testEmptyQuery() {
tester.assertParsed(null, "", Query.Type.ALL);
}
@Test
- public void testNotOnly() {
+ void testNotOnly() {
tester.assertParsed(null, "-foobar", Query.Type.ALL);
}
@Test
- public void testMultipleNotsOnlt() {
+ void testMultipleNotsOnlt() {
tester.assertParsed(null, "-foo -bar -foobar", Query.Type.ALL);
}
@Test
- public void testOnlyNotComposite() {
+ void testOnlyNotComposite() {
tester.assertParsed(null, "-(foo bar baz)", Query.Type.ALL);
}
@Test
- public void testNestedCompositesDefaultOr() {
+ void testNestedCompositesDefaultOr() {
tester.assertParsed("RANK (OR foobar bar baz) foo xyzzy",
- "foo +(foobar +(bar baz)) xyzzy", Query.Type.ANY);
+ "foo +(foobar +(bar baz)) xyzzy", Query.Type.ANY);
}
@Test
- public void testNestedCompositesDefaultAnd() {
+ void testNestedCompositesDefaultAnd() {
tester.assertParsed("AND foo (OR foobar bar baz) xyzzy",
- "foo +(foobar +(bar baz)) xyzzy", Query.Type.ALL);
+ "foo +(foobar +(bar baz)) xyzzy", Query.Type.ALL);
}
@Test
- public void testNestedCompositesPhraseDefault() {
+ void testNestedCompositesPhraseDefault() {
tester.assertParsed("\"foo foobar bar baz xyzzy\"",
- "foo +(foobar +(bar baz)) xyzzy", Query.Type.PHRASE);
+ "foo +(foobar +(bar baz)) xyzzy", Query.Type.PHRASE);
}
@Test
- public void testNumeric() {
+ void testNumeric() {
tester.assertParsed("34", "34", Query.Type.ANY);
}
@Test
- public void testGreaterNumeric() {
+ void testGreaterNumeric() {
tester.assertParsed("<454", "<454", Query.Type.ANY);
}
@Test
- public void testGreaterNumericWithIndex() {
- IntItem item = (IntItem)tester.assertParsed("score:<454", "score:<454", Query.Type.ANY);
+ void testGreaterNumericWithIndex() {
+ IntItem item = (IntItem) tester.assertParsed("score:<454", "score:<454", Query.Type.ANY);
assertEquals("score", item.getIndexName());
assertEquals(454L, item.getToLimit().number());
assertFalse(item.getToLimit().isInclusive());
}
@Test
- public void testSmallerNumeric() {
+ void testSmallerNumeric() {
tester.assertParsed(">454", ">454", Query.Type.ANY);
}
@Test
- public void testSmallerNumericWithIndex() {
- IntItem item = (IntItem)tester.assertParsed("score:>454", "score:>454", Query.Type.ANY);
+ void testSmallerNumericWithIndex() {
+ IntItem item = (IntItem) tester.assertParsed("score:>454", "score:>454", Query.Type.ANY);
assertEquals("score", item.getIndexName());
assertEquals(454L, item.getFromLimit().number());
assertFalse(item.getFromLimit().isInclusive());
}
@Test
- public void testFullRange() {
+ void testFullRange() {
tester.assertParsed("[34;454]", "[34;454]", Query.Type.ANY);
}
@Test
- public void testFullRangeLimit() {
+ void testFullRangeLimit() {
tester.assertParsed("[34;454;7]", "[34;454;7]", Query.Type.ANY);
tester.assertParsed("[34;454;-7]", "[34;454;-7]", Query.Type.ANY);
}
@Test
- public void testLowOpenRange() {
+ void testLowOpenRange() {
tester.assertParsed("[;454]", "[;454]", Query.Type.ANY);
}
@Test
- public void testHiOpenRange() {
+ void testHiOpenRange() {
tester.assertParsed("[34;]", "[34;]", Query.Type.ANY);
}
@Test
- public void testNumericWithIndex() {
+ void testNumericWithIndex() {
tester.assertParsed("document.size:[34;454]", "document.size:[34;454]", Query.Type.ANY);
}
@Test
- public void testMultipleNumeric() {
+ void testMultipleNumeric() {
tester.assertParsed("OR [34;454] <34", "[34;454] <34", Query.Type.ANY);
}
@Test
- public void testMultipleIntegerWithIndex() {
+ void testMultipleIntegerWithIndex() {
tester.assertParsed("OR document.size:[34;454] date:>1234567890",
- "document.size:[34;454] date:>1234567890", Query.Type.ANY);
+ "document.size:[34;454] date:>1234567890", Query.Type.ANY);
}
@Test
- public void testMixedNumericAndOtherTerms() {
+ void testMixedNumericAndOtherTerms() {
tester.assertParsed("RANK (AND document.size:<1024 xyzzy) foo date:>123456890",
- "foo +document.size:<1024 +xyzzy date:>123456890",
- Query.Type.ANY);
+ "foo +document.size:<1024 +xyzzy date:>123456890",
+ Query.Type.ANY);
}
@Test
- public void testEmptyPhrase() {
+ void testEmptyPhrase() {
tester.assertParsed("\"to be or not\"", "\"\"to be or not", Query.Type.ANY);
}
@Test
- public void testItemPhraseEmptyPhrase() {
+ void testItemPhraseEmptyPhrase() {
tester.assertParsed("RANK to \"or not to be\"", "+to\"or not to be\"\"\"", Query.Type.ANY);
}
@Test
- public void testSimpleQuery() {
+ void testSimpleQuery() {
tester.assertParsed("OR if am \"f g 4 2\" maybe", "if am \" f g 4 2\"\" maybe", Query.Type.ANY);
}
@Test
- public void testExcessivePluses() {
+ void testExcessivePluses() {
tester.assertParsed("+(AND other is nothing) -test",
- "++other +++++is ++++++nothing -test", Query.Type.ANY);
+ "++other +++++is ++++++nothing -test", Query.Type.ANY);
}
@Test
- public void testMinusAndPluses() {
+ void testMinusAndPluses() {
tester.assertParsed(null, "--test+-if", Query.Type.ANY);
}
@Test
- public void testPlusesAndMinuses() {
+ void testPlusesAndMinuses() {
tester.assertParsed("AND a b c d d", "a+b+c+d--d", Query.Type.ANY);
}
@Test
- public void testNumbers() {
+ void testNumbers() {
tester.assertParsed("AND 123 2132odfd 934032 32423", "123+2132odfd.934032,,32423", Query.Type.ANY);
}
@Test
- public void testOtherSignsInQuote() {
+ void testOtherSignsInQuote() {
tester.assertParsed("AND 0032 4 320 24329043", "0032+4\\320.24329043", Query.Type.ANY);
}
@Test
- public void testGribberish() {
+ void testGribberish() {
tester.assertParsed("1349832840234l3040roer\u00e6lf12",
- ",1349832840234l3040roer\u00e6lf12",
- Query.Type.ANY);
+ ",1349832840234l3040roer\u00e6lf12",
+ Query.Type.ANY);
}
@Test
- public void testUrl() {
+ void testUrl() {
tester.assertParsed("AND www:www www:hotelaiguablava www:com",
- "+www:www.hotelaiguablava:com",
- Query.Type.ANY);
+ "+www:www.hotelaiguablava:com",
+ Query.Type.ANY);
}
@Test
- public void testUrlGribberish() {
+ void testUrlGribberish() {
tester.assertParsed("OR (AND 3 16) fast.type:lycosoffensive",
- "[ 3:16 fast.type:lycosoffensive",
- Query.Type.ANY);
+ "[ 3:16 fast.type:lycosoffensive",
+ Query.Type.ANY);
}
@Test
- public void testBracedWordAny() {
+ void testBracedWordAny() {
tester.assertParsed("foo", "(foo)", Query.Type.ANY);
}
@Test
- public void testBracedWordAll() {
+ void testBracedWordAll() {
tester.assertParsed("foo", "(foo)", Query.Type.ALL);
}
@Test
- public void testBracedWords() {
+ void testBracedWords() {
tester.assertParsed("OR (OR foo bar) (OR xyzzy foobar)",
"(foo bar) (xyzzy foobar)", Query.Type.ANY);
}
@Test
- public void testNullAdvanced() {
+ void testNullAdvanced() {
tester.assertParsed(null, null, Query.Type.ADVANCED);
}
@Test
- public void testEmptyAdvanced() {
+ void testEmptyAdvanced() {
tester.assertParsed(null, "", Query.Type.ADVANCED);
}
@Test
- public void testSimpleAdvanced() {
+ void testSimpleAdvanced() {
tester.assertParsed("foobar", "foobar", Query.Type.ADVANCED);
}
@Test
- public void testPrefixAdvanced() {
+ void testPrefixAdvanced() {
tester.assertParsed("url:foobar", "url:foobar", Query.Type.ADVANCED);
}
@Test
- public void testPrefixWithDotAdvanced() {
+ void testPrefixWithDotAdvanced() {
tester.assertParsed("normal.title:foobar", "normal.title:foobar", Query.Type.ADVANCED);
}
@Test
- public void testUTF8Advanced() {
+ void testUTF8Advanced() {
tester.assertParsed("m\u00fcnchen", "m\u00fcnchen", Query.Type.ADVANCED);
}
@Test
- public void testSimplePhraseAdvanced() {
+ void testSimplePhraseAdvanced() {
tester.assertParsed("\"foo bar foobar\"", "\"foo bar foobar\"", Query.Type.ADVANCED);
}
@Test
- public void testSimplePhraseWithIndexAdvanced() {
+ void testSimplePhraseWithIndexAdvanced() {
tester.assertParsed("normal.title:\"foo bar foobar\"",
- "normal.title:\"foo bar foobar\"",
- Query.Type.ADVANCED);
+ "normal.title:\"foo bar foobar\"",
+ Query.Type.ADVANCED);
}
@Test
- public void testMultiplePhrasesAdvanced() {
+ void testMultiplePhrasesAdvanced() {
tester.assertParsed("AND \"foo bar foobar\" \"baz gaz faz\"",
- "\"foo bar foobar\" and \"baz gaz faz\"",
- Query.Type.ADVANCED);
+ "\"foo bar foobar\" and \"baz gaz faz\"",
+ Query.Type.ADVANCED);
}
@Test
- public void testNumberAdvanced() {
+ void testNumberAdvanced() {
tester.assertParsed("34", "34", Query.Type.ADVANCED);
}
@Test
- public void testLargerNumberAdvanced() {
+ void testLargerNumberAdvanced() {
tester.assertParsed("<454", "<454", Query.Type.ADVANCED);
}
@Test
- public void testLesserNumberAdvanced() {
+ void testLesserNumberAdvanced() {
tester.assertParsed(">454", ">454", Query.Type.ADVANCED);
}
@Test
- public void testRangeAdvanced() {
+ void testRangeAdvanced() {
tester.assertParsed("[34;454]", "[34;454]", Query.Type.ADVANCED);
}
@Test
- public void testLowOpenRangeAdvanced() {
+ void testLowOpenRangeAdvanced() {
tester.assertParsed("[;454]", "[;454]", Query.Type.ADVANCED);
}
@Test
- public void testHighOpenRangeAdvanced() {
+ void testHighOpenRangeAdvanced() {
tester.assertParsed("[34;]", "[34;]", Query.Type.ADVANCED);
}
@Test
- public void testIdexedRangeAdvanced() {
+ void testIdexedRangeAdvanced() {
tester.assertParsed("document.size:[34;454]", "document.size:[34;454]", Query.Type.ADVANCED);
}
@Test
- public void testSimpleAndAdvanced() {
+ void testSimpleAndAdvanced() {
tester.assertParsed("AND foo bar", "foo and bar", Query.Type.ADVANCED);
}
@Test
- public void testSimpleOrAdvanced() {
+ void testSimpleOrAdvanced() {
tester.assertParsed("OR foo bar", "foo or bar", Query.Type.ADVANCED);
}
@Test
- public void testSimpleAndNotAdvanced() {
+ void testSimpleAndNotAdvanced() {
tester.assertParsed("+foo -bar", "foo andnot bar", Query.Type.ADVANCED);
}
@Test
- public void testSimpleRankAdvanced() {
+ void testSimpleRankAdvanced() {
tester.assertParsed("RANK foo bar", "foo rank bar", Query.Type.ADVANCED);
}
@Test
- public void testMultipleAndAdvanced() {
+ void testMultipleAndAdvanced() {
tester.assertParsed("AND foo bar foobar", "foo and bar and foobar", Query.Type.ADVANCED);
}
@Test
- public void testMultipleOrAdvanced() {
+ void testMultipleOrAdvanced() {
tester.assertParsed("OR foo bar foobar", "foo or bar or foobar", Query.Type.ADVANCED);
}
@Test
- public void testMultipleAndnotAdvanced() {
+ void testMultipleAndnotAdvanced() {
tester.assertParsed("+foo -bar -foobar", "foo andnot bar andnot foobar", Query.Type.ADVANCED);
}
@Test
- public void testMultipleRankAdvanced() {
+ void testMultipleRankAdvanced() {
tester.assertParsed("RANK foo bar foobar", "foo rank bar rank foobar", Query.Type.ADVANCED);
}
@Test
- public void testMixedAdvanced() {
+ void testMixedAdvanced() {
tester.assertParsed("OR (AND foo bar) foobar", "foo and bar or foobar", Query.Type.ADVANCED);
}
@Test
- public void testNestedAdvanced() {
+ void testNestedAdvanced() {
tester.assertParsed("AND foo (OR bar foobar)", "foo and (bar or foobar)", Query.Type.ADVANCED);
}
@Test
- public void testMultipleNestedAdvanced() {
+ void testMultipleNestedAdvanced() {
tester.assertParsed("+(AND foo xyzzy) -(OR bar foobar)",
- "(foo and xyzzy) andnot (bar or foobar)", Query.Type.ADVANCED);
+ "(foo and xyzzy) andnot (bar or foobar)", Query.Type.ADVANCED);
}
@Test
- public void testDoubleNestedAdvanced() {
+ void testDoubleNestedAdvanced() {
tester.assertParsed("AND foo (OR bar (OR xyzzy foobar))",
- "foo and (bar or (xyzzy or foobar))", Query.Type.ADVANCED);
+ "foo and (bar or (xyzzy or foobar))", Query.Type.ADVANCED);
}
@Test
- public void testDeeplyAdvanced() {
+ void testDeeplyAdvanced() {
tester.assertParsed(
"AND foo (OR bar (OR (AND (AND baz (+(OR bazar zyxxy) -fozbaz)) (OR boz bozor) xyzzy) foobar))",
"foo and (bar or ((baz and ((bazar or zyxxy) andnot fozbaz)) and (boz or bozor) and xyzzy or foobar))",
@@ -604,7 +601,7 @@ public class ParseTestCase {
}
@Test
- public void testDeeplyAdvancedUppercase() {
+ void testDeeplyAdvancedUppercase() {
tester.assertParsed(
"AND FOO (OR BAR (OR (AND (AND BAZ (+(OR BAZAR ZYXXY) -FOZBAZ)) (OR BOZ BOZOR) XYZZY) FOOBAR))",
"FOO AND (BAR OR ((BAZ AND ((BAZAR OR ZYXXY) ANDNOT FOZBAZ)) AND (BOZ OR BOZOR) AND XYZZY OR FOOBAR))",
@@ -612,230 +609,230 @@ public class ParseTestCase {
}
@Test
- public void testAbortedIntegerRange() {
+ void testAbortedIntegerRange() {
tester.assertParsed("AND audio.audall:744 audio.audall:ph",
"+audio.audall:[744 +audio.audall:ph", Query.Type.ANY);
}
@Test
- public void testJunk() {
+ void testJunk() {
tester.assertParsed("+l -fast.type:offensive",
",;'/.<l:>? -fast.type:offensive", Query.Type.ALL);
}
@Test
- public void testOneTermPhraseWithIndex() {
+ void testOneTermPhraseWithIndex() {
tester.assertParsed("normal.title:foo", "normal.title:\"foo\"", Query.Type.ANY);
}
@Test
- public void testOneTermPhraseWithIndexAdvanced() {
+ void testOneTermPhraseWithIndexAdvanced() {
tester.assertParsed("normal.title:foo", "normal.title:\"foo\"", Query.Type.ADVANCED);
}
@Test
- public void testIncorrect1Advanced() {
+ void testIncorrect1Advanced() {
tester.assertParsed("\"to be or not\"", "\"\"to be or not", Query.Type.ADVANCED);
}
@Test
- public void testIncorrect2Advanced() {
+ void testIncorrect2Advanced() {
tester.assertParsed("AND to \"or not to be\"", "+to\"or not to be\"\"\"", Query.Type.ADVANCED);
}
@Test
- public void testIncorrect3Advanced() {
+ void testIncorrect3Advanced() {
tester.assertParsed("AND if am \"f g 4 2\" maybe",
"if am \" f g 4 2\"\" maybe", Query.Type.ADVANCED);
}
@Test
- public void testIncorrect4Advanced() {
+ void testIncorrect4Advanced() {
tester.assertParsed("AND other is nothing test",
"++other +++++is ++++++nothing -test", Query.Type.ADVANCED);
}
@Test
- public void testImplicitPhrase1Advanced() {
+ void testImplicitPhrase1Advanced() {
tester.assertParsed("AND test if", "--test+-if", Query.Type.ADVANCED);
}
@Test
- public void testImplicitPhrase2Advanced() {
+ void testImplicitPhrase2Advanced() {
tester.assertParsed("AND a b c d d", "a+b+c+d--d", Query.Type.ADVANCED);
}
@Test
- public void testImplicitPhrase3Advanced() {
+ void testImplicitPhrase3Advanced() {
tester.assertParsed("AND 123 2132odfd 934032 32423",
"123+2132odfd.934032,,32423", Query.Type.ADVANCED);
}
@Test
- public void testImplicitPhrase4Advanced() {
+ void testImplicitPhrase4Advanced() {
tester.assertParsed("AND 0032 4 320 24329043", "0032+4\\320.24329043", Query.Type.ADVANCED);
}
@Test
- public void testUtf8Advanced() {
+ void testUtf8Advanced() {
tester.assertParsed("1349832840234l3040roer\u00e6lf12",
",1349832840234l3040roer\u00e6lf12", Query.Type.ADVANCED);
}
@Test
- public void testOperatorSearchAdvanced() {
+ void testOperatorSearchAdvanced() {
tester.assertParsed("RANK (OR (AND and and) or andnot) rank",
"and and and or or or andnot rank rank", Query.Type.ADVANCED);
}
@Test
- public void testIncorrectParenthesisAdvanced() {
+ void testIncorrectParenthesisAdvanced() {
tester.assertParsed("AND foo bar", "foo and bar )", Query.Type.ADVANCED);
}
@Test
- public void testOpeningParenthesisOnlyAdvanced() {
+ void testOpeningParenthesisOnlyAdvanced() {
tester.assertParsed("AND foo (OR bar (AND foobar xyzzy))",
"(foo and (bar or (foobar and xyzzy", Query.Type.ADVANCED);
}
@Test
- public void testSimpleWeight() {
+ void testSimpleWeight() {
tester.assertParsed("foo!150", "foo!", Query.Type.ANY);
}
@Test
- public void testMultipleWeight() {
+ void testMultipleWeight() {
tester.assertParsed("foo!250", "foo!!!", Query.Type.ANY);
}
@Test
- public void testExplicitWeight() {
+ void testExplicitWeight() {
tester.assertParsed("foo!200", "foo!200", Query.Type.ANY);
}
@Test
- public void testExplicitZeroWeight() {
+ void testExplicitZeroWeight() {
tester.assertParsed("foo!0", "foo!0", Query.Type.ANY);
}
@Test
- public void testSimplePhraseWeight() {
+ void testSimplePhraseWeight() {
tester.assertParsed("\"foo bar\"!150", "\"foo bar\"!", Query.Type.ANY);
}
@Test
- public void testSingleHyphen() {
+ void testSingleHyphen() {
tester.assertParsed("AND a b", "a-b", Query.Type.ALL);
}
@Test
- public void testUserCase() {
+ void testUserCase() {
tester.assertParsed("\"a a\"", "\"a- a-*\"", Query.Type.ALL);
}
@Test
- public void testMultiplePhraseWeight() {
+ void testMultiplePhraseWeight() {
tester.assertParsed("\"foo bar\"!250", "\"foo bar\"!!!", Query.Type.ANY);
}
@Test
- public void testExplicitPhraseWeight() {
+ void testExplicitPhraseWeight() {
tester.assertParsed("\"foo bar\"!200", "\"foo bar\"!200", Query.Type.ANY);
}
@Test
- public void testUrlSubmodeHyphen() {
+ void testUrlSubmodeHyphen() {
assertTrue(ParsingTester.createIndexFacts().newSession(new Query()).getIndex("url.all").isUriIndex());
tester.assertParsed("url.all:\"www-microsoft com\"", "url.all:www-microsoft.com", Query.Type.ANY);
}
@Test
- public void testUrlSubmodeUnderscore() {
+ void testUrlSubmodeUnderscore() {
tester.assertParsed("url.all:\"www_microsoft com\"", "url.all:www_microsoft.com", Query.Type.ANY);
}
@Test
- public void testUrlSubmode() {
+ void testUrlSubmode() {
tester.assertParsed("host.all:\"www-microsoft com $\"", "host.all:www-microsoft.com", Query.Type.ANY);
}
@Test
- public void testExplicitHostNameAnchoringHost() {
+ void testExplicitHostNameAnchoringHost() {
tester.assertParsed("host.all:\"^ www-microsoft com $\"", "host.all:^www-microsoft.com$", Query.Type.ANY);
}
@Test
- public void testExplicitHostNameAnchoringSite() {
+ void testExplicitHostNameAnchoringSite() {
tester.assertParsed("site:\"^ www-microsoft com $\"", "site:^www-microsoft.com$", Query.Type.ANY);
}
@Test
- public void testExplicitHostNameAnchoring() {
+ void testExplicitHostNameAnchoring() {
tester.assertParsed("host.all:\"^ http www krangaz-central com index html $\"",
"host.all:^http://www.krangaz-central.com/index.html$",
Query.Type.ANY);
}
@Test
- public void testExplicitHostAnchoringRemoval() {
+ void testExplicitHostAnchoringRemoval() {
tester.assertParsed("host.all:\"www-microsoft com\"",
"host.all:www-microsoft.com*", Query.Type.ANY);
}
@Test
- public void testQuery1Any() {
+ void testQuery1Any() {
tester.assertParsed("RANK (AND fast \"search engine\") kernel",
"+fast +\"search engine\" kernel", Query.Type.ANY);
}
@Test
- public void testQuery1Advanced() {
+ void testQuery1Advanced() {
tester.assertParsed("RANK (AND fast \"search engine\") kernel",
"+fast and \"search engine\" rank kernel", Query.Type.ADVANCED);
}
@Test
- public void testQuery2Any() {
+ void testQuery2Any() {
tester.assertParsed("+(OR title:car bmw) -z3", "title:car bmw -z3",
Query.Type.ANY);
}
@Test
- public void testQuery2Advanced() {
+ void testQuery2Advanced() {
tester.assertParsed("+(OR title:car bmw) -z3", "title:car or bmw andnot z3", Query.Type.ADVANCED);
}
@Test
- public void testQuery3All() {
+ void testQuery3All() {
tester.assertParsed("+(AND FAST search domain:no pagedepth:0) -title:phrase",
- "FAST search -title:phrase domain:no Pagedepth:0",
- Query.Type.ALL);
+ "FAST search -title:phrase domain:no Pagedepth:0",
+ Query.Type.ALL);
}
@Test
- public void testQuery4Advanced() {
+ void testQuery4Advanced() {
tester.assertParsed("AND (+(AND FAST search) -title:phrase) domain:no pagedepth:0",
- "FAST and search andnot title:phrase and domain:no and Pagedepth:0",
- Query.Type.ADVANCED);
+ "FAST and search andnot title:phrase and domain:no and Pagedepth:0",
+ Query.Type.ADVANCED);
}
@Test
- public void testQuery5Any() {
+ void testQuery5Any() {
tester.assertParsed("AND alltheweb fast search", "+alltheweb +fast +search", Query.Type.ANY);
}
@Test
- public void testQuery6Any() {
+ void testQuery6Any() {
tester.assertParsed("RANK (+(AND query language) -sql) search", "+query +language -sql search", Query.Type.ANY);
}
@Test
- public void testQuery7Any() {
+ void testQuery7Any() {
tester.assertParsed(
"+(AND alltheweb (OR search engine)) -(OR excite altavista)",
"(alltheweb and (search or engine)) andnot (excite or altavista)",
@@ -843,7 +840,7 @@ public class ParseTestCase {
}
@Test
- public void testQuery8Advanced() {
+ void testQuery8Advanced() {
tester.assertParsed(
"RANK (AND \"search engines\" \"query processing\") \"fast search\"",
"(\"search engines\" and \"query processing\") rank \"fast search\"",
@@ -851,132 +848,132 @@ public class ParseTestCase {
}
@Test
- public void testPStrangeAdvanced() {
+ void testPStrangeAdvanced() {
tester.assertParsed("AND AND r.s:jnl", "( AND +r.s:jnl) ", Query.Type.ADVANCED);
}
@Test
- public void testEmptyNestAdvanced() {
+ void testEmptyNestAdvanced() {
tester.assertParsed(null, "() ", Query.Type.ADVANCED);
}
@Test
- public void testNestedBeginningAdvanced() {
+ void testNestedBeginningAdvanced() {
tester.assertParsed("AND (OR a b) c", "(a or b) and c", Query.Type.ADVANCED);
}
@Test
- public void testNestedPositiveAny() {
+ void testNestedPositiveAny() {
tester.assertParsed("AND (OR a b) c", "+(a b) +c", Query.Type.ANY);
}
@Test
- public void testParseAdvancedQuery() {
+ void testParseAdvancedQuery() {
tester.assertParsed("AND joplin remediation r.s:jnl",
"(joplin and + and remediation and +r.s:jnl)",
Query.Type.ADVANCED);
}
@Test
- public void testSimpleDotPhraseAny() {
+ void testSimpleDotPhraseAny() {
tester.assertParsed("OR a (AND b c) d", "a b.c d", Query.Type.ANY);
}
@Test
- public void testSimpleHyphenPhraseAny() {
+ void testSimpleHyphenPhraseAny() {
tester.assertParsed("OR a (AND b c) d", "a b-c d", Query.Type.ANY);
}
@Test
- public void testAnotherSimpleDotPhraseAny() {
+ void testAnotherSimpleDotPhraseAny() {
tester.assertParsed("OR (AND a b) c d", "a.b c d", Query.Type.ANY);
}
@Test
- public void testYetAnotherSimpleDotPhraseAny() {
+ void testYetAnotherSimpleDotPhraseAny() {
tester.assertParsed("OR a b (AND c d)", "a b c.d", Query.Type.ANY);
}
@Test
- public void testVariousSeparatorsPhraseAny() {
+ void testVariousSeparatorsPhraseAny() {
tester.assertParsed("AND a b c d", "a-b.c%d", Query.Type.ANY);
}
@Test
- public void testDoublyMarkedPhraseAny() {
+ void testDoublyMarkedPhraseAny() {
tester.assertParsed("OR a \"b c\" d", "a \"b.c\" d", Query.Type.ANY);
}
@Test
- public void testPartlyDoublyMarkedPhraseAny() {
+ void testPartlyDoublyMarkedPhraseAny() {
tester.assertParsed("OR a \"b c d\"", "a \"b.c d\"", Query.Type.ANY);
}
@Test
- public void testIndexedDottedPhraseAny() {
+ void testIndexedDottedPhraseAny() {
tester.assertParsed("OR a (AND url:b url:c) d", "a url:b.c d", Query.Type.ANY);
}
@Test
- public void testIndexedPlusedPhraseAny() {
+ void testIndexedPlusedPhraseAny() {
tester.assertParsed("OR a (AND normal.title:b normal.title:c) d", "a normal.title:b+c d", Query.Type.ANY);
}
@Test
- public void testNestedNotAny() {
+ void testNestedNotAny() {
tester.assertParsed(
"RANK (+(OR normal.title:foobar (AND url:www url:pvv url:org)) -foo) a",
"a +(normal.title:foobar url:www.pvv.org) -foo", Query.Type.ANY);
}
@Test
- public void testDottedPhraseAdvanced() {
+ void testDottedPhraseAdvanced() {
tester.assertParsed("OR a (AND b c)", "a or b.c", Query.Type.ADVANCED);
}
@Test
- public void testHyphenPhraseAdvanced() {
+ void testHyphenPhraseAdvanced() {
tester.assertParsed("OR (AND a (AND b c)) d", "a and b-c or d", Query.Type.ADVANCED);
}
@Test
- public void testAnotherDottedPhraseAdvanced() {
+ void testAnotherDottedPhraseAdvanced() {
tester.assertParsed("OR (AND a b) c", "a.b or c", Query.Type.ADVANCED);
}
@Test
- public void testNottedDottedPhraseAdvanced() {
+ void testNottedDottedPhraseAdvanced() {
tester.assertParsed("+a -(AND c d)", "a andnot c.d", Query.Type.ADVANCED);
}
@Test
- public void testVariousSeparatorsPhraseAdvanced() {
+ void testVariousSeparatorsPhraseAdvanced() {
tester.assertParsed("AND a b c d", "a-b.c%d", Query.Type.ADVANCED);
}
@Test
- public void testDoublyPhrasedAdvanced() {
+ void testDoublyPhrasedAdvanced() {
tester.assertParsed("OR (AND a \"b c\") d", "a and \"b.c\" or d", Query.Type.ADVANCED);
}
@Test
- public void testPartlyDoublyPhrasedAdvanced() {
+ void testPartlyDoublyPhrasedAdvanced() {
tester.assertParsed("OR a \"b c d\"", "a or \"b.c d\"", Query.Type.ADVANCED);
}
@Test
- public void testNestedDottedPhraseAdvanced() {
+ void testNestedDottedPhraseAdvanced() {
tester.assertParsed("AND a (OR url:\"b c\" d)", "a and(url:\"b.c\" or d)", Query.Type.ADVANCED);
}
@Test
- public void testNestedPlussedPhraseAdvanced() {
+ void testNestedPlussedPhraseAdvanced() {
tester.assertParsed("AND (OR a (AND normal.title:b normal.title:c)) d",
"a or normal.title:b+c and d", Query.Type.ADVANCED);
}
@Test
- public void testNottedNestedDottedPhraseAdvanced() {
+ void testNottedNestedDottedPhraseAdvanced() {
tester.assertParsed(
"+(AND a (OR normal.title:foobar (AND url:www url:pvv url:org))) -foo",
"a and (normal.title:foobar or url:www.pvv.org) andnot foo",
@@ -984,570 +981,570 @@ public class ParseTestCase {
}
@Test
- public void testPlusedThenQuotedPhraseAny() {
+ void testPlusedThenQuotedPhraseAny() {
tester.assertParsed("\"a b c\"", "a+\"b c\"", Query.Type.ANY);
}
@Test
- public void testPlusedTwiceThenQuotedPhraseAny() {
+ void testPlusedTwiceThenQuotedPhraseAny() {
tester.assertParsed("AND a b c d", "a+b+\"c d\"", Query.Type.ANY);
}
@Test
- public void testPlusedThenQuotedPhraseAdvanced() {
+ void testPlusedThenQuotedPhraseAdvanced() {
tester.assertParsed("\"a b c\"", "a+\"b c\"", Query.Type.ADVANCED);
}
@Test
- public void testPhrasesInBraces() {
+ void testPhrasesInBraces() {
tester.assertParsed("AND url.domain:microsoft url.domain:com",
"+(url.domain:microsoft.com)", Query.Type.ALL);
}
@Test
- public void testDoublyPhrasedPhrasesInBraces() {
+ void testDoublyPhrasedPhrasesInBraces() {
tester.assertParsed("url.domain:\"microsoft com\"",
"+(url.domain:\"microsoft.com\")", Query.Type.ALL);
}
@Test
- public void testSinglePrefixTerm() {
+ void testSinglePrefixTerm() {
Item root = tester.assertParsed("prefix*", "prefix*", Query.Type.ANY);
assertTrue(root instanceof PrefixItem);
}
@Test
- public void testSingleSubstringTerm() {
+ void testSingleSubstringTerm() {
Item root = tester.assertParsed("*substring*", "*substring*", Query.Type.ANY);
assertTrue(root instanceof SubstringItem);
}
@Test
- public void testSingleSuffixTerm() {
+ void testSingleSuffixTerm() {
Item root = tester.assertParsed("*suffix", "*suffix", Query.Type.ANY);
assertTrue(root instanceof SuffixItem);
}
@Test
- public void testPrefixAndWordTerms() {
+ void testPrefixAndWordTerms() {
Item root = tester.assertParsed("OR foo prefix* bar", "foo prefix* bar", Query.Type.ANY);
- assertTrue(((OrItem)root).getItem(1) instanceof PrefixItem);
+ assertTrue(((OrItem) root).getItem(1) instanceof PrefixItem);
}
@Test
- public void testSubstringAndWordTerms() {
+ void testSubstringAndWordTerms() {
Item root = tester.assertParsed("OR foo *substring* bar", "foo *substring* bar", Query.Type.ANY);
- assertTrue(((OrItem)root).getItem(1) instanceof SubstringItem);
+ assertTrue(((OrItem) root).getItem(1) instanceof SubstringItem);
}
@Test
- public void testSuffixAndWordTerms() {
+ void testSuffixAndWordTerms() {
Item root = tester.assertParsed("OR foo *suffix bar", "foo *suffix bar", Query.Type.ANY);
- assertTrue(((OrItem)root).getItem(1) instanceof SuffixItem);
+ assertTrue(((OrItem) root).getItem(1) instanceof SuffixItem);
}
@Test
- public void testPhraseNotPrefix() {
+ void testPhraseNotPrefix() {
tester.assertParsed("OR foo (AND prefix bar)", "foo prefix*bar", Query.Type.ANY);
}
@Test
- public void testPhraseNotSubstring() {
+ void testPhraseNotSubstring() {
tester.assertParsed("OR foo (AND substring bar)", "foo *substring*bar", Query.Type.ANY);
}
@Test
- public void testPhraseNotSuffix() {
+ void testPhraseNotSuffix() {
tester.assertParsed("OR (AND foo suffix) bar", "foo*suffix bar", Query.Type.ANY);
}
@Test
- public void testIndexedPrefix() {
+ void testIndexedPrefix() {
Item root = tester.assertParsed("foo.bar:prefix*", "foo.bar:prefix*", Query.Type.ANY);
assertTrue(root instanceof PrefixItem);
}
@Test
- public void testIndexedSubstring() {
+ void testIndexedSubstring() {
Item root = tester.assertParsed("foo.bar:*substring*", "foo.bar:*substring*", Query.Type.ANY);
assertTrue(root instanceof SubstringItem);
}
@Test
- public void testIndexedSuffix() {
+ void testIndexedSuffix() {
Item root = tester.assertParsed("foo.bar:*suffix", "foo.bar:*suffix", Query.Type.ANY);
assertTrue(root instanceof SuffixItem);
}
@Test
- public void testIndexedPhraseNotPrefix() {
+ void testIndexedPhraseNotPrefix() {
tester.assertParsed("AND foo.bar:prefix foo.bar:xyzzy", "foo.bar:prefix*xyzzy", Query.Type.ANY);
}
@Test
- public void testIndexedPhraseNotSubstring() {
+ void testIndexedPhraseNotSubstring() {
tester.assertParsed("AND foo.bar:substring foo.bar:xyzzy", "foo.bar:*substring*xyzzy", Query.Type.ANY);
}
@Test
- public void testIndexedPhraseNotSuffix() {
+ void testIndexedPhraseNotSuffix() {
tester.assertParsed("AND foo.bar:xyzzy foo.bar:suffix", "foo.bar:xyzzy*suffix", Query.Type.ANY);
}
@Test
- public void testPrefixWithWeight() {
+ void testPrefixWithWeight() {
Item root = tester.assertParsed("prefix*!200", "prefix*!200", Query.Type.ANY);
assertTrue(root instanceof PrefixItem);
}
@Test
- public void testSubstringWithWeight() {
+ void testSubstringWithWeight() {
Item root = tester.assertParsed("*substring*!200", "*substring*!200", Query.Type.ANY);
assertTrue(root instanceof SubstringItem);
}
@Test
- public void testSuffixWithWeight() {
+ void testSuffixWithWeight() {
Item root = tester.assertParsed("*suffix!200", "*suffix!200", Query.Type.ANY);
assertTrue(root instanceof SuffixItem);
}
/** Non existing index → and **/
@Test
- public void testNonIndexPhraseNotPrefix() {
+ void testNonIndexPhraseNotPrefix() {
tester.assertParsed("AND void prefix", "void:prefix*", Query.Type.ANY);
}
@Test
- public void testNonIndexPhraseNotSubstring() {
+ void testNonIndexPhraseNotSubstring() {
tester.assertParsed("AND void substring", "void:*substring*", Query.Type.ANY);
}
@Test
- public void testNonIndexPhraseNotSuffix() {
+ void testNonIndexPhraseNotSuffix() {
tester.assertParsed("AND void suffix", "void:*suffix", Query.Type.ANY);
}
/** Explicit phrase → remove '*' **/
@Test
- public void testExplicitPhraseNotPrefix() {
+ void testExplicitPhraseNotPrefix() {
tester.assertParsed("\"prefix bar\"", "\"prefix* bar\"", Query.Type.ANY);
}
@Test
- public void testExplicitPhraseNotSubstring() {
+ void testExplicitPhraseNotSubstring() {
tester.assertParsed("\"substring bar\"", "\"*substring* bar\"", Query.Type.ANY);
}
@Test
- public void testExplicitPhraseNotSuffix() {
+ void testExplicitPhraseNotSuffix() {
tester.assertParsed("\"suffix bar\"", "\"*suffix bar\"", Query.Type.ANY);
}
/** Extra star is ignored */
@Test
- public void testPrefixExtraStar() {
+ void testPrefixExtraStar() {
Item root = tester.assertParsed("prefix*", "prefix**", Query.Type.ANY);
assertTrue(root instanceof PrefixItem);
}
@Test
- public void testSubstringExtraStar() {
+ void testSubstringExtraStar() {
Item root = tester.assertParsed("*substring*", "**substring**", Query.Type.ANY);
assertTrue(root instanceof SubstringItem);
}
@Test
- public void testSuffixExtraStar() {
+ void testSuffixExtraStar() {
Item root = tester.assertParsed("*suffix", "**suffix", Query.Type.ANY);
assertTrue(root instanceof SuffixItem);
}
@Test
- public void testPrefixExtraSpace() {
+ void testPrefixExtraSpace() {
Item root = tester.assertParsed("prefix", "prefix *", Query.Type.ANY);
assertTrue(root instanceof WordItem);
}
@Test
- public void testSubstringExtraSpace() {
+ void testSubstringExtraSpace() {
Item root = tester.assertParsed("*substring*", "* substring*", Query.Type.ANY);
assertTrue(root instanceof SubstringItem);
}
@Test
- public void testSubstringExtraSpace2() {
+ void testSubstringExtraSpace2() {
Item root = tester.assertParsed("*substring", "* substring *", Query.Type.ANY);
assertTrue(root instanceof SuffixItem);
}
@Test
- public void testSuffixExtraSpace() {
+ void testSuffixExtraSpace() {
Item root = tester.assertParsed("*suffix", "* suffix", Query.Type.ANY);
assertTrue(root instanceof SuffixItem);
}
/** Extra spaces with index **/
@Test
- public void testIndexPrefixExtraSpace() {
+ void testIndexPrefixExtraSpace() {
tester.assertParsed("AND foo prefix", "foo:prefix *", Query.Type.ANY);
}
@Test
- public void testIndexSubstringExtraSpace() {
+ void testIndexSubstringExtraSpace() {
Item root = tester.assertParsed("OR foo substring*", "foo:* substring*", Query.Type.ANY);
- assertTrue(((OrItem)root).getItem(0) instanceof WordItem);
- assertTrue(((OrItem)root).getItem(1) instanceof PrefixItem);
+ assertTrue(((OrItem) root).getItem(0) instanceof WordItem);
+ assertTrue(((OrItem) root).getItem(1) instanceof PrefixItem);
}
@Test
- public void testIndexSubstringExtraSpace2() {
+ void testIndexSubstringExtraSpace2() {
Item root = tester.assertParsed("OR foo substring", "foo:* substring *", Query.Type.ANY);
- assertTrue(((OrItem)root).getItem(0) instanceof WordItem);
- assertTrue(((OrItem)root).getItem(1) instanceof WordItem);
+ assertTrue(((OrItem) root).getItem(0) instanceof WordItem);
+ assertTrue(((OrItem) root).getItem(1) instanceof WordItem);
}
@Test
- public void testIndexSuffixExtraSpace() {
+ void testIndexSuffixExtraSpace() {
Item root = tester.assertParsed("OR foo suffix", "foo:* suffix", Query.Type.ANY);
- assertTrue(((OrItem)root).getItem(0) instanceof WordItem);
- assertTrue(((OrItem)root).getItem(1) instanceof WordItem);
+ assertTrue(((OrItem) root).getItem(0) instanceof WordItem);
+ assertTrue(((OrItem) root).getItem(1) instanceof WordItem);
}
/** Various tests for prefix, substring, and suffix terms **/
@Test
- public void testTermsWithStarsAndSpaces() {
+ void testTermsWithStarsAndSpaces() {
tester.assertParsed("OR foo *bar", "foo * bar", Query.Type.ANY);
}
@Test
- public void testTermsWithStarsAndSpaces2() {
+ void testTermsWithStarsAndSpaces2() {
tester.assertParsed("OR foo *bar *baz", "foo * * bar * * baz", Query.Type.ANY);
}
@Test
- public void testTermsWithStarsAndPlussAndMinus() {
+ void testTermsWithStarsAndPlussAndMinus() {
tester.assertParsed("+(AND *bar baz*) -*foo*", "+*bar -*foo* +baz*", Query.Type.ANY);
}
@Test
- public void testTermsWithStarsAndPlussAndMinus2() {
+ void testTermsWithStarsAndPlussAndMinus2() {
tester.assertParsed("OR *bar *foo baz", "+ * bar - * foo * + baz *", Query.Type.ANY);
}
@Test
- public void testTermsWithStarsAndExclamation() {
+ void testTermsWithStarsAndExclamation() {
tester.assertParsed("OR foo* 200 *bar* 200 *baz 200", "foo* !200 *bar* !200 *baz !200", Query.Type.ANY);
}
@Test
- public void testTermsWithStarsAndExclamation2() {
+ void testTermsWithStarsAndExclamation2() {
tester.assertParsed("OR foo 200 *bar 200", "foo *!200 *bar *!200", Query.Type.ANY);
}
@Test
- public void testTermsWithStarsAndParenthesis() {
+ void testTermsWithStarsAndParenthesis() {
tester.assertParsed("RANK *baz *bar* foo*", "(foo*) (*bar*) (*baz)", Query.Type.ANY);
}
@Test
- public void testTermsWithStarsAndParenthesis2() {
+ void testTermsWithStarsAndParenthesis2() {
tester.assertParsed("RANK baz bar foo", "(foo)* *(bar)* *(baz)", Query.Type.ANY);
}
@Test
- public void testSimpleAndFilter() {
+ void testSimpleAndFilter() {
tester.assertParsed("AND bar |foo", "bar", "+foo", Query.Type.ANY);
}
@Test
- public void testSimpleRankFilter() {
+ void testSimpleRankFilter() {
tester.assertParsed("RANK bar |foo", "bar", "foo", Query.Type.ANY);
}
@Test
- public void testSimpleNotFilter() {
+ void testSimpleNotFilter() {
tester.assertParsed("+bar -|foo", "bar", "-foo", Query.Type.ANY);
}
@Test
- public void testSimpleCompoundFilter1() {
+ void testSimpleCompoundFilter1() {
tester.assertParsed("RANK (AND bar |foo1) |foo2", "bar", "+foo1 foo2",
Query.Type.ANY);
}
@Test
- public void testSimpleCompoundFilter2() {
+ void testSimpleCompoundFilter2() {
tester.assertParsed("+(AND bar |foo1) -|foo3", "bar", "+foo1 -foo3",
Query.Type.ANY);
}
@Test
- public void testSimpleCompoundFilter3() {
+ void testSimpleCompoundFilter3() {
tester.assertParsed("RANK (+bar -|foo3) |foo2", "bar", "foo2 -foo3",
Query.Type.ANY);
}
@Test
- public void testSimpleCompoundFilter4() {
+ void testSimpleCompoundFilter4() {
tester.assertParsed("RANK (+(AND bar |foo1) -|foo3) |foo2", "bar",
"+foo1 foo2 -foo3", Query.Type.ANY);
}
@Test
- public void testAndFilterEmptyQuery() {
+ void testAndFilterEmptyQuery() {
tester.assertParsed("|foo", "", "+foo", Query.Type.ANY);
}
@Test
- public void testRankFilterEmptyQuery() {
+ void testRankFilterEmptyQuery() {
tester.assertParsed("|foo", "", "foo", Query.Type.ANY);
}
@Test
- public void testNotFilterEmptyQuery() {
+ void testNotFilterEmptyQuery() {
tester.assertParsed(null, "", "-foo", Query.Type.ANY);
}
@Test
- public void testCompoundFilter1EmptyQuery() {
+ void testCompoundFilter1EmptyQuery() {
tester.assertParsed("RANK |foo1 |foo2", "", "+foo1 foo2", Query.Type.ANY);
}
@Test
- public void testCompoundFilter2EmptyQuery() {
+ void testCompoundFilter2EmptyQuery() {
tester.assertParsed("+|foo1 -|foo3", "", "+foo1 -foo3", Query.Type.ANY);
}
@Test
- public void testCompoundFilter3EmptyQuery() {
+ void testCompoundFilter3EmptyQuery() {
tester.assertParsed("+|foo2 -|foo3", "", "foo2 -foo3", Query.Type.ANY);
}
@Test
- public void testCompoundFilter4EmptyQuery() {
+ void testCompoundFilter4EmptyQuery() {
tester.assertParsed("RANK (+|foo1 -|foo3) |foo2", "", "+foo1 foo2 -foo3",
Query.Type.ANY);
}
@Test
- public void testMultitermAndFilter() {
+ void testMultitermAndFilter() {
tester.assertParsed("AND bar |foo |foz", "bar", "+foo +foz", Query.Type.ANY);
}
@Test
- public void testMultitermRankFilter() {
+ void testMultitermRankFilter() {
tester.assertParsed("RANK bar |foo |foz", "bar", "foo foz", Query.Type.ANY);
}
@Test
- public void testMultitermNotFilter() {
+ void testMultitermNotFilter() {
tester.assertParsed("+bar -|foo -|foz", "bar", "-foo -foz", Query.Type.ANY);
}
@Test
- public void testMultitermCompoundFilter1() {
+ void testMultitermCompoundFilter1() {
tester.assertParsed("RANK (AND bar |foo1 |foz1) |foo2 |foz2", "bar",
"+foo1 +foz1 foo2 foz2", Query.Type.ANY);
}
@Test
- public void testMultitermCompoundFilter2() {
+ void testMultitermCompoundFilter2() {
tester.assertParsed("+(AND bar |foo1 |foz1) -|foo3 -|foz3", "bar",
"+foo1 +foz1 -foo3 -foz3", Query.Type.ANY);
}
@Test
- public void testMultitermCompoundFilter3() {
+ void testMultitermCompoundFilter3() {
tester.assertParsed("RANK (+bar -|foo3 -|foz3) |foo2 |foz2", "bar",
"foo2 foz2 -foo3 -foz3", Query.Type.ANY);
}
@Test
- public void testMultitermCompoundFilter4() {
+ void testMultitermCompoundFilter4() {
tester.assertParsed("RANK (+(AND bar |foo1 |foz1) -|foo3 -|foz3) |foo2 |foz2",
"bar", "+foo1 +foz1 foo2 foz2 -foo3 -foz3", Query.Type.ANY);
}
@Test
- public void testMultitermAndFilterEmptyQuery() {
+ void testMultitermAndFilterEmptyQuery() {
tester.assertParsed("AND |foo |foz", "", "+foo +foz", Query.Type.ANY);
}
@Test
- public void testMultitermRankFilterEmptyQuery() {
+ void testMultitermRankFilterEmptyQuery() {
tester.assertParsed("OR |foo |foz", "", "foo foz", Query.Type.ANY);
}
@Test
- public void testMultitermNotFilterEmptyQuery() {
+ void testMultitermNotFilterEmptyQuery() {
tester.assertParsed(null, "", "-foo -foz", Query.Type.ANY);
}
@Test
- public void testMultitermCompoundFilter1EmptyQuery() {
+ void testMultitermCompoundFilter1EmptyQuery() {
tester.assertParsed("RANK (AND |foo1 |foz1) |foo2 |foz2", "",
"+foo1 +foz1 foo2 foz2", Query.Type.ANY);
}
@Test
- public void testMultitermCompoundFilter2EmptyQuery() {
+ void testMultitermCompoundFilter2EmptyQuery() {
tester.assertParsed("+(AND |foo1 |foz1) -|foo3 -|foz3", "",
"+foo1 +foz1 -foo3 -foz3", Query.Type.ANY);
}
@Test
- public void testMultitermCompoundFilter3EmptyQuery() {
+ void testMultitermCompoundFilter3EmptyQuery() {
tester.assertParsed("+(OR |foo2 |foz2) -|foo3 -|foz3", "",
"foo2 foz2 -foo3 -foz3", Query.Type.ANY);
}
@Test
- public void testMultitermCompoundFilter4EmptyQuery() {
+ void testMultitermCompoundFilter4EmptyQuery() {
tester.assertParsed("RANK (+(AND |foo1 |foz1) -|foo3 -|foz3) |foo2 |foz2", "",
"+foo1 +foz1 foo2 foz2 -foo3 -foz3", Query.Type.ANY);
}
@Test
- public void testMultipleDifferentPhraseSeparators() {
+ void testMultipleDifferentPhraseSeparators() {
tester.assertParsed("AND foo bar", "foo.-.bar", Query.Type.ANY);
}
@Test
- public void testNoisyFilter() {
+ void testNoisyFilter() {
tester.assertParsed("RANK (+(AND foobar kanoo) -|foo) |bar", "foobar and kanoo",
"-foo ;+;bar", Query.Type.ADVANCED);
}
@Test
- public void testReallyNoisyQuery1() {
+ void testReallyNoisyQuery1() {
tester.assertParsed("AND word another", "&word\"()/&#)(/&another!\"", Query.Type.ALL);
}
@Test
- public void testReallyNoisyQuery2() {
+ void testReallyNoisyQuery2() {
tester.assertParsed("AND \u03bc\u03bc hei", "&&&`\u00b5\u00b5=@hei", Query.Type.ALL);
}
@Test
- public void testReallyNoisyQuery3() {
+ void testReallyNoisyQuery3() {
tester.assertParsed("AND hei hallo du der", "hei-hallo;du;der", Query.Type.ALL);
}
@Test
- public void testNumberParsing() {
+ void testNumberParsing() {
Item root = tester.parseQuery("normal:400", null, Language.UNKNOWN, Query.Type.ANY, TestLinguistics.INSTANCE);
assertEquals(root.getCode(), 5);
}
@Test
- public void testRangeParsing() {
+ void testRangeParsing() {
Item root = tester.parseQuery("normal:[5;400]", null, Language.UNKNOWN, Query.Type.ANY, TestLinguistics.INSTANCE);
assertEquals(root.toString(), "normal:[5;400]");
assertEquals(root.getCode(), 5);
}
@Test
- public void testNumberAsPrefix() {
+ void testNumberAsPrefix() {
Item root = tester.assertParsed("89*", "89*", Query.Type.ANY);
assertTrue(root instanceof PrefixItem);
}
@Test
- public void testNumberAsSubstring() {
+ void testNumberAsSubstring() {
Item root = tester.assertParsed("*89*", "*89*", Query.Type.ANY);
assertTrue(root instanceof SubstringItem);
}
@Test
- public void testNumberAsSuffix() {
+ void testNumberAsSuffix() {
Item root = tester.assertParsed("*89", "*89", Query.Type.ANY);
assertTrue(root instanceof SuffixItem);
}
@Test
- public void testTheStupidSymbolsWhichAreNowWordCharactersInUnicode() {
+ void testTheStupidSymbolsWhichAreNowWordCharactersInUnicode() {
tester.assertParsed("AND yz a", "yz\u00A8\u00AA\u00AF", Query.Type.ANY);
}
@Test
- public void testTWoWords() {
+ void testTWoWords() {
tester.assertParsed("\"hei h\u00e5\"", "\"hei h\u00e5\"", Query.Type.ANY);
}
@Test
- public void testLoneStar() {
+ void testLoneStar() {
assertNull(tester.parseQuery("*", null, Language.UNKNOWN, Query.Type.ANY, TestLinguistics.INSTANCE));
}
@Test
- public void testLoneStarWithFilter() {
+ void testLoneStarWithFilter() {
tester.assertParsed("|a", "*", "+a", Query.Type.ANY);
}
@Test
- public void testImplicitPhrasingWithIndex() {
+ void testImplicitPhrasingWithIndex() {
tester.assertParsed("AND a:b a:c", "a:/b/c", Query.Type.ANY);
}
@Test
- public void testSingleNoisyTermWithIndex() {
+ void testSingleNoisyTermWithIndex() {
tester.assertParsed("a:b", "a:/b", Query.Type.ANY);
}
@Test
- public void testSingleNoisyPhraseWithIndex() {
+ void testSingleNoisyPhraseWithIndex() {
tester.assertParsed("AND mail:yahoo mail:com", "mail:@yahoo.com", Query.Type.ANY);
}
@Test
- public void testPhraseWithWeightAndIndex() {
+ void testPhraseWithWeightAndIndex() {
tester.assertParsed("to:\"a b\"!150", "to:\"a b\"!150", Query.Type.ANY);
}
@Test
- public void testTermWithWeightAndIndex() {
+ void testTermWithWeightAndIndex() {
tester.assertParsed("to:a!150", "to:a!150", Query.Type.ANY);
}
@Test
- public void testPhrasingWithIndexAndQuerySyntax() {
+ void testPhrasingWithIndexAndQuerySyntax() {
tester.assertParsed("to:\"a b c\"", "to:\"a (b c)\"", Query.Type.ANY);
}
@Test
- public void testPhrasingWithIndexAndHalfBrokenQuerySyntax() {
+ void testPhrasingWithIndexAndHalfBrokenQuerySyntax() {
tester.assertParsed("to:\"a b c\"", "to:\"a +b c)\"", Query.Type.ANY);
}
@Test
- public void testURLHostQueryOneTerm1() {
+ void testURLHostQueryOneTerm1() {
tester.assertParsed("site:\"com $\"", "site:com", Query.Type.ANY);
}
@Test
- public void testURLHostQueryOneTerm2() {
+ void testURLHostQueryOneTerm2() {
tester.assertParsed("site:com", "site:com*", Query.Type.ANY);
}
@Test
- public void testURLHostQueryOneTerm3() {
+ void testURLHostQueryOneTerm3() {
tester.assertParsed("site:\"com $\"", "site:.com", Query.Type.ANY);
}
@Test
- public void testURLHostQueryOneTerm4() {
+ void testURLHostQueryOneTerm4() {
tester.assertParsed("site:\"^ com $\"", "site:^com", Query.Type.ANY);
}
@Test
- public void testURLHostQueryOneTerm5() {
+ void testURLHostQueryOneTerm5() {
tester.assertParsed("site:\"^ com\"", "site:^com*", Query.Type.ANY);
}
@Test
- public void testFullURLQuery() {
+ void testFullURLQuery() {
tester.assertParsed(
"url.all:\"http shopping yahoo-inc com 1080 this is a path shop d hab id 1804905709 frag1\"",
"url.all:http://shopping.yahoo-inc.com:1080/this/is/a/path/shop?d=hab&id=1804905709#frag1",
@@ -1555,7 +1552,7 @@ public class ParseTestCase {
}
@Test
- public void testURLQueryHyphen() {
+ void testURLQueryHyphen() {
tester.assertParsed(
"url.all:\"http news bbc co uk go rss test - sport1 hi tennis 4112866 stm\"",
"url.all:http://news.bbc.co.uk/go/rss/test/-/sport1/hi/tennis/4112866.stm",
@@ -1563,7 +1560,7 @@ public class ParseTestCase {
}
@Test
- public void testURLQueryUnderScoreNumber() {
+ void testURLQueryUnderScoreNumber() {
tester.assertParsed(
"url.all:\"ap 20050621 45_ap_on_re_la_am_ca aruba_missing_teen_5\"",
"url.all:/ap/20050621/45_ap_on_re_la_am_ca/aruba_missing_teen_5",
@@ -1571,7 +1568,7 @@ public class ParseTestCase {
}
@Test
- public void testOtherComplexUrls() {
+ void testOtherComplexUrls() {
tester.assertParsed(
"url.all:\"http redir folha com br redir online dinheiro rss091 http www1 folha uol com br folha dinheiro ult91u96593 shtml\"",
"url.all:http://redir.folha.com.br/redir/online/dinheiro/rss091/*http://www1.folha.uol.com.br/folha/dinheiro/ult91u96593.shtml",
@@ -1595,33 +1592,33 @@ public class ParseTestCase {
}
@Test
- public void testTooGreedyUrlParsing() {
+ void testTooGreedyUrlParsing() {
tester.assertParsed("AND site:\"nypost com $\" about", "site:nypost.com about",
Query.Type.ALL);
}
@Test
- public void testTooGreedyUrlParsing2() {
+ void testTooGreedyUrlParsing2() {
tester.assertParsed("AND site:\"nypost com $\" about foo",
"site:nypost.com about foo", Query.Type.ALL);
}
@Test
- public void testSimplerDurbin() {
+ void testSimplerDurbin() {
tester.assertParsed("+(OR language:en \"Durbin said\" a) -newstype:rssexclude",
"( a (\"Durbin said\" ) -newstype:rssexclude (language:en )",
Query.Type.ALL);
}
@Test
- public void testSimplerDurbin2() {
+ void testSimplerDurbin2() {
tester.assertParsed("+(AND \"Durbin said\" language:en) -newstype:rssexclude",
"( , (\"Durbin said\" ) -newstype:rssexclude (language:en )",
Query.Type.ALL);
}
@Test
- public void testDurbin() {
+ void testDurbin() {
tester.assertParsed(
"AND \"Richard Durbin\" Welfare (+(OR language:en \"Durbin said\" \"Durbin says\" \"Durbin added\" \"Durbin agreed\" \"Durbin questioned\" date:>1109664000) -newstype:rssexclude)",
"(\"Richard Durbin\" ) \"Welfare\" ((\"Durbin said\" \"Durbin says\" \"Durbin added\" \"Durbin agreed\" \"Durbin questioned\" ) -newstype:rssexclude date:>1109664000 (language:en )",
@@ -1629,35 +1626,35 @@ public class ParseTestCase {
}
@Test
- public void testTooLongQueryTerms() {
+ void testTooLongQueryTerms() {
tester.assertParsed("AND 545558598787gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggcfffffffffffffffffffffffffffffffffffffffffffccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccclllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqlkjhcxxdfffxdzzaqwwsxedcrfvtgbyhnujmikkiloolpppof filter ew 545558598787gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggcfffffffffffffffffffffffffffffffffffffffffffccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccclllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqlkjhcxxdfffxdzzaqwwsxedcrfvtgbyhnujmikkiloolpppof 2b 2f 545558598787gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggcfffffffffffffffffffffffffffffffffffffffffffccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccclllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqlkjhcxxdfffxdzzaqwwsxedcrfvtgbyhnujmikkiloolpppof",
"+/545558598787gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggcfffffffffffffffffffffffffffffffffffffffffffccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccclllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqlkjhcxxdfffxdzzaqwwsxedcrfvtgbyhnujmikkiloolpppof&filter=ew:545558598787gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggcfffffffffffffffffffffffffffffffffffffffffffccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccclllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqlkjhcxxdfffxdzzaqwwsxedcrfvtgbyhnujmikkiloolpppof!1000 =.2b..2f.545558598787gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggcfffffffffffffffffffffffffffffffffffffffffffccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccclllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqlkjhcxxdfffxdzzaqwwsxedcrfvtgbyhnujmikkiloolpppof",
Query.Type.ALL);
}
@Test
- public void testNonSpecialTokenParsing() {
+ void testNonSpecialTokenParsing() {
ParsingTester customTester = new ParsingTester(SpecialTokens.empty());
customTester.assertParsed("OR c or c with (AND tcp ip)", "c# or c++ with tcp/ip", Query.Type.ANY);
}
@Test
- public void testNonIndexWithColons1() {
+ void testNonIndexWithColons1() {
tester.assertParsed("OR this is (AND notan iindex)", "this is notan:iindex", Query.Type.ANY);
}
@Test
- public void testNonIndexWithColons2() {
+ void testNonIndexWithColons2() {
tester.assertParsed("OR this is (AND notan iindex either)", "this is notan:iindex:either", Query.Type.ANY);
}
@Test
- public void testIndexThenUnderscoreTermBecomesIndex() {
+ void testIndexThenUnderscoreTermBecomesIndex() {
tester.assertParsed("AND name:batch name:article", "name:batch_article", Query.Type.ANY);
}
@Test
- public void testFakeCJKSegmenting() {
+ void testFakeCJKSegmenting() {
// "first" "second" and "third" are segments in the test language
Item item = tester.parseQuery("name:firstsecondthird", null, Language.CHINESE_SIMPLIFIED, Query.Type.ANY, TestLinguistics.INSTANCE);
@@ -1675,7 +1672,7 @@ public class ParseTestCase {
}
@Test
- public void testFakeCJKSegmentingOfPhrase() {
+ void testFakeCJKSegmentingOfPhrase() {
// "first" "second" and "third" are segments in the test language
Item item = tester.parseQuery("name:\"firstsecondthird\"", null, Language.CHINESE_SIMPLIFIED, Query.Type.ANY, TestLinguistics.INSTANCE);
@@ -1689,23 +1686,23 @@ public class ParseTestCase {
assertEquals("name", ((WordItem) segment.getItem(0)).getIndexName());
assertEquals("name", ((WordItem) segment.getItem(1)).getIndexName());
- assertEquals("name", ((WordItem)segment.getItem(2)).getIndexName());
+ assertEquals("name", ((WordItem) segment.getItem(2)).getIndexName());
}
@Test
- public void testAndItemAndImplicitPhrase() {
+ void testAndItemAndImplicitPhrase() {
tester.assertParsed("AND \u00d8 \u00d8 \u00d8 \u00d9",
- "\u00d8\u00b9\u00d8\u00b1\u00d8\u00a8\u00d9", "",
- Query.Type.ALL, Language.CHINESE_SIMPLIFIED);
+ "\u00d8\u00b9\u00d8\u00b1\u00d8\u00a8\u00d9", "",
+ Query.Type.ALL, Language.CHINESE_SIMPLIFIED);
}
@Test
- public void testAvoidMultiLevelAndForLongCJKQueries() {
+ void testAvoidMultiLevelAndForLongCJKQueries() {
Item root = tester.parseQuery(
"\u30d7\u30ed\u91ce\u7403\u962a\u795e\u306e\u672c\u62e0\u5730\u3001\u7532\u5b50\u5712\u7403\u5834\uff08\u5175\u5eab\u770c\u897f\u5bae\u5e02\uff09\u306f\uff11\u65e5\u3001\uff11\uff19\uff12\uff14\u5e74\u30d7\u30ed\u91ce\u7403\u962a\u795e\u306e\u672c\u62e0\u5730\u3001\u7532\u5b50\u5712\u7403\u5834\uff08\u5175\u5eab\u770c\u897f\u5bae\u5e02\uff09\u306f\uff11\u65e5\u3001\uff11\uff19\uff12\uff14\u5e74\u30d7\u30ed\u91ce\u7403\u962a\u795e\u306e\u672c\u62e0\u5730\u3001\u7532\u5b50\u5712\u7403\u5834\uff08\u5175\u5eab\u770c\u897f\u5bae\u5e02\uff09\u306f\uff11\u65e5\u3001\uff11\uff19\uff12\uff14\u5e74\u30d7\u30ed\u91ce\u7403\u962a\u795e\u306e\u672c\u62e0\u5730\u3001\u7532\u5b50\u5712\u7403\u5834\uff08\u5175\u5eab\u770c\u897f\u5bae\u5e02\uff09\u306f\uff11\u65e5\u3001\uff11\uff19\uff12\uff14\u5e74\u30d7\u30ed\u91ce\u7403\u962a\u795e\u306e\u672c\u62e0\u5730\u3001\u7532\u5b50\u5712\u7403\u5834\uff08\u5175\u5eab\u770c\u897f\u5bae\u5e02\uff09\u306f\uff11\u65e5\u3001\uff11\uff19\uff12\uff14\u5e74\u30d7\u30ed\u91ce\u7403\u962a\u795e\u306e\u672c\u62e0\u5730\u3001\u7532\u5b50\u5712\u7403\u5834\uff08\u5175\u5eab\u770c\u897f\u5bae\u5e02\uff09\u306f\uff11\u65e5\u3001\uff11\uff19\uff12\uff14\u5e74",
"", Language.UNKNOWN, Query.Type.ALL, TestLinguistics.INSTANCE);
- assertTrue("Query tree too deep when parsing CJK queries.", 4 > stackDepth(0, root));
+ assertTrue(4 > stackDepth(0, root), "Query tree too deep when parsing CJK queries.");
}
private int stackDepth(int i, Item root) {
@@ -1724,151 +1721,151 @@ public class ParseTestCase {
}
@Test
- public void testFakeCJKSegmentingOfMultiplePhrases() {
+ void testFakeCJKSegmentingOfMultiplePhrases() {
Item item = tester.parseQuery("name:firstsecond.s", null, Language.CHINESE_SIMPLIFIED, Query.Type.ANY, TestLinguistics.INSTANCE);
assertEquals("AND (SAND name:first name:second) name:s", item.toString());
}
@Test
- public void testOrFilter() {
+ void testOrFilter() {
tester.assertParsed("AND d (OR |a |b)", "d", "+(a b)", Query.Type.ALL);
}
@Test
- public void testOrFilterWithTypeAdv() {
+ void testOrFilterWithTypeAdv() {
tester.assertParsed("AND d (OR |a |b)", "d", "+(a b)", Query.Type.ADVANCED);
}
@Test
- public void testPhraseFilter() {
+ void testPhraseFilter() {
tester.assertParsed("AND d |\"a b\"", "d", "+\"a b\"", Query.Type.ALL);
}
@Test
- public void testMinusAndFilter() {
+ void testMinusAndFilter() {
tester.assertParsed("+d -(AND |a |b)", "d", "-(a b)", Query.Type.ALL);
}
@Test
- public void testOrAndSomeTermsFilter() {
+ void testOrAndSomeTermsFilter() {
tester.assertParsed("RANK d |c |a |b |e", "d", "c (a b) e", Query.Type.ALL);
}
// This is an ugly parse tree, but it's at least reasonable
@Test
- public void testOrAndSomeTermsFilterAndAnAnd() {
- AndItem root=(AndItem)tester.assertParsed("AND (RANK d |c |a |b |e) (OR |e |f)", "d", "c (a b) e +(e f)", Query.Type.ALL);
+ void testOrAndSomeTermsFilterAndAnAnd() {
+ AndItem root = (AndItem) tester.assertParsed("AND (RANK d |c |a |b |e) (OR |e |f)", "d", "c (a b) e +(e f)", Query.Type.ALL);
assertFalse(root.isFilter()); // AND
assertFalse(root.getItem(0).isFilter()); // RANK
- assertFalse(((RankItem)root.getItem(0)).getItem(0).isFilter()); // d
- assertTrue(((RankItem)root.getItem(0)).getItem(1).isFilter()); // c
- assertTrue(((RankItem)root.getItem(0)).getItem(2).isFilter()); // a
- assertTrue(((RankItem)root.getItem(0)).getItem(3).isFilter()); // b
- assertTrue(((RankItem)root.getItem(0)).getItem(4).isFilter()); // e
+ assertFalse(((RankItem) root.getItem(0)).getItem(0).isFilter()); // d
+ assertTrue(((RankItem) root.getItem(0)).getItem(1).isFilter()); // c
+ assertTrue(((RankItem) root.getItem(0)).getItem(2).isFilter()); // a
+ assertTrue(((RankItem) root.getItem(0)).getItem(3).isFilter()); // b
+ assertTrue(((RankItem) root.getItem(0)).getItem(4).isFilter()); // e
assertFalse(root.getItem(1).isFilter()); // OR
- assertTrue(((OrItem)root.getItem(1)).getItem(0).isFilter()); // e
- assertTrue(((OrItem)root.getItem(1)).getItem(1).isFilter()); // f
+ assertTrue(((OrItem) root.getItem(1)).getItem(0).isFilter()); // e
+ assertTrue(((OrItem) root.getItem(1)).getItem(1).isFilter()); // f
}
@Test
- public void testUrlNotConsumingBrace() {
+ void testUrlNotConsumingBrace() {
tester.assertParsed("AND A (OR url.all:B url.all:C) D E", "A (url.all:B url.all:C) D E", Query.Type.ALL);
}
// Really a syntax error on part of the user, but it's part of
// the logic where balanced braces are allowed in URLs
@Test
- public void testUrlNotConsumingBrace2() {
+ void testUrlNotConsumingBrace2() {
tester.assertParsed("AND A (OR url.all:B url.all:C) D E",
"A (url.all:B url.all:C)D E", Query.Type.ALL);
}
@Test
- public void testSiteNotConsumingBrace() {
+ void testSiteNotConsumingBrace() {
tester.assertParsed("AND A (OR site:\"B $\" site:\"C $\") D E",
"A (site:B site:C) D E", Query.Type.ALL);
}
@Test
- public void testCommaOnlyLeadsToImplicitPhrasing() {
+ void testCommaOnlyLeadsToImplicitPhrasing() {
tester.assertParsed("AND A B C", "A,B,C", Query.Type.ALL);
}
@Test
- public void testBangDoesNotBindAcrossSpace() {
+ void testBangDoesNotBindAcrossSpace() {
tester.assertParsed("word", "word !", Query.Type.ALL);
}
@Test
- public void testLotsOfPlusMinus() {
+ void testLotsOfPlusMinus() {
tester.assertParsed("OR word term", "word - + - + - term", Query.Type.ANY);
}
@Test
- public void testLotsOfMinusPlus() {
+ void testLotsOfMinusPlus() {
tester.assertParsed("OR word term", "word - + - + term", Query.Type.ANY);
}
@Test
- public void testMinusDoesNotBindAcrossSpace() {
+ void testMinusDoesNotBindAcrossSpace() {
tester.assertParsed("OR word term", "word - term", Query.Type.ANY);
}
@Test
- public void testPlusDoesNotBindAcrossSpace() {
+ void testPlusDoesNotBindAcrossSpace() {
tester.assertParsed("OR word term", "word + term", Query.Type.ANY);
}
@Test
- public void testMinusDoesNotBindAcrossSpaceAllQuery() {
+ void testMinusDoesNotBindAcrossSpaceAllQuery() {
tester.assertParsed("AND word term", "word - term", Query.Type.ALL);
}
@Test
- public void testPlusDoesNotBindAcrossSpaceAllQuery() {
+ void testPlusDoesNotBindAcrossSpaceAllQuery() {
tester.assertParsed("AND word term", "word + term", Query.Type.ALL);
}
@Test
- public void testNoSpaceInIndexPrefix() {
+ void testNoSpaceInIndexPrefix() {
tester.assertParsed("AND url domain:s url.domain:b",
"url. domain:s url.domain:b", Query.Type.ALL);
}
@Test
- public void testNestedParensAndLittleElse() {
+ void testNestedParensAndLittleElse() {
tester.assertParsed("OR a b c d", "((a b) (c d))", Query.Type.ALL);
}
// This is simply to control it doesn't crash
@Test
- public void testNestedParensAndLittleElseMoreBroken() {
+ void testNestedParensAndLittleElseMoreBroken() {
tester.assertParsed("AND (OR a b) (OR c d)", "(a b) +(c d))", Query.Type.ALL);
}
@Test
- public void testNestedUnbalancedParensAndLittleElseMoreBroken() {
+ void testNestedUnbalancedParensAndLittleElseMoreBroken() {
tester.assertParsed("OR a b c d", "((a b) +(c d)", Query.Type.ALL);
}
@Test
- public void testUnbalancedParens() {
+ void testUnbalancedParens() {
tester.assertParsed("AND a b (OR c d)", "a b) +(c d))", Query.Type.ALL);
}
@Test
- public void testUnbalancedStartingParens() {
+ void testUnbalancedStartingParens() {
tester.assertParsed("OR a b c d", "((a b) +(c d", Query.Type.ALL);
}
@Test
- public void testJPMobileExceptionQuery() {
+ void testJPMobileExceptionQuery() {
tester.assertParsed("OR concat and (AND make string) 1 47 or",
- "(concat \"and\" (make-string 1 47) \"or\")", Query.Type.ALL);
+ "(concat \"and\" (make-string 1 47) \"or\")", Query.Type.ALL);
}
@Test
- public void testColonDoesNotBindAcrossSpace() {
+ void testColonDoesNotBindAcrossSpace() {
tester.assertParsed("b", "a: b", Query.Type.ALL);
tester.assertParsed("AND a b", "a : b", Query.Type.ALL);
tester.assertParsed("AND a b", "a :b", Query.Type.ALL);
@@ -1877,14 +1874,14 @@ public class ParseTestCase {
}
@Test
- public void testGermanUriDecompounding() {
+ void testGermanUriDecompounding() {
tester.assertParsed("url.all:\"kommunikationsfehler de\"",
- "url.all:kommunikationsfehler.de", "", Query.Type.ALL, Language.GERMAN);
+ "url.all:kommunikationsfehler.de", "", Query.Type.ALL, Language.GERMAN);
}
// Check the parser doesn't fail on these horrible query strings
@Test
- public void testTicket443882() {
+ void testTicket443882() {
tester.assertParsed(
"AND australian LOTTERY (+(OR language:en IN AFFILIATION WITH THE UK NATIONAL LOTTERY date:>1125475200) -newstype:rssexclude)",
"australian LOTTERY (IN AFFILIATION WITH THE UK NATIONAL LOTTERY -newstype:rssexclude date:>1125475200 (language:en )",
@@ -1900,7 +1897,7 @@ public class ParseTestCase {
}
@Test
- public void testParensInQuotes() {
+ void testParensInQuotes() {
tester.assertParsed("AND ringtone (OR a:\"Delivery SMAF large max 150kB 063\" a:\"RealMusic Delivery\")",
"ringtone AND (a:\"Delivery SMAF large max.150kB (063)\" OR a:\"RealMusic Delivery\" )",
Query.Type.ADVANCED);
@@ -1914,7 +1911,7 @@ public class ParseTestCase {
}
@Test
- public void testMixedCaseIndexNames() {
+ void testMixedCaseIndexNames() {
tester.assertParsed("AND mixedCase:a mixedCase:b notAnIndex c mixedCase:d",
"mixedcase:a MIXEDCASE:b notAnIndex:c mixedCase:d",
Query.Type.ALL);
@@ -1922,9 +1919,9 @@ public class ParseTestCase {
/** CJK special tokens should be recognized also on non-boundaries */
@Test
- public void testChineseSpecialTokens() {
+ void testChineseSpecialTokens() {
tester.assertParsed("AND cat tcp/ip zu foo dotnet bar dotnet dotnet c# c++ bar dotnet dotnet wiz",
- "cattcp/ipzu foo.netbar.net.netC#c++bar.net.netwiz","", Query.Type.ALL, Language.CHINESE_SIMPLIFIED);
+ "cattcp/ipzu foo.netbar.net.netC#c++bar.net.netwiz", "", Query.Type.ALL, Language.CHINESE_SIMPLIFIED);
}
/**
@@ -1932,69 +1929,69 @@ public class ParseTestCase {
* but right now it is not
*/
@Test
- public void testChineseSpecialTokensWithMultiSegmentReplace() {
+ void testChineseSpecialTokensWithMultiSegmentReplace() {
// special-token-fs is a special token, to be replaced by firstsecond, first and second are segments in test
- tester.assertParsed("AND tcp/ip firstsecond dotnet firstsecond (SAND first second)","tcp/ipspecial-token-fs.net special-token-fs firstsecond",
- "", Query.Type.ALL, Language.CHINESE_SIMPLIFIED, TestLinguistics.INSTANCE);
+ tester.assertParsed("AND tcp/ip firstsecond dotnet firstsecond (SAND first second)", "tcp/ipspecial-token-fs.net special-token-fs firstsecond",
+ "", Query.Type.ALL, Language.CHINESE_SIMPLIFIED, TestLinguistics.INSTANCE);
}
@Test
- public void testSpaceAndTermWeights() {
+ void testSpaceAndTermWeights() {
tester.assertParsed("AND yahoo!360 yahoo 360 yahoo!150 360 yahoo 360 yahoo yahoo!150 yahoo!200",
- "yahoo!360 yahoo !360 yahoo! 360 yahoo ! 360 yahoo !!! yahoo! ! yahoo!!", Query.Type.ALL);
+ "yahoo!360 yahoo !360 yahoo! 360 yahoo ! 360 yahoo !!! yahoo! ! yahoo!!", Query.Type.ALL);
}
@Test
- public void testNumbersAndNot() {
+ void testNumbersAndNot() {
tester.assertParsed("AND a -12", "a -12", Query.Type.ALL);
}
@Test
- public void testNumbersAndDoubleNot() {
+ void testNumbersAndDoubleNot() {
tester.assertParsed("+a --12", "a --12", Query.Type.ALL);
}
@Test
- public void testNegativeNumberWithIndex() {
+ void testNegativeNumberWithIndex() {
tester.assertParsed("normal:-12", "normal:-12", Query.Type.ALL);
}
@Test
- public void testNegativeTermPositiveNumberWithIndex() {
+ void testNegativeTermPositiveNumberWithIndex() {
tester.assertParsed("+a -normal:12", "a -normal:12", Query.Type.ALL);
}
@Test
- public void testNegativeTermNegativeNumberWithIndex() {
+ void testNegativeTermNegativeNumberWithIndex() {
tester.assertParsed("+a -normal:-12", "a -normal:-12", Query.Type.ALL);
}
@Test
- public void testNegativeTermPositiveNumberInParentheses() {
+ void testNegativeTermPositiveNumberInParentheses() {
tester.assertParsed("+a -12", "a -(12)", Query.Type.ALL);
tester.assertParsed("+a -(AND 12 15)", "a -(12 15)", Query.Type.ALL);
tester.assertParsed("+a -12 -15", "a -(12) -(15)", Query.Type.ALL);
}
@Test
- public void testSingleNegativeNumberLikeTerm() {
+ void testSingleNegativeNumberLikeTerm() {
tester.assertParsed("-12", "-12", Query.Type.ALL);
}
@Test
- public void testNegativeLessThan() {
+ void testNegativeLessThan() {
tester.assertParsed("normal:<-3", "normal:<-3", Query.Type.ALL);
tester.assertParsed("<-3", "<-3", Query.Type.ALL);
}
@Test
- public void testNegativeBiggerThan() {
+ void testNegativeBiggerThan() {
tester.assertParsed("normal:>-3", "normal:>-3", Query.Type.ALL);
tester.assertParsed(">-3", ">-3", Query.Type.ALL);
}
@Test
- public void testNegativesInRanges() {
+ void testNegativesInRanges() {
tester.assertParsed("normal:[-4;9]", "normal:[-4;9]", Query.Type.ALL);
tester.assertParsed("[-4;9]", "[-4;9]", Query.Type.ALL);
tester.assertParsed("normal:[-4;-9]", "normal:[-4;-9]", Query.Type.ALL);
@@ -2002,51 +1999,51 @@ public class ParseTestCase {
}
@Test
- public void testDecimal() {
- Item root=tester.assertParsed("2.2", "2.2", Query.Type.ALL);
+ void testDecimal() {
+ Item root = tester.assertParsed("2.2", "2.2", Query.Type.ALL);
assertTrue(root instanceof IntItem);
tester.assertParsed("normal:2.2", "normal:2.2", Query.Type.ALL);
}
@Test
- public void testVersionNumbers() {
+ void testVersionNumbers() {
tester.assertParsed("AND 1 0 9", "1.0.9", Query.Type.ALL);
}
@Test
- public void testDecimalNumbersAndNot() {
+ void testDecimalNumbersAndNot() {
tester.assertParsed("AND a -12.2", "a -12.2", Query.Type.ALL);
}
@Test
- public void testDecimalNumbersAndDoubleNot() {
+ void testDecimalNumbersAndDoubleNot() {
tester.assertParsed("+a --12.2", "a --12.2", Query.Type.ALL);
}
@Test
- public void testNegativeDecimalNumberWithIndex() {
+ void testNegativeDecimalNumberWithIndex() {
tester.assertParsed("normal:-12.2", "normal:-12.2", Query.Type.ALL);
}
@Test
- public void testSingleNegativeDecimalNumberLikeTerm() {
+ void testSingleNegativeDecimalNumberLikeTerm() {
tester.assertParsed("-12.2", "-12.2", Query.Type.ALL);
}
@Test
- public void testNegativeDecimalLessThan() {
+ void testNegativeDecimalLessThan() {
tester.assertParsed("normal:<-3.14", "normal:<-3.14", Query.Type.ALL);
tester.assertParsed("<-3.14", "<-3.14", Query.Type.ALL);
}
@Test
- public void testNegativeDecimalBiggerThan() {
+ void testNegativeDecimalBiggerThan() {
tester.assertParsed("normal:>-3.14", "normal:>-3.14", Query.Type.ALL);
tester.assertParsed(">-3.14", ">-3.14", Query.Type.ALL);
}
@Test
- public void testNegativesDecimalInRanges() {
+ void testNegativesDecimalInRanges() {
tester.assertParsed("normal:[-4.16;9.2]", "normal:[-4.16;9.2]", Query.Type.ALL);
tester.assertParsed("[-4.16;9.2]", "[-4.16;9.2]", Query.Type.ALL);
tester.assertParsed("normal:[-4.16;-9.2]", "normal:[-4.16;-9.2]", Query.Type.ALL);
@@ -2054,12 +2051,12 @@ public class ParseTestCase {
}
@Test
- public void testRangesAndNoise() {
+ void testRangesAndNoise() {
tester.assertParsed("[2;3]", "[2;3]]", Query.Type.ALL);
}
@Test
- public void testIndexNoise() {
+ void testIndexNoise() {
tester.assertParsed("AND normal:a notanindex", "normal:a normal: notanindex:", Query.Type.ALL);
tester.assertParsed(null, "normal:", Query.Type.ALL);
tester.assertParsed(null, "normal:!", Query.Type.ALL);
@@ -2070,13 +2067,13 @@ public class ParseTestCase {
}
@Test
- public void testIndexNoiseAndExplicitPhrases() {
+ void testIndexNoiseAndExplicitPhrases() {
tester.assertParsed("normal:\"a b\"", "normal:\" a b\"", Query.Type.ALL);
tester.assertParsed("normal:\"a b\"", "normal:\"a b\"", Query.Type.ALL);
}
@Test
- public void testExactMatchParsing1() {
+ void testExactMatchParsing1() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index1 = new Index("testexact1");
@@ -2092,13 +2089,13 @@ public class ParseTestCase {
customTester.assertParsed("testexact1:/,%&#", "testexact1:/,%&#", Query.Type.ALL);
customTester.assertParsed("testexact2:/,%&#!!", "testexact2:/,%&#!!()/aa*::*&", Query.Type.ALL);
- customTester.assertParsed("AND word1 (OR testexact1:word2 testexact1:word3)","word1 AND (testexact1:word2 OR testexact1:word3 )",Query.Type.ADVANCED);
- customTester.assertParsed("AND word (OR testexact1:AND testexact1:OR)","word AND (testexact1: AND OR testexact1: OR )",Query.Type.ADVANCED);
+ customTester.assertParsed("AND word1 (OR testexact1:word2 testexact1:word3)", "word1 AND (testexact1:word2 OR testexact1:word3 )", Query.Type.ADVANCED);
+ customTester.assertParsed("AND word (OR testexact1:AND testexact1:OR)", "word AND (testexact1: AND OR testexact1: OR )", Query.Type.ADVANCED);
}
/** Testing terminators containing control characters in conjunction with those control characters */
@Test
- public void testExactMatchParsing2() {
+ void testExactMatchParsing2() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index1 = new Index("testexact1");
@@ -2108,12 +2105,12 @@ public class ParseTestCase {
IndexFacts indexFacts = new IndexFacts(new IndexModel(sd));
ParsingTester customTester = new ParsingTester(indexFacts);
- customTester.assertParsed("testexact1:_-_*!200","testexact1:_-_*!**!!",Query.Type.ALL);
+ customTester.assertParsed("testexact1:_-_*!200", "testexact1:_-_*!**!!", Query.Type.ALL);
}
/** Testing terminators containing control characters in conjunction with those control characters */
@Test
- public void testExactMatchParsing3() {
+ void testExactMatchParsing3() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index1 = new Index("testexact1");
@@ -2123,48 +2120,48 @@ public class ParseTestCase {
IndexFacts indexFacts = new IndexFacts(new IndexModel(sd));
ParsingTester customTester = new ParsingTester(indexFacts);
- customTester.assertParsed("testexact1:_-_*!200","testexact1:_-_**!!",Query.Type.ALL);
+ customTester.assertParsed("testexact1:_-_*!200", "testexact1:_-_**!!", Query.Type.ALL);
}
// bug 1393139
@Test
- public void testMinimalBritneyFilter() {
+ void testMinimalBritneyFilter() {
tester.assertParsed("RANK (+a -|c) b", "a RANK b", "-c", Query.Type.ADVANCED);
}
@Test
- public void testBritneyFilter() {
+ void testBritneyFilter() {
tester.assertParsed("RANK (+(AND performernameall:britney performernameall:spears songnameall:toxic |SongConsumable:1 |country:us |collapsedrecord:1 |doctype:song) -|collapsecount:0) (AND metadata:britney metadata:spears metadata:toxic)",
- "((performernameall:britney AND performernameall:spears AND songnameall:toxic) RANK (metadata:britney AND metadata:spears AND metadata:toxic))",
- "+SongConsumable:1 +country:us +collapsedrecord:1 -collapsecount:0 +doctype:song",
- Query.Type.ADVANCED);
+ "((performernameall:britney AND performernameall:spears AND songnameall:toxic) RANK (metadata:britney AND metadata:spears AND metadata:toxic))",
+ "+SongConsumable:1 +country:us +collapsedrecord:1 -collapsecount:0 +doctype:song",
+ Query.Type.ADVANCED);
tester.assertParsed("AND (+(AND (RANK (OR (AND performernameall:britney performernameall:spears songnameall:toxic) (AND performernameall:britney performernameall:spears songnameall:toxic)) (AND metadata:britney metadata:spears metadata:toxic)) |SongConsumable:1 |country:us |collapsedrecord:1) -|collapsecount:0) |doctype:song",
- "(((performernameall:britney AND performernameall:spears AND songnameall:toxic) OR (performernameall:britney AND performernameall:spears AND songnameall:toxic)) RANK (metadata:britney AND metadata:spears AND metadata:toxic)))",
- "+SongConsumable:1 +country:us +collapsedrecord:1 -collapsecount:0 +doctype:song",
- Query.Type.ADVANCED);
+ "(((performernameall:britney AND performernameall:spears AND songnameall:toxic) OR (performernameall:britney AND performernameall:spears AND songnameall:toxic)) RANK (metadata:britney AND metadata:spears AND metadata:toxic)))",
+ "+SongConsumable:1 +country:us +collapsedrecord:1 -collapsecount:0 +doctype:song",
+ Query.Type.ADVANCED);
}
// bug 1412840
@Test
- public void testGreedyPhrases() {
+ void testGreedyPhrases() {
tester.assertParsed("AND title:why title:\"1 2\"", "title:\"why\" title:\"&\" title:\"1/2\"", Query.Type.ALL);
}
// bug 1509347
@Test
- public void testUnderscoreInFieldNames() {
+ void testUnderscoreInFieldNames() {
tester.assertParsed("AND title:why score_under:what score_under:>5000",
- "title:why score_under:what score_under:>5000",
- Query.Type.ALL);
+ "title:why score_under:what score_under:>5000",
+ Query.Type.ALL);
}
// bug 1509347
@Test
- public void testLeadingUnderscoreInFieldNames() {
+ void testLeadingUnderscoreInFieldNames() {
tester.assertParsed("AND title:why _under_score_:what _under_score_:>5000",
- "title:why _under_score_:what _under_score_:>5000",
- Query.Type.ALL);
+ "title:why _under_score_:what _under_score_:>5000",
+ Query.Type.ALL);
}
// Re-add if underscore should be a word character
@@ -2185,7 +2182,7 @@ public class ParseTestCase {
// bug 524918
@Test
- public void testAdvancedSyntaxParensAndQuotes() {
+ void testAdvancedSyntaxParensAndQuotes() {
tester.assertParsed("OR a (AND \"b c d\" e)",
"a OR (\"b (c) d\" AND e)",
Query.Type.ADVANCED);
@@ -2195,7 +2192,7 @@ public class ParseTestCase {
// this needs to become series of tests where the tokenizer
// and parser will step on each other's toes.
@Test
- public void testStarFirstInAttributes() {
+ void testStarFirstInAttributes() {
tester.assertParsed("exactindex:*test",
"exactindex:*test",
Query.Type.ALL);
@@ -2203,162 +2200,162 @@ public class ParseTestCase {
}
@Test
- public void testOneWordWebParsing() {
- tester.assertParsed("a","a",Query.Type.WEB);
+ void testOneWordWebParsing() {
+ tester.assertParsed("a", "a", Query.Type.WEB);
}
@Test
- public void testTwoWordWebParsing() {
- tester.assertParsed("AND a b","a b",Query.Type.WEB);
+ void testTwoWordWebParsing() {
+ tester.assertParsed("AND a b", "a b", Query.Type.WEB);
}
@Test
- public void testPlusWordWebParsing1() {
- Item root=tester.assertParsed("AND a b","+a b",Query.Type.WEB);
- assertTrue(((AndItem)root).getItem(0).isProtected());
- assertFalse(((AndItem)root).getItem(1).isProtected());
+ void testPlusWordWebParsing1() {
+ Item root = tester.assertParsed("AND a b", "+a b", Query.Type.WEB);
+ assertTrue(((AndItem) root).getItem(0).isProtected());
+ assertFalse(((AndItem) root).getItem(1).isProtected());
}
@Test
- public void testPlusWordWebParsing2() {
- Item root=tester.assertParsed("AND a b","+a +b",Query.Type.WEB);
- assertTrue(((AndItem)root).getItem(0).isProtected());
- assertTrue(((AndItem)root).getItem(1).isProtected());
+ void testPlusWordWebParsing2() {
+ Item root = tester.assertParsed("AND a b", "+a +b", Query.Type.WEB);
+ assertTrue(((AndItem) root).getItem(0).isProtected());
+ assertTrue(((AndItem) root).getItem(1).isProtected());
}
@Test
- public void testNegativeWordsParsing1() {
- Item root=tester.assertParsed("+a -b","a -b",Query.Type.WEB);
- assertFalse(((NotItem)root).getItem(0).isProtected());
- assertTrue(((NotItem)root).getItem(1).isProtected());
+ void testNegativeWordsParsing1() {
+ Item root = tester.assertParsed("+a -b", "a -b", Query.Type.WEB);
+ assertFalse(((NotItem) root).getItem(0).isProtected());
+ assertTrue(((NotItem) root).getItem(1).isProtected());
}
@Test
- public void testNegativeWordsParsing2() {
- Item root=tester.assertParsed("+a -b","+a -b",Query.Type.WEB);
- assertTrue(((NotItem)root).getItem(0).isProtected());
- assertTrue(((NotItem)root).getItem(1).isProtected());
+ void testNegativeWordsParsing2() {
+ Item root = tester.assertParsed("+a -b", "+a -b", Query.Type.WEB);
+ assertTrue(((NotItem) root).getItem(0).isProtected());
+ assertTrue(((NotItem) root).getItem(1).isProtected());
}
@Test
- public void testNegativeWordsParsing3() {
- tester.assertParsed("+a -b","-b a",Query.Type.WEB);
+ void testNegativeWordsParsing3() {
+ tester.assertParsed("+a -b", "-b a", Query.Type.WEB);
}
@Test
- public void testNegativeWordsParsing4() {
- tester.assertParsed("+(AND a b) -c -d","a b -c -d",Query.Type.WEB);
+ void testNegativeWordsParsing4() {
+ tester.assertParsed("+(AND a b) -c -d", "a b -c -d", Query.Type.WEB);
}
@Test
- public void testNegativeWordsParsing5() {
- tester.assertParsed("+(AND a \"b c\" d) -e -f","a -e \"b c\" d -f",Query.Type.WEB);
+ void testNegativeWordsParsing5() {
+ tester.assertParsed("+(AND a \"b c\" d) -e -f", "a -e \"b c\" d -f", Query.Type.WEB);
}
@Test
- public void testPhraseWebParsing() {
- tester.assertParsed("\"a b\"","\"a b\"",Query.Type.WEB);
+ void testPhraseWebParsing() {
+ tester.assertParsed("\"a b\"", "\"a b\"", Query.Type.WEB);
}
@Test
- public void testPhraseAndExtraTermWebParsing() {
- tester.assertParsed("AND \"a b\" c","\"a b\" c",Query.Type.WEB);
+ void testPhraseAndExtraTermWebParsing() {
+ tester.assertParsed("AND \"a b\" c", "\"a b\" c", Query.Type.WEB);
}
@Test
- public void testNotOrWebParsing() {
- tester.assertParsed("AND a or b","a or b",Query.Type.WEB);
+ void testNotOrWebParsing() {
+ tester.assertParsed("AND a or b", "a or b", Query.Type.WEB);
}
@Test
- public void testNotOrALLParsing() {
- tester.assertParsed("AND a OR b","a OR b",Query.Type.ALL);
+ void testNotOrALLParsing() {
+ tester.assertParsed("AND a OR b", "a OR b", Query.Type.ALL);
}
@Test
- public void testOrParsing1() {
- tester.assertParsed("OR a b","a OR b",Query.Type.WEB);
+ void testOrParsing1() {
+ tester.assertParsed("OR a b", "a OR b", Query.Type.WEB);
}
@Test
- public void testOrParsing2() {
- tester.assertParsed("OR a b c","a OR b OR c",Query.Type.WEB);
+ void testOrParsing2() {
+ tester.assertParsed("OR a b c", "a OR b OR c", Query.Type.WEB);
}
@Test
- public void testOrParsing3() {
- tester.assertParsed("OR a (AND b c) \"d e\"","a OR b c OR \"d e\"",Query.Type.WEB);
+ void testOrParsing3() {
+ tester.assertParsed("OR a (AND b c) \"d e\"", "a OR b c OR \"d e\"", Query.Type.WEB);
}
@Test
- public void testOrParsing4() {
- tester.assertParsed("OR (AND or1 a) or2","or1 a OR or2",Query.Type.WEB);
+ void testOrParsing4() {
+ tester.assertParsed("OR (AND or1 a) or2", "or1 a OR or2", Query.Type.WEB);
}
@Test
- public void testOrCornerCase1() {
- tester.assertParsed("AND OR a","OR a",Query.Type.WEB);
+ void testOrCornerCase1() {
+ tester.assertParsed("AND OR a", "OR a", Query.Type.WEB);
}
@Test
- public void testOrCornerCase2() {
- tester.assertParsed("AND OR a","OR a OR",Query.Type.WEB); // Don't care
+ void testOrCornerCase2() {
+ tester.assertParsed("AND OR a", "OR a OR", Query.Type.WEB); // Don't care
}
@Test
- public void testOrCornerCase3() {
- tester.assertParsed("AND OR a","OR a OR OR",Query.Type.WEB); // Don't care
+ void testOrCornerCase3() {
+ tester.assertParsed("AND OR a", "OR a OR OR", Query.Type.WEB); // Don't care
}
@Test
- public void testOrCornerCase4() {
- tester.assertParsed("+(OR (AND a b) (AND d c) (AND g h)) -e -f","a b OR d c -e -f OR g h",Query.Type.WEB);
+ void testOrCornerCase4() {
+ tester.assertParsed("+(OR (AND a b) (AND d c) (AND g h)) -e -f", "a b OR d c -e -f OR g h", Query.Type.WEB);
}
@Test
- public void testOdd1Web() {
- tester.assertParsed("AND window print error", "+window.print() +error",Query.Type.WEB);
+ void testOdd1Web() {
+ tester.assertParsed("AND window print error", "+window.print() +error", Query.Type.WEB);
}
@Test
- public void testNotOnlyWeb() {
+ void testNotOnlyWeb() {
tester.assertParsed(null, "-foobar", Query.Type.WEB);
}
@Test
- public void testMultipleNotsOnltWeb() {
+ void testMultipleNotsOnltWeb() {
tester.assertParsed(null, "-foo -bar -foobar", Query.Type.WEB);
}
@Test
- public void testOnlyNotCompositeWeb() {
+ void testOnlyNotCompositeWeb() {
tester.assertParsed(null, "-(foo bar baz)", Query.Type.WEB);
}
@Test
- public void testSingleNegativeNumberLikeTermWeb() {
+ void testSingleNegativeNumberLikeTermWeb() {
tester.assertParsed("-12", "-12", Query.Type.WEB);
}
@Test
- public void testSingleNegativeDecimalNumberLikeTermWeb() {
+ void testSingleNegativeDecimalNumberLikeTermWeb() {
tester.assertParsed("-12.2", "-12.2", Query.Type.WEB);
}
@Test
- public void testDefaultWebIndices() {
- tester.assertParsed("AND notanindex b","notanindex:b", Query.Type.WEB);
- tester.assertParsed("site:\"b $\"","site:b", Query.Type.WEB);
- tester.assertParsed("hostname:b","hostname:b", Query.Type.WEB);
- tester.assertParsed("link:b","link:b", Query.Type.WEB);
- tester.assertParsed("url:b","url:b", Query.Type.WEB);
- tester.assertParsed("inurl:b","inurl:b", Query.Type.WEB);
- tester.assertParsed("intitle:b","intitle:b", Query.Type.WEB);
+ void testDefaultWebIndices() {
+ tester.assertParsed("AND notanindex b", "notanindex:b", Query.Type.WEB);
+ tester.assertParsed("site:\"b $\"", "site:b", Query.Type.WEB);
+ tester.assertParsed("hostname:b", "hostname:b", Query.Type.WEB);
+ tester.assertParsed("link:b", "link:b", Query.Type.WEB);
+ tester.assertParsed("url:b", "url:b", Query.Type.WEB);
+ tester.assertParsed("inurl:b", "inurl:b", Query.Type.WEB);
+ tester.assertParsed("intitle:b", "intitle:b", Query.Type.WEB);
}
@Test
- public void testHTMLWeb() {
- tester.assertParsed("AND h2 Title h2","<h2>Title</h2>",Query.Type.WEB);
+ void testHTMLWeb() {
+ tester.assertParsed("AND h2 Title h2", "<h2>Title</h2>", Query.Type.WEB);
}
/**
@@ -2366,82 +2363,82 @@ public class ParseTestCase {
* The information about added bangs is available from the origin as shown (do not use the weight to find this)
*/
@Test
- public void testShortcutsWeb() {
- tester.assertParsed("AND map new york","map new york",Query.Type.WEB);
+ void testShortcutsWeb() {
+ tester.assertParsed("AND map new york", "map new york", Query.Type.WEB);
- AndItem root=(AndItem)tester.assertParsed("AND map!150 new york","map! new york",Query.Type.WEB);
- assertEquals('!',((WordItem)root.getItem(0)).getOrigin().charAfter(0));
+ AndItem root = (AndItem) tester.assertParsed("AND map!150 new york", "map! new york", Query.Type.WEB);
+ assertEquals('!', ((WordItem) root.getItem(0)).getOrigin().charAfter(0));
- root=(AndItem)tester.assertParsed("AND barack obama news!150","barack obama news!",Query.Type.WEB);
- assertEquals('!',((WordItem)root.getItem(2)).getOrigin().charAfter(0));
+ root = (AndItem) tester.assertParsed("AND barack obama news!150", "barack obama news!", Query.Type.WEB);
+ assertEquals('!', ((WordItem) root.getItem(2)).getOrigin().charAfter(0));
}
@Test
- public void testZipCodeShortcutWeb() {
- tester.assertParsed("12345","12345",Query.Type.WEB);
- IntItem root=(IntItem)tester.assertParsed("00012!150","00012!",Query.Type.WEB);
- assertEquals('!',root.getOrigin().charAfter(0));
+ void testZipCodeShortcutWeb() {
+ tester.assertParsed("12345", "12345", Query.Type.WEB);
+ IntItem root = (IntItem) tester.assertParsed("00012!150", "00012!", Query.Type.WEB);
+ assertEquals('!', root.getOrigin().charAfter(0));
}
@Test
- public void testDouble() {
- Item number=tester.assertParsed("123456789.987654321","123456789.987654321",Query.Type.ALL);
+ void testDouble() {
+ Item number = tester.assertParsed("123456789.987654321", "123456789.987654321", Query.Type.ALL);
assertTrue(number instanceof IntItem);
}
@Test
- public void testLong() {
- Item number=tester.assertParsed("3000000000000","3000000000000",Query.Type.ALL);
+ void testLong() {
+ Item number = tester.assertParsed("3000000000000", "3000000000000", Query.Type.ALL);
assertTrue(number instanceof IntItem);
}
@Test
- public void testNear1() {
- tester.assertParsed("NEAR(2) new york","new NEAR york",Query.Type.ADVANCED);
+ void testNear1() {
+ tester.assertParsed("NEAR(2) new york", "new NEAR york", Query.Type.ADVANCED);
}
@Test
- public void testNear2() {
- tester.assertParsed("ONEAR(2) new york","new ONEAR york",Query.Type.ADVANCED);
+ void testNear2() {
+ tester.assertParsed("ONEAR(2) new york", "new ONEAR york", Query.Type.ADVANCED);
}
@Test
- public void testNear3() {
- tester.assertParsed("NEAR(3) new york","new NEAR(3) york",Query.Type.ADVANCED);
+ void testNear3() {
+ tester.assertParsed("NEAR(3) new york", "new NEAR(3) york", Query.Type.ADVANCED);
}
@Test
- public void testNear4() {
- tester.assertParsed("ONEAR(3) new york","new ONEAR(3) york",Query.Type.ADVANCED);
+ void testNear4() {
+ tester.assertParsed("ONEAR(3) new york", "new ONEAR(3) york", Query.Type.ADVANCED);
}
@Test
- public void testNear5() {
- tester.assertParsed("NEAR(3) map new york","map NEAR(3) new NEAR(3) york",Query.Type.ADVANCED);
+ void testNear5() {
+ tester.assertParsed("NEAR(3) map new york", "map NEAR(3) new NEAR(3) york", Query.Type.ADVANCED);
}
@Test
- public void testNear6() {
- tester.assertParsed("ONEAR(3) map new york","map ONEAR(3) new ONEAR(3) york",Query.Type.ADVANCED);
+ void testNear6() {
+ tester.assertParsed("ONEAR(3) map new york", "map ONEAR(3) new ONEAR(3) york", Query.Type.ADVANCED);
}
@Test
- public void testNear7() {
- tester.assertParsed("NEAR(4) (NEAR(3) map new) york","map NEAR(3) new NEAR(4) york",Query.Type.ADVANCED);
+ void testNear7() {
+ tester.assertParsed("NEAR(4) (NEAR(3) map new) york", "map NEAR(3) new NEAR(4) york", Query.Type.ADVANCED);
}
@Test
- public void testNear8() {
- tester.assertParsed("ONEAR(4) (ONEAR(3) map new) york","map ONEAR(3) new ONEAR(4) york",Query.Type.ADVANCED);
+ void testNear8() {
+ tester.assertParsed("ONEAR(4) (ONEAR(3) map new) york", "map ONEAR(3) new ONEAR(4) york", Query.Type.ADVANCED);
}
@Test
- public void testNearPrefix() {
- tester.assertParsed("NEAR(2) a b*","a NEAR b*",Query.Type.ADVANCED);
+ void testNearPrefix() {
+ tester.assertParsed("NEAR(2) a b*", "a NEAR b*", Query.Type.ADVANCED);
}
@Test
- public void testNestedBracesAndPhrases() {
+ void testNestedBracesAndPhrases() {
String userQuery = "(\"Secondary Curriculum\" (\"Key Stage 3\" OR KS3) (\"Key Stage 4\" OR KS4)) ";
tester.assertParsed(
"OR \"Secondary Curriculum\" \"Key Stage 3\" OR KS3 \"Key Stage 4\" OR KS4",
@@ -2458,53 +2455,53 @@ public class ParseTestCase {
}
@Test
- public void testYetAnotherCycleQuery() {
+ void testYetAnotherCycleQuery() {
tester.assertParsed("+(OR (+d -f) b) -c",
"( b -c ( d -f )",
Query.Type.ALL);
}
@Test
- public void testSimpleEquivAdvanced() {
+ void testSimpleEquivAdvanced() {
tester.assertParsed("EQUIV foo bar baz", "foo equiv bar equiv baz", Query.Type.ADVANCED);
}
@Test
- public void testEquivWordIntPhraseAdvanced() {
+ void testEquivWordIntPhraseAdvanced() {
tester.assertParsed("EQUIV foo 5 \"a b\"", "foo equiv 5 equiv \"a b\"", Query.Type.ADVANCED);
}
@Test
- public void testEquivRejectCompositeAdvanced() {
+ void testEquivRejectCompositeAdvanced() {
try {
tester.assertParsed("this should not parse", "foo equiv (a or b)", Query.Type.ADVANCED);
- } catch(Exception e) {
+ } catch (Exception e) {
// Success
}
}
@Test
- public void testSimpleWandAdvanced() {
+ void testSimpleWandAdvanced() {
tester.assertParsed("WEAKAND(100) foo bar baz", "foo wand bar wand baz", Query.Type.ADVANCED);
}
@Test
- public void testSimpleWandAdvancedWithNonDefaultN() {
+ void testSimpleWandAdvancedWithNonDefaultN() {
tester.assertParsed("WEAKAND(32) foo bar baz", "foo weakand(32) bar weakand(32) baz", Query.Type.ADVANCED);
}
@Test
- public void testSimpleWandAdvancedWithNonDefaultNAndWeights() {
+ void testSimpleWandAdvancedWithNonDefaultNAndWeights() {
tester.assertParsed("WEAKAND(32) foo!32 bar!64 baz", "foo!32 weakand(32) bar!64 weakand(32) baz", Query.Type.ADVANCED);
}
@Test
- public void testTwoRanges() {
- tester.assertParsed("AND score:[1.25;2.18] age:[25;30]","score:[1.25;2.18] AND age:[25;30]", Query.Type.ADVANCED);
+ void testTwoRanges() {
+ tester.assertParsed("AND score:[1.25;2.18] age:[25;30]", "score:[1.25;2.18] AND age:[25;30]", Query.Type.ADVANCED);
}
@Test
- public void testTooLargeTermWeights() {
+ void testTooLargeTermWeights() {
// This behavior is a bit silly:
tester.assertParsed("AND a 12345678901234567890", "a!12345678901234567890", Query.Type.ALL);
// but in light of
@@ -2515,7 +2512,7 @@ public class ParseTestCase {
}
@Test
- public void testAndSegmenting() {
+ void testAndSegmenting() {
Item root = tester.parseQuery("a'b&c'd", Language.ENGLISH, Query.Type.ALL);
assertTrue(root instanceof AndItem);
AndItem top = (AndItem) root;
@@ -2527,59 +2524,59 @@ public class ParseTestCase {
Item t2 = seg1.getItem(1);
Item t3 = seg2.getItem(0);
Item t4 = seg2.getItem(1);
- assertTrue(((TaggableItem)t2).hasUniqueID());
- assertTrue(((TaggableItem)t3).hasUniqueID());
- assertTrue(((TaggableItem)t1).getConnectedItem() == t2);
- assertTrue(((TaggableItem)t2).getConnectedItem() == t3);
- assertTrue(((TaggableItem)t3).getConnectedItem() == t4);
+ assertTrue(((TaggableItem) t2).hasUniqueID());
+ assertTrue(((TaggableItem) t3).hasUniqueID());
+ assertEquals(((TaggableItem) t1).getConnectedItem(), t2);
+ assertEquals(((TaggableItem) t2).getConnectedItem(), t3);
+ assertEquals(((TaggableItem) t3).getConnectedItem(), t4);
}
@Test
- public void testSiteAndSegmentPhrases() {
+ void testSiteAndSegmentPhrases() {
tester.assertParsed("host.all:\"www abc com x y-z $\"",
- "host.all:www.abc.com/x'y-z", "",
- Query.Type.ALL, Language.ENGLISH);
+ "host.all:www.abc.com/x'y-z", "",
+ Query.Type.ALL, Language.ENGLISH);
}
@Test
- public void testSiteAndSegmentPhrasesFollowedByText() {
+ void testSiteAndSegmentPhrasesFollowedByText() {
tester.assertParsed("AND host.all:\"www abc com x y-z $\" (SAND a b)",
- "host.all:www.abc.com/x'y-z a'b", "",
- Query.Type.ALL, Language.ENGLISH);
+ "host.all:www.abc.com/x'y-z a'b", "",
+ Query.Type.ALL, Language.ENGLISH);
}
@Test
- public void testIntItemFollowedByDot() {
- tester.assertParsed("AND Campion Ste 3 When To Her Lute Corinna Sings","Campion Ste: 3. When To Her Lute Corinna Sings", Query.Type.ALL);
+ void testIntItemFollowedByDot() {
+ tester.assertParsed("AND Campion Ste 3 When To Her Lute Corinna Sings", "Campion Ste: 3. When To Her Lute Corinna Sings", Query.Type.ALL);
}
@Test
- public void testNotIntItemIfPrecededByHyphen() {
- tester.assertParsed("AND Horny Horny '98 Radio Edit","Horny [Horny '98 Radio Edit]]", Query.Type.ALL);
+ void testNotIntItemIfPrecededByHyphen() {
+ tester.assertParsed("AND Horny Horny '98 Radio Edit", "Horny [Horny '98 Radio Edit]]", Query.Type.ALL);
}
@Test
- public void testNonAsciiNumber() {
+ void testNonAsciiNumber() {
tester.assertParsed("AND title:199 title:119 title:201 title:149", "title:199.119.201.149", Query.Type.ALL);
}
@Test
- public void testNoGrammar1() {
+ void testNoGrammar1() {
tester.assertParsed("WEAKAND(100) foobar", "foobar", Query.Type.TOKENIZE);
}
@Test
- public void testNoGrammar2() {
+ void testNoGrammar2() {
tester.assertParsed("WEAKAND(100) foobar", "-foobar", Query.Type.TOKENIZE);
}
@Test
- public void testNoGrammar3() {
+ void testNoGrammar3() {
tester.assertParsed("WEAKAND(100) foo bar", "foo -bar", Query.Type.TOKENIZE);
}
@Test
- public void testNoGrammar4() {
+ void testNoGrammar4() {
tester.assertParsed("WEAKAND(100) foo bar baz one two 37", "foo -(bar baz \"one two\" 37)", Query.Type.TOKENIZE);
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParsingTester.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParsingTester.java
index 42bc1c22529..ab314c4c1e7 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParsingTester.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParsingTester.java
@@ -23,9 +23,7 @@ import com.yahoo.search.query.parser.ParserFactory;
import java.util.ArrayList;
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.*;
/**
* A utility for writing parser tests
@@ -119,10 +117,10 @@ public class ParsingTester {
Language language, Linguistics linguistics) {
Item root = parseQuery(toParse, filter, language, mode, linguistics);
if (parsed == null) {
- assertTrue("root should be null, but was " + root, root == null);
+ assertNull(root);
} else {
- assertNotNull("Got null from parsing " + toParse, root);
- assertEquals("Parse of '" + toParse + "'", parsed, root.toString());
+ assertNotNull(root, "Got null from parsing " + toParse);
+ assertEquals(parsed, root.toString(), "Parse of '" + toParse + "'");
}
return root;
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/SubstringTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/SubstringTestCase.java
index e7d938e6bd8..129563d1456 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/SubstringTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/SubstringTestCase.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.prelude.query.parser.test;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.CompositeItem;
import com.yahoo.prelude.query.WordItem;
import com.yahoo.search.Query;
@@ -11,6 +9,8 @@ import com.yahoo.search.Query;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Check Substring in conjunction with query tokenization and parsing behaves properly.
*
@@ -19,15 +19,15 @@ import java.net.URLEncoder;
public class SubstringTestCase {
@Test
- public final void testTokenLengthAndLowercasing() {
+ final void testTokenLengthAndLowercasing() {
Query q = new Query("/?query=\u0130");
- WordItem root = (WordItem) ((CompositeItem)q.getModel().getQueryTree().getRoot()).getItem(0);
+ WordItem root = (WordItem) ((CompositeItem) q.getModel().getQueryTree().getRoot()).getItem(0);
assertEquals("\u0130", root.getRawWord());
}
@Test
- public final void testBug5968479() {
+ final void testBug5968479() {
String first = "\u0130\u015EBANKASI";
String second = "GAZ\u0130EM\u0130R";
Query q = new Query("/?query=" + enc(first) + "%20" + enc(second));
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java
index 5b660f78429..1ff5574ec03 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/TokenizerTestCase.java
@@ -10,7 +10,7 @@ import com.yahoo.language.process.SpecialTokenRegistry;
import com.yahoo.language.process.SpecialTokens;
import com.yahoo.prelude.query.parser.Token;
import com.yahoo.prelude.query.parser.Tokenizer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,9 +29,7 @@ import static com.yahoo.prelude.query.parser.Token.Kind.SPACE;
import static com.yahoo.prelude.query.parser.Token.Kind.STAR;
import static com.yahoo.prelude.query.parser.Token.Kind.UNDERSCORE;
import static com.yahoo.prelude.query.parser.Token.Kind.WORD;
-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.*;
/**
* Tests the tokenizer
@@ -41,7 +39,7 @@ import static org.junit.Assert.assertTrue;
public class TokenizerTestCase {
@Test
- public void testPlainTokenization() {
+ void testPlainTokenization() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("default"));
@@ -76,14 +74,14 @@ public class TokenizerTestCase {
}
@Test
- public void testOutsideBMPCodepoints() {
+ void testOutsideBMPCodepoints() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
List<?> tokens = tokenizer.tokenize("\ud841\udd47");
assertEquals(new Token(WORD, "\ud841\udd47"), tokens.get(0));
}
@Test
- public void testOneSpecialToken() {
+ void testOneSpecialToken() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("default"));
@@ -93,7 +91,7 @@ public class TokenizerTestCase {
}
@Test
- public void testSpecialTokenCombination() {
+ void testSpecialTokenCombination() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("default"));
@@ -121,7 +119,7 @@ public class TokenizerTestCase {
* separated by space, as special token recognition happens before tokenization
*/
@Test
- public void testSpecialTokenCJK() {
+ void testSpecialTokenCJK() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSubstringSpecialTokens(true);
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("replacing"));
@@ -146,7 +144,7 @@ public class TokenizerTestCase {
}
@Test
- public void testSpecialTokenCaseInsensitive() {
+ void testSpecialTokenCaseInsensitive() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("default"));
@@ -162,7 +160,7 @@ public class TokenizerTestCase {
}
@Test
- public void testSpecialTokenNonMatch() {
+ void testSpecialTokenNonMatch() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("default"));
@@ -187,7 +185,7 @@ public class TokenizerTestCase {
}
@Test
- public void testSpecialTokenConfigurationDefault() {
+ void testSpecialTokenConfigurationDefault() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("default"));
@@ -212,7 +210,7 @@ public class TokenizerTestCase {
}
@Test
- public void testSpecialTokenConfigurationOther() {
+ void testSpecialTokenConfigurationOther() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("other"));
@@ -247,7 +245,7 @@ public class TokenizerTestCase {
}
@Test
- public void testTokenReplacing() {
+ void testTokenReplacing() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("replacing"));
@@ -273,7 +271,7 @@ public class TokenizerTestCase {
}
@Test
- public void testExactMatchTokenization() {
+ void testExactMatchTokenization() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index1 = new Index("testexact1");
@@ -286,8 +284,8 @@ public class TokenizerTestCase {
IndexFacts facts = new IndexFacts(new IndexModel(sd));
IndexFacts.Session session = facts.newSession(Collections.emptySet(), Collections.emptySet());
- Tokenizer tokenizer=new Tokenizer(new SimpleLinguistics());
- List<?> tokens=tokenizer.tokenize("normal a:b (normal testexact1:/,%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*& b:c", "default", session);
+ Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
+ List<?> tokens = tokenizer.tokenize("normal a:b (normal testexact1:/,%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*& b:c", "default", session);
// tokenizer.print();
assertEquals(new Token(WORD, "normal"), tokens.get(0));
assertEquals(new Token(SPACE, " "), tokens.get(1));
@@ -317,7 +315,7 @@ public class TokenizerTestCase {
}
@Test
- public void testExactMatchTokenizationTerminatorTerminatesQuery() {
+ void testExactMatchTokenizationTerminatorTerminatesQuery() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index1 = new Index("testexact1");
@@ -354,7 +352,7 @@ public class TokenizerTestCase {
}
@Test
- public void testExactMatchTokenizationWithTerminatorTerminatedByEndOfString() {
+ void testExactMatchTokenizationWithTerminatorTerminatedByEndOfString() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index1 = new Index("testexact1");
@@ -391,7 +389,7 @@ public class TokenizerTestCase {
}
@Test
- public void testExactMatchTokenizationEndsByColon() {
+ void testExactMatchTokenizationEndsByColon() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index1 = new Index("testexact1");
@@ -429,7 +427,7 @@ public class TokenizerTestCase {
}
@Test
- public void testExactMatchHeuristics() {
+ void testExactMatchHeuristics() {
SearchDefinition sd = new SearchDefinition("testsd");
Index index1 = new Index("testexact1");
@@ -542,7 +540,7 @@ public class TokenizerTestCase {
assertEquals(new Token(WORD, "testexact1"), tokens.get(0));
assertEquals(new Token(COLON, ":"), tokens.get(1));
assertEquals(new Token(STAR, "*"), tokens.get(2));
- assertEquals(new Token(WORD, "foobar*!100"),tokens.get(3));
+ assertEquals(new Token(WORD, "foobar*!100"), tokens.get(3));
assertEquals(new Token(EXCLAMATION, "!"), tokens.get(4));
tokens = tokenizer.tokenize("testexact1:foo(bar)", facts);
@@ -582,7 +580,7 @@ public class TokenizerTestCase {
tokens = tokenizer.tokenize("testexact1:\"news search\" testexact2:resolved", facts);
assertEquals(new Token(WORD, "testexact1"), tokens.get(0));
assertEquals(new Token(COLON, ":"), tokens.get(1));
- assertEquals(new Token(WORD, "news search"),tokens.get(2));
+ assertEquals(new Token(WORD, "news search"), tokens.get(2));
assertEquals(new Token(SPACE, " "), tokens.get(3));
assertEquals(new Token(WORD, "testexact2"), tokens.get(4));
assertEquals(new Token(COLON, ":"), tokens.get(5));
@@ -592,7 +590,7 @@ public class TokenizerTestCase {
assertEquals(new Token(LBRACE, "("), tokens.get(0));
assertEquals(new Token(WORD, "testexact1"), tokens.get(1));
assertEquals(new Token(COLON, ":"), tokens.get(2));
- assertEquals(new Token(WORD, "news search"),tokens.get(3));
+ assertEquals(new Token(WORD, "news search"), tokens.get(3));
assertEquals(new Token(SPACE, " "), tokens.get(4));
assertEquals(new Token(WORD, "testexact1"), tokens.get(5));
assertEquals(new Token(COLON, ":"), tokens.get(6));
@@ -614,7 +612,7 @@ public class TokenizerTestCase {
tokens = tokenizer.tokenize("testexact1:\"news search\"!200", facts);
assertEquals(new Token(WORD, "testexact1"), tokens.get(0));
assertEquals(new Token(COLON, ":"), tokens.get(1));
- assertEquals(new Token(WORD, "news search"),tokens.get(2));
+ assertEquals(new Token(WORD, "news search"), tokens.get(2));
assertEquals(new Token(EXCLAMATION, "!"), tokens.get(3));
assertEquals(new Token(NUMBER, "200"), tokens.get(4));
@@ -705,7 +703,7 @@ public class TokenizerTestCase {
}
@Test
- public void testSingleQuoteAsWordCharacter() {
+ void testSingleQuoteAsWordCharacter() {
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
tokenizer.setSpecialTokens(createSpecialTokens().getSpecialTokens("default"));
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/WashPhrasesTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/WashPhrasesTestCase.java
index 061089cd25f..f0b768a010f 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/WashPhrasesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/WashPhrasesTestCase.java
@@ -13,10 +13,10 @@ import com.yahoo.search.query.parser.Parsable;
import com.yahoo.search.query.parser.Parser;
import com.yahoo.search.query.parser.ParserEnvironment;
import com.yahoo.search.query.parser.ParserFactory;
-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 guards against in single item phrases.
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertNull;
public class WashPhrasesTestCase {
@Test
- public void testSimplePositive() {
+ void testSimplePositive() {
PhraseItem root = new PhraseItem();
root.addItem(new WordItem("abc"));
@@ -34,7 +34,7 @@ public class WashPhrasesTestCase {
}
@Test
- public void testPositive1() {
+ void testPositive1() {
AndItem root = new AndItem();
root.addItem(new WordItem("a"));
@@ -47,7 +47,7 @@ public class WashPhrasesTestCase {
}
@Test
- public void testPositive2() {
+ void testPositive2() {
AndItem root = new AndItem();
root.addItem(new WordItem("a"));
@@ -64,22 +64,22 @@ public class WashPhrasesTestCase {
}
@Test
- public void testNoTerms() {
+ void testNoTerms() {
assertNull(transformQuery("\"\""));
}
@Test
- public void testNegative1() {
+ void testNegative1() {
assertEquals("\"abc def\"", transformQuery("\"abc def\""));
}
@Test
- public void testNegative2() {
+ void testNegative2() {
assertEquals("AND a \"abc def\" b", transformQuery("a \"abc def\" b"));
}
- @Test
- public void testNegative3() {
+ @Test
+ void testNegative3() {
AndItem root = new AndItem();
root.addItem(new WordItem("a"));
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/DotProductItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/DotProductItemTestCase.java
index 1585e58ca5d..2bb8584cba3 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/DotProductItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/DotProductItemTestCase.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.prelude.query.test;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* @author havardpe
*/
public class DotProductItemTestCase {
@Test
- public void testDotProductItem() {
+ void testDotProductItem() {
DotProductItem item = new DotProductItem("index_name");
assertEquals("index_name", item.getIndexName());
assertEquals(Item.ItemType.DOTPRODUCT, item.getItemType());
}
@Test
- public void testDotProductClone() {
+ void testDotProductClone() {
DotProductItem dpOrig = new DotProductItem("myDP");
- dpOrig.addToken("first",11);
+ dpOrig.addToken("first", 11);
dpOrig.getTokens();
DotProductItem dpClone = (DotProductItem) dpOrig.clone();
dpClone.addToken("second", 22);
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/IntItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/IntItemTestCase.java
index 28cf5008417..3e1abddbdf4 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/IntItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/IntItemTestCase.java
@@ -5,9 +5,9 @@ import com.yahoo.prelude.query.AndItem;
import com.yahoo.prelude.query.IntItem;
import com.yahoo.prelude.query.WeakAndItem;
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
@@ -15,7 +15,7 @@ import static org.junit.Assert.assertEquals;
public class IntItemTestCase {
@Test
- public void testEquals() {
+ void testEquals() {
Query q1 = new Query("/?query=123%20456%20789");
Query q2 = new Query("/?query=123%20456");
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/ItemEncodingTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/ItemEncodingTestCase.java
index eb880bab826..c43d7e3b9d5 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/ItemEncodingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/ItemEncodingTestCase.java
@@ -10,11 +10,11 @@ import com.yahoo.prelude.query.PureWeightedInteger;
import com.yahoo.prelude.query.PureWeightedString;
import com.yahoo.prelude.query.WeakAndItem;
import com.yahoo.prelude.query.WordItem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Item encoding tests
@@ -25,17 +25,17 @@ public class ItemEncodingTestCase {
private void assertType(ByteBuffer buffer, int etype, int features) {
byte type = buffer.get();
- assertEquals("Code", etype, type & 0x1f);
- assertEquals("Features", features, (type & 0xe0) >> 5);
+ assertEquals(etype, type & 0x1f, "Code");
+ assertEquals(features, (type & 0xe0) >> 5, "Features");
}
private void assertWeight(ByteBuffer buffer, int weight) {
int w = (weight > (1 << 5)) ? buffer.getShort() & 0x3fff: buffer.get();
- assertEquals("Weight", weight, w);
+ assertEquals(weight, w, "Weight");
}
@Test
- public void testWordItemEncoding() {
+ void testWordItemEncoding() {
WordItem word = new WordItem("test");
word.setWeight(150);
@@ -44,14 +44,14 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 1, count);
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 4, 1);
assertWeight(buffer, 150);
- assertEquals("Index length", 0, buffer.get());
- assertEquals("Word length", 4, buffer.get());
- assertEquals("Word length", 4, buffer.remaining());
+ assertEquals(0, buffer.get(), "Index length");
+ assertEquals(4, buffer.get(), "Word length");
+ assertEquals(4, buffer.remaining(), "Word length");
assertEquals('t', buffer.get());
assertEquals('e', buffer.get());
assertEquals('s', buffer.get());
@@ -59,20 +59,20 @@ public class ItemEncodingTestCase {
}
@Test
- public void testStartHostMarkerEncoding() {
+ void testStartHostMarkerEncoding() {
WordItem word = MarkerWordItem.createStartOfHost();
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = word.encode(buffer);
buffer.flip();
- assertEquals("Serialization count", 1, count);
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 4, 0);
- assertEquals("Index length", 0, buffer.get());
- assertEquals("Word length", 9, buffer.get());
- assertEquals("Word length", 9, buffer.remaining());
+ assertEquals(0, buffer.get(), "Index length");
+ assertEquals(9, buffer.get(), "Word length");
+ assertEquals(9, buffer.remaining(), "Word length");
assertEquals('S', buffer.get());
assertEquals('t', buffer.get());
assertEquals('A', buffer.get());
@@ -85,7 +85,7 @@ public class ItemEncodingTestCase {
}
@Test
- public void testEndHostMarkerEncoding() {
+ void testEndHostMarkerEncoding() {
WordItem word = MarkerWordItem.createEndOfHost();
ByteBuffer buffer = ByteBuffer.allocate(128);
@@ -93,13 +93,13 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 1, count);
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 4, 0);
- assertEquals("Index length", 0, buffer.get());
- assertEquals("Word length", 7, buffer.get());
- assertEquals("Word length", 7, buffer.remaining());
+ assertEquals(0, buffer.get(), "Index length");
+ assertEquals(7, buffer.get(), "Word length");
+ assertEquals(7, buffer.remaining(), "Word length");
assertEquals('E', buffer.get());
assertEquals('n', buffer.get());
assertEquals('D', buffer.get());
@@ -110,7 +110,7 @@ public class ItemEncodingTestCase {
}
@Test
- public void testFilterWordItemEncoding() {
+ void testFilterWordItemEncoding() {
WordItem word = new WordItem("test");
word.setFilter(true);
@@ -119,14 +119,14 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 1, count);
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 4, 4);
assertEquals(0x08, buffer.get());
- assertEquals("Index length", 0, buffer.get());
- assertEquals("Word length", 4, buffer.get());
- assertEquals("Word length", 4, buffer.remaining());
+ assertEquals(0, buffer.get(), "Index length");
+ assertEquals(4, buffer.get(), "Word length");
+ assertEquals(4, buffer.remaining(), "Word length");
assertEquals('t', buffer.get());
assertEquals('e', buffer.get());
assertEquals('s', buffer.get());
@@ -134,7 +134,7 @@ public class ItemEncodingTestCase {
}
@Test
- public void testNoRankedNoPositionDataWordItemEncoding() {
+ void testNoRankedNoPositionDataWordItemEncoding() {
WordItem word = new WordItem("test");
word.setRanked(false);
word.setPositionData(false);
@@ -144,14 +144,14 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 1, count);
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 4, 4);
assertEquals(0x05, buffer.get());
- assertEquals("Index length", 0, buffer.get());
- assertEquals("Word length", 4, buffer.get());
- assertEquals("Word length", 4, buffer.remaining());
+ assertEquals(0, buffer.get(), "Index length");
+ assertEquals(4, buffer.get(), "Word length");
+ assertEquals(4, buffer.remaining(), "Word length");
assertEquals('t', buffer.get());
assertEquals('e', buffer.get());
assertEquals('s', buffer.get());
@@ -159,10 +159,10 @@ public class ItemEncodingTestCase {
}
@Test
- public void testAndItemEncoding() {
+ void testAndItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
- AndItem and=new AndItem();
+ AndItem and = new AndItem();
and.addItem(a);
and.addItem(b);
@@ -171,21 +171,21 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 3, count);
+ assertEquals(3, count, "Serialization count");
assertType(buffer, 1, 0);
- assertEquals("And arity", 2, buffer.get());
+ assertEquals(2, buffer.get(), "And arity");
- assertWord(buffer,"a");
- assertWord(buffer,"b");
+ assertWord(buffer, "a");
+ assertWord(buffer, "b");
}
@Test
- public void testNearItemEncoding() {
+ void testNearItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
- NearItem near=new NearItem(7);
+ NearItem near = new NearItem(7);
near.addItem(a);
near.addItem(b);
@@ -194,22 +194,22 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 3, count);
+ assertEquals(3, count, "Serialization count");
assertType(buffer, 11, 0);
- assertEquals("Near arity", 2, buffer.get());
- assertEquals("Limit", 7, buffer.get());
+ assertEquals(2, buffer.get(), "Near arity");
+ assertEquals(7, buffer.get(), "Limit");
- assertWord(buffer,"a");
- assertWord(buffer,"b");
+ assertWord(buffer, "a");
+ assertWord(buffer, "b");
}
@Test
- public void testONearItemEncoding() {
+ void testONearItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
- NearItem onear=new ONearItem(7);
+ NearItem onear = new ONearItem(7);
onear.addItem(a);
onear.addItem(b);
@@ -218,18 +218,18 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 3, count);
+ assertEquals(3, count, "Serialization count");
assertType(buffer, 12, 0);
- assertEquals("Near arity", 2, buffer.get());
- assertEquals("Limit", 7, buffer.get());
+ assertEquals(2, buffer.get(), "Near arity");
+ assertEquals(7, buffer.get(), "Limit");
- assertWord(buffer,"a");
- assertWord(buffer,"b");
+ assertWord(buffer, "a");
+ assertWord(buffer, "b");
}
@Test
- public void testEquivItemEncoding() {
+ void testEquivItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
EquivItem equiv = new EquivItem();
@@ -241,17 +241,17 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 3, count);
+ assertEquals(3, count, "Serialization count");
assertType(buffer, 14, 0);
- assertEquals("Equiv arity", 2, buffer.get());
+ assertEquals(2, buffer.get(), "Equiv arity");
assertWord(buffer, "a");
assertWord(buffer, "b");
}
@Test
- public void testWandItemEncoding() {
+ void testWandItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
WeakAndItem wand = new WeakAndItem();
@@ -263,11 +263,11 @@ public class ItemEncodingTestCase {
buffer.flip();
- assertEquals("Serialization count", 3, count);
+ assertEquals(3, count, "Serialization count");
assertType(buffer, 16, 0);
- assertEquals("WeakAnd arity", 2, buffer.get());
- assertEquals("WeakAnd N", 100, buffer.getShort() & 0x3fff);
+ assertEquals(2, buffer.get(), "WeakAnd arity");
+ assertEquals(100, buffer.getShort() & 0x3fff, "WeakAnd N");
assertEquals(0, buffer.get());
assertWord(buffer, "a");
@@ -275,65 +275,66 @@ public class ItemEncodingTestCase {
}
@Test
- public void testPureWeightedStringEncoding() {
+ void testPureWeightedStringEncoding() {
PureWeightedString a = new PureWeightedString("a");
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = a.encode(buffer);
buffer.flip();
- assertEquals("Serialization size", 3, buffer.remaining());
- assertEquals("Serialization count", 1, count);
+ assertEquals(3, buffer.remaining(), "Serialization size");
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 19, 0);
assertString(buffer, a.getString());
}
@Test
- public void testPureWeightedStringEncodingWithNonDefaultWeight() {
+ void testPureWeightedStringEncodingWithNonDefaultWeight() {
PureWeightedString a = new PureWeightedString("a", 7);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = a.encode(buffer);
buffer.flip();
- assertEquals("Serialization size", 4, buffer.remaining());
- assertEquals("Serialization count", 1, count);
+ assertEquals(4, buffer.remaining(), "Serialization size");
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 19, 1);
assertWeight(buffer, 7);
assertString(buffer, a.getString());
}
@Test
- public void testPureWeightedIntegerEncoding() {
+ void testPureWeightedIntegerEncoding() {
PureWeightedInteger a = new PureWeightedInteger(23432568763534865l);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = a.encode(buffer);
buffer.flip();
- assertEquals("Serialization size", 9, buffer.remaining());
- assertEquals("Serialization count", 1, count);
+ assertEquals(9, buffer.remaining(), "Serialization size");
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 20, 0);
- assertEquals("Value", a.getValue(), buffer.getLong());
+ assertEquals(a.getValue(), buffer.getLong(), "Value");
}
@Test
- public void testPureWeightedLongEncodingWithNonDefaultWeight() {
+ void testPureWeightedLongEncodingWithNonDefaultWeight() {
PureWeightedInteger a = new PureWeightedInteger(23432568763534865l, 7);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = a.encode(buffer);
buffer.flip();
- assertEquals("Serialization size", 10, buffer.remaining());
- assertEquals("Serialization count", 1, count);
+ assertEquals(10, buffer.remaining(), "Serialization size");
+ assertEquals(1, count, "Serialization count");
assertType(buffer, 20, 1);
assertWeight(buffer, 7);
- assertEquals("Value", a.getValue(), buffer.getLong());;
+ assertEquals(a.getValue(), buffer.getLong(), "Value");
+ ;
}
private void assertString(ByteBuffer buffer, String word) {
- assertEquals("Word length", word.length(), buffer.get());
+ assertEquals(word.length(), buffer.get(), "Word length");
for (int i=0; i<word.length(); i++) {
- assertEquals("Character at " + i,word.charAt(i), buffer.get());
+ assertEquals(word.charAt(i), buffer.get(), "Character at " + i);
}
}
private void assertWord(ByteBuffer buffer,String word) {
assertType(buffer, 4, 0);
- assertEquals("Index length", 0, buffer.get());
+ assertEquals(0, buffer.get(), "Index length");
assertString(buffer, word);
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/PhraseItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/PhraseItemTestCase.java
index bd0bfd3f29a..1e4418f1b73 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/PhraseItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/PhraseItemTestCase.java
@@ -4,9 +4,9 @@ package com.yahoo.prelude.query.test;
import com.yahoo.prelude.query.PhraseItem;
import com.yahoo.prelude.query.PhraseSegmentItem;
import com.yahoo.prelude.query.WordItem;
-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 methods changing phrase items.
@@ -16,7 +16,7 @@ import static org.junit.Assert.assertEquals;
public class PhraseItemTestCase {
@Test
- public void testAddItem() {
+ void testAddItem() {
PhraseItem p = new PhraseItem();
PhraseSegmentItem pp = new PhraseSegmentItem("", false, false);
PhraseItem ppp = new PhraseItem();
@@ -32,7 +32,7 @@ public class PhraseItemTestCase {
}
@Test
- public void testAddItemWithIndex() {
+ void testAddItemWithIndex() {
PhraseItem p = new PhraseItem();
PhraseSegmentItem pp = new PhraseSegmentItem("", false, false);
PhraseItem ppp = new PhraseItem();
@@ -48,7 +48,7 @@ public class PhraseItemTestCase {
}
@Test
- public void testSetItem() {
+ void testSetItem() {
PhraseItem backup = new PhraseItem();
PhraseSegmentItem segment = new PhraseSegmentItem("", false, false);
PhraseItem innerPhrase = new PhraseItem();
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/PredicateQueryItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/PredicateQueryItemTestCase.java
index 1fe0ded8d6b..a27a11b8f15 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/PredicateQueryItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/PredicateQueryItemTestCase.java
@@ -3,14 +3,14 @@ package com.yahoo.prelude.query.test;
import com.yahoo.prelude.query.Item;
import com.yahoo.prelude.query.PredicateQueryItem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Iterator;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Magnar Nedland
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals;
public class PredicateQueryItemTestCase {
@Test
- public void requireThatItemConstantsAreSet() {
+ void requireThatItemConstantsAreSet() {
PredicateQueryItem item = new PredicateQueryItem();
assertEquals(Item.ItemType.PREDICATE_QUERY, item.getItemType());
assertEquals("PREDICATE_QUERY_ITEM", item.getName());
@@ -29,7 +29,7 @@ public class PredicateQueryItemTestCase {
}
@Test
- public void requireThatFeaturesCanBeAdded() {
+ void requireThatFeaturesCanBeAdded() {
PredicateQueryItem item = new PredicateQueryItem();
assertEquals(0, item.getFeatures().size());
item.addFeature("foo", "bar");
@@ -45,7 +45,7 @@ public class PredicateQueryItemTestCase {
}
@Test
- public void requireThatRangeFeaturesCanBeAdded() {
+ void requireThatRangeFeaturesCanBeAdded() {
PredicateQueryItem item = new PredicateQueryItem();
assertEquals(0, item.getRangeFeatures().size());
item.addRangeFeature("foo", 23);
@@ -61,7 +61,7 @@ public class PredicateQueryItemTestCase {
}
@Test
- public void requireThatToStringWorks() {
+ void requireThatToStringWorks() {
PredicateQueryItem item = new PredicateQueryItem();
assertEquals("PREDICATE_QUERY_ITEM ", item.toString());
item.addFeature("foo", "bar");
@@ -73,7 +73,7 @@ public class PredicateQueryItemTestCase {
}
@Test
- public void requireThatPredicateQueryItemCanBeEncoded() {
+ void requireThatPredicateQueryItemCanBeEncoded() {
PredicateQueryItem item = new PredicateQueryItem();
assertEquals("PREDICATE_QUERY_ITEM ", item.toString());
item.addFeature("foo", "bar");
@@ -84,12 +84,12 @@ public class PredicateQueryItemTestCase {
byte[] actual = new byte[buffer.remaining()];
buffer.get(actual);
assertArrayEquals(new byte[]{
- 23, // PREDICATE_QUERY code 23
- 9, 'p', 'r', 'e', 'd', 'i', 'c', 'a', 't', 'e',
- 2, // 2 features
- 3, 'f', 'o', 'o', 3, 'b', 'a', 'r', -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
- 3, 'f', 'o', 'o', 3, 'b', 'a', 'z', 0, 0, 0, 0, 0, 0, -1, -1, // key, value, subquery
- 0}, // no range features
+ 23, // PREDICATE_QUERY code 23
+ 9, 'p', 'r', 'e', 'd', 'i', 'c', 'a', 't', 'e',
+ 2, // 2 features
+ 3, 'f', 'o', 'o', 3, 'b', 'a', 'r', -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
+ 3, 'f', 'o', 'o', 3, 'b', 'a', 'z', 0, 0, 0, 0, 0, 0, -1, -1, // key, value, subquery
+ 0}, // no range features
actual);
item.addRangeFeature("foo", 23);
@@ -100,19 +100,19 @@ public class PredicateQueryItemTestCase {
actual = new byte[buffer.remaining()];
buffer.get(actual);
assertArrayEquals(new byte[]{
- 23, // PREDICATE_QUERY code 23
- 9, 'p', 'r', 'e', 'd', 'i', 'c', 'a', 't', 'e',
- 2, // 2 features
- 3, 'f', 'o', 'o', 3, 'b', 'a', 'r', -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
- 3, 'f', 'o', 'o', 3, 'b', 'a', 'z', 0, 0, 0, 0, 0, 0, -1, -1, // key, value, subquery
- 2, // 2 range features
- 3, 'f', 'o', 'o', 0, 0, 0, 0, 0, 0, 0, 23, -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
- 3, 'f', 'o', 'o', 0, 0, 0, 0, 0, 0, 0, 34, -1, -1, -1, -1, -1, -1, -1, -2}, // key, value, subquery
+ 23, // PREDICATE_QUERY code 23
+ 9, 'p', 'r', 'e', 'd', 'i', 'c', 'a', 't', 'e',
+ 2, // 2 features
+ 3, 'f', 'o', 'o', 3, 'b', 'a', 'r', -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
+ 3, 'f', 'o', 'o', 3, 'b', 'a', 'z', 0, 0, 0, 0, 0, 0, -1, -1, // key, value, subquery
+ 2, // 2 range features
+ 3, 'f', 'o', 'o', 0, 0, 0, 0, 0, 0, 0, 23, -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
+ 3, 'f', 'o', 'o', 0, 0, 0, 0, 0, 0, 0, 34, -1, -1, -1, -1, -1, -1, -1, -2}, // key, value, subquery
actual);
}
@Test
- public void requireThatPredicateQueryItemWithManyAttributesCanBeEncoded() {
+ void requireThatPredicateQueryItemWithManyAttributesCanBeEncoded() {
PredicateQueryItem item = new PredicateQueryItem();
assertEquals("PREDICATE_QUERY_ITEM ", item.toString());
for (int i = 0; i < 200; ++i) {
@@ -126,11 +126,11 @@ public class PredicateQueryItemTestCase {
byte [] expectedPrefix = new byte[]{
23, // PREDICATE_QUERY code 23
9, 'p', 'r', 'e', 'd', 'i', 'c', 'a', 't', 'e',
- (byte)0x80, (byte)0xc8, // 200 features (0x80c8 => 0xc8 == 200)
+ (byte) 0x80, (byte) 0xc8, // 200 features (0x80c8 => 0xc8 == 200)
3, 'f', 'o', 'o', 3, 'b', 'a', 'r', -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
3, 'f', 'o', 'o', 3, 'b', 'a', 'r', -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
3, 'f', 'o', 'o', 3, 'b', 'a', 'r', -1, -1, -1, -1, -1, -1, -1, -1, // key, value, subquery
- }; // ...
+ }; // ...
assertArrayEquals(expectedPrefix, Arrays.copyOfRange(actual, 0, expectedPrefix.length));
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/QueryCanonicalizerTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/QueryCanonicalizerTestCase.java
index cd8691d9db0..81aa28a5326 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/QueryCanonicalizerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/QueryCanonicalizerTestCase.java
@@ -4,12 +4,9 @@ package com.yahoo.prelude.query.test;
import com.yahoo.prelude.query.*;
import com.yahoo.search.Query;
import com.yahoo.search.query.QueryTree;
-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.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -17,7 +14,7 @@ import static org.junit.Assert.assertFalse;
public class QueryCanonicalizerTestCase {
@Test
- public void testSingleLevelSingleItemComposite() {
+ void testSingleLevelSingleItemComposite() {
CompositeItem root = new AndItem();
root.addItem(new WordItem("word"));
@@ -25,7 +22,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testSingleLevelSingleItemNonReducibleComposite() {
+ void testSingleLevelSingleItemNonReducibleComposite() {
CompositeItem root = new WeakAndItem();
root.addItem(new WordItem("word"));
@@ -33,7 +30,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testMultilevelSingleItemComposite() {
+ void testMultilevelSingleItemComposite() {
CompositeItem root = new AndItem();
CompositeItem and1 = new AndItem();
CompositeItem and2 = new AndItem();
@@ -45,7 +42,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testMultilevelComposite() {
+ void testMultilevelComposite() {
// AND (RANK (AND a b c)) WAND(25,0.0,1.0)
AndItem and = new AndItem();
RankItem rank = new RankItem();
@@ -62,7 +59,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testMultilevelEmptyComposite() {
+ void testMultilevelEmptyComposite() {
CompositeItem root = new AndItem();
CompositeItem and1 = new AndItem();
CompositeItem and2 = new AndItem();
@@ -73,7 +70,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testMultilevelMultiBranchEmptyComposite() {
+ void testMultilevelMultiBranchEmptyComposite() {
CompositeItem root = new AndItem();
CompositeItem and1 = new AndItem();
CompositeItem and21 = new AndItem();
@@ -90,7 +87,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testMultilevelMultiBranchSingleItemComposite() {
+ void testMultilevelMultiBranchSingleItemComposite() {
CompositeItem root = new AndItem();
CompositeItem and1 = new AndItem();
CompositeItem and21 = new AndItem();
@@ -108,7 +105,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testMultilevelWeakAndCollapsing() {
+ void testMultilevelWeakAndCollapsing() {
CompositeItem root = new WeakAndItem();
CompositeItem l1 = new WeakAndItem();
CompositeItem l2 = new WeakAndItem();
@@ -132,7 +129,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testWeakAndCollapsingRequireSameNAndIndex() {
+ void testWeakAndCollapsingRequireSameNAndIndex() {
CompositeItem root = new WeakAndItem(10);
CompositeItem l1 = new WeakAndItem(100);
CompositeItem l2 = new WeakAndItem(100);
@@ -149,12 +146,12 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testNullRoot() {
+ void testNullRoot() {
assertCanonicalized(null, "No query", new Query());
}
@Test
- public void testNestedNull() {
+ void testNestedNull() {
CompositeItem root = new AndItem();
CompositeItem or = new AndItem();
CompositeItem and = new AndItem();
@@ -169,7 +166,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testNestedNullItem() {
+ void testNestedNullItem() {
CompositeItem root = new AndItem();
CompositeItem or = new AndItem();
CompositeItem and = new AndItem();
@@ -186,7 +183,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testNestedNullAndSingle() {
+ void testNestedNullAndSingle() {
CompositeItem root = new AndItem();
CompositeItem or = new OrItem();
@@ -199,7 +196,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testRemovalOfUnnecessaryComposites() {
+ void testRemovalOfUnnecessaryComposites() {
CompositeItem root = new AndItem();
CompositeItem or = new OrItem();
@@ -215,21 +212,21 @@ public class QueryCanonicalizerTestCase {
/** Multiple levels of the same AND/OR should collapse */
@Test
- public void testMultilevelCollapsing() {
+ void testMultilevelCollapsing() {
CompositeItem root = new AndItem();
CompositeItem l1 = new AndItem();
CompositeItem l2 = new AndItem();
CompositeItem l3 = new AndItem();
-
+
root.addItem(l1);
l1.addItem(new WordItem("l1i1"));
l1.addItem(l2);
-
+
l2.addItem(new WordItem("l2i1"));
l2.addItem(l3);
l2.addItem(new WordItem("l2i2"));
-
+
l3.addItem(new WordItem("l3i1"));
l3.addItem(new WordItem("l3i2"));
@@ -238,7 +235,7 @@ public class QueryCanonicalizerTestCase {
/** Multiple levels of different composites should not collapse */
@Test
- public void testMultilevelNonCollapsing() {
+ void testMultilevelNonCollapsing() {
CompositeItem root = new AndItem();
CompositeItem l1 = new AndItem();
CompositeItem l2 = new OrItem();
@@ -259,7 +256,7 @@ public class QueryCanonicalizerTestCase {
/** Multiple levels of RANK should collapse */
@Test
- public void testMultilevelRankCollapsing() {
+ void testMultilevelRankCollapsing() {
CompositeItem root = new RankItem();
CompositeItem l1 = new RankItem();
CompositeItem l2 = new RankItem();
@@ -283,7 +280,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testNegativeMustHaveNegatives() {
+ void testNegativeMustHaveNegatives() {
CompositeItem root = new NotItem();
root.addItem(new WordItem("positive"));
@@ -291,26 +288,26 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testNegative() {
+ void testNegative() {
NotItem root = new NotItem();
root.addNegativeItem(new WordItem("negative"));
- assertCanonicalized("-negative",null, root);
+ assertCanonicalized("-negative", null, root);
}
@Test
- public void testNegativeOnly() {
+ void testNegativeOnly() {
CompositeItem root = new AndItem();
NotItem not = new NotItem();
root.addItem(not);
root.addItem(new WordItem("word"));
not.addNegativeItem(new WordItem("negative"));
- assertCanonicalized("AND (-negative) word",null, root);
+ assertCanonicalized("AND (-negative) word", null, root);
}
@Test
- public void testCollapseFalseItemInAnd() {
+ void testCollapseFalseItemInAnd() {
CompositeItem root = new AndItem();
root.addItem(new WordItem("i1"));
root.addItem(new FalseItem());
@@ -318,7 +315,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testRemoveFalseItemInOr() {
+ void testRemoveFalseItemInOr() {
CompositeItem root = new OrItem();
AndItem and = new AndItem(); // this gets collapse to just FALSE, which is then removed
root.addItem(and);
@@ -329,7 +326,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testCollapseFalseItemInNot() {
+ void testCollapseFalseItemInNot() {
CompositeItem root = new NotItem();
root.addItem(new FalseItem()); // false ANDNOT ... is false
root.addItem(new WordItem("i1"));
@@ -337,7 +334,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testRemoveFalseItemInNot() {
+ void testRemoveFalseItemInNot() {
CompositeItem root = new NotItem();
root.addItem(new WordItem("i1"));
root.addItem(new FalseItem()); // ... ANDNOT false is redundant
@@ -345,7 +342,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testCollapseFalseItemInRank() {
+ void testCollapseFalseItemInRank() {
CompositeItem root = new RankItem();
root.addItem(new FalseItem()); // false RANK ... is false
root.addItem(new WordItem("i1"));
@@ -353,7 +350,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testRemoveFalseItemInRank() {
+ void testRemoveFalseItemInRank() {
CompositeItem root = new RankItem();
root.addItem(new WordItem("i1"));
root.addItem(new FalseItem()); // ... RANK false is redundant
@@ -365,13 +362,13 @@ public class QueryCanonicalizerTestCase {
* (which strictly is an implementation detail which we should rather hide).
*/
@Test
- public void testConnexityAndCloning() {
+ void testConnexityAndCloning() {
Query q = new Query("?query=a%20b");
CompositeItem root = (CompositeItem) q.getModel().getQueryTree().getRoot();
((WordItem) root.getItem(0)).setConnectivity(root.getItem(1), java.lang.Math.E);
q = q.clone();
- assertNull("Not prepared yet", q.getRanking().getProperties().get("vespa.term.1.connexity"));
+ assertNull(q.getRanking().getProperties().get("vespa.term.1.connexity"), "Not prepared yet");
q.prepare();
assertEquals("2", q.getRanking().getProperties().get("vespa.term.1.connexity").get(0));
assertEquals("2.718281828459045", q.getRanking().getProperties().get("vespa.term.1.connexity").get(1));
@@ -385,7 +382,7 @@ public class QueryCanonicalizerTestCase {
* (which strictly is an implementation detail which we should rather hide).
*/
@Test
- public void testSignificance() {
+ void testSignificance() {
Query q = new Query("?query=a%20b");
CompositeItem root = (CompositeItem) q.getModel().getQueryTree().getRoot();
((WordItem) root.getItem(0)).setSignificance(0.5);
@@ -396,7 +393,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testPhraseWeight() {
+ void testPhraseWeight() {
PhraseItem root = new PhraseItem();
root.setWeight(200);
root.addItem(new WordItem("a"));
@@ -404,7 +401,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testEquivDuplicateRemoval() {
+ void testEquivDuplicateRemoval() {
{
EquivItem root = new EquivItem();
root.addItem(new WordItem("a"));
@@ -470,7 +467,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void testRankDuplicateCheapification() {
+ void testRankDuplicateCheapification() {
AndItem and = new AndItem();
WordItem shoe = new WordItem("shoe", "prod");
and.addItem(shoe);
@@ -491,7 +488,7 @@ public class QueryCanonicalizerTestCase {
}
@Test
- public void queryTreeExceedsAllowedSize() {
+ void queryTreeExceedsAllowedSize() {
Query query = new Query();
QueryTree tree = query.getModel().getQueryTree();
tree.setRoot(new WordItem("A"));
@@ -513,7 +510,7 @@ public class QueryCanonicalizerTestCase {
assertEquals(expectedError, error);
if (canonicalForm == null) {
- assertNull(null, query.getModel().getQueryTree().getRoot());
+ assertNull(query.getModel().getQueryTree().getRoot());
} else {
assertEquals(canonicalForm, query.getModel().getQueryTree().getRoot().toString());
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/QueryLanguageTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/QueryLanguageTestCase.java
index a43f1a542c3..12d179b489e 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/QueryLanguageTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/QueryLanguageTestCase.java
@@ -6,9 +6,9 @@ import com.yahoo.prelude.query.NotItem;
import com.yahoo.prelude.query.PhraseItem;
import com.yahoo.prelude.query.WordItem;
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;
/**
* <p>Tests that the correct query language strings are generated for various
@@ -24,14 +24,14 @@ import static org.junit.Assert.assertEquals;
public class QueryLanguageTestCase {
@Test
- public void testWord() {
+ void testWord() {
WordItem w = new WordItem("test");
assertEquals("test", w.toString());
}
@Test
- public void testWordWithIndex() {
+ void testWordWithIndex() {
WordItem w = new WordItem("test");
w.setIndexName("test.index");
@@ -39,7 +39,7 @@ public class QueryLanguageTestCase {
}
@Test
- public void testPhrase() {
+ void testPhrase() {
PhraseItem p = new PhraseItem();
p.addItem(new WordItem("part"));
@@ -49,7 +49,7 @@ public class QueryLanguageTestCase {
}
@Test
- public void testPhraseWithIndex() {
+ void testPhraseWithIndex() {
PhraseItem p = new PhraseItem();
p.addItem(new WordItem("part"));
@@ -60,7 +60,7 @@ public class QueryLanguageTestCase {
}
@Test
- public void testNotItem() {
+ void testNotItem() {
NotItem n = new NotItem();
n.addNegativeItem(new WordItem("notthis"));
@@ -70,22 +70,22 @@ public class QueryLanguageTestCase {
}
@Test
- public void testLanguagesInQueryParameter() {
+ void testLanguagesInQueryParameter() {
// Right parameter is the parameter given in the query, as language=
// Left parameter is the language sent to linguistics
// Ancient
- assertLanguage(Language.CHINESE_SIMPLIFIED,"zh-cn");
- assertLanguage(Language.CHINESE_SIMPLIFIED,"zh-Hans");
- assertLanguage(Language.CHINESE_SIMPLIFIED,"zh-hans");
- assertLanguage(Language.CHINESE_TRADITIONAL,"zh-tw");
- assertLanguage(Language.CHINESE_TRADITIONAL,"zh-Hant");
- assertLanguage(Language.CHINESE_TRADITIONAL,"zh-hant");
- assertLanguage(Language.CHINESE_TRADITIONAL,"zh");
+ assertLanguage(Language.CHINESE_SIMPLIFIED, "zh-cn");
+ assertLanguage(Language.CHINESE_SIMPLIFIED, "zh-Hans");
+ assertLanguage(Language.CHINESE_SIMPLIFIED, "zh-hans");
+ assertLanguage(Language.CHINESE_TRADITIONAL, "zh-tw");
+ assertLanguage(Language.CHINESE_TRADITIONAL, "zh-Hant");
+ assertLanguage(Language.CHINESE_TRADITIONAL, "zh-hant");
+ assertLanguage(Language.CHINESE_TRADITIONAL, "zh");
assertLanguage(Language.ENGLISH, "en");
assertLanguage(Language.GERMAN, "de");
assertLanguage(Language.JAPANESE, "ja");
- assertLanguage(Language.fromLanguageTag("jp") ,"jp");
+ assertLanguage(Language.fromLanguageTag("jp"), "jp");
assertLanguage(Language.KOREAN, "ko");
// Since 2.0
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/QueryTestCase.java
index bfdc9ae1552..1abbc2d87dc 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/QueryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/QueryTestCase.java
@@ -8,12 +8,12 @@ import com.yahoo.search.query.parser.Parsable;
import com.yahoo.search.query.parser.Parser;
import com.yahoo.search.query.parser.ParserEnvironment;
import com.yahoo.search.query.parser.ParserFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
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;
/**
* Tests query trees
@@ -24,7 +24,7 @@ public class QueryTestCase {
/** Tests that query hash and equality is value dependent only */
@Test
- public void testQueryEquality() {
+ void testQueryEquality() {
String query = "RANK (+(AND \"baz gaz faz\" bazar) -\"foo bar foobar\") foofoo xyzzy";
String filter = "foofoo -\"foo bar foobar\" xyzzy +\"baz gaz faz\" +bazar";
@@ -37,11 +37,11 @@ public class QueryTestCase {
/** Check copy of query trees is a deep copy */
@Test
- public void testDeepCopy() {
+ void testDeepCopy() {
Item root1 = parseQuery("a and b and (c or d) and e rank f andnot g", null, Query.Type.ADVANCED);
Item root2 = root1.clone();
- assertTrue("Item.clone() should be a deep copy.",nonIdenticalTrees(root1, root2));
+ assertTrue(nonIdenticalTrees(root1, root2), "Item.clone() should be a deep copy.");
}
private static Item parseQuery(String query, String filter, Query.Type type) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java
index 3032a7b625f..a2f5016645b 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/RangeItemTestCase.java
@@ -3,16 +3,16 @@ package com.yahoo.prelude.query.test;
import com.yahoo.prelude.query.IntItem;
import com.yahoo.prelude.query.RangeItem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class RangeItemTestCase {
@Test
- public void testRangeConstruction() {
+ void testRangeConstruction() {
verifyRange(new RangeItem(5, 7, 9, "a", true), 9, true);
verifyRange(new RangeItem(5, 7, "a", true), 0, true);
verifyRange(new RangeItem(5, 7, "a"), 0, false);
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/SameElementItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/SameElementItemTestCase.java
index c05d7d48f6b..198ad2b46f9 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/SameElementItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/SameElementItemTestCase.java
@@ -9,20 +9,18 @@ import com.yahoo.prelude.query.Substring;
import com.yahoo.prelude.query.TermItem;
import com.yahoo.prelude.query.WordAlternativesItem;
import com.yahoo.prelude.query.WordItem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-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.*;
public class SameElementItemTestCase {
@Test
- public void testAddItem() {
+ void testAddItem() {
SameElementItem s = new SameElementItem("structa");
s.addItem(new WordItem("b", "f1"));
s.addItem(new WordItem("c", "f2"));
@@ -31,18 +29,18 @@ public class SameElementItemTestCase {
}
@Test
- public void testClone() {
+ void testClone() {
SameElementItem s = new SameElementItem("structa");
s.addItem(new WordItem("b", "f1"));
s.addItem(new WordItem("c", "f2"));
s.addItem(new WordItem("d", "f3"));
assertEquals("structa:{f1:b f2:c f3:d}", s.toString());
- SameElementItem c = (SameElementItem)s.clone();
+ SameElementItem c = (SameElementItem) s.clone();
assertEquals("structa:{f1:b f2:c f3:d}", c.toString());
}
@Test
- public void requireAllChildrenHaveStructMemberNameSet() {
+ void requireAllChildrenHaveStructMemberNameSet() {
try {
SameElementItem s = new SameElementItem("structa");
s.addItem(new WordItem("b", "f1"));
@@ -55,7 +53,7 @@ public class SameElementItemTestCase {
}
@Test
- public void requireAllowCommonPrefix() {
+ void requireAllowCommonPrefix() {
SameElementItem s = new SameElementItem("structa");
s.addItem(new WordItem("b", "f1"));
s.addItem(new WordItem("c", "structaf2"));
@@ -63,7 +61,7 @@ public class SameElementItemTestCase {
}
@Test
- public void requireChildrenCanHavePrefixCommonWithParent() {
+ void requireChildrenCanHavePrefixCommonWithParent() {
SameElementItem s = new SameElementItem("structa");
s.addItem(new WordItem("b", "f1"));
s.addItem(new WordItem("c", "structa.f2"));
@@ -71,7 +69,7 @@ public class SameElementItemTestCase {
}
@Test
- public void requireAllChildrenHaveNonEmptyTerm() {
+ void requireAllChildrenHaveNonEmptyTerm() {
try {
SameElementItem s = new SameElementItem("structa");
s.addItem(new WordItem("", "f2"));
@@ -83,7 +81,7 @@ public class SameElementItemTestCase {
}
@Test
- public void requireNoChildrenAreWordAlternatives() {
+ void requireNoChildrenAreWordAlternatives() {
try {
SameElementItem s = new SameElementItem("structa");
s.addItem(new AndItem());
@@ -91,12 +89,12 @@ public class SameElementItemTestCase {
}
catch (IllegalArgumentException e) { // Success
assertEquals("Child item (AND ) should be an instance of class com.yahoo.prelude.query.TermItem but is class com.yahoo.prelude.query.AndItem",
- e.getMessage());
+ e.getMessage());
}
}
@Test
- public void requireAllChildrenAreTermItems() {
+ void requireAllChildrenAreTermItems() {
try {
SameElementItem s = new SameElementItem("structa");
s.addItem(new WordAlternativesItem("test", true, new Substring("origin"), List.of(new WordAlternativesItem.Alternative("a", 0.3))));
@@ -118,13 +116,13 @@ public class SameElementItemTestCase {
}
@Test
- public void requireExtractSingleItemToExtractSingles() {
+ void requireExtractSingleItemToExtractSingles() {
verifyExtractSingle(new WordItem("b", "f1"));
verifyExtractSingle(new IntItem("7", "f1"));
}
@Test
- public void requireExtractSingleItemToExtractSinglesOnly() {
+ void requireExtractSingleItemToExtractSinglesOnly() {
SameElementItem s = new SameElementItem("structa");
s.addItem(new WordItem("b", "f1"));
s.addItem(new WordItem("c", "f2"));
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/SegmentItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/SegmentItemTestCase.java
index 66653a95dbb..b0271bec896 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/SegmentItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/SegmentItemTestCase.java
@@ -1,11 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query.test;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.PhraseSegmentItem;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.query.WordItem;
/**
@@ -16,7 +15,7 @@ import com.yahoo.prelude.query.WordItem;
public class SegmentItemTestCase {
@Test
- public final void test() {
+ final void test() {
PhraseSegmentItem item = new PhraseSegmentItem("a b c", false, true);
item.addItem(new WordItem("a"));
item.addItem(new WordItem("b"));
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/WandItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/WandItemTestCase.java
index 6a13ea130bc..40753ee1533 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/WandItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/WandItemTestCase.java
@@ -6,14 +6,14 @@ import com.yahoo.prelude.query.PureWeightedString;
import com.yahoo.prelude.query.WandItem;
import com.yahoo.prelude.query.textualrepresentation.Discloser;
import com.yahoo.prelude.query.textualrepresentation.TextualQueryRepresentation;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit tests for WandItem.
*/
@@ -22,7 +22,7 @@ public class WandItemTestCase {
private static final double DELTA = 0.0000001;
@Test
- public void requireThatWandItemCanBeConstructed() {
+ void requireThatWandItemCanBeConstructed() {
WandItem item = new WandItem("myfield", 10);
assertEquals("myfield", item.getIndexName());
assertEquals(10, item.getTargetNumHits());
@@ -32,14 +32,14 @@ public class WandItemTestCase {
}
@Test
- public void requireThatEncodeIsWorking() {
+ void requireThatEncodeIsWorking() {
WandItem item = createSimpleItem();
ByteBuffer actual = ByteBuffer.allocate(128);
ByteBuffer expect = ByteBuffer.allocate(128);
expect.put((byte) 22).put((byte) 1);
Item.putString("myfield", expect);
- expect.put((byte)10); // targetNumHits
+ expect.put((byte) 10); // targetNumHits
expect.putDouble(20); // scoreThreshold
expect.putDouble(2.0); // thresholdBoostFactor
new PureWeightedString("foo", 30).encode(expect);
@@ -53,19 +53,24 @@ public class WandItemTestCase {
}
@Test
- public void requireThatToStringIsWorking() {
- assertEquals("WAND(10,20.0,2.0) myfield{[30]:\"foo\"}", createSimpleItem().toString());
+ void requireThatToStringIsWorking() {
+ assertEquals("WAND(10,20.0,2.0) myfield{[30]:\"foo\"}", createSimpleItem().toString());
}
@Test
- public void requireThatDiscloseIsWorking() {
+ void requireThatDiscloseIsWorking() {
class TestDiscloser implements Discloser {
public final Map<String, Object> props = new HashMap<>();
+
public void addProperty(String key, Object value) {
props.put(key, value);
}
- public void setValue(Object value) {}
- public void addChild(Item item) {}
+
+ public void setValue(Object value) {
+ }
+
+ public void addChild(Item item) {
+ }
}
TestDiscloser discloser = new TestDiscloser();
createSimpleItem().disclose(discloser);
@@ -76,17 +81,17 @@ public class WandItemTestCase {
}
@Test
- public void testTextualRepresentation() {
+ void testTextualRepresentation() {
WandItem item = new WandItem("myfield", 10);
item.addToken("term1", 10);
item.setScoreThreshold(20);
item.setThresholdBoostFactor(2.0);
assertEquals("WAND[index=\"myfield\" scoreThreshold=20.0 targetNumHits=10 thresholdBoostFactor=2.0]{\n" +
- " PURE_WEIGHTED_STRING[weight=10]{\n" +
- " \"term1\"\n" +
- " }\n" +
- "}\n",
- new TextualQueryRepresentation(item).toString());
+ " PURE_WEIGHTED_STRING[weight=10]{\n" +
+ " \"term1\"\n" +
+ " }\n" +
+ "}\n",
+ new TextualQueryRepresentation(item).toString());
}
private static WandItem createSimpleItem() {
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/test/WeightedSetItemTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/test/WeightedSetItemTestCase.java
index 8a335c9119d..1cd657a1940 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/test/WeightedSetItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/test/WeightedSetItemTestCase.java
@@ -6,19 +6,16 @@ import com.yahoo.prelude.query.Item;
import com.yahoo.prelude.query.PureWeightedString;
import com.yahoo.prelude.query.WeightedSetItem;
import com.yahoo.prelude.query.WordItem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
-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.jupiter.api.Assertions.*;
public class WeightedSetItemTestCase {
@Test
- public void testTokenAPI() {
+ void testTokenAPI() {
WeightedSetItem ws = new WeightedSetItem("index");
assertEquals(0, ws.getNumTokens());
assertNull(ws.getTokenWeight("bogus"));
@@ -55,11 +52,11 @@ public class WeightedSetItemTestCase {
}
@Test
- public void testNegativeWeight() {
+ void testNegativeWeight() {
WeightedSetItem ws = new WeightedSetItem("index");
assertEquals(Integer.valueOf(-10), ws.addToken("bad", -10));
assertEquals(1, ws.getNumTokens());
- assertEquals(Integer.valueOf(-10), ws.getTokenWeight("bad"));
+ assertEquals(Integer.valueOf(-10), ws.getTokenWeight("bad"));
}
static class FakeWSItem extends CompositeIndexedItem {
@@ -77,7 +74,7 @@ public class WeightedSetItemTestCase {
}
@Test
- public void testEncoding() {
+ void testEncoding() {
WeightedSetItem item = new WeightedSetItem("index");
// need 2 alternative reference encoding, as the encoding
// order is kept undefined to improve performance.
@@ -94,11 +91,11 @@ public class WeightedSetItemTestCase {
ByteBuffer actual = ByteBuffer.allocate(128);
ByteBuffer expect1 = ByteBuffer.allocate(128);
ByteBuffer expect2 = ByteBuffer.allocate(128);
- expect1.put((byte)15).put((byte)2);
+ expect1.put((byte) 15).put((byte) 2);
Item.putString("index", expect1);
new PureWeightedString("foo", 10).encode(expect1);
new PureWeightedString("bar", 20).encode(expect1);
- expect2.put((byte)15).put((byte)2);
+ expect2.put((byte) 15).put((byte) 2);
Item.putString("index", expect2);
new PureWeightedString("bar", 20).encode(expect2);
new PureWeightedString("foo", 10).encode(expect2);
@@ -110,9 +107,9 @@ public class WeightedSetItemTestCase {
expect2.flip();
if (actual.equals(expect1)) {
- assertFalse(actual.equals(expect2));
+ assertNotEquals(actual, expect2);
} else {
- assertTrue(actual.equals(expect2));
+ assertEquals(actual, expect2);
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/query/textualrepresentation/test/TextualQueryRepresentationTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/textualrepresentation/test/TextualQueryRepresentationTestCase.java
index 213f912c0a5..cf65205fe34 100644
--- a/container-search/src/test/java/com/yahoo/prelude/query/textualrepresentation/test/TextualQueryRepresentationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/query/textualrepresentation/test/TextualQueryRepresentationTestCase.java
@@ -11,11 +11,11 @@ import java.util.HashSet;
import java.util.Map;
import com.yahoo.prelude.query.Item;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.query.textualrepresentation.Discloser;
import com.yahoo.prelude.query.textualrepresentation.TextualQueryRepresentation;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
/**
* Test of TextualQueryRepresentation.
@@ -102,14 +102,14 @@ public class TextualQueryRepresentationTestCase {
}
@Test
- public void testBasic() throws Exception {
+ void testBasic() throws Exception {
String basicText = getTextualQueryRepresentation(basic);
assertEquals(getCorrect("basic.txt"), basicText);
}
@Test
- public void testComposite() throws Exception {
+ void testComposite() throws Exception {
String compositeText = getTextualQueryRepresentation(composite);
assertEquals(getCorrect("composite.txt"), compositeText);
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/CJKSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/CJKSearcherTestCase.java
index b3b96299b90..0c24da54ec4 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/CJKSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/CJKSearcherTestCase.java
@@ -18,10 +18,10 @@ import com.yahoo.search.query.parser.ParserEnvironment;
import com.yahoo.search.query.parser.ParserFactory;
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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* @author Steinar Knutsen
@@ -32,9 +32,9 @@ public class CJKSearcherTestCase {
"querytransform/test/cjk-index-info.cfg", null);
@Test
- public void testTermWeight() {
+ void testTermWeight() {
assertTransformed("efg!10", "SAND e!10 fg!10",
- Query.Type.ALL, Language.CHINESE_SIMPLIFIED, Language.CHINESE_TRADITIONAL, TestLinguistics.INSTANCE);
+ Query.Type.ALL, Language.CHINESE_SIMPLIFIED, Language.CHINESE_TRADITIONAL, TestLinguistics.INSTANCE);
}
/**
@@ -43,14 +43,14 @@ public class CJKSearcherTestCase {
* must combine overlapping tokens as PHRASE, not AND to avoid a too high recall because of the token overlap.
*/
@Test
- public void testCjkQueryWithOverlappingTokens() {
+ void testCjkQueryWithOverlappingTokens() {
// The test language segmenter will segment "bcd" into the overlapping tokens "bc" "cd"
assertTransformed("bcd", "SAND bc cd", Query.Type.ALL, Language.CHINESE_SIMPLIFIED, Language.CHINESE_TRADITIONAL,
- TestLinguistics.INSTANCE);
+ TestLinguistics.INSTANCE);
// While "efg" will be segmented into one of the standard options, "e" "fg"
assertTransformed("efg", "SAND e fg", Query.Type.ALL, Language.CHINESE_SIMPLIFIED, Language.CHINESE_TRADITIONAL,
- TestLinguistics.INSTANCE);
+ TestLinguistics.INSTANCE);
}
private void assertTransformed(String queryString, String expected, Query.Type mode, Language actualLanguage,
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/CollapsePhraseSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/CollapsePhraseSearcherTestCase.java
index 498d6ca2980..3aaf941c6f5 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/CollapsePhraseSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/CollapsePhraseSearcherTestCase.java
@@ -9,12 +9,12 @@ import com.yahoo.prelude.query.PhraseItem;
import com.yahoo.prelude.query.WordItem;
import com.yahoo.prelude.querytransform.CollapsePhraseSearcher;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Check CollapsePhraseSearcher works and only is triggered when it
@@ -25,14 +25,14 @@ import static org.junit.Assert.assertEquals;
public class CollapsePhraseSearcherTestCase {
@Test
- public void testSimplePositive() {
+ void testSimplePositive() {
PhraseItem root = new PhraseItem();
root.addItem(new WordItem("abc"));
assertEquals("abc", transformQuery(root));
}
@Test
- public void testPositive1() {
+ void testPositive1() {
AndItem root = new AndItem();
root.addItem(new WordItem("a"));
PhraseItem embedded = new PhraseItem();
@@ -40,11 +40,11 @@ public class CollapsePhraseSearcherTestCase {
root.addItem(embedded);
root.addItem(new WordItem("e"));
assertEquals("AND a bcd e",
- transformQuery(root));
+ transformQuery(root));
}
@Test
- public void testPositive2() {
+ void testPositive2() {
AndItem root = new AndItem();
root.addItem(new WordItem("a"));
CompositeItem embedded = new AndItem();
@@ -55,21 +55,21 @@ public class CollapsePhraseSearcherTestCase {
root.addItem(embedded);
root.addItem(new WordItem("e"));
assertEquals("AND a (AND bcd def) e",
- transformQuery(root));
+ transformQuery(root));
}
@Test
- public void testNoTerms() {
+ void testNoTerms() {
assertEquals("NULL", transformQuery("?query=" + enc("\"\"")));
}
@Test
- public void testNegative1() {
+ void testNegative1() {
assertEquals("WEAKAND(100) \"abc def\"", transformQuery("?query=" + enc("\"abc def\"")));
}
@Test
- public void testNegative2() {
+ void testNegative2() {
assertEquals("WEAKAND(100) a \"abc def\" b", transformQuery("?query=" + enc("a \"abc def\" b")));
}
@@ -83,7 +83,7 @@ public class CollapsePhraseSearcherTestCase {
}
@Test
- public void testNegative3() {
+ void testNegative3() {
AndItem root = new AndItem();
root.addItem(new WordItem("a"));
CompositeItem embedded = new AndItem();
@@ -95,7 +95,7 @@ public class CollapsePhraseSearcherTestCase {
root.addItem(embedded);
root.addItem(new WordItem("e"));
assertEquals("AND a (AND bcd \"def ghi\") e",
- transformQuery(root));
+ transformQuery(root));
}
private String transformQuery(String rawQuery) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
index a434fbd9949..16e27303fa8 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
@@ -10,11 +10,11 @@ import com.yahoo.search.Query;
import com.yahoo.prelude.querytransform.LiteralBoostSearcher;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests the complete field match query transformer
@@ -24,55 +24,55 @@ import static org.junit.Assert.assertEquals;
public class LiteralBoostSearcherTestCase {
@Test
- public void testSimpleQueryWithBoost() {
+ void testSimpleQueryWithBoost() {
assertEquals("RANK (WEAKAND(100) abc) default_literal:abc",
- transformQuery("?query=abc&source=cluster1&restrict=type1"));
+ transformQuery("?query=abc&source=cluster1&restrict=type1"));
}
@Test
- public void testSimpleQueryNoBoost() {
+ void testSimpleQueryNoBoost() {
assertEquals("WEAKAND(100) abc",
transformQuery("?query=abc&source=cluster1&restrict=type2"));
}
@Test
- public void testQueryWithExplicitIndex() {
+ void testQueryWithExplicitIndex() {
assertEquals("RANK (WEAKAND(100) absolute:abc) absolute_literal:abc",
transformQuery("?query=absolute:abc&source=cluster1&restrict=type1"));
}
@Test
- public void testQueryWithExplicitIndexNoBoost() {
+ void testQueryWithExplicitIndexNoBoost() {
assertEquals("WEAKAND(100) absolute:abc",
transformQuery("?query=absolute:abc&source=cluster1&restrict=type2"));
}
@Test
- public void testQueryWithNegativeBranch() {
- assertEquals("RANK (+(AND abc def) -ghi) "+
- "default_literal:abc default_literal:def",
- transformQuery("?query=abc and def andnot ghi&type=adv&source=cluster1&restrict=type1"));
+ void testQueryWithNegativeBranch() {
+ assertEquals("RANK (+(AND abc def) -ghi) " +
+ "default_literal:abc default_literal:def",
+ transformQuery("?query=abc and def andnot ghi&type=adv&source=cluster1&restrict=type1"));
}
@Test
- public void testJumbledQuery() {
+ void testJumbledQuery() {
assertEquals
- ("RANK (OR (+(OR abc def) -ghi) jkl) " +
- "default_literal:abc default_literal:def default_literal:jkl",
- transformQuery("?query=abc or def andnot ghi or jkl&type=adv&source=cluster1&restrict=type1"));
+ ("RANK (OR (+(OR abc def) -ghi) jkl) " +
+ "default_literal:abc default_literal:def default_literal:jkl",
+ transformQuery("?query=abc or def andnot ghi or jkl&type=adv&source=cluster1&restrict=type1"));
}
@Test
- public void testTermindexQuery() {
- assertEquals("RANK (+(WEAKAND(100) a b d) -c) default_literal:a "+
- "default_literal:b default_literal:d",
- transformQuery("?query=a b -c d&source=cluster1&restrict=type1"));
+ void testTermindexQuery() {
+ assertEquals("RANK (+(WEAKAND(100) a b d) -c) default_literal:a " +
+ "default_literal:b default_literal:d",
+ transformQuery("?query=a b -c d&source=cluster1&restrict=type1"));
}
@Test
- public void testQueryWithoutBoost() {
+ void testQueryWithoutBoost() {
assertEquals("RANK (AND nonexistant a nonexistant b) default_literal:nonexistant default_literal:a default_literal:nonexistant default_literal:b",
- transformQuery("?query=nonexistant:a nonexistant:b&source=cluster1&restrict=type1&type=all"));
+ transformQuery("?query=nonexistant:a nonexistant:b&source=cluster1&restrict=type1&type=all"));
}
private String transformQuery(String rawQuery) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NoRankingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NoRankingSearcherTestCase.java
index 107a82f3186..16d6bd40178 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NoRankingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NoRankingSearcherTestCase.java
@@ -5,41 +5,41 @@ import com.yahoo.search.Query;
import com.yahoo.prelude.querytransform.NoRankingSearcher;
import com.yahoo.search.Searcher;
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.jupiter.api.Assertions.assertEquals;
public class NoRankingSearcherTestCase {
Searcher s = new NoRankingSearcher();
@Test
- public void testDoSearch() {
+ void testDoSearch() {
Query q = new Query("?query=a&sorting=%2ba%20-b&ranking=hello");
assertEquals("hello", q.getRanking().getProfile());
new Execution(s, Execution.Context.createContextStub()).search(q);
assertEquals("unranked", q.getRanking().getProfile());
- }
+ }
@Test
- public void testSortOnRelevanceAscending() {
+ void testSortOnRelevanceAscending() {
Query q = new Query("?query=a&sorting=%2ba%20-b%20-[rank]&ranking=hello");
new Execution(s, Execution.Context.createContextStub()).search(q);
assertEquals("hello", q.getRanking().getProfile());
- }
+ }
@Test
- public void testSortOnRelevanceDescending() {
+ void testSortOnRelevanceDescending() {
Query q = new Query("?query=a&sorting=%2ba%20-b%20-[rank]&ranking=hello");
new Execution(s, Execution.Context.createContextStub()).search(q);
assertEquals("hello", q.getRanking().getProfile());
- }
+ }
@Test
- public void testNoSorting() {
+ void testNoSorting() {
Query q = new Query("?query=a");
new Execution(s, Execution.Context.createContextStub()).search(q);
assertEquals("default", q.getRanking().getProfile());
- }
+ }
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NonPhrasingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NonPhrasingSearcherTestCase.java
index 462e57a2b37..5a090a51415 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NonPhrasingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NonPhrasingSearcherTestCase.java
@@ -7,9 +7,9 @@ import com.yahoo.prelude.query.WordItem;
import com.yahoo.prelude.querytransform.NonPhrasingSearcher;
import com.yahoo.search.Searcher;
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.jupiter.api.Assertions.assertEquals;
/**
* Tests non-phrasing
@@ -21,58 +21,58 @@ public class NonPhrasingSearcherTestCase {
private Searcher searcher;
@Test
- public void testSingleWordNonPhrasing() {
- searcher=
- new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testSingleWordNonPhrasing() {
+ searcher =
+ new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
- Query query=new Query("?query=void+aword+kanoo");
+ Query query = new Query("?query=void+aword+kanoo");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
assertEquals("WEAKAND(100) void kanoo", query.getModel().getQueryTree().getRoot().toString());
}
@Test
- public void testMultipleWordNonPhrasing() {
- searcher=
- new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testMultipleWordNonPhrasing() {
+ searcher =
+ new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
- Query query=new Query("?query=void+tudor+vidor+kanoo");
+ Query query = new Query("?query=void+tudor+vidor+kanoo");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
- CompositeItem item=(CompositeItem) query.getModel().getQueryTree().getRoot();
- assertEquals(2,item.getItemCount());
- assertEquals("void",((WordItem)item.getItem(0)).getWord());
- assertEquals("kanoo",((WordItem)item.getItem(1)).getWord());
+ CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
+ assertEquals(2, item.getItemCount());
+ assertEquals("void", ((WordItem) item.getItem(0)).getWord());
+ assertEquals("kanoo", ((WordItem) item.getItem(1)).getWord());
}
@Test
- public void testNoNonPhrasingIfNoOtherPhrases() {
- searcher=
- new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testNoNonPhrasingIfNoOtherPhrases() {
+ searcher =
+ new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
- Query query=new Query("?query=tudor+vidor");
+ Query query = new Query("?query=tudor+vidor");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
- CompositeItem item=(CompositeItem) query.getModel().getQueryTree().getRoot();
- assertEquals(2,item.getItemCount());
- assertEquals("tudor",((WordItem)item.getItem(0)).getWord());
- assertEquals("vidor",((WordItem)item.getItem(1)).getWord());
+ CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
+ assertEquals(2, item.getItemCount());
+ assertEquals("tudor", ((WordItem) item.getItem(0)).getWord());
+ assertEquals("vidor", ((WordItem) item.getItem(1)).getWord());
}
@Test
- public void testNoNonPhrasingIfSuggestOnly() {
- searcher=
- new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testNoNonPhrasingIfSuggestOnly() {
+ searcher =
+ new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
- Query query=new Query("?query=void+tudor+vidor+kanoo&suggestonly=true");
+ Query query = new Query("?query=void+tudor+vidor+kanoo&suggestonly=true");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
- CompositeItem item=(CompositeItem) query.getModel().getQueryTree().getRoot();
- assertEquals(4,item.getItemCount());
- assertEquals("void",((WordItem)item.getItem(0)).getWord());
- assertEquals("tudor",((WordItem)item.getItem(1)).getWord());
- assertEquals("vidor",((WordItem)item.getItem(2)).getWord());
- assertEquals("kanoo",((WordItem)item.getItem(3)).getWord());
+ CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
+ assertEquals(4, item.getItemCount());
+ assertEquals("void", ((WordItem) item.getItem(0)).getWord());
+ assertEquals("tudor", ((WordItem) item.getItem(1)).getWord());
+ assertEquals("vidor", ((WordItem) item.getItem(2)).getWord());
+ assertEquals("kanoo", ((WordItem) item.getItem(3)).getWord());
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java
index 7ab50118c6d..239f4500297 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.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.prelude.querytransform.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;
import com.google.common.collect.ImmutableList;
import com.yahoo.language.Linguistics;
@@ -19,7 +19,7 @@ import com.yahoo.prelude.IndexModel;
import com.yahoo.prelude.querytransform.NormalizingSearcher;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@@ -38,35 +38,35 @@ public class NormalizingSearcherTestCase {
private static final Linguistics linguistics = new SimpleLinguistics();
@Test
- public void testNoNormalizingNecssary() {
+ void testNoNormalizingNecssary() {
Query query = new Query("/search?query=bilen&search=cluster1&restrict=type1");
createExecution().search(query);
assertEquals("WEAKAND(100) bilen", query.getModel().getQueryTree().getRoot().toString());
}
@Test
- public void testAttributeQuery() {
+ void testAttributeQuery() {
Query query = new Query("/search?query=attribute:" + enc("b\u00e9yonc\u00e8 b\u00e9yonc\u00e8") + "&search=cluster1&restrict=type1");
createExecution().search(query);
assertEquals("WEAKAND(100) attribute:b\u00e9yonc\u00e8 beyonce", query.getModel().getQueryTree().getRoot().toString());
}
@Test
- public void testOneTermNormalizing() {
+ void testOneTermNormalizing() {
Query query = new Query("/search?query=b\u00e9yonc\u00e8&search=cluster1&restrict=type1");
createExecution().search(query);
assertEquals("WEAKAND(100) beyonce", query.getModel().getQueryTree().getRoot().toString());
}
@Test
- public void testOneTermNoNormalizingDifferentSearchDef() {
+ void testOneTermNoNormalizingDifferentSearchDef() {
Query query = new Query("/search?query=b\u00e9yonc\u00e8&search=cluster1&restrict=type2");
createExecution().search(query);
assertEquals("WEAKAND(100) béyoncè", query.getModel().getQueryTree().getRoot().toString());
}
@Test
- public void testTwoTermQuery() throws UnsupportedEncodingException {
+ void testTwoTermQuery() throws UnsupportedEncodingException {
Query query = new Query("/search?query=" + enc("b\u00e9yonc\u00e8 beyonc\u00e9") + "&search=cluster1&restrict=type1");
createExecution().search(query);
assertEquals("WEAKAND(100) beyonce beyonce", query.getModel().getQueryTree().getRoot().toString());
@@ -82,7 +82,7 @@ public class NormalizingSearcherTestCase {
}
@Test
- public void testPhraseQuery() {
+ void testPhraseQuery() {
Query query = new Query("/search?query=" + enc("\"b\u00e9yonc\u00e8 beyonc\u00e9\"") + "&search=cluster1&restrict=type1");
query.getTrace().setLevel(2);
createExecution().search(query);
@@ -90,7 +90,7 @@ public class NormalizingSearcherTestCase {
}
@Test
- public void testLiteralBoost() {
+ void testLiteralBoost() {
Query query = new Query("/search?query=nop&search=cluster1&restrict=type1");
List<WordAlternativesItem.Alternative> terms = new ArrayList<>();
Substring origin = new Substring(0, 5, "h\u00F4tels");
@@ -107,12 +107,12 @@ public class NormalizingSearcherTestCase {
assertEquals(.7d * .7d, a.exactness, 1e-15);
}
}
- assertTrue("Did not find the expected normalized form \"hotel\".", foundHotel);
+ assertTrue(foundHotel, "Did not find the expected normalized form \"hotel\".");
}
@Test
- public void testPhraseSegmentNormalization() {
+ void testPhraseSegmentNormalization() {
Query query = new Query("/search?query=&search=cluster1&restrict=type1");
PhraseSegmentItem phraseSegment = new PhraseSegmentItem("default", false, false);
phraseSegment.addItem(new WordItem("net"));
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhraseMatcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhraseMatcherTestCase.java
index 623c480796c..da7b29272a2 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhraseMatcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhraseMatcherTestCase.java
@@ -5,14 +5,11 @@ import com.yahoo.prelude.query.AndItem;
import com.yahoo.prelude.query.IntItem;
import com.yahoo.prelude.query.WordItem;
import com.yahoo.prelude.querytransform.PhraseMatcher;
-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.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -20,118 +17,118 @@ import static org.junit.Assert.assertNull;
public class PhraseMatcherTestCase {
@Test
- public void testSingleItemMatching() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testSingleItemMatching() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
matcher.setMatchSingleItems(true);
- List<?> matches=matcher.matchPhrases(new WordItem("aword"));
+ List<?> matches = matcher.matchPhrases(new WordItem("aword"));
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(1,match.getLength());
- assertEquals("",match.getData());
- assertEquals(null,match.getOwner());
- assertEquals(0,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem("aword"),i.next());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(1, match.getLength());
+ assertEquals("", match.getData());
+ assertNull(match.getOwner());
+ assertEquals(0, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem("aword"), i.next());
assertNull(i.getReplace());
assertFalse(i.hasNext());
}
@Test
- public void testSingleItemMatchingCaseInsensitive() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testSingleItemMatchingCaseInsensitive() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
matcher.setMatchSingleItems(true);
final String mixedCase = "aWoRD";
- List<?> matches=matcher.matchPhrases(new WordItem(mixedCase));
+ List<?> matches = matcher.matchPhrases(new WordItem(mixedCase));
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(1,match.getLength());
- assertEquals("",match.getData());
- assertEquals(null,match.getOwner());
- assertEquals(0,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem(mixedCase),i.next());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(1, match.getLength());
+ assertEquals("", match.getData());
+ assertNull(match.getOwner());
+ assertEquals(0, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem(mixedCase), i.next());
assertNull(i.getReplace());
assertFalse(i.hasNext());
}
@Test
- public void testSingleItemMatchingWithPluralIgnore() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa",true);
+ void testSingleItemMatchingWithPluralIgnore() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa", true);
matcher.setMatchSingleItems(true);
- List<?> matches=matcher.matchPhrases(new WordItem("awords"));
+ List<?> matches = matcher.matchPhrases(new WordItem("awords"));
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(1,match.getLength());
- assertEquals("",match.getData());
- assertEquals(null,match.getOwner());
- assertEquals(0,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem("awords"),i.next());
- assertEquals("aword",i.getReplace());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(1, match.getLength());
+ assertEquals("", match.getData());
+ assertNull(match.getOwner());
+ assertEquals(0, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem("awords"), i.next());
+ assertEquals("aword", i.getReplace());
assertFalse(i.hasNext());
}
@Test
- public void testSingleItemMatchingCaseInsensitiveWithPluralIgnore() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa",true);
+ void testSingleItemMatchingCaseInsensitiveWithPluralIgnore() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa", true);
matcher.setMatchSingleItems(true);
final String mixedCase = "aWoRDS";
- List<?> matches=matcher.matchPhrases(new WordItem(mixedCase));
+ List<?> matches = matcher.matchPhrases(new WordItem(mixedCase));
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(1,match.getLength());
- assertEquals("",match.getData());
- assertEquals(null,match.getOwner());
- assertEquals(0,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem(mixedCase),i.next());
- assertEquals("aword",i.getReplace());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(1, match.getLength());
+ assertEquals("", match.getData());
+ assertNull(match.getOwner());
+ assertEquals(0, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem(mixedCase), i.next());
+ assertEquals("aword", i.getReplace());
assertFalse(i.hasNext());
}
@Test
- public void testPhraseMatching() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa",true);
- AndItem and=new AndItem();
+ void testPhraseMatching() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa", true);
+ AndItem and = new AndItem();
and.addItem(new WordItem("noisebefore"));
and.addItem(new WordItem("this"));
and.addItem(new WordItem("is"));
and.addItem(new WordItem("a"));
and.addItem(new WordItem("test"));
and.addItem(new WordItem("noiseafter"));
- List<?> matches=matcher.matchPhrases(and);
+ List<?> matches = matcher.matchPhrases(and);
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(4,match.getLength());
- assertEquals("",match.getData());
- assertEquals(and,match.getOwner());
- assertEquals(1,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem("this"),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem("is"),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem("a"),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem("test"),i.next());
- assertEquals(null,i.getReplace());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(4, match.getLength());
+ assertEquals("", match.getData());
+ assertEquals(and, match.getOwner());
+ assertEquals(1, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem("this"), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem("is"), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem("a"), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem("test"), i.next());
+ assertNull(i.getReplace());
assertFalse(i.hasNext());
}
@Test
- public void testPhraseMatchingCaseInsensitive() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa",true);
- AndItem and=new AndItem();
+ void testPhraseMatchingCaseInsensitive() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa", true);
+ AndItem and = new AndItem();
and.addItem(new WordItem("noisebefore"));
final String firstWord = "thIs";
and.addItem(new WordItem(firstWord));
@@ -142,93 +139,93 @@ public class PhraseMatcherTestCase {
final String fourthWord = "tEst";
and.addItem(new WordItem(fourthWord));
and.addItem(new WordItem("noiseafter"));
- List<?> matches=matcher.matchPhrases(and);
+ List<?> matches = matcher.matchPhrases(and);
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(4,match.getLength());
- assertEquals("",match.getData());
- assertEquals(and,match.getOwner());
- assertEquals(1,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem(firstWord),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem(secondWord),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem(thirdWord),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem(fourthWord),i.next());
- assertEquals(null,i.getReplace());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(4, match.getLength());
+ assertEquals("", match.getData());
+ assertEquals(and, match.getOwner());
+ assertEquals(1, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem(firstWord), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem(secondWord), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem(thirdWord), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem(fourthWord), i.next());
+ assertNull(i.getReplace());
assertFalse(i.hasNext());
}
@Test
- public void testPhraseMatchingWithNumber() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa",true);
- AndItem and=new AndItem();
+ void testPhraseMatchingWithNumber() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa", true);
+ AndItem and = new AndItem();
and.addItem(new WordItem("noisebefore"));
and.addItem(new WordItem("this"));
and.addItem(new WordItem("is"));
and.addItem(new IntItem("3"));
and.addItem(new WordItem("tests"));
and.addItem(new WordItem("noiseafter"));
- List<?> matches=matcher.matchPhrases(and);
+ List<?> matches = matcher.matchPhrases(and);
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(4,match.getLength());
- assertEquals("",match.getData());
- assertEquals(and,match.getOwner());
- assertEquals(1,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem("this"),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem("is"),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new IntItem("3"),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem("tests"),i.next());
- assertEquals(null,i.getReplace());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(4, match.getLength());
+ assertEquals("", match.getData());
+ assertEquals(and, match.getOwner());
+ assertEquals(1, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem("this"), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem("is"), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new IntItem("3"), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem("tests"), i.next());
+ assertNull(i.getReplace());
assertFalse(i.hasNext());
}
@Test
- public void testPhraseMatchingWithPluralIgnore() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa",true);
- AndItem and=new AndItem();
+ void testPhraseMatchingWithPluralIgnore() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa", true);
+ AndItem and = new AndItem();
and.addItem(new WordItem("noisebefore"));
and.addItem(new WordItem("thi"));
and.addItem(new WordItem("is"));
and.addItem(new WordItem("a"));
and.addItem(new WordItem("tests"));
and.addItem(new WordItem("noiseafter"));
- List<?> matches=matcher.matchPhrases(and);
+ List<?> matches = matcher.matchPhrases(and);
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(4,match.getLength());
- assertEquals("",match.getData());
- assertEquals(and,match.getOwner());
- assertEquals(1,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem("thi"),i.next());
- assertEquals("this",i.getReplace());
- assertEquals(new WordItem("is"),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem("a"),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem("tests"),i.next());
- assertEquals("test",i.getReplace());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(4, match.getLength());
+ assertEquals("", match.getData());
+ assertEquals(and, match.getOwner());
+ assertEquals(1, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem("thi"), i.next());
+ assertEquals("this", i.getReplace());
+ assertEquals(new WordItem("is"), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem("a"), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem("tests"), i.next());
+ assertEquals("test", i.getReplace());
assertFalse(i.hasNext());
}
@Test
- public void testPhraseMatchingCaseInsensitiveWithPluralIgnore() {
- PhraseMatcher matcher=new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa",true);
- AndItem and=new AndItem();
+ void testPhraseMatchingCaseInsensitiveWithPluralIgnore() {
+ PhraseMatcher matcher = new PhraseMatcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa", true);
+ AndItem and = new AndItem();
and.addItem(new WordItem("noisebefore"));
final String firstWord = "thI";
and.addItem(new WordItem(firstWord));
@@ -239,24 +236,24 @@ public class PhraseMatcherTestCase {
final String fourthWord = "tEsts";
and.addItem(new WordItem(fourthWord));
and.addItem(new WordItem("noiseafter"));
- List<?> matches=matcher.matchPhrases(and);
+ List<?> matches = matcher.matchPhrases(and);
assertNotNull(matches);
- assertEquals(1,matches.size());
- PhraseMatcher.Phrase match=(PhraseMatcher.Phrase)matches.get(0);
- assertEquals(4,match.getLength());
- assertEquals("",match.getData());
- assertEquals(and,match.getOwner());
- assertEquals(1,match.getStartIndex());
- PhraseMatcher.Phrase.MatchIterator i=match.itemIterator();
- assertEquals(new WordItem(firstWord),i.next());
- assertEquals("this",i.getReplace());
- assertEquals(new WordItem(secondWord),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem(thirdWord),i.next());
- assertEquals(null,i.getReplace());
- assertEquals(new WordItem(fourthWord),i.next());
- assertEquals("test",i.getReplace());
+ assertEquals(1, matches.size());
+ PhraseMatcher.Phrase match = (PhraseMatcher.Phrase) matches.get(0);
+ assertEquals(4, match.getLength());
+ assertEquals("", match.getData());
+ assertEquals(and, match.getOwner());
+ assertEquals(1, match.getStartIndex());
+ PhraseMatcher.Phrase.MatchIterator i = match.itemIterator();
+ assertEquals(new WordItem(firstWord), i.next());
+ assertEquals("this", i.getReplace());
+ assertEquals(new WordItem(secondWord), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem(thirdWord), i.next());
+ assertNull(i.getReplace());
+ assertEquals(new WordItem(fourthWord), i.next());
+ assertEquals("test", i.getReplace());
assertFalse(i.hasNext());
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhrasingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhrasingSearcherTestCase.java
index 8f2ae910d1b..9eca9a5fed8 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhrasingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/PhrasingSearcherTestCase.java
@@ -11,10 +11,10 @@ import com.yahoo.prelude.query.WordItem;
import com.yahoo.prelude.querytransform.PhrasingSearcher;
import com.yahoo.search.Searcher;
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.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests phrasing stuff
@@ -25,104 +25,104 @@ import static org.junit.Assert.assertTrue;
public class PhrasingSearcherTestCase {
@Test
- public void testTotalPhrasing() {
- Searcher searcher=
- new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
-
- Query query=new Query();
- AndItem andItem=new AndItem();
- andItem.addItem(new WordItem("tudor","someindex"));
- andItem.addItem(new WordItem("vidor","someindex"));
+ void testTotalPhrasing() {
+ Searcher searcher =
+ new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+
+ Query query = new Query();
+ AndItem andItem = new AndItem();
+ andItem.addItem(new WordItem("tudor", "someindex"));
+ andItem.addItem(new WordItem("vidor", "someindex"));
query.getModel().getQueryTree().setRoot(andItem);
new Execution(searcher, Execution.Context.createContextStub()).search(query);
- Item item=((CompositeItem) query.getModel().getQueryTree().getRoot()).getItem(0);
+ Item item = ((CompositeItem) query.getModel().getQueryTree().getRoot()).getItem(0);
assertTrue(item instanceof PhraseItem);
- PhraseItem phrase=(PhraseItem)item;
- assertEquals(2,phrase.getItemCount());
- assertEquals("tudor",phrase.getWordItem(0).getWord());
- assertEquals("vidor",phrase.getWordItem(1).getWord());
- assertEquals("someindex",phrase.getIndexName());
+ PhraseItem phrase = (PhraseItem) item;
+ assertEquals(2, phrase.getItemCount());
+ assertEquals("tudor", phrase.getWordItem(0).getWord());
+ assertEquals("vidor", phrase.getWordItem(1).getWord());
+ assertEquals("someindex", phrase.getIndexName());
}
@Test
- public void testPartialPhrasing() {
- Searcher searcher=
- new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testPartialPhrasing() {
+ Searcher searcher =
+ new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
- Query query=new Query("?query=void%20tudor%20vidor%20kanoo");
+ Query query = new Query("?query=void%20tudor%20vidor%20kanoo");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
- CompositeItem item=(CompositeItem) query.getModel().getQueryTree().getRoot();
- assertEquals("void",((WordItem)item.getItem(0)).getWord());
- assertEquals("kanoo",((WordItem)item.getItem(2)).getWord());
-
- PhraseItem phrase=(PhraseItem)item.getItem(1);
- assertEquals(2,phrase.getItemCount());
- assertEquals("tudor",phrase.getWordItem(0).getWord());
- assertEquals("vidor",phrase.getWordItem(1).getWord());
+ CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
+ assertEquals("void", ((WordItem) item.getItem(0)).getWord());
+ assertEquals("kanoo", ((WordItem) item.getItem(2)).getWord());
+
+ PhraseItem phrase = (PhraseItem) item.getItem(1);
+ assertEquals(2, phrase.getItemCount());
+ assertEquals("tudor", phrase.getWordItem(0).getWord());
+ assertEquals("vidor", phrase.getWordItem(1).getWord());
}
@Test
- public void testPartialPhrasingSuggestOnly() {
- Searcher searcher=
- new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testPartialPhrasingSuggestOnly() {
+ Searcher searcher =
+ new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
- Query query=new Query("?query=void%20tudor%20vidor%20kanoo&suggestonly=true");
+ Query query = new Query("?query=void%20tudor%20vidor%20kanoo&suggestonly=true");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
- CompositeItem item=(CompositeItem) query.getModel().getQueryTree().getRoot();
- assertEquals("void", ((WordItem)item.getItem(0)).getWord());
- assertEquals("tudor",((WordItem)item.getItem(1)).getWord());
- assertEquals("vidor",((WordItem)item.getItem(2)).getWord());
- assertEquals("kanoo",((WordItem)item.getItem(3)).getWord());
+ CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
+ assertEquals("void", ((WordItem) item.getItem(0)).getWord());
+ assertEquals("tudor", ((WordItem) item.getItem(1)).getWord());
+ assertEquals("vidor", ((WordItem) item.getItem(2)).getWord());
+ assertEquals("kanoo", ((WordItem) item.getItem(3)).getWord());
}
@Test
- public void testNoPhrasingIfDifferentIndices() {
- Searcher searcher=
- new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
-
- Query query=new Query();
- AndItem andItem=new AndItem();
- andItem.addItem(new WordItem("tudor","someindex"));
- andItem.addItem(new WordItem("vidor","anotherindex"));
+ void testNoPhrasingIfDifferentIndices() {
+ Searcher searcher =
+ new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+
+ Query query = new Query();
+ AndItem andItem = new AndItem();
+ andItem.addItem(new WordItem("tudor", "someindex"));
+ andItem.addItem(new WordItem("vidor", "anotherindex"));
query.getModel().getQueryTree().setRoot(andItem);
new Execution(searcher, Execution.Context.createContextStub()).search(query);
- CompositeItem item=(CompositeItem) query.getModel().getQueryTree().getRoot();
+ CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
assertTrue(item.getItem(0) instanceof WordItem);
- WordItem word=(WordItem)item.getItem(0);
- assertEquals("tudor",word.getWord());
+ WordItem word = (WordItem) item.getItem(0);
+ assertEquals("tudor", word.getWord());
assertTrue(item.getItem(1) instanceof WordItem);
- word=(WordItem)item.getItem(1);
- assertEquals("vidor",word.getWord());
+ word = (WordItem) item.getItem(1);
+ assertEquals("vidor", word.getWord());
}
@Test
- public void testMultiplePhrases() {
- Searcher searcher=
- new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
-
- Query query=new Query();
- AndItem andItem=new AndItem();
- andItem.addItem(new WordItem("tudor","someindex"));
- andItem.addItem(new WordItem("tudor","someindex"));
- andItem.addItem(new WordItem("vidor","someindex"));
- andItem.addItem(new WordItem("vidor","someindex"));
-
- OrItem orItem=new OrItem();
+ void testMultiplePhrases() {
+ Searcher searcher =
+ new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+
+ Query query = new Query();
+ AndItem andItem = new AndItem();
+ andItem.addItem(new WordItem("tudor", "someindex"));
+ andItem.addItem(new WordItem("tudor", "someindex"));
+ andItem.addItem(new WordItem("vidor", "someindex"));
+ andItem.addItem(new WordItem("vidor", "someindex"));
+
+ OrItem orItem = new OrItem();
andItem.addItem(orItem);
orItem.addItem(new WordItem("tudor"));
- AndItem andItem2=new AndItem();
- andItem2.addItem(new WordItem("this","anotherindex"));
- andItem2.addItem(new WordItem("is","anotherindex"));
- andItem2.addItem(new WordItem("a","anotherindex"));
- andItem2.addItem(new WordItem("test","anotherindex"));
- andItem2.addItem(new WordItem("tudor","anotherindex"));
- andItem2.addItem(new WordItem("vidor","anotherindex"));
+ AndItem andItem2 = new AndItem();
+ andItem2.addItem(new WordItem("this", "anotherindex"));
+ andItem2.addItem(new WordItem("is", "anotherindex"));
+ andItem2.addItem(new WordItem("a", "anotherindex"));
+ andItem2.addItem(new WordItem("test", "anotherindex"));
+ andItem2.addItem(new WordItem("tudor", "anotherindex"));
+ andItem2.addItem(new WordItem("vidor", "anotherindex"));
orItem.addItem(andItem2);
orItem.addItem(new WordItem("vidor"));
@@ -134,12 +134,12 @@ public class PhrasingSearcherTestCase {
}
@Test
- public void testNoDetection() {
- Searcher searcher=
- new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
+ void testNoDetection() {
+ Searcher searcher =
+ new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
- Query query=new Query();
- AndItem andItem=new AndItem();
+ Query query = new Query();
+ AndItem andItem = new AndItem();
andItem.addItem(new WordItem("no"));
andItem.addItem(new WordItem("such"));
andItem.addItem(new WordItem("phrase"));
@@ -152,11 +152,11 @@ public class PhrasingSearcherTestCase {
}
@Test
- public void testNoFileNoChange() {
+ void testNoFileNoChange() {
Searcher searcher = new PhrasingSearcher("");
- Query query=new Query();
- AndItem andItem=new AndItem();
+ Query query = new Query();
+ AndItem andItem = new AndItem();
andItem.addItem(new WordItem("no", "anindex"));
andItem.addItem(new WordItem("such", "anindex"));
andItem.addItem(new WordItem("phrase", "indexo"));
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/QueryRewriteTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/QueryRewriteTestCase.java
index b8c5244fb98..16bfd5f315e 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/QueryRewriteTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/QueryRewriteTestCase.java
@@ -13,11 +13,9 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.searchchain.Execution;
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.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
@@ -25,7 +23,7 @@ import static org.junit.Assert.assertTrue;
public class QueryRewriteTestCase {
@Test
- public void testOptimizeByRestrict() {
+ void testOptimizeByRestrict() {
Query query = new Query("?query=sddocname:music");
query.getModel().setRestrict("music");
QueryRewrite.optimizeByRestrict(query);
@@ -33,7 +31,7 @@ public class QueryRewriteTestCase {
}
@Test
- public void requireThatOptimizeByRestrictSimplifiesORItemsThatHaveFullRecallAndDontImpactRank() {
+ void requireThatOptimizeByRestrictSimplifiesORItemsThatHaveFullRecallAndDontImpactRank() {
assertRewritten("sddocname:foo OR sddocname:bar OR sddocname:baz", "foo", "sddocname:foo");
assertRewritten("sddocname:foo OR sddocname:bar OR sddocname:baz", "bar", "sddocname:bar");
assertRewritten("sddocname:foo OR sddocname:bar OR sddocname:baz", "baz", "sddocname:baz");
@@ -48,16 +46,16 @@ public class QueryRewriteTestCase {
}
@Test
- public void testRestrictRewriteDoesNotRemoveRankContributingTerms() {
+ void testRestrictRewriteDoesNotRemoveRankContributingTerms() {
Query query = query("sddocname:per OR foo OR bar", "per");
assertRewritten(query, "OR sddocname:per foo bar");
- ((OrItem)query.getModel().getQueryTree().getRoot()).getItem(2).setRanked(false); // set 'bar' unranked
+ ((OrItem) query.getModel().getQueryTree().getRoot()).getItem(2).setRanked(false); // set 'bar' unranked
assertRewritten(query, "OR sddocname:per foo");
assertRewritten("sddocname:per OR foo OR (bar AND fuz)", "per", "OR sddocname:per foo (AND bar fuz)");
}
@Test
- public void testRankContributingTermsAreNotRemovedOnFullRecall() {
+ void testRankContributingTermsAreNotRemovedOnFullRecall() {
Query query = new Query(QueryTestCase.httpEncode("?query=default:term1 OR default:term2 OR default:term3 OR sddocname:per&type=adv&recall=+id:1&restrict=per"));
RecallSearcher searcher = new RecallSearcher();
Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
@@ -67,7 +65,7 @@ public class QueryRewriteTestCase {
}
@Test
- public void requireThatOptimizeByRestrictSimplifiesANDItemsThatHaveZeroRecall() {
+ void requireThatOptimizeByRestrictSimplifiesANDItemsThatHaveZeroRecall() {
assertRewritten("sddocname:foo AND bar AND baz", "cox", "NULL");
assertRewritten("foo AND sddocname:bar AND baz", "cox", "NULL");
assertRewritten("foo AND bar AND sddocname:baz", "cox", "NULL");
@@ -82,7 +80,7 @@ public class QueryRewriteTestCase {
}
@Test
- public void testRestrictRewrite() {
+ void testRestrictRewrite() {
assertRewritten("a AND b", "per", "AND a b");
assertRewritten("a OR b", "per", "OR a b");
assertRewritten("sddocname:per", "per", "sddocname:per");
@@ -94,9 +92,9 @@ public class QueryRewriteTestCase {
assertRewritten("sddocname:perder ANDNOT b", "per", "NULL");
assertRewritten("a ANDNOT sddocname:per a b", "per", "NULL");
}
-
+
@Test
- public void testRestrictRank() {
+ void testRestrictRank() {
assertRewritten("sddocname:per&filter=abc", "espen", "NULL");
assertRewritten("sddocname:per&filter=abc", "per", "RANK sddocname:per |abc");
assertRewritten("sddocname:per RANK bar", "per", "RANK sddocname:per bar");
@@ -119,7 +117,7 @@ public class QueryRewriteTestCase {
}
@Test
- public void assertAndNotMovedUp() {
+ void assertAndNotMovedUp() {
Query query = new Query();
NotItem not = new NotItem();
not.addPositiveItem(new WordItem("a"));
@@ -139,7 +137,7 @@ public class QueryRewriteTestCase {
}
@Test
- public void assertMultipleAndNotIsCollapsed() {
+ void assertMultipleAndNotIsCollapsed() {
Query query = new Query();
NotItem not1 = new NotItem();
not1.addPositiveItem(new WordItem("a"));
@@ -165,7 +163,7 @@ public class QueryRewriteTestCase {
AndItem a = (AndItem) n.getPositiveItem();
assertEquals(5, a.getItemCount());
assertEquals("na1", n.getItem(1).toString());
- assertEquals("na2",n.getItem(2).toString());
+ assertEquals("na2", n.getItem(2).toString());
assertEquals("nb", n.getItem(3).toString());
assertEquals("1", a.getItem(0).toString());
assertEquals("a", a.getItem(1).toString());
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/RecallSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/RecallSearcherTestCase.java
index 409d01b5c46..e2d1555701c 100755
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/RecallSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/RecallSearcherTestCase.java
@@ -16,12 +16,9 @@ import com.yahoo.prelude.query.NullItem;
import com.yahoo.prelude.query.WordItem;
import com.yahoo.prelude.querytransform.RecallSearcher;
import com.yahoo.search.searchchain.Execution;
-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.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Simon Thoresen Hult
@@ -29,7 +26,7 @@ import static org.junit.Assert.fail;
public class RecallSearcherTestCase {
@Test
- public void testIgnoreEmptyProperty() {
+ void testIgnoreEmptyProperty() {
RecallSearcher searcher = new RecallSearcher();
Query query = new Query();
Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
@@ -38,7 +35,7 @@ public class RecallSearcherTestCase {
}
@Test
- public void testDenyRankItems() {
+ void testDenyRankItems() {
RecallSearcher searcher = new RecallSearcher();
Query query = new Query("?recall=foo");
Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
@@ -46,7 +43,7 @@ public class RecallSearcherTestCase {
}
@Test
- public void testParse() {
+ void testParse() {
List<String> empty = new ArrayList<>();
assertQueryTree("?query=foo", Arrays.asList("foo"), empty);
assertQueryTree("?recall=%2bfoo", empty, Arrays.asList("foo"));
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/StemmingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/StemmingSearcherTestCase.java
index 0d7b0caa65b..bcb243b4563 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/StemmingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/StemmingSearcherTestCase.java
@@ -17,10 +17,10 @@ import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.search.searchchain.Execution;
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.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:mathiasm@yahoo-inc.com">Mathias M. Lidal</a>
@@ -32,13 +32,13 @@ public class StemmingSearcherTestCase {
"querytransform/test/", null);
@Test
- public void testStemOnlySomeTerms() {
+ void testStemOnlySomeTerms() {
assertStem("/search?query=Holes in CVS and Subversion nostem:Found",
- "WEAKAND(100) hole in cvs and subversion nostem:Found");
+ "WEAKAND(100) hole in cvs and subversion nostem:Found");
}
@Test
- public void testPhraseSegmentTransforms() {
+ void testPhraseSegmentTransforms() {
Query q1 = buildQueryWithSegmentPhrase();
executeStemming(q1);
assertEquals("AND a 'd e'", q1.getModel().getQueryTree().getRoot().toString());
@@ -61,65 +61,65 @@ public class StemmingSearcherTestCase {
}
@Test
- public void testPreserveConnectivityToPhrase() {
+ void testPreserveConnectivityToPhrase() {
Query q1 = buildQueryWithSegmentPhrase();
- CompositeItem r = (CompositeItem)q1.getModel().getQueryTree().getRoot();
- WordItem first = (WordItem)r.getItem(0);
- PhraseSegmentItem second = (PhraseSegmentItem)r.getItem(1);
+ CompositeItem r = (CompositeItem) q1.getModel().getQueryTree().getRoot();
+ WordItem first = (WordItem) r.getItem(0);
+ PhraseSegmentItem second = (PhraseSegmentItem) r.getItem(1);
first.setConnectivity(second, 1.0d);
executeStemming(q1);
assertEquals("AND a 'd e'", q1.getModel().getQueryTree().getRoot().toString());
- r = (CompositeItem)q1.getModel().getQueryTree().getRoot();
- first = (WordItem)r.getItem(0);
- second = (PhraseSegmentItem)r.getItem(1);
+ r = (CompositeItem) q1.getModel().getQueryTree().getRoot();
+ first = (WordItem) r.getItem(0);
+ second = (PhraseSegmentItem) r.getItem(1);
var origSecond = first.getConnectedItem();
- assertEquals("Connectivity incorrect.", second, first.getConnectedItem());
+ assertEquals(second, first.getConnectedItem(), "Connectivity incorrect.");
}
@Test
- public void testDontStemPrefixes() {
+ void testDontStemPrefixes() {
assertStem("/search?query=ist*&language=de", "WEAKAND(100) ist*");
}
@Test
- public void testStemming() {
+ void testStemming() {
Query query = new Query("/search?query=");
executeStemming(query);
assertTrue(query.getModel().getQueryTree().getRoot() instanceof NullItem);
}
@Test
- public void testNounStemming() {
+ void testNounStemming() {
assertStem("/search?query=noun:towers noun:tower noun:tow",
- "WEAKAND(100) noun:tower noun:tower noun:tow");
+ "WEAKAND(100) noun:tower noun:tower noun:tow");
assertStem("/search?query=notnoun:towers notnoun:tower notnoun:tow",
- "WEAKAND(100) notnoun:tower notnoun:tower notnoun:tow");
+ "WEAKAND(100) notnoun:tower notnoun:tower notnoun:tow");
}
@SuppressWarnings("deprecation")
@Test
- public void testEmptyIndexInfo() {
+ void testEmptyIndexInfo() {
String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/querytransform/test/emptyindexinfo.cfg";
ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
- IndexFacts indexFacts = new IndexFacts(new IndexModel(config, (QrSearchersConfig)null));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
Query q = new Query(QueryTestCase.httpEncode("?query=cars"));
new Execution(new Chain<Searcher>(new StemmingSearcher(linguistics)),
- Execution.Context.createContextStub(indexFacts, linguistics)).search(q);
+ Execution.Context.createContextStub(indexFacts, linguistics)).search(q);
assertEquals("WEAKAND(100) cars", q.getModel().getQueryTree().getRoot().toString());
}
@Test
- public void testLiteralBoost() {
+ void testLiteralBoost() {
Query q = new Query(QueryTestCase.httpEncode("/search?language=en&search=three"));
WordItem scratch = new WordItem("trees", true);
scratch.setStemmed(false);
q.getModel().getQueryTree().setRoot(scratch);
executeStemming(q);
- assertTrue("Expected a set of word alternatives as root.",
- q.getModel().getQueryTree().getRoot() instanceof WordAlternativesItem);
+ assertTrue(q.getModel().getQueryTree().getRoot() instanceof WordAlternativesItem,
+ "Expected a set of word alternatives as root.");
WordAlternativesItem w = (WordAlternativesItem) q.getModel().getQueryTree().getRoot();
boolean foundExpectedBaseForm = false;
for (WordAlternativesItem.Alternative a : w.getAlternatives()) {
@@ -128,16 +128,16 @@ public class StemmingSearcherTestCase {
foundExpectedBaseForm = true;
}
}
- assertTrue("Did not find original word form in query.", foundExpectedBaseForm);
+ assertTrue(foundExpectedBaseForm, "Did not find original word form in query.");
}
@Test
- public void testMultipleStemming() {
+ void testMultipleStemming() {
Query q = new Query(QueryTestCase.httpEncode("/search?language=en&search=four&query=trees \"nouns girls\" flowers \"a verbs a\" girls&default-index=foobar"));
executeStemming(q);
- assertEquals("WEAKAND(100) WORD_ALTERNATIVES foobar:[ tree(0.7) trees(1.0) ] "+
- "foobar:\"noun girl\" WORD_ALTERNATIVES foobar:[ flower(0.7) flowers(1.0) ] "+
- "foobar:\"a verb a\" WORD_ALTERNATIVES foobar:[ girl(0.7) girls(1.0) ]", q.getModel().getQueryTree().getRoot().toString());
+ assertEquals("WEAKAND(100) WORD_ALTERNATIVES foobar:[ tree(0.7) trees(1.0) ] " +
+ "foobar:\"noun girl\" WORD_ALTERNATIVES foobar:[ flower(0.7) flowers(1.0) ] " +
+ "foobar:\"a verb a\" WORD_ALTERNATIVES foobar:[ girl(0.7) girls(1.0) ]", q.getModel().getQueryTree().getRoot().toString());
}
private Execution.Context newExecutionContext() {
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
index 4fffc450e74..156a0dcbb3e 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
@@ -31,12 +31,9 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChain;
import com.yahoo.search.searchchain.SearchChainRegistry;
import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
-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.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests the BlendingSearcher class
@@ -125,7 +122,7 @@ public class BlendingSearcherTestCase {
}
@Test
- public void testitTwoPhase() {
+ void testitTwoPhase() {
DocumentSourceSearcher chain1 = new DocumentSourceSearcher();
DocumentSourceSearcher chain2 = new DocumentSourceSearcher();
DocumentSourceSearcher chain3 = new DocumentSourceSearcher();
@@ -137,27 +134,63 @@ public class BlendingSearcherTestCase {
Result r3 = new Result(q);
r1.setTotalHitCount(13);
- r1.hits().add(new Hit("http://host1.com", 101){{setSource("one");}});
- r1.hits().add(new Hit("http://host2.com", 102){{setSource("one");}});
- r1.hits().add(new Hit("http://host3.com", 103){{setSource("one");}});
+ r1.hits().add(new Hit("http://host1.com", 101){
+ {
+ setSource("one");
+ }
+ });
+ r1.hits().add(new Hit("http://host2.com", 102){
+ {
+ setSource("one");
+ }
+ });
+ r1.hits().add(new Hit("http://host3.com", 103){
+ {
+ setSource("one");
+ }
+ });
chain1.addResult(q, r1);
r2.setTotalHitCount(17);
- r2.hits().add(new Hit("http://host1.com", 101){{setSource("two");}});
- r2.hits().add(new Hit("http://host2.com", 102){{setSource("two");}});
- r2.hits().add(new Hit("http://host4.com", 104){{setSource("two");}});
+ r2.hits().add(new Hit("http://host1.com", 101){
+ {
+ setSource("two");
+ }
+ });
+ r2.hits().add(new Hit("http://host2.com", 102){
+ {
+ setSource("two");
+ }
+ });
+ r2.hits().add(new Hit("http://host4.com", 104){
+ {
+ setSource("two");
+ }
+ });
chain2.addResult(q, r2);
r3.setTotalHitCount(37);
- r3.hits().add(new Hit("http://host5.com", 100){{setSource("three");}});
- r3.hits().add(new Hit("http://host6.com", 106){{setSource("three");}});
- r3.hits().add(new Hit("http://host7.com", 105){{setSource("three");}});
+ r3.hits().add(new Hit("http://host5.com", 100){
+ {
+ setSource("three");
+ }
+ });
+ r3.hits().add(new Hit("http://host6.com", 106){
+ {
+ setSource("three");
+ }
+ });
+ r3.hits().add(new Hit("http://host7.com", 105){
+ {
+ setSource("three");
+ }
+ });
chain3.addResult(q, r3);
BlendingSearcherWrapper blender1 = new BlendingSearcherWrapper();
blender1.addSource("one", chain1);
blender1.initialize();
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result br1 = new Execution(blender1, Execution.Context.createContextStub()).search(q);
assertEquals(3, br1.getHitCount());
assertEquals(13, br1.getTotalHitCount());
@@ -167,7 +200,7 @@ public class BlendingSearcherTestCase {
blender2.addSource("two", chain1);
blender2.addSource("three", chain2);
blender2.initialize();
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result br2 = new Execution(blender2, Execution.Context.createContextStub()).search(q);
assertEquals(6, br2.getHitCount());
assertEquals(30, br2.getTotalHitCount());
@@ -178,28 +211,28 @@ public class BlendingSearcherTestCase {
blender3.addSource("five", chain2);
blender3.addSource("six", chain3);
blender3.initialize();
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result br3 = new Execution(blender3, Execution.Context.createContextStub()).search(q);
assertEquals(9, br3.getHitCount());
assertEquals(67, br3.getTotalHitCount());
assertEquals("http://host6.com/", br3.hits().get(0).getId().toString());
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result br4 = new Execution(blender3, Execution.Context.createContextStub()).search(q);
assertEquals(9, br4.getHitCount());
assertEquals("http://host6.com/", br4.hits().get(0).getId().toString());
- q.setWindow( 3, 10);
+ q.setWindow(3, 10);
Result br5 = new Execution(blender3, Execution.Context.createContextStub()).search(q);
assertEquals(6, br5.getHitCount());
assertEquals("http://host3.com/", br5.hits().get(0).getId().toString());
- q.setWindow( 3, 10);
+ q.setWindow(3, 10);
br5 = new Execution(blender3, Execution.Context.createContextStub()).search(q);
assertEquals(6, br5.getHitCount());
assertEquals("http://host3.com/", br5.hits().get(0).getId().toString());
- q.setWindow( 3, 10);
+ q.setWindow(3, 10);
br5 = new Execution(blender3, Execution.Context.createContextStub()).search(q);
assertEquals(6, br5.getHitCount());
assertEquals("http://host3.com/", br5.hits().get(0).getId().toString());
@@ -207,7 +240,7 @@ public class BlendingSearcherTestCase {
}
@Test
- public void testMultipleBackendsWithDuplicateRemoval() {
+ void testMultipleBackendsWithDuplicateRemoval() {
DocumentSourceSearcher docSource1 = new DocumentSourceSearcher();
DocumentSourceSearcher docSource2 = new DocumentSourceSearcher();
Query q = new Query("/search?query=hannibal&search=a,b");
@@ -225,14 +258,14 @@ public class BlendingSearcherTestCase {
blender.addSource(new Chain<>("a", new FillSearcher(), docSource1));
blender.addSource(new Chain<>("b", new FillSearcher(), docSource2));
blender.initialize();
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result cr = new Execution(blender, Execution.Context.createContextStub()).search(q);
assertEquals(1, cr.getHitCount());
assertEquals(101, ((int) cr.hits().get(0).getRelevance().getScore()));
}
@Test
- public void testMultipleBackendsWithErrorMerging() {
+ void testMultipleBackendsWithErrorMerging() {
DocumentSourceSearcher docSource1 = new DocumentSourceSearcher();
DocumentSourceSearcher docSource2 = new DocumentSourceSearcher();
Query q = new Query("/search?query=hannibal&search=a,b");
@@ -249,25 +282,25 @@ public class BlendingSearcherTestCase {
blender.addSource(new Chain<>("a", new FillSearcher(), docSource1));
blender.addSource(new Chain<>("b", new FillSearcher(), docSource2));
blender.initialize();
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result cr = new Execution(blender, Execution.Context.createContextStub()).search(q);
assertEquals(2, cr.getHitCount());
assertEquals(1, cr.getConcreteHitCount());
com.yahoo.search.result.ErrorHit errorHit = cr.hits().getErrorHit();
Iterator errorIterator = errorHit.errorIterator();
List<String> errorList = Arrays.asList("Source 'a': No backends in service. Try later",
- "Source 'b': 2: Request too large");
+ "Source 'b': 2: Request too large");
String a = errorIterator.next().toString();
- assertTrue(a, errorList.contains(a));
+ assertTrue(errorList.contains(a), a);
String b = errorIterator.next().toString();
- assertTrue(a, errorList.contains(b));
+ assertTrue(errorList.contains(b), a);
assertFalse(errorIterator.hasNext());
assertEquals(102, ((int) cr.hits().get(1).getRelevance().getScore()));
assertEquals(com.yahoo.container.protect.Error.NO_BACKENDS_IN_SERVICE.code, cr.hits().getError().getCode());
}
@Test
- public void testBlendingWithSortSpec() {
+ void testBlendingWithSortSpec() {
DocumentSourceSearcher docSource1 = new DocumentSourceSearcher();
DocumentSourceSearcher docSource2 = new DocumentSourceSearcher();
@@ -310,7 +343,7 @@ public class BlendingSearcherTestCase {
blender.addSource(new Chain<>("a", new FillSearcher(), docSource1));
blender.addSource(new Chain<>("b", new FillSearcher(), docSource2));
blender.initialize();
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result br = new Execution(blender, Execution.Context.createContextStub()).search(q);
assertEquals(202, ((int) br.hits().get(0).getRelevance().getScore()));
assertEquals(103, ((int) br.hits().get(1).getRelevance().getScore()));
@@ -326,7 +359,7 @@ public class BlendingSearcherTestCase {
* But are we sure fsearch handles this case correctly?
*/
@Test
- public void testBlendingWithSortSpecAnd2Phase() {
+ void testBlendingWithSortSpecAnd2Phase() {
DocumentSourceSearcher docSource1 = new DocumentSourceSearcher();
DocumentSourceSearcher docSource2 = new DocumentSourceSearcher();
@@ -362,7 +395,7 @@ public class BlendingSearcherTestCase {
blender.addSource("chainedone", docSource1);
blender.addSource("chainedtwo", docSource2);
blender.initialize();
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result br = new Execution(blender, Execution.Context.createContextStub()).search(q);
assertEquals(202, ((int) br.hits().get(0).getRelevance().getScore()));
assertEquals(103, ((int) br.hits().get(1).getRelevance().getScore()));
@@ -400,7 +433,7 @@ public class BlendingSearcherTestCase {
}
@Test
- public void testOnlyFirstBackend() {
+ void testOnlyFirstBackend() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=first");
@@ -410,7 +443,7 @@ public class BlendingSearcherTestCase {
}
@Test
- public void testOnlySecondBackend() {
+ void testOnlySecondBackend() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=second");
@@ -421,7 +454,7 @@ public class BlendingSearcherTestCase {
}
@Test
- public void testBothBackendsExplicitly() {
+ void testBothBackendsExplicitly() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=first,second");
@@ -433,7 +466,7 @@ public class BlendingSearcherTestCase {
}
@Test
- public void testBothBackendsImplicitly() {
+ void testBothBackendsImplicitly() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana");
@@ -445,7 +478,7 @@ public class BlendingSearcherTestCase {
}
@Test
- public void testNonexistingBackendCausesError() {
+ void testNonexistingBackendCausesError() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=nonesuch");
@@ -459,7 +492,7 @@ public class BlendingSearcherTestCase {
}
@Test
- public void testNonexistingBackendsCausesErrorOnFirst() {
+ void testNonexistingBackendsCausesErrorOnFirst() {
// Feel free to change to include all in the detail message...
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=nonesuch,orsuch");
@@ -471,11 +504,11 @@ public class BlendingSearcherTestCase {
assertEquals("Invalid query parameter", e.getMessage());
//TODO: Do not depend on sources order
assertEquals("4: Invalid query parameter: Could not resolve source ref 'nonesuch'. Could not resolve source ref 'orsuch'. Valid source refs are first, second.",
- e.toString());
+ e.toString());
}
@Test
- public void testExistingAndNonExistingBackendCausesBothErrorAndResult() {
+ void testExistingAndNonExistingBackendCausesBothErrorAndResult() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=first,nonesuch,second");
@@ -488,11 +521,11 @@ public class BlendingSearcherTestCase {
ErrorMessage e = result.hits().getError();
//TODO: Do not depend on sources order
assertEquals("Could not resolve source ref 'nonesuch'. Valid source refs are first, second.",
- e.getDetailedMessage());
+ e.getDetailedMessage());
}
@Test
- public void testBlendingFederationWithGrouping() {
+ void testBlendingFederationWithGrouping() {
DocumentSourceSearcher docSource1 = new DocumentSourceSearcher();
DocumentSourceSearcher docSource2 = new DocumentSourceSearcher();
@@ -528,22 +561,22 @@ public class BlendingSearcherTestCase {
blender.addSource(new Chain<>("a", new FillSearcher(), docSource1));
blender.addSource(new Chain<>("b", new FillSearcher(), docSource2));
blender.initialize();
- q.setWindow( 0, 10);
+ q.setWindow(0, 10);
Result result = new Execution(blender, Execution.Context.createContextStub()).search(q);
assertEquals(2, result.hits().size());
assertTrue(result.hits().get(0) instanceof RootGroup);
- RootGroup resultRoot1 = (RootGroup)result.hits().get(0);
+ RootGroup resultRoot1 = (RootGroup) result.hits().get(0);
assertEquals(1, resultRoot1.asList().size());
assertTrue(result.hits().get(1) instanceof RootGroup);
- RootGroup resultRoot2 = (RootGroup)result.hits().get(1);
+ RootGroup resultRoot2 = (RootGroup) result.hits().get(1);
assertEquals(2, resultRoot2.asList().size());
}
/** Multiple document types in the same cluster are returned without a top level group representing each */
@Test
- public void testBlendingMultipleDocumentTypesWithGrouping() {
+ void testBlendingMultipleDocumentTypesWithGrouping() {
DocumentSourceSearcher docSource = new DocumentSourceSearcher();
Query q = new Query("/search?query=test");
@@ -574,23 +607,23 @@ public class BlendingSearcherTestCase {
docSource.addResult(q, r);
Chain<Searcher> chain = new Chain<>("main",
- new FillSearcher(),
- new BlendingSearcher(ComponentId.fromString("test"), new QrSearchersConfig.Builder().build()),
- docSource);
- q.setWindow( 0, 10);
+ new FillSearcher(),
+ new BlendingSearcher(ComponentId.fromString("test"), new QrSearchersConfig.Builder().build()),
+ docSource);
+ q.setWindow(0, 10);
Result result = new Execution(chain, Execution.Context.createContextStub()).search(q);
assertEquals(3, result.hits().size());
assertTrue(result.hits().get(0) instanceof Group);
- Group resultSubGroup1 = (Group)result.hits().get(0);
+ Group resultSubGroup1 = (Group) result.hits().get(0);
assertEquals(4, resultSubGroup1.asList().size());
assertTrue(result.hits().get(1) instanceof Group);
- Group resultSubGroup2 = (Group)result.hits().get(1);
+ Group resultSubGroup2 = (Group) result.hits().get(1);
assertEquals(3, resultSubGroup2.asList().size());
assertTrue(result.hits().get(2) instanceof Group);
- Group resultSubGroup3 = (Group)result.hits().get(2);
+ Group resultSubGroup3 = (Group) result.hits().get(2);
assertEquals(2, resultSubGroup3.asList().size());
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/FieldCollapsingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/FieldCollapsingSearcherTestCase.java
index de6a55354fd..4a2a34a64c2 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/FieldCollapsingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/FieldCollapsingSearcherTestCase.java
@@ -21,18 +21,14 @@ import com.yahoo.search.result.HitGroup;
import com.yahoo.search.result.Relevance;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
-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.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.*;
/**
* Tests the FieldCollapsingSearcher class
@@ -42,7 +38,7 @@ import static org.junit.Assert.assertTrue;
public class FieldCollapsingSearcherTestCase {
@Test
- public void testFieldCollapsingWithoutHits() {
+ void testFieldCollapsingWithoutHits() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
@@ -59,7 +55,7 @@ public class FieldCollapsingSearcherTestCase {
}
@Test
- public void testFieldCollapsingWithoutHitsHugeOffset() {
+ void testFieldCollapsingWithoutHitsHugeOffset() {
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
@@ -75,7 +71,7 @@ public class FieldCollapsingSearcherTestCase {
}
@Test
- public void testFieldCollapsing() {
+ void testFieldCollapsing() {
Map<Searcher, Searcher> chained = new HashMap<>();
// Set up
@@ -89,7 +85,7 @@ public class FieldCollapsingSearcherTestCase {
// The searcher turns off collapsing further on in the chain
q.properties().set("collapse", "0");
Result r = new Result(q);
- r.hits().add(createHit("http://acme.org/a.html",10, 0));
+ r.hits().add(createHit("http://acme.org/a.html", 10, 0));
r.hits().add(createHit("http://acme.org/b.html", 9, 0));
r.hits().add(createHit("http://acme.org/c.html", 9, 1));
r.hits().add(createHit("http://acme.org/d.html", 8, 1));
@@ -106,14 +102,14 @@ public class FieldCollapsingSearcherTestCase {
assertEquals(4, r.getHitCount());
assertEquals(1, docsource.getQueryCount());
- assertHit("http://acme.org/a.html",10, 0, r.hits().get(0));
+ assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
}
@Test
- public void testFieldCollapsingTwoPhase() {
+ void testFieldCollapsingTwoPhase() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
@@ -125,7 +121,7 @@ public class FieldCollapsingSearcherTestCase {
// The searcher turns off collapsing further on in the chain
q.properties().set("collapse", "0");
Result r = new Result(q);
- r.hits().add(createHit("http://acme.org/a.html",10, 0));
+ r.hits().add(createHit("http://acme.org/a.html", 10, 0));
r.hits().add(createHit("http://acme.org/b.html", 9, 0));
r.hits().add(createHit("http://acme.org/c.html", 9, 1));
r.hits().add(createHit("http://acme.org/d.html", 8, 1));
@@ -142,14 +138,14 @@ public class FieldCollapsingSearcherTestCase {
assertEquals(4, r.getHitCount());
assertEquals(1, docsource.getQueryCount());
- assertHit("http://acme.org/a.html",10,0, r.hits().get(0));
- assertHit("http://acme.org/c.html", 9,1, r.hits().get(1));
- assertHit("http://acme.org/e.html", 8,2, r.hits().get(2));
- assertHit("http://acme.org/g.html", 7,3, r.hits().get(3));
+ assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
+ assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
+ assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
+ assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
}
@Test
- public void testNoCollapsingIfNotAskedTo() {
+ void testNoCollapsingIfNotAskedTo() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher();
@@ -158,7 +154,7 @@ public class FieldCollapsingSearcherTestCase {
Query q = new Query("?query=test_collapse");
Result r = new Result(q);
- r.hits().add(createHit("http://acme.org/a.html",10, 0));
+ r.hits().add(createHit("http://acme.org/a.html", 10, 0));
r.hits().add(createHit("http://acme.org/b.html", 9, 0));
r.hits().add(createHit("http://acme.org/c.html", 9, 1));
r.hits().add(createHit("http://acme.org/d.html", 8, 1));
@@ -182,10 +178,10 @@ public class FieldCollapsingSearcherTestCase {
* an excessive number of backend requests
*/
@Test
- public void testCollapsingLargeCollection() {
+ void testCollapsingLargeCollection() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
- FieldCollapsingSearcher collapse = new FieldCollapsingSearcher(4,2.0,"amid");
+ FieldCollapsingSearcher collapse = new FieldCollapsingSearcher(4, 2.0, "amid");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(collapse, docsource);
@@ -193,7 +189,7 @@ public class FieldCollapsingSearcherTestCase {
// The searcher turns off collapsing further on in the chain
q.properties().set("collapse", "0");
Result r = new Result(q);
- r.hits().add(createHit("http://acme.org/a.html",10, 0));
+ r.hits().add(createHit("http://acme.org/a.html", 10, 0));
r.hits().add(createHit("http://acme.org/b.html", 9, 0));
r.hits().add(createHit("http://acme.org/c.html", 9, 0));
r.hits().add(createHit("http://acme.org/d.html", 8, 0));
@@ -212,7 +208,7 @@ public class FieldCollapsingSearcherTestCase {
assertEquals(2, r.getHitCount());
assertEquals(2, docsource.getQueryCount());
- assertHit("http://acme.org/a.html",10, 0, r.hits().get(0));
+ assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/i.html", 5, 1, r.hits().get(1));
// Next results
@@ -220,17 +216,17 @@ public class FieldCollapsingSearcherTestCase {
r = doSearch(collapse, q, 2, 2, chained);
assertEquals(1, r.getHitCount());
assertEquals(2, docsource.getQueryCount());
- assertHit("http://acme.org/j.html",4, 2, r.hits().get(0));
+ assertHit("http://acme.org/j.html", 4, 2, r.hits().get(0));
}
/**
* Tests collapsing of "messy" data
*/
@Test
- public void testCollapsingDispersedCollection() {
+ void testCollapsingDispersedCollection() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
- FieldCollapsingSearcher collapse = new FieldCollapsingSearcher(1,2.0,"amid");
+ FieldCollapsingSearcher collapse = new FieldCollapsingSearcher(1, 2.0, "amid");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(collapse, docsource);
@@ -256,12 +252,12 @@ public class FieldCollapsingSearcherTestCase {
r = doSearch(collapse, q, 0, 3, chained);
assertEquals(2, r.getHitCount());
- assertHit("http://acme.org/a.html",10,1,r.hits().get(0));
- assertHit("http://acme.org/c.html",10,0,r.hits().get(1));
+ assertHit("http://acme.org/a.html", 10, 1, r.hits().get(0));
+ assertHit("http://acme.org/c.html", 10, 0, r.hits().get(1));
}
@Test
- public void testQueryTransformAndCollapsing() {
+ void testQueryTransformAndCollapsing() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
@@ -277,14 +273,14 @@ public class FieldCollapsingSearcherTestCase {
// The searcher turns off collapsing further on in the chain
q.properties().set("collapse", "0");
Result r = new Result(q);
- r.hits().add(createHit("http://acme.org/a.html",10,0));
- r.hits().add(createHit("http://acme.org/b.html", 9,0));
- r.hits().add(createHit("http://acme.org/c.html", 9,0));
- r.hits().add(createHit("http://acme.org/d.html", 8,0));
- r.hits().add(createHit("http://acme.org/e.html", 8,0));
- r.hits().add(createHit("http://acme.org/f.html", 7,0));
- r.hits().add(createHit("http://acme.org/g.html", 7,0));
- r.hits().add(createHit("http://acme.org/h.html", 6,1));
+ r.hits().add(createHit("http://acme.org/a.html", 10, 0));
+ r.hits().add(createHit("http://acme.org/b.html", 9, 0));
+ r.hits().add(createHit("http://acme.org/c.html", 9, 0));
+ r.hits().add(createHit("http://acme.org/d.html", 8, 0));
+ r.hits().add(createHit("http://acme.org/e.html", 8, 0));
+ r.hits().add(createHit("http://acme.org/f.html", 7, 0));
+ r.hits().add(createHit("http://acme.org/g.html", 7, 0));
+ r.hits().add(createHit("http://acme.org/h.html", 6, 1));
r.setTotalHitCount(8);
docsource.addResult(q, r);
@@ -294,12 +290,12 @@ public class FieldCollapsingSearcherTestCase {
assertEquals(2, docsource.getQueryCount());
assertEquals(2, r.getHitCount());
- assertHit("http://acme.org/a.html",10, 0, r.hits().get(0));
+ assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/h.html", 6, 1, r.hits().get(1));
}
@Test
- public void testFieldCollapsingTwoPhaseSelectSummary() {
+ void testFieldCollapsingTwoPhaseSelectSummary() {
// Set up
Map<Searcher, Searcher> chained = new HashMap<>();
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
@@ -311,14 +307,14 @@ public class FieldCollapsingSearcherTestCase {
// The searcher turns off collapsing further on in the chain
q.properties().set("collapse", "0");
Result r = new Result(q);
- r.hits().add(createHit("http://acme.org/a.html",10,0));
- r.hits().add(createHit("http://acme.org/b.html", 9,0));
- r.hits().add(createHit("http://acme.org/c.html", 9,1));
- r.hits().add(createHit("http://acme.org/d.html", 8,1));
- r.hits().add(createHit("http://acme.org/e.html", 8,2));
- r.hits().add(createHit("http://acme.org/f.html", 7,2));
- r.hits().add(createHit("http://acme.org/g.html", 7,3));
- r.hits().add(createHit("http://acme.org/h.html", 6,3));
+ r.hits().add(createHit("http://acme.org/a.html", 10, 0));
+ r.hits().add(createHit("http://acme.org/b.html", 9, 0));
+ r.hits().add(createHit("http://acme.org/c.html", 9, 1));
+ r.hits().add(createHit("http://acme.org/d.html", 8, 1));
+ r.hits().add(createHit("http://acme.org/e.html", 8, 2));
+ r.hits().add(createHit("http://acme.org/f.html", 7, 2));
+ r.hits().add(createHit("http://acme.org/g.html", 7, 3));
+ r.hits().add(createHit("http://acme.org/h.html", 6, 3));
r.setTotalHitCount(8);
docsource.addResult(q, r);
@@ -329,7 +325,7 @@ public class FieldCollapsingSearcherTestCase {
assertEquals(4, r.getHitCount());
assertEquals(1, docsource.getQueryCount());
assertTrue(r.isFilled("placeholder"));
- assertHit("http://acme.org/a.html",10, 0, r.hits().get(0));
+ assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
@@ -343,18 +339,18 @@ public class FieldCollapsingSearcherTestCase {
assertEquals(1, docsource.getQueryCount());
assertFalse(r.isFilled("placeholder"));
assertTrue(r.isFilled("short"));
- assertHit("http://acme.org/a.html",10, 0, r.hits().get(0));
+ assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
}
@Test
- public void testFieldCollapsingWithGrouping() {
+ void testFieldCollapsingWithGrouping() {
// Set up
FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
- Chain<Searcher> chain=new Chain<>(collapse,new AddAggregationStyleGroupingResultSearcher(),docsource);
+ Chain<Searcher> chain = new Chain<>(collapse, new AddAggregationStyleGroupingResultSearcher(), docsource);
// Caveat: Collapse is set to false, because that's what the
// collapser asks for
@@ -362,7 +358,7 @@ public class FieldCollapsingSearcherTestCase {
// The searcher turns off collapsing further on in the chain
q.properties().set("collapse", "0");
Result r = new Result(q);
- r.hits().add(createHit("http://acme.org/a.html",10, 0));
+ r.hits().add(createHit("http://acme.org/a.html", 10, 0));
r.hits().add(createHit("http://acme.org/b.html", 9, 0));
r.hits().add(createHit("http://acme.org/c.html", 9, 1));
r.hits().add(createHit("http://acme.org/d.html", 8, 1));
@@ -380,7 +376,7 @@ public class FieldCollapsingSearcherTestCase {
// Assert that the regular hits are collapsed
assertEquals(4 + 1, result.getHitCount());
assertEquals(1, docsource.getQueryCount());
- assertHit("http://acme.org/a.html",10, 0, result.hits().get(0));
+ assertHit("http://acme.org/a.html", 10, 0, result.hits().get(0));
assertHit("http://acme.org/c.html", 9, 1, result.hits().get(1));
assertHit("http://acme.org/e.html", 8, 2, result.hits().get(2));
assertHit("http://acme.org/g.html", 7, 3, result.hits().get(3));
@@ -388,12 +384,12 @@ public class FieldCollapsingSearcherTestCase {
// Assert that the aggregation group hierarchy is left intact
HitGroup root = getFirstGroupIn(result.hits());
assertNotNull(root);
- assertEquals("group:root:",root.getId().stringValue().substring(0, 11)); // The id ends by a global counter currently
+ assertEquals("group:root:", root.getId().stringValue().substring(0, 11)); // The id ends by a global counter currently
assertEquals(1, root.size());
- HitGroup groupList = (GroupList)root.get("grouplist:g1");
+ HitGroup groupList = (GroupList) root.get("grouplist:g1");
assertNotNull(groupList);
assertEquals(1, groupList.size());
- HitGroup group = (HitGroup)groupList.get("group:long:37");
+ HitGroup group = (HitGroup) groupList.get("group:long:37");
assertNotNull(group);
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JSONDebugSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JSONDebugSearcherTestCase.java
index 6a230da4950..a10ecfb99e0 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JSONDebugSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JSONDebugSearcherTestCase.java
@@ -14,10 +14,10 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
import com.yahoo.yolean.trace.TraceNode;
import com.yahoo.yolean.trace.TraceVisitor;
-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;
/**
* Visit the trace and check JSON payload is stored there when requested.
@@ -30,7 +30,7 @@ public class JSONDebugSearcherTestCase {
private static final String DUMPJSON = "?query=1&dumpjson=jsonfield&tracelevel=6";
@Test
- public void test() {
+ void test() {
Chain<Searcher> searchChain = makeSearchChain("{1: 2}", new JSONDebugSearcher());
Execution e = new Execution(searchChain, Execution.Context.createContextStub());
e.search(new Query(NODUMPJSON));
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
index 706d217269b..bd72ed9fd08 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.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.prelude.searcher.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
@@ -22,7 +20,7 @@ import com.yahoo.search.result.Relevance;
import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
import com.yahoo.prelude.searcher.JuniperSearcher;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -113,19 +111,19 @@ public class JuniperSearcherTestCase {
}
@Test
- public void testFieldRewriting() {
+ void testFieldRewriting() {
Result check = createResult("\u001FXYZ\u001F\u001EQWE\u001FJKL\u001FASD&");
assertEquals(1, check.getHitCount());
assertEquals("<hi>XYZ</hi><sep />QWE<hi>JKL</hi>ASD&",
- check.hits().get(0).getField("dynteaser").toString());
+ check.hits().get(0).getField("dynteaser").toString());
check = createResult("a&b&c");
assertEquals(1, check.getHitCount());
assertEquals("a&b&c",
- check.hits().get(0).getField("dynteaser").toString());
+ check.hits().get(0).getField("dynteaser").toString());
}
@Test
- public void testNoRewritingDueToSearchDefinition() {
+ void testNoRewritingDueToSearchDefinition() {
Result check = createResult("two", "\u001FXYZ\u001F\u001EQWE\u001FJKL\u001FASD&");
assertEquals(1, check.getHitCount());
assertEquals("\u001FXYZ\u001F\u001EQWE\u001FJKL\u001FASD&",
@@ -137,20 +135,20 @@ public class JuniperSearcherTestCase {
}
@Test
- public void testBoldingEquals() {
+ void testBoldingEquals() {
assertNotEquals(new Query("?query=12"), new Query("?query=12&bolding=false"));
}
@Test
- public void testUnboldedRewriting() {
+ void testUnboldedRewriting() {
Result check = createResult("one", "\u001FXYZ\u001F\u001EQWE\u001FJKL\u001FASD&", false);
assertEquals(1, check.getHitCount());
assertEquals("XYZ...QWEJKLASD&",
- check.hits().get(0).getField("dynteaser").toString());
+ check.hits().get(0).getField("dynteaser").toString());
}
@Test
- public void testAnnotatedSummaryFields() {
+ void testAnnotatedSummaryFields() {
Result check = createResult("\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");
assertEquals(1, check.getHitCount());
assertEquals("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 />", check.hits().get(0).getField("dynteaser").toString());
@@ -185,7 +183,7 @@ public class JuniperSearcherTestCase {
}
@Test
- public void testThatIncompleteAnnotationWithHighlightIsIgnored() {
+ void testThatIncompleteAnnotationWithHighlightIsIgnored() {
// Look at bug 5707026 for details.
{
Result check = createResult("of\u001e\u001fyahoo\u001f\uFFFB! \uFFF9Angels\uFFFAangels\uFFFB \uFFF9\u001fYahoo\u001f\uFFFA\u001fyahoo\u001f\uFFFB! \uFFF9Angles\uFFFAangels\uFFFB \uFFF9is\uFFFAbe\u001e");
@@ -202,7 +200,7 @@ public class JuniperSearcherTestCase {
}
@Test
- public void testThatIncompleteAnnotationWithHighlightAtTheBeginningIsIgnored() {
+ void testThatIncompleteAnnotationWithHighlightAtTheBeginningIsIgnored() {
{
Result check = createResult("\u001e\u001fIncomplete\uFFFAincomplete\uFFFB\u001f \uFFF9Original\uFFFAstemmed\uFFFB\u001e");
assertEquals(1, check.getHitCount());
@@ -221,7 +219,7 @@ public class JuniperSearcherTestCase {
}
@Test
- public void testThatIncompleteAnnotationWithHighlightAtTheEndIsIgnored() {
+ void testThatIncompleteAnnotationWithHighlightAtTheEndIsIgnored() {
{
Result check = createResult("\u001e\uFFF9Original\uFFFAstemmed\uFFFB \u001f\uFFF9Incomplete\uFFFAincomplete\u001f\u001e");
assertEquals(1, check.getHitCount());
@@ -240,7 +238,7 @@ public class JuniperSearcherTestCase {
}
@Test
- public void testExplicitTwoPhase() {
+ void testExplicitTwoPhase() {
Chain<Searcher> searchChain = createSearchChain("one", "\u001e\uFFFAbe\uFFFB within the set of \u001f\uFFF9documents\uFFFAdocument\uFFFB\u001f. \uFFF9phrases\uFFFA\u001E\uFFFA\uFFFB to as a remedy). Each of the \u001fdocument\u001f \uFFF9fields\uFFFAfield\uFFFB in a catalog can be \uFFF9\u001e");
Query q = new Query("?query=12");
Result check = createExecution(searchChain).search(q);
@@ -252,7 +250,7 @@ public class JuniperSearcherTestCase {
}
@Test
- public void testCompoundWordsBolding() {
+ void testCompoundWordsBolding() {
Result check = createResult("\u001eTest \u001fkommunikations\u001f\u001ffehler\u001f");
assertEquals(1, check.getHitCount());
assertEquals("<sep />Test <hi>kommunikationsfehler</hi>", check.hits().get(0).getField("dynteaser").toString());
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/MultipleResultsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/MultipleResultsTestCase.java
index 0a250c9b973..0024bf9cd66 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/MultipleResultsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/MultipleResultsTestCase.java
@@ -11,10 +11,10 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
-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;
/**
* Test of MultipleResultsSearcher
@@ -30,7 +30,7 @@ public class MultipleResultsTestCase {
private Chain<Searcher> chain;
- @Before
+ @BeforeEach
public void setUp() {
docSource=new DocumentSourceSearcher();
searcher=new MultipleResultsSearcher();
@@ -38,11 +38,11 @@ public class MultipleResultsTestCase {
}
@Test
- public void testRetrieveHeterogenousHits() {
+ void testRetrieveHeterogenousHits() {
Query query = createQuery();
Result originalResult = new Result(query);
- int n1 = 15, n2 = 25, n3 = 25, n4=25;
+ int n1 = 15, n2 = 25, n3 = 25, n4 = 25;
addHits(originalResult, "others", n1);
addHits(originalResult, "music", n2);
addHits(originalResult, "movies", n3);
@@ -51,23 +51,23 @@ public class MultipleResultsTestCase {
docSource.addResult(query, originalResult);
- query.setWindow(0,30);
+ query.setWindow(0, 30);
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
- HitGroup musicGroup = (HitGroup)result.hits().get("music");
- HitGroup moviesGroup = (HitGroup)result.hits().get("movies");
+ HitGroup musicGroup = (HitGroup) result.hits().get("music");
+ HitGroup moviesGroup = (HitGroup) result.hits().get("movies");
- assertEquals( 15, musicGroup.size() );
- assertEquals( 15, moviesGroup.size() );
- assertEquals( 3, docSource.getQueryCount() );
+ assertEquals(15, musicGroup.size());
+ assertEquals(15, moviesGroup.size());
+ assertEquals(3, docSource.getQueryCount());
}
@Test
- public void testRetrieveHitsForGroup() {
+ void testRetrieveHitsForGroup() {
Query query = createQuery();
Result originalResult = new Result(query);
- int n1 = 200, n2=30;
+ int n1 = 200, n2 = 30;
addHits(originalResult, "music", n1, 1000);
addHits(originalResult, "movies", n2, 100);
originalResult.setTotalHitCount(n1 + n2);
@@ -81,18 +81,18 @@ public class MultipleResultsTestCase {
docSource.addResult(restrictedQuery, restrictedResult);
- query.setWindow(0,30);
+ query.setWindow(0, 30);
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
- HitGroup musicGroup = (HitGroup)result.hits().get("music");
- HitGroup moviesGroup = (HitGroup)result.hits().get("movies");
+ HitGroup musicGroup = (HitGroup) result.hits().get("music");
+ HitGroup moviesGroup = (HitGroup) result.hits().get("movies");
- assertEquals( 15, musicGroup.size());
- assertEquals( 15, moviesGroup.size());
+ assertEquals(15, musicGroup.size());
+ assertEquals(15, moviesGroup.size());
}
@Test
- public void testNoHitsForResultSet() {
+ void testNoHitsForResultSet() {
Query query = createQuery();
Result originalResult = new Result(query);
@@ -104,14 +104,14 @@ public class MultipleResultsTestCase {
docSource.addResult(query, originalResult);
- query.setWindow(0,30);
+ query.setWindow(0, 30);
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
- HitGroup musicGroup = (HitGroup)result.hits().get("music");
- HitGroup moviesGroup = (HitGroup)result.hits().get("movies");
+ HitGroup musicGroup = (HitGroup) result.hits().get("music");
+ HitGroup moviesGroup = (HitGroup) result.hits().get("movies");
- assertEquals( 15, musicGroup.size());
- assertEquals( 0, moviesGroup.size());
+ assertEquals(15, musicGroup.size());
+ assertEquals(0, moviesGroup.size());
}
private void addHits(Result result, String docName, int numHits,
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/PosSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/PosSearcherTestCase.java
index 43911b33161..755a1c11d47 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/PosSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/PosSearcherTestCase.java
@@ -10,12 +10,12 @@ import com.yahoo.search.Searcher;
import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.search.result.ErrorHit;
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 static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for the PosSearcher
@@ -31,7 +31,7 @@ public class PosSearcherTestCase {
* Tests basic lat/long input.
*/
@Test
- public void testBasics() {
+ void testBasics() {
Query q = new Query();
q.properties().set("pos.ll", "N0;E0");
doSearch(searcher, q, 0, 10);
@@ -47,44 +47,44 @@ public class PosSearcherTestCase {
* Tests basic bounding box input.
*/
@Test
- public void testBoundingBox() {
+ void testBoundingBox() {
Query q = new Query();
q.properties().set("pos.bb", "n=51.9,s=50.2,e=0.34,w=-10.01");
doSearch(searcher, q, 0, 10);
assertEquals("[2,-10010000,50200000,340000,51900000]",
- q.getRanking().getLocation().toString());
+ q.getRanking().getLocation().toString());
q = new Query();
q.properties().set("pos.bb", "n=0,s=0,e=123.456789,w=-123.456789");
doSearch(searcher, q, 0, 10);
assertEquals("[2,-123456789,0,123456789,0]",
- q.getRanking().getLocation().toString());
+ q.getRanking().getLocation().toString());
q = new Query();
q.properties().set("pos.bb", "n=12.345678,s=-12.345678,e=0,w=0");
doSearch(searcher, q, 0, 10);
assertEquals("[2,0,-12345678,0,12345678]",
- q.getRanking().getLocation().toString());
+ q.getRanking().getLocation().toString());
q = new Query();
q.properties().set("pos.bb", "n=0.000001,s=-0.000001,e=0.000001,w=-0.000001");
doSearch(searcher, q, 0, 10);
assertEquals("[2,-1,-1,1,1]",
- q.getRanking().getLocation().toString());
+ q.getRanking().getLocation().toString());
}
/**
* Tests basic bounding box input.
*/
@Test
- public void testBoundingBoxAndRadius() {
+ void testBoundingBoxAndRadius() {
Query q = new Query();
q.properties().set("pos.bb", "n=60.111,s=59.999,e=30.111,w=29.999");
q.properties().set("pos.ll", "N60;E30");
doSearch(searcher, q, 0, 10);
assertEquals(
"[2,29999000,59999000,30111000,60111000]" +
- "(2,30000000,60000000,450668,0,1,0,2147483647)",
+ "(2,30000000,60000000,450668,0,1,0,2147483647)",
q.getRanking().getLocation().toString());
}
@@ -92,7 +92,7 @@ public class PosSearcherTestCase {
* Tests different ways of specifying the radius.
*/
@Test
- public void testRadiusUnits() {
+ void testRadiusUnits() {
Query q = new Query();
q.properties().set("pos.ll", "N0;E0");
q.properties().set("pos.radius", "2km");
@@ -130,7 +130,7 @@ public class PosSearcherTestCase {
* Tests xy position (internal format).
*/
@Test
- public void testXY() {
+ void testXY() {
Query q = new Query();
q.properties().set("pos.xy", "22500;22500");
doSearch(searcher, q, 0, 10);
@@ -144,7 +144,7 @@ public class PosSearcherTestCase {
}
@Test
- public void testNotOverridingOldStyleParameters() {
+ void testNotOverridingOldStyleParameters() {
PosSearcher searcher = new PosSearcher();
Query q = new Query("?query=test&pos.ll=N10.15;E6.08&location=(2,-1100222,0,300,0,1,0,CalcLatLon)");
q.setTraceLevel(1);
@@ -156,7 +156,7 @@ public class PosSearcherTestCase {
* Tests input parameters that should report errors.
*/
@Test
- public void testInvalidInput() {
+ void testInvalidInput() {
PosSearcher searcher = new PosSearcher();
Result result;
@@ -164,18 +164,18 @@ public class PosSearcherTestCase {
q.properties().set("pos.ll", "NE74.14;E14.48");
result = doSearch(searcher, q, 0, 10);
assertEquals("Error in pos parameters: Unable to parse lat/long string 'NE74.14;E14.48': already set direction once, cannot add direction: E",
- ((ErrorHit)result.hits().get(0)).errors().iterator().next().getDetailedMessage());
+ ((ErrorHit) result.hits().get(0)).errors().iterator().next().getDetailedMessage());
q = new Query();
q.properties().set("pos.ll", "NE74.14;E14.48");
q.properties().set("pos.xy", "82400, 72800");
result = doSearch(searcher, q, 0, 10);
assertEquals("Error in pos parameters: Cannot handle both lat/long and xy coords at the same time",
- ((ErrorHit)result.hits().get(0)).errors().iterator().next().getDetailedMessage());
+ ((ErrorHit) result.hits().get(0)).errors().iterator().next().getDetailedMessage());
}
@Test
- public void testWrappingTheNorthPole() {
+ void testWrappingTheNorthPole() {
Query q = new Query();
q.properties().set("pos.ll", "N89.9985365158;E122.163600102");
q.properties().set("pos.radius", "20mi");
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
index 0b926f5e9b7..be297b5d6c3 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
@@ -15,14 +15,15 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.result.Relevance;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
-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.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests hit property quoting.
@@ -38,10 +39,10 @@ public class QuotingSearcherTestCase {
}
@Test
- public void testBasicQuoting() {
+ void testBasicQuoting() {
Map<Searcher, Searcher> chained = new HashMap<>();
Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/"
- + "searcher/test/testquoting.cfg");
+ + "searcher/test/testquoting.cfg");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(s, docsource);
Query q = new Query("?query=a");
@@ -58,10 +59,10 @@ public class QuotingSearcherTestCase {
}
@Test
- public void testBasicQuotingWithNoisyStrings() {
+ void testBasicQuotingWithNoisyStrings() {
Map<Searcher, Searcher> chained = new HashMap<>();
Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/"
- + "searcher/test/testquoting.cfg");
+ + "searcher/test/testquoting.cfg");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(s, docsource);
Query q = new Query("?query=a");
@@ -78,10 +79,10 @@ public class QuotingSearcherTestCase {
}
@Test
- public void testFieldQuotingWithNoisyStrings() {
+ void testFieldQuotingWithNoisyStrings() {
Map<Searcher, Searcher> chained = new HashMap<>();
Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/"
- + "searcher/test/testquoting.cfg");
+ + "searcher/test/testquoting.cfg");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(s, docsource);
Query q = new Query("?query=a");
@@ -99,10 +100,10 @@ public class QuotingSearcherTestCase {
@Test
- public void testNoQuotingWithOtherTypes() {
+ void testNoQuotingWithOtherTypes() {
Map<Searcher, Searcher> chained = new HashMap<>();
Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/"
- + "searcher/test/testquoting.cfg");
+ + "searcher/test/testquoting.cfg");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(s, docsource);
Query q = new Query("?query=a");
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
index 061c9bc5681..9375dc2a4b2 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
@@ -17,10 +17,10 @@ import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.yql.YqlParser;
-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 Magnar Nedland
@@ -28,7 +28,7 @@ import static org.junit.Assert.assertNull;
public class ValidatePredicateSearcherTestCase {
@Test
- public void testValidQuery() {
+ void testValidQuery() {
ValidatePredicateSearcher searcher = new ValidatePredicateSearcher();
String q = "select * from sources * where predicate(predicate_field,0,{\"age\":20L})";
Result r = doSearch(searcher, q, "predicate-bounds [0..99]");
@@ -36,7 +36,7 @@ public class ValidatePredicateSearcherTestCase {
}
@Test
- public void testQueryOutOfBounds() {
+ void testQueryOutOfBounds() {
ValidatePredicateSearcher searcher = new ValidatePredicateSearcher();
String q = "select * from sources * where predicate(predicate_field,0,{\"age\":200L})";
Result r = doSearch(searcher, q, "predicate-bounds [0..99]");
@@ -44,7 +44,7 @@ public class ValidatePredicateSearcherTestCase {
}
@Test
- public void queryFailsWhenPredicateFieldIsUsedInTermSearch() {
+ void queryFailsWhenPredicateFieldIsUsedInTermSearch() {
ValidatePredicateSearcher searcher = new ValidatePredicateSearcher();
String q = "select * from sources * where predicate_field CONTAINS \"true\"";
Result r = doSearch(searcher, q, "predicate-bounds [0..99]");
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidateSortingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidateSortingSearcherTestCase.java
index 6b8c268f4ca..4090fbc5de3 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidateSortingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidateSortingSearcherTestCase.java
@@ -12,13 +12,12 @@ import com.yahoo.search.config.ClusterConfig;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.test.QueryTestCase;
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.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Check sorting validation behaves OK.
@@ -43,7 +42,7 @@ public class ValidateSortingSearcherTestCase {
}
@Test
- public void testBasicValidation() {
+ void testBasicValidation() {
assertNotNull(quoteAndTransform("+a -b +c"));
assertNotNull(quoteAndTransform("+a"));
assertNotNull(quoteAndTransform(null));
@@ -54,12 +53,12 @@ public class ValidateSortingSearcherTestCase {
}
@Test
- public void testInvalidSpec() {
+ void testInvalidSpec() {
assertNull(quoteAndTransform("+a -e +c"));
}
@Test
- public void testConfigOverride() {
+ void testConfigOverride() {
assertEquals("[ASCENDING:uca(title,en_US,TERTIARY)]", quoteAndTransform("title"));
assertEquals("[ASCENDING:uca(title,en_US,TERTIARY)]", quoteAndTransform("uca(title)"));
assertEquals("[ASCENDING:uca(title,en_US,TERTIARY)]", quoteAndTransform("+uca(title)"));
@@ -67,7 +66,7 @@ public class ValidateSortingSearcherTestCase {
}
@Test
- public void requireThatQueryLocaleIsDefault() {
+ void requireThatQueryLocaleIsDefault() {
assertEquals("[ASCENDING:lowercase(a)]", quoteAndTransform("a"));
assertEquals("[ASCENDING:uca(a,en_US,PRIMARY)]", transform("a", "en-US"));
assertEquals("[ASCENDING:uca(a,en_NO,PRIMARY)]", transform("a", "en-NO"));
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/parser/test/SemanticsParserTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/parser/test/SemanticsParserTestCase.java
index bf99a709df3..3a366882475 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/parser/test/SemanticsParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/parser/test/SemanticsParserTestCase.java
@@ -8,11 +8,9 @@ import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.semantics.RuleBase;
import com.yahoo.prelude.semantics.RuleImporter;
import com.yahoo.prelude.semantics.parser.ParseException;
-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.*;
/**
* Tests parsing of semantic rules bases
@@ -24,33 +22,33 @@ public class SemanticsParserTestCase {
private final static String ROOT = "src/test/java/com/yahoo/prelude/semantics/parser/test/";
@Test
- public void testRuleReading() throws java.io.IOException, ParseException {
+ void testRuleReading() throws java.io.IOException, ParseException {
RuleBase rules = new RuleImporter(new SimpleLinguistics()).importFile(ROOT + "rules.sr");
Iterator<?> i = rules.ruleIterator();
assertEquals("[listing] [preposition] [place] -> listing:[listing] place:[place]!150",
- i.next().toString());
+ i.next().toString());
assertEquals("[listing] [place] +> place:[place]",
- i.next().toString());
+ i.next().toString());
assertEquals("[brand] -> brand:[brand]",
- i.next().toString());
+ i.next().toString());
assertEquals("[category] -> category:[category]",
- i.next().toString());
+ i.next().toString());
assertEquals("digital camera -> digicamera",
- i.next().toString());
+ i.next().toString());
assertEquals("(parameter.ranking='cat'), (parameter.ranking='cat0') -> one", i.next().toString());
assertFalse(i.hasNext());
i = rules.conditionIterator();
assertEquals("[listing] :- restaurant, shop, cafe, hotel",
- i.next().toString());
+ i.next().toString());
assertEquals("[preposition] :- in, at, near",
- i.next().toString());
+ i.next().toString());
assertEquals("[place] :- geary",
- i.next().toString());
+ i.next().toString());
assertEquals("[brand] :- sony, dell",
- i.next().toString());
+ i.next().toString());
assertEquals("[category] :- digital camera, camera, phone",
- i.next().toString());
+ i.next().toString());
assertFalse(i.hasNext());
assertTrue(rules.isDefault());
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/AlibabaTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/AlibabaTestCase.java
index d1000e031da..8ff14011483 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/AlibabaTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/AlibabaTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test a case reported by Alibaba
@@ -15,23 +15,23 @@ public class AlibabaTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testNumberReplacement() {
- assertSemantics("AND nokia 3100","3100");
+ void testNumberReplacement() {
+ assertSemantics("AND nokia 3100", "3100");
}
@Test
- public void testRuleFollowingNumber() {
- assertSemantics("lenovo","legend");
+ void testRuleFollowingNumber() {
+ assertSemantics("lenovo", "legend");
}
@Test
- public void testCombinedNumberAndRegular1() {
- assertSemantics("AND lenovo nokia 3100","legend 3100");
+ void testCombinedNumberAndRegular1() {
+ assertSemantics("AND lenovo nokia 3100", "legend 3100");
}
@Test
- public void testCombinedNumberAndRegular2() {
- assertSemantics("AND nokia 3100 lenovo","3100 legend");
+ void testCombinedNumberAndRegular2() {
+ assertSemantics("AND nokia 3100 lenovo", "3100 legend");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/AnchorTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/AnchorTestCase.java
index 9173053e660..dfba036efae 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/AnchorTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/AnchorTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests anchoring
@@ -15,7 +15,7 @@ public class AnchorTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testSingleWordAnchoredBothSides() {
+ void testSingleWordAnchoredBothSides() {
assertSemantics("anchor", "word");
assertSemantics("anchor", "anotherword");
assertSemantics("notthisword", "notthisword");
@@ -23,7 +23,7 @@ public class AnchorTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testMultiwordAnchored() {
+ void testMultiwordAnchored() {
assertSemantics("anchor", "this is complete");
assertSemantics("AND this is complete toomuch", "this is complete toomuch");
assertSemantics("anchor", "a phrase");
@@ -31,28 +31,28 @@ public class AnchorTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testFirstAnchored() {
- assertSemantics("anchor","first");
- assertSemantics("AND anchor andmore","first andmore");
- assertSemantics("AND before first","before first");
- assertSemantics("AND before first andmore","before first andmore");
+ void testFirstAnchored() {
+ assertSemantics("anchor", "first");
+ assertSemantics("AND anchor andmore", "first andmore");
+ assertSemantics("AND before first", "before first");
+ assertSemantics("AND before first andmore", "before first andmore");
}
@Test
- public void testLastAnchored() {
- assertSemantics("anchor","last");
- assertSemantics("AND andmore anchor","andmore last");
- assertSemantics("AND last after","last after");
- assertSemantics("AND andmore last after","andmore last after");
+ void testLastAnchored() {
+ assertSemantics("anchor", "last");
+ assertSemantics("AND andmore anchor", "andmore last");
+ assertSemantics("AND last after", "last after");
+ assertSemantics("AND andmore last after", "andmore last after");
}
@Test
- public void testFirstAndLastAnchored() {
- assertSemantics("AND anchor anchor","first last");
- assertSemantics("AND last first","last first");
- assertSemantics("AND anchor between anchor","first between last");
- assertSemantics("AND anchor last after","first last after");
- assertSemantics("AND before first anchor","before first last");
+ void testFirstAndLastAnchored() {
+ assertSemantics("AND anchor anchor", "first last");
+ assertSemantics("AND last first", "last first");
+ assertSemantics("AND anchor between anchor", "first between last");
+ assertSemantics("AND anchor last after", "first last after");
+ assertSemantics("AND before first anchor", "before first last");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataNotTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataNotTestCase.java
index 4493038fc86..b138ba50ca9 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataNotTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataNotTestCase.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.prelude.semantics.test;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
/**
* Tests that ![a] is interpreted as "default:![a]", not as "!default:[a]",
@@ -16,9 +16,10 @@ public class AutomataNotTestCase extends RuleBaseAbstractTestCase {
super("automatanot.sr", "semantics.fsa");
}
+ // TODO: MAKE THIS WORK!
@Test
- @Ignore // TODO: MAKE THIS WORK!
- public void testAutomataNot() {
+ @Disabled
+ void testAutomataNot() {
if (System.currentTimeMillis() > 0) return;
assertSemantics("carpenter", "carpenter");
assertSemantics("RANK brukbar busname:brukbar", "brukbar");
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataTestCase.java
index 71e36e45acc..a9c7202f7cd 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/AutomataTestCase.java
@@ -3,11 +3,11 @@ package com.yahoo.prelude.semantics.test;
import com.yahoo.search.Query;
import com.yahoo.prelude.semantics.RuleBase;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+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;
/**
* Tests rule bases using automatas for matching
@@ -23,62 +23,63 @@ public class AutomataTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testAutomataRuleBase() {
- RuleBase ruleBase=searcher.getDefaultRuleBase();
- assertEquals(RuleBase.class,ruleBase.getClass());
+ void testAutomataRuleBase() {
+ RuleBase ruleBase = searcher.getDefaultRuleBase();
+ assertEquals(RuleBase.class, ruleBase.getClass());
assertTrue(ruleBase.getSource().endsWith(root + "automatarules.sr"));
- assertEquals(root + "semantics.fsa",ruleBase.getAutomataFile());
+ assertEquals(root + "semantics.fsa", ruleBase.getAutomataFile());
- Query query=new Query("?query=sony+digital+camera");
- ruleBase.analyze(query,0);
+ Query query = new Query("?query=sony+digital+camera");
+ ruleBase.analyze(query, 0);
assertEquals("RANK (WEAKAND(100) sony digital camera) dsp1:sony dsp5:digicamera", query.getModel().getQueryTree().getRoot().toString());
- query=new Query("?query=sony+digital+camera&rules.reload");
- ruleBase=searcher.getDefaultRuleBase();
+ query = new Query("?query=sony+digital+camera&rules.reload");
+ ruleBase = searcher.getDefaultRuleBase();
assertTrue(ruleBase.getSource().endsWith(root + "automatarules.sr"));
- assertEquals(root + "semantics.fsa",ruleBase.getAutomataFile());
- ruleBase.analyze(query,0);
+ assertEquals(root + "semantics.fsa", ruleBase.getAutomataFile());
+ ruleBase.analyze(query, 0);
assertEquals("RANK (WEAKAND(100) sony digital camera) dsp1:sony dsp5:digicamera", query.getModel().getQueryTree().getRoot().toString());
}
@Test
- public void testAutomataSingleQuery() {
- assertSemantics("RANK sony dsp1:sony","sony");
+ void testAutomataSingleQuery() {
+ assertSemantics("RANK sony dsp1:sony", "sony");
}
@Test
- public void testAutomataFilterIsIgnored() {
- assertSemantics("RANK sony |something dsp1:sony","sony&filter=something");
- assertSemantics("RANK something |sony","something&filter=sony");
+ void testAutomataFilterIsIgnored() {
+ assertSemantics("RANK sony |something dsp1:sony", "sony&filter=something");
+ assertSemantics("RANK something |sony", "something&filter=sony");
}
@Test
- public void testAutomataPluralMatches() {
- assertSemantics("RANK sonys dsp1:sony","sonys");
+ void testAutomataPluralMatches() {
+ assertSemantics("RANK sonys dsp1:sony", "sonys");
- assertSemantics("RANK (AND car cleaner) dsp1:\"car cleaners\" dsp5:\"car cleaners\"","car cleaner");
+ assertSemantics("RANK (AND car cleaner) dsp1:\"car cleaners\" dsp5:\"car cleaners\"", "car cleaner");
- assertSemantics("RANK (AND sony digitals cameras) dsp1:sony dsp5:digicamera","sony digitals cameras");
+ assertSemantics("RANK (AND sony digitals cameras) dsp1:sony dsp5:digicamera", "sony digitals cameras");
}
@Test
- public void testMatchingMultipleAutomataConditionsSingleWord() {
- assertSemantics("RANK carpenter dsp1:carpenter dsp5:carpenter","carpenter");
+ void testMatchingMultipleAutomataConditionsSingleWord() {
+ assertSemantics("RANK carpenter dsp1:carpenter dsp5:carpenter", "carpenter");
}
@Test
- public void testMatchingMultipleAutomataConditionsPhrase() {
- assertSemantics("RANK (AND car cleaners) dsp1:\"car cleaners\" dsp5:\"car cleaners\"","car cleaners");
+ void testMatchingMultipleAutomataConditionsPhrase() {
+ assertSemantics("RANK (AND car cleaners) dsp1:\"car cleaners\" dsp5:\"car cleaners\"", "car cleaners");
}
+ // TODO: Make this work again
@Test
- @Ignore // TODO: Make this work again
- public void testReplaceOnNoMatch() {
- assertSemantics("nomatch:sonny","sonny&donomatch");
- assertSemantics("RANK sony dsp1:sony","sony&donomatch");
- assertSemantics("RANK sonys dsp1:sony","sonys&donomatch");
- assertSemantics("AND nomatch:sonny nomatch:boy","sonny boy&donomatch");
- assertSemantics("RANK (AND sony nomatch:boy) dsp1:sony","sony boy&donomatch");
+ @Disabled
+ void testReplaceOnNoMatch() {
+ assertSemantics("nomatch:sonny", "sonny&donomatch");
+ assertSemantics("RANK sony dsp1:sony", "sony&donomatch");
+ assertSemantics("RANK sonys dsp1:sony", "sonys&donomatch");
+ assertSemantics("AND nomatch:sonny nomatch:boy", "sonny boy&donomatch");
+ assertSemantics("RANK (AND sony nomatch:boy) dsp1:sony", "sony boy&donomatch");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/BacktrackingTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/BacktrackingTestCase.java
index 06f7112f851..3a4f0344994 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/BacktrackingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/BacktrackingTestCase.java
@@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import com.yahoo.component.chain.Chain;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.search.Query;
import com.yahoo.prelude.semantics.RuleImporter;
@@ -14,9 +16,7 @@ import com.yahoo.search.Searcher;
import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -50,47 +50,47 @@ public class BacktrackingTestCase {
// Literal terms ---------------
@Test
- public void testMultilevelBacktrackingLiteralTerms() {
- assertSemantics("WEAKAND(100) replaced","word1 word2 word5 word8");
+ void testMultilevelBacktrackingLiteralTerms() {
+ assertSemantics("WEAKAND(100) replaced", "word1 word2 word5 word8");
}
@Test
- public void testMultilevelBacktrackingWontReorderOthertermsLiteralTerms() {
- assertSemantics("WEAKAND(100) other1 other2 other3 replaced","other1 other2 other3 word1 word2 word5 word8");
+ void testMultilevelBacktrackingWontReorderOthertermsLiteralTerms() {
+ assertSemantics("WEAKAND(100) other1 other2 other3 replaced", "other1 other2 other3 word1 word2 word5 word8");
}
@Test
- public void testMultilevelBacktrackingWithMulticompoundMatchLiteralTerms() {
- assertSemantics("WEAKAND(100) other1 other2 other3 replaced","other1 other2 other3 word1 word2 word5-word8");
+ void testMultilevelBacktrackingWithMulticompoundMatchLiteralTerms() {
+ assertSemantics("WEAKAND(100) other1 other2 other3 replaced", "other1 other2 other3 word1 word2 word5-word8");
}
@Test
- public void testMultilevelBacktrackingPreservePartialMatchBeforeLiteralTerms() {
- assertSemantics("WEAKAND(100) word1 word2 word5 replaced","word1 word2 word5 word1 word2 word5 word8");
+ void testMultilevelBacktrackingPreservePartialMatchBeforeLiteralTerms() {
+ assertSemantics("WEAKAND(100) word1 word2 word5 replaced", "word1 word2 word5 word1 word2 word5 word8");
}
@Test
- public void testMultilevelBacktrackingPreservePartialMatchAfterLiteralTerms() {
- assertSemantics("WEAKAND(100) replaced word1 word2 word5","word1 word2 word5 word8 word1 word2 word5 ");
+ void testMultilevelBacktrackingPreservePartialMatchAfterLiteralTerms() {
+ assertSemantics("WEAKAND(100) replaced word1 word2 word5", "word1 word2 word5 word8 word1 word2 word5 ");
}
// reference terms ---------------
@Test
- public void testMultilevelBacktrackingReferenceTerms() {
- assertSemantics("WEAKAND(100) ref:ref1 ref:ref2 ref:ref5 ref:ref8","ref1 ref2 ref5 ref8");
+ void testMultilevelBacktrackingReferenceTerms() {
+ assertSemantics("WEAKAND(100) ref:ref1 ref:ref2 ref:ref5 ref:ref8", "ref1 ref2 ref5 ref8");
}
@Test
- public void testMultilevelBacktrackingPreservePartialMatchBeforeReferenceTerms() {
+ void testMultilevelBacktrackingPreservePartialMatchBeforeReferenceTerms() {
assertSemantics("WEAKAND(100) ref1 ref2 ref5 ref:ref1 ref:ref2 ref:ref5 ref:ref8",
- "ref1 ref2 ref5 ref1 ref2 ref5 ref8");
+ "ref1 ref2 ref5 ref1 ref2 ref5 ref8");
}
@Test
- public void testMultilevelBacktrackingPreservePartialMatchAfterReferenceTerms() {
+ void testMultilevelBacktrackingPreservePartialMatchAfterReferenceTerms() {
assertSemantics("WEAKAND(100) ref:ref1 ref:ref2 ref:ref5 ref:ref8 ref1 ref2 ref5",
- "ref1 ref2 ref5 ref8 ref1 ref2 ref5");
+ "ref1 ref2 ref5 ref8 ref1 ref2 ref5");
}
private Result doSearch(Searcher searcher, Query query, int offset, int hits) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/BlendingTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/BlendingTestCase.java
index 9e590698f4a..334ff8d05a6 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/BlendingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/BlendingTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.prelude.semantics.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;
/**
* Tests blending rules
@@ -19,9 +19,9 @@ public class BlendingTestCase extends RuleBaseAbstractTestCase {
/** Tests parameter literal matching */
@Test
- public void testLiteralEquals() {
- assertParameterSemantics("AND a sun came cd","a sun came cd","search","[music]");
- assertParameterSemantics("AND driving audi","driving audi","search","[cars]");
+ void testLiteralEquals() {
+ assertParameterSemantics("AND a sun came cd", "a sun came cd", "search", "[music]");
+ assertParameterSemantics("AND driving audi", "driving audi", "search", "[cars]");
//assertParameterSemantics("AND audi music quality","audi music quality","search","carstereos",1);
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/CJKTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/CJKTestCase.java
index 0aaa5f2cea7..457a2063173 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/CJKTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/CJKTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests that using rule bases containing cjk characters work
@@ -15,14 +15,14 @@ public class CJKTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testIt() {
- assertSemantics("\u7d22a","a\u7d22");
- assertSemantics("\u7d22a","\u7d22a");
- assertSemantics("brand:\u7d22\u5c3c","\u7d22\u5c3c");
- assertSemantics("brand:\u60e0\u666e","\u60e0\u666e");
- assertSemantics("brand:\u4f73\u80fd","\u4f73\u80fd");
- assertSemantics("AND brand:\u4f73\u80fd \u7d22a","\u4f73\u80fd a\u7d22");
- assertSemantics("\u4f73\u80fd\u7d22\u5c3c","\u4f73\u80fd\u7d22\u5c3c");
+ void testIt() {
+ assertSemantics("\u7d22a", "a\u7d22");
+ assertSemantics("\u7d22a", "\u7d22a");
+ assertSemantics("brand:\u7d22\u5c3c", "\u7d22\u5c3c");
+ assertSemantics("brand:\u60e0\u666e", "\u60e0\u666e");
+ assertSemantics("brand:\u4f73\u80fd", "\u4f73\u80fd");
+ assertSemantics("AND brand:\u4f73\u80fd \u7d22a", "\u4f73\u80fd a\u7d22");
+ assertSemantics("\u4f73\u80fd\u7d22\u5c3c", "\u4f73\u80fd\u7d22\u5c3c");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonTestCase.java
index 988d69a55d3..0c5447c120a 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -17,30 +17,30 @@ public class ComparisonTestCase extends RuleBaseAbstractTestCase {
* different conditions (coffee, island)
*/
@Test
- public void testNamedConditionReturnComparison() {
+ void testNamedConditionReturnComparison() {
// Not sufficient that both conditions are matched
- assertSemantics("AND borneo arabica island:borneo coffee:arabica","borneo arabica");
+ assertSemantics("AND borneo arabica island:borneo coffee:arabica", "borneo arabica");
// They must match the same word
- assertSemantics("AND java noise island:java coffee:java control:ambigous off","java noise");
+ assertSemantics("AND java noise island:java coffee:java control:ambigous off", "java noise");
// Works also when there are other, not-equal matches
assertSemantics("AND borneo arabica java island:borneo island:java coffee:arabica coffee:java control:ambigous off",
- "borneo arabica java");
+ "borneo arabica java");
}
@Test
- public void testContainsAsSubstring() {
- assertSemantics("AND java island:java coffee:java control:ambigous off","java");
- assertSemantics("AND kanava island:kanava off","kanava");
- assertSemantics("AND borneo island:borneo","borneo");
+ void testContainsAsSubstring() {
+ assertSemantics("AND java island:java coffee:java control:ambigous off", "java");
+ assertSemantics("AND kanava island:kanava off", "kanava");
+ assertSemantics("AND borneo island:borneo", "borneo");
}
@Test
- public void testAlphanumericComparison() {
- assertSemantics("a","a");
- assertSemantics("AND z highletter","z");
- assertSemantics("AND p highletter","p");
+ void testAlphanumericComparison() {
+ assertSemantics("a", "a");
+ assertSemantics("AND z highletter", "z");
+ assertSemantics("AND p highletter", "p");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonsTestCase.java
index a8fe78ac1ff..867a57aebeb 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ComparisonsTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -13,11 +13,11 @@ public class ComparisonsTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testLiteralEquals() {
- assertSemantics("a","a");
- assertSemantics("RANK a foo:a","a&ranking=category");
- assertSemantics("a","a&ranking=somethingelse");
- assertSemantics("a","a&otherparam=category");
+ void testLiteralEquals() {
+ assertSemantics("a", "a");
+ assertSemantics("RANK a foo:a", "a&ranking=category");
+ assertSemantics("a", "a&ranking=somethingelse");
+ assertSemantics("a", "a&otherparam=category");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ConditionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ConditionTestCase.java
index 17eb4120b84..d7297bd79a4 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ConditionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ConditionTestCase.java
@@ -14,10 +14,10 @@ import com.yahoo.prelude.semantics.rule.ProductionRule;
import com.yahoo.prelude.semantics.rule.ReplacingProductionRule;
import com.yahoo.prelude.semantics.rule.SequenceCondition;
import com.yahoo.prelude.semantics.rule.TermCondition;
-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
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue;
public class ConditionTestCase {
@Test
- public void testTermCondition() {
+ void testTermCondition() {
var linguistics = new RuleBaseLinguistics(new SimpleLinguistics());
TermCondition term = new TermCondition("foo", linguistics);
Query query = new Query("?query=foo");
@@ -33,23 +33,23 @@ public class ConditionTestCase {
}
@Test
- public void testSequenceCondition() {
+ void testSequenceCondition() {
var linguistics = new RuleBaseLinguistics(new SimpleLinguistics());
TermCondition term1 = new TermCondition("foo", linguistics);
- TermCondition term2 = new TermCondition("bar",linguistics);
+ TermCondition term2 = new TermCondition("bar", linguistics);
SequenceCondition sequence = new SequenceCondition();
sequence.addCondition(term1);
sequence.addCondition(term2);
Query query = new Query("?query=foo+bar");
- assertTrue(query + " matches " + sequence,sequence.matches(new Evaluation(query, null).freshRuleEvaluation()));
+ assertTrue(sequence.matches(new Evaluation(query, null).freshRuleEvaluation()), query + " matches " + sequence);
Query query2 = new Query("?query=foo");
- assertFalse(query2 + " does not match " + sequence,sequence.matches(new Evaluation(query2, null).freshRuleEvaluation()));
+ assertFalse(sequence.matches(new Evaluation(query2, null).freshRuleEvaluation()), query2 + " does not match " + sequence);
Query query3 = new Query("?query=bar");
- assertFalse(query3 + " does not match " + sequence,sequence.matches(new Evaluation(query3, null).freshRuleEvaluation()));
+ assertFalse(sequence.matches(new Evaluation(query3, null).freshRuleEvaluation()), query3 + " does not match " + sequence);
}
@Test
- public void testChoiceCondition() {
+ void testChoiceCondition() {
var linguistics = new RuleBaseLinguistics(new SimpleLinguistics());
TermCondition term1 = new TermCondition("foo", linguistics);
TermCondition term2 = new TermCondition("bar", linguistics);
@@ -57,18 +57,18 @@ public class ConditionTestCase {
choice.addCondition(term1);
choice.addCondition(term2);
Query query1 = new Query("?query=foo+bar");
- assertTrue(query1 + " matches " + choice, choice.matches(new Evaluation(query1, null).freshRuleEvaluation()));
+ assertTrue(choice.matches(new Evaluation(query1, null).freshRuleEvaluation()), query1 + " matches " + choice);
Query query2 = new Query("?query=foo");
- assertTrue(query2 + " matches " + choice, choice.matches(new Evaluation(query2, null).freshRuleEvaluation()));
+ assertTrue(choice.matches(new Evaluation(query2, null).freshRuleEvaluation()), query2 + " matches " + choice);
Query query3 = new Query("?query=bar");
- assertTrue(query3 + " matches " + choice, choice.matches(new Evaluation(query3, null).freshRuleEvaluation()));
+ assertTrue(choice.matches(new Evaluation(query3, null).freshRuleEvaluation()), query3 + " matches " + choice);
}
@Test
- public void testNamedConditionReference() {
+ void testNamedConditionReference() {
var linguistics = new RuleBaseLinguistics(new SimpleLinguistics());
TermCondition term = new TermCondition("foo", linguistics);
- NamedCondition named = new NamedCondition("cond",term);
+ NamedCondition named = new NamedCondition("cond", term);
ConditionReference reference = new ConditionReference("cond");
// To initialize the condition reference...
@@ -81,7 +81,7 @@ public class ConditionTestCase {
ruleBase.initialize();
Query query = new Query("?query=foo");
- assertTrue(query + " matches " + reference,reference.matches(new Evaluation(query, null).freshRuleEvaluation()));
+ assertTrue(reference.matches(new Evaluation(query, null).freshRuleEvaluation()), query + " matches " + reference);
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ConfigurationTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ConfigurationTestCase.java
index 7d9ea07339f..569ae569f18 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ConfigurationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ConfigurationTestCase.java
@@ -13,13 +13,12 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.test.QueryTestCase;
-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.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests creating a set of rule bases (the same set as in inheritingrules) from config
@@ -52,7 +51,7 @@ public class ConfigurationTestCase {
}
@Test
- public void testReadingConfigurationRuleBase() {
+ void testReadingConfigurationRuleBase() {
RuleBase parent = searcher.getRuleBase("parent");
assertNotNull(parent);
assertEquals("parent", parent.getName());
@@ -60,7 +59,7 @@ public class ConfigurationTestCase {
}
@Test
- public void testParent() {
+ void testParent() {
assertSemantics("WEAKAND(100) vehiclebrand:audi", "audi cars", "parent");
assertSemantics("WEAKAND(100) vehiclebrand:alfa", "alfa bus", "parent");
assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv", "bmw motorcycle", "parent.sr");
@@ -69,7 +68,7 @@ public class ConfigurationTestCase {
}
@Test
- public void testChild1() {
+ void testChild1() {
assertSemantics("WEAKAND(100) vehiclebrand:skoda", "audi cars", "child1.sr");
assertSemantics("WEAKAND(100) vehiclebrand:alfa", "alfa bus", "child1");
assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv", "bmw motorcycle", "child1");
@@ -78,7 +77,7 @@ public class ConfigurationTestCase {
}
@Test
- public void testChild2() {
+ void testChild2() {
assertSemantics("WEAKAND(100) vehiclebrand:audi", "audi cars", "child2");
assertSemantics("WEAKAND(100) vehiclebrand:alfa", "alfa bus", "child2.sr");
assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv", "bmw motorcycle", "child2.sr");
@@ -87,7 +86,7 @@ public class ConfigurationTestCase {
}
@Test
- public void testGrandchild() {
+ void testGrandchild() {
assertSemantics("WEAKAND(100) vehiclebrand:skoda", "audi cars", "grandchild.sr");
assertSemantics("WEAKAND(100) vehiclebrand:alfa", "alfa bus", "grandchild");
assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv", "bmw motorcycle", "grandchild");
@@ -96,7 +95,7 @@ public class ConfigurationTestCase {
}
@Test
- public void testSearcher() {
+ void testSearcher() {
assertSemantics("WEAKAND(100) vehiclebrand:skoda", "vw cars", "grandchild");
assertSemantics("WEAKAND(100) vehiclebrand:skoda", "vw cars", "grandchild.sd");
try {
@@ -110,14 +109,14 @@ public class ConfigurationTestCase {
assertSemanticsRulesOff("WEAKAND(100) vw cars", "vw cars");
assertSemantics("WEAKAND(100) vw car", "vw cars", "child2");
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","skoda cars","child2");
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "skoda cars", "child2");
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","audi cars", "child1");
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","vw cars", "child1");
- assertSemantics("WEAKAND(100) skoda car", "skoda cars","child1");
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "audi cars", "child1");
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "vw cars", "child1");
+ assertSemantics("WEAKAND(100) skoda car", "skoda cars", "child1");
assertSemantics("WEAKAND(100) vw car", "vw cars", "parent");
- assertSemantics("WEAKAND(100) skoda car", "skoda cars","parent");
+ assertSemantics("WEAKAND(100) skoda car", "skoda cars", "parent");
}
private Result doSearch(Searcher searcher, Query query, int offset, int hits) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/DuplicateRuleTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/DuplicateRuleTestCase.java
index 76c8c3966b7..a692217fef6 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/DuplicateRuleTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/DuplicateRuleTestCase.java
@@ -5,10 +5,10 @@ import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.semantics.RuleBaseException;
import com.yahoo.prelude.semantics.RuleImporter;
import com.yahoo.prelude.semantics.parser.ParseException;
-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 @@ public class DuplicateRuleTestCase {
private final String root = "src/test/java/com/yahoo/prelude/semantics/test/rulebases/";
@Test
- public void testDuplicateRuleBaseLoading() throws java.io.IOException, ParseException {
+ void testDuplicateRuleBaseLoading() throws java.io.IOException, ParseException {
if (System.currentTimeMillis() > 0) return; // TODO: Include this test...
try {
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/Ellipsis2TestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/Ellipsis2TestCase.java
index 28ffe549711..0808092da65 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/Ellipsis2TestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/Ellipsis2TestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* tersts the ellipsis rule base
@@ -15,8 +15,8 @@ public class Ellipsis2TestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testUnreferencedEllipsis() {
- assertSemantics("AND a b c someindex:\"a b c\"","a b c");
+ void testUnreferencedEllipsis() {
+ assertSemantics("AND a b c someindex:\"a b c\"", "a b c");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/EllipsisTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/EllipsisTestCase.java
index 1c570220f52..d1fe2091bc2 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/EllipsisTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/EllipsisTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* tersts the ellipsis rule base
@@ -15,34 +15,34 @@ public class EllipsisTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testUnreferencedEllipsis() {
- assertSemantics("AND why is stench unpleasant about:stench","why is stench unpleasant");
- assertSemantics("AND why is the sky blue about:\"the sky\"","why is the sky blue");
+ void testUnreferencedEllipsis() {
+ assertSemantics("AND why is stench unpleasant about:stench", "why is stench unpleasant");
+ assertSemantics("AND why is the sky blue about:\"the sky\"", "why is the sky blue");
assertSemantics("AND why is aardwark almost always most relevant in dictionaries about:aardwark",
- "why is aardwark almost always most relevant in dictionaries");
+ "why is aardwark almost always most relevant in dictionaries");
}
@Test
- public void testReferencedEllipsis() {
- assertSemantics("album:parade","parade album");
- assertSemantics("album:\"a sun came\"","a sun came album");
- assertSemantics("album:parade","parade cd");
- assertSemantics("album:\"a sun came\"","a sun came cd");
+ void testReferencedEllipsis() {
+ assertSemantics("album:parade", "parade album");
+ assertSemantics("album:\"a sun came\"", "a sun came album");
+ assertSemantics("album:parade", "parade cd");
+ assertSemantics("album:\"a sun came\"", "a sun came cd");
}
@Test
- public void testEllipsisInNamedCondition() {
- assertSemantics("AND name:\"a sun came\" product:video","buy a sun came");
- assertSemantics("AND name:stalker product:video","buy stalker video");
- assertSemantics("AND name:\"the usual suspects\" product:video","buy the usual suspects video");
+ void testEllipsisInNamedCondition() {
+ assertSemantics("AND name:\"a sun came\" product:video", "buy a sun came");
+ assertSemantics("AND name:stalker product:video", "buy stalker video");
+ assertSemantics("AND name:\"the usual suspects\" product:video", "buy the usual suspects video");
}
@Test
- public void testMultipleEllipsis() {
- assertSemantics("AND from:paris to:texas","from paris to texas");
- assertSemantics("AND from:\"sao paulo\" to:\"real madrid\"","from sao paulo to real madrid");
- assertSemantics("AND from:\"from from\" to:oslo","from from from to oslo");
- assertSemantics("AND from:\"from from to\" to:koko","from from from to to koko"); // Matching is greedy left-right
+ void testMultipleEllipsis() {
+ assertSemantics("AND from:paris to:texas", "from paris to texas");
+ assertSemantics("AND from:\"sao paulo\" to:\"real madrid\"", "from sao paulo to real madrid");
+ assertSemantics("AND from:\"from from\" to:oslo", "from from from to oslo");
+ assertSemantics("AND from:\"from from to\" to:koko", "from from from to to koko"); // Matching is greedy left-right
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTestCase.java
index 8f9c33dab51..d04ea0eabf9 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -13,8 +13,8 @@ public class ExactMatchTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testCompleteMatch() {
- assertSemantics("AND primetime in no time","primetime notime");
+ void testCompleteMatch() {
+ assertSemantics("AND primetime in no time", "primetime notime");
}
/*
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTrickTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTrickTestCase.java
index c566b05405d..6ca055ff980 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTrickTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExactMatchTrickTestCase.java
@@ -3,7 +3,7 @@ package com.yahoo.prelude.semantics.test;
import com.yahoo.search.Query;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -15,20 +15,20 @@ public class ExactMatchTrickTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testCompleteMatch() {
+ void testCompleteMatch() {
assertSemantics("AND default:primetime default:in default:no default:time", "primetime notime");
}
@Test
- public void testCompleteMatchWithNegative() { // Notice ordering bug
+ void testCompleteMatchWithNegative() { // Notice ordering bug
assertSemantics("+(AND default:primetime default:in default:time default:no TRUE) -regionexcl:us",
- new Query(QueryTestCase.httpEncode("?query=primetime ANDNOT regionexcl:us&type=adv")));
+ new Query(QueryTestCase.httpEncode("?query=primetime ANDNOT regionexcl:us&type=adv")));
}
@Test
- public void testCompleteMatchWithFilterAndNegative() {
+ void testCompleteMatchWithFilterAndNegative() {
assertSemantics("AND (+(AND default:primetime default:in default:time default:no TRUE) -regionexcl:us) |lang:en",
- new Query(QueryTestCase.httpEncode("?query=primetime ANDNOT regionexcl:us&type=adv&filter=+lang:en")));
+ new Query(QueryTestCase.httpEncode("?query=primetime ANDNOT regionexcl:us&type=adv&filter=+lang:en")));
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java
index 111f37bf8e4..13b65716ffc 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ExpansionTestCase extends RuleBaseAbstractTestCase {
@@ -10,24 +10,24 @@ public class ExpansionTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testOrExpansion() {
+ void testOrExpansion() {
assertSemantics("OR or1 or2 or3", "or1");
}
@Test
- public void testEquivExpansion1() {
+ void testEquivExpansion1() {
assertSemantics("EQUIV equiv1 equiv2 equiv3", "equiv1");
}
@Test
- public void testEquivExpansion2() {
+ void testEquivExpansion2() {
assertSemantics("EQUIV testfield:e1 testfield:e2 testfield:e3", "testfield:foo");
}
@Test
- public void testEquivExpansion3() {
+ void testEquivExpansion3() {
assertSemantics("AND testfield:e1 testfield:e2 testfield:e3 testfield:e1 testfield:e2 testfield:e3",
- "testfield:foo testfield:bar");
+ "testfield:foo testfield:bar");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/InheritanceTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/InheritanceTestCase.java
index baec0066fb3..e9fa8dfa4be 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/InheritanceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/InheritanceTestCase.java
@@ -15,12 +15,9 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
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.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -58,7 +55,7 @@ public class InheritanceTestCase {
}
@Test
- public void testInclusion() {
+ void testInclusion() {
assertTrue(grandchild.includes("child1"));
assertTrue(grandchild.includes("child2"));
assertTrue(grandchild.includes("parent"));
@@ -74,8 +71,8 @@ public class InheritanceTestCase {
}
@Test
- public void testInclusionOrderAndContentDump() {
- StringTokenizer lines = new StringTokenizer(grandchild.toContentString(),"\n",false);
+ void testInclusionOrderAndContentDump() {
+ StringTokenizer lines = new StringTokenizer(grandchild.toContentString(), "\n", false);
assertEquals("vw -> audi", lines.nextToken());
assertEquals("car -> car", lines.nextToken());
assertEquals("[brand] [vehicle] -> vehiclebrand:[brand]", lines.nextToken());
@@ -88,7 +85,7 @@ public class InheritanceTestCase {
}
@Test
- public void testParent() {
+ void testParent() {
assertSemantics("WEAKAND(100) vehiclebrand:audi", "audi cars", parent);
assertSemantics("WEAKAND(100) vehiclebrand:alfa", "alfa bus", parent);
assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv", "bmw motorcycle", parent);
@@ -97,7 +94,7 @@ public class InheritanceTestCase {
}
@Test
- public void testChild1() {
+ void testChild1() {
assertSemantics("WEAKAND(100) vehiclebrand:skoda", "audi cars", child1);
assertSemantics("WEAKAND(100) vehiclebrand:alfa", "alfa bus", child1);
assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv", "bmw motorcycle", child1);
@@ -106,25 +103,25 @@ public class InheritanceTestCase {
}
@Test
- public void testChild2() {
- assertSemantics("WEAKAND(100) vehiclebrand:audi","audi cars", child2);
- assertSemantics("WEAKAND(100) vehiclebrand:alfa","alfa bus", child2);
- assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv","bmw motorcycle", child2);
- assertSemantics("WEAKAND(100) vw car","vw cars", child2);
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","skoda cars", child2);
+ void testChild2() {
+ assertSemantics("WEAKAND(100) vehiclebrand:audi", "audi cars", child2);
+ assertSemantics("WEAKAND(100) vehiclebrand:alfa", "alfa bus", child2);
+ assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv", "bmw motorcycle", child2);
+ assertSemantics("WEAKAND(100) vw car", "vw cars", child2);
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "skoda cars", child2);
}
@Test
- public void testGrandchild() {
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","audi cars", grandchild);
- assertSemantics("WEAKAND(100) vehiclebrand:alfa","alfa bus", grandchild);
- assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv","bmw motorcycle", grandchild);
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","vw cars", grandchild);
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","skoda cars", grandchild);
+ void testGrandchild() {
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "audi cars", grandchild);
+ assertSemantics("WEAKAND(100) vehiclebrand:alfa", "alfa bus", grandchild);
+ assertSemantics("AND (WEAKAND(100) vehiclebrand:bmw) expensivetv", "bmw motorcycle", grandchild);
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "vw cars", grandchild);
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "skoda cars", grandchild);
}
@Test
- public void testRuleBaseNames() {
+ void testRuleBaseNames() {
assertEquals("parent", parent.getName());
assertEquals("child1", child1.getName());
assertEquals("child2", child2.getName());
@@ -132,10 +129,10 @@ public class InheritanceTestCase {
}
@Test
- public void testSearcher() {
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","vw cars", "");
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","vw cars", "&rules.rulebase=grandchild");
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","vw cars", "&rules.rulebase=grandchild.sd");
+ void testSearcher() {
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "vw cars", "");
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "vw cars", "&rules.rulebase=grandchild");
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "vw cars", "&rules.rulebase=grandchild.sd");
try {
assertSemantics("WEAKAND(100) vw cars", "vw cars", "&rules.rulebase=doesntexist");
fail("No exception on missing rule base");
@@ -147,14 +144,14 @@ public class InheritanceTestCase {
assertSemantics("WEAKAND(100) vw cars", "vw cars", "&rules.off");
assertSemantics("WEAKAND(100) vw car", "vw cars", "&rules.rulebase=child2");
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","skoda cars","&rules.rulebase=child2");
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "skoda cars", "&rules.rulebase=child2");
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","audi cars", "&rules.rulebase=child1");
- assertSemantics("WEAKAND(100) vehiclebrand:skoda","vw cars", "&rules.rulebase=child1");
- assertSemantics("WEAKAND(100) skoda car", "skoda cars","&rules.rulebase=child1");
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "audi cars", "&rules.rulebase=child1");
+ assertSemantics("WEAKAND(100) vehiclebrand:skoda", "vw cars", "&rules.rulebase=child1");
+ assertSemantics("WEAKAND(100) skoda car", "skoda cars", "&rules.rulebase=child1");
assertSemantics("WEAKAND(100) vw car", "vw cars", "&rules.rulebase=parent");
- assertSemantics("WEAKAND(100) skoda car", "skoda cars","&rules.rulebase=parent");
+ assertSemantics("WEAKAND(100) skoda car", "skoda cars", "&rules.rulebase=parent");
}
protected void assertSemantics(String result,String input,String ruleSelection) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/LabelMatchingTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/LabelMatchingTestCase.java
index d45e114e89f..0a12ea2c49f 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/LabelMatchingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/LabelMatchingTestCase.java
@@ -4,7 +4,7 @@ package com.yahoo.prelude.semantics.test;
import java.io.IOException;
import com.yahoo.prelude.semantics.parser.ParseException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests label-dependent matching
@@ -19,30 +19,30 @@ public class LabelMatchingTestCase extends RuleBaseAbstractTestCase {
/** Tests that matching with no label matches the default label (index) only */
@Test
- public void testDefaultLabelMatching() throws IOException, ParseException {
- assertSemantics("matched:term","term");
- assertSemantics("alabel:term","alabel:term");
+ void testDefaultLabelMatching() throws IOException, ParseException {
+ assertSemantics("matched:term", "term");
+ assertSemantics("alabel:term", "alabel:term");
- assertSemantics("AND term2 hit","term2");
- assertSemantics("alabel:term2","alabel:term2");
+ assertSemantics("AND term2 hit", "term2");
+ assertSemantics("alabel:term2", "alabel:term2");
}
@Test
- public void testSpecificLabelMatchingInConditionReference() throws IOException, ParseException {
- assertSemantics("+dcattitle:restaurants -dcat:hotel","dcattitle:restaurants");
+ void testSpecificLabelMatchingInConditionReference() throws IOException, ParseException {
+ assertSemantics("+dcattitle:restaurants -dcat:hotel", "dcattitle:restaurants");
}
@Test
- public void testSpecificlabelMatchingInNestedCondition() throws IOException, ParseException {
- assertSemantics("three","foo:one");
- assertSemantics("three","foo:two");
- assertSemantics("bar:one","bar:one");
- assertSemantics("bar:two","bar:two");
- assertSemantics("foo:three","foo:three");
- assertSemantics("one","one");
- assertSemantics("two","two");
- assertSemantics("AND three three","foo:one foo:two");
- assertSemantics("AND bar:one bar:two","bar:one bar:two");
+ void testSpecificlabelMatchingInNestedCondition() throws IOException, ParseException {
+ assertSemantics("three", "foo:one");
+ assertSemantics("three", "foo:two");
+ assertSemantics("bar:one", "bar:one");
+ assertSemantics("bar:two", "bar:two");
+ assertSemantics("foo:three", "foo:three");
+ assertSemantics("one", "one");
+ assertSemantics("two", "two");
+ assertSemantics("AND three three", "foo:one foo:two");
+ assertSemantics("AND bar:one bar:two", "bar:one bar:two");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchAllTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchAllTestCase.java
index 22b24e1a0b0..270c2789ec5 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchAllTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchAllTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* tersts the ellipsis rule base
@@ -15,17 +15,17 @@ public class MatchAllTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testMatchAll() {
- assertSemantics("RANK a normtitle:a","a");
- assertSemantics("RANK (AND a b) normtitle:\"a b\"","a b");
- assertSemantics("RANK (AND a a b a) normtitle:\"a a b a\"","a a b a");
+ void testMatchAll() {
+ assertSemantics("RANK a normtitle:a", "a");
+ assertSemantics("RANK (AND a b) normtitle:\"a b\"", "a b");
+ assertSemantics("RANK (AND a a b a) normtitle:\"a a b a\"", "a a b a");
}
@Test
- public void testMatchAllFilterIsIgnored() {
- assertSemantics("RANK a |b normtitle:a","a&filter=b");
- assertSemantics("RANK (AND a b) |b |c normtitle:\"a b\"","a b&filter=b c");
- assertSemantics("RANK (AND a a b a) |a |a |c |d |b normtitle:\"a a b a\"","a a b a&filter=a a c d b");
+ void testMatchAllFilterIsIgnored() {
+ assertSemantics("RANK a |b normtitle:a", "a&filter=b");
+ assertSemantics("RANK (AND a b) |b |c normtitle:\"a b\"", "a b&filter=b c");
+ assertSemantics("RANK (AND a a b a) |a |a |c |d |b normtitle:\"a a b a\"", "a a b a&filter=a a c d b");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchOnlyIfNotOnlyTermTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchOnlyIfNotOnlyTermTestCase.java
index c398f0ed99e..30a88e74e91 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchOnlyIfNotOnlyTermTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/MatchOnlyIfNotOnlyTermTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Experiments with a way to match only if it doesn't remove all hard conditions in the query.
@@ -16,13 +16,13 @@ public class MatchOnlyIfNotOnlyTermTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testMatch() {
+ void testMatch() {
assertSemantics("RANK showname:\"saturday night live\"!1000 (AND justin timberlake)", "justin timberlake snl");
assertSemantics("RANK showname:\"saturday night live\"!1000 (AND justin timberlake)", "justin timberlake saturday night live");
}
@Test
- public void testNoMatch() {
+ void testNoMatch() {
// TODO: This shows that we do match, i.e that currently the behavior is undesired
assertSemantics("showname:\"saturday night live\"!1000", "snl");
assertSemantics("showname:\"saturday night live\"!1000", "saturday night live");
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/MusicTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/MusicTestCase.java
index 006dcb3c714..49766cc027c 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/MusicTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/MusicTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests the rewriting in the semanticsearcher system test
@@ -11,7 +11,7 @@ import org.junit.Test;
public class MusicTestCase {
@Test
- public void testMusic() {
+ void testMusic() {
var tester = new RuleBaseTester("music.sr");
tester.assertSemantics("AND song:together artist:youngbloods", "together by youngbloods");
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/NoStemmingTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/NoStemmingTestCase.java
index fbdd72fe6ac..04bc3249efe 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/NoStemmingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/NoStemmingTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests a case reported by tularam
@@ -16,20 +16,20 @@ public class NoStemmingTestCase extends RuleBaseAbstractTestCase {
/** Should rewrite correctly */
@Test
- public void testCorrectRewriting1() {
- assertSemantics("+(AND i:arts i:sciences TRUE) -i:b","i:as -i:b");
+ void testCorrectRewriting1() {
+ assertSemantics("+(AND i:arts i:sciences TRUE) -i:b", "i:as -i:b");
}
/** Should rewrite correctly too */
@Test
- public void testCorrectRewriting2() {
- assertSemantics("+(AND i:arts i:sciences i:crafts TRUE) -i:b","i:asc -i:b");
+ void testCorrectRewriting2() {
+ assertSemantics("+(AND i:arts i:sciences i:crafts TRUE) -i:b", "i:asc -i:b");
}
/** Should not rewrite */
@Test
- public void testNoRewriting() {
- assertSemantics("+i:a -i:s","i:a -i:s");
+ void testNoRewriting() {
+ assertSemantics("+i:a -i:s", "i:a -i:s");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/NotTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/NotTestCase.java
index c76db0a7afd..0ec320c7780 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/NotTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/NotTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -13,11 +13,11 @@ public class NotTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testLiteralEquals() {
- assertSemantics("RANK a foo:a","a");
- assertSemantics("a","a&ranking=category");
- assertSemantics("RANK a foo:a","a&ranking=somethingelse");
- assertSemantics("RANK a foo:a","a&otherparam=category");
+ void testLiteralEquals() {
+ assertSemantics("RANK a foo:a", "a");
+ assertSemantics("a", "a&ranking=category");
+ assertSemantics("RANK a foo:a", "a&ranking=somethingelse");
+ assertSemantics("RANK a foo:a", "a&otherparam=category");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/NumbersTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/NumbersTestCase.java
index b18cafdd161..60ccaa35cc4 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/NumbersTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/NumbersTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests numbers as conditions and productions
@@ -15,13 +15,13 @@ public class NumbersTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testNumbers() {
- assertSemantics("elite","1337");
- assertSemantics("1","one");
- assertSemantics("AND bort ned","opp");
- assertSemantics("AND kanoo knagg","foo bar");
- assertSemantics("AND 3 three","two 2");
- assertSemantics("AND 1 elite","one 1337");
+ void testNumbers() {
+ assertSemantics("elite", "1337");
+ assertSemantics("1", "one");
+ assertSemantics("AND bort ned", "opp");
+ assertSemantics("AND kanoo knagg", "foo bar");
+ assertSemantics("AND 3 three", "two 2");
+ assertSemantics("AND 1 elite", "one 1337");
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/NumericTermsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/NumericTermsTestCase.java
index f76deeacbb5..b63b3579c76 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/NumericTermsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/NumericTermsTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests numeric terms
@@ -15,13 +15,13 @@ public class NumericTermsTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testNumericProduction() {
- assertSemantics("+restaurants -ycat2gc:96929265","restaurants");
+ void testNumericProduction() {
+ assertSemantics("+restaurants -ycat2gc:96929265", "restaurants");
}
@Test
- public void testNumericConditionAndProduction() {
- assertSemantics("48","49");
+ void testNumericConditionAndProduction() {
+ assertSemantics("48", "49");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java
index 1d6eea8d7de..045d8698547 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -13,14 +13,14 @@ public class OrPhraseTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testReplacing1() {
- assertSemantics("OR title:\"software engineer\" (AND new york)","software engineer new york");
- assertSemantics("title:\"software engineer\"","software engineer"); // Skip or when there is nothing else
+ void testReplacing1() {
+ assertSemantics("OR title:\"software engineer\" (AND new york)", "software engineer new york");
+ assertSemantics("title:\"software engineer\"", "software engineer"); // Skip or when there is nothing else
}
@Test
- public void testReplacing2() {
- assertSemantics("OR lotr \"lord of the rings\"","lotr");
+ void testReplacing2() {
+ assertSemantics("OR lotr \"lord of the rings\"", "lotr");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/Parameter2TestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/Parameter2TestCase.java
index 5b1c38b7752..b9332effcb7 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/Parameter2TestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/Parameter2TestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.prelude.semantics.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;
/**
* Tests parameter matching and production
@@ -19,8 +19,8 @@ public class Parameter2TestCase extends RuleBaseAbstractTestCase {
/** Tests parameter production */
@Test
- public void testParameterProduction() {
- assertRankParameterSemantics("WEAKAND(100) a","a&ranking=usrank","date",0);
+ void testParameterProduction() {
+ assertRankParameterSemantics("WEAKAND(100) a", "a&ranking=usrank", "date", 0);
}
private void assertRankParameterSemantics(String producedQuery,String inputQuery,
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ParameterTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ParameterTestCase.java
index b597443d1d3..7df1ccbc156 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ParameterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ParameterTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.prelude.semantics.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;
/**
* Tests parameter matching and production
@@ -19,7 +19,7 @@ public class ParameterTestCase extends RuleBaseAbstractTestCase {
/** Tests parameter literal matching */
@Test
- public void testLiteralEquals() {
+ void testLiteralEquals() {
assertSemantics("a", "a");
assertSemantics("RANK a foo:a", "a&ranking=category");
assertSemantics("a", "a&ranking=somethingelse");
@@ -28,7 +28,7 @@ public class ParameterTestCase extends RuleBaseAbstractTestCase {
/** Tests parameter matching of larger */
@Test
- public void testLarger() {
+ void testLarger() {
assertSemantics("a", "a");
assertSemantics("AND a largepage", "a&hits=11");
assertSemantics("AND a largepage", "a&hits=12");
@@ -36,8 +36,8 @@ public class ParameterTestCase extends RuleBaseAbstractTestCase {
/** Tests parameter containment matching */
@Test
- public void testContainsAsList() {
- assertSemantics("a","a");
+ void testContainsAsList() {
+ assertSemantics("a", "a");
assertSemantics("AND a intent:music", "a&search=music");
assertSemantics("AND a intent:music", "a&search=music,books");
assertSemantics("AND a intent:music", "a&search=kanoos,music,books");
@@ -45,7 +45,7 @@ public class ParameterTestCase extends RuleBaseAbstractTestCase {
/** Tests parameter production */
@Test
- public void testParameterProduction() {
+ void testParameterProduction() {
assertParameterSemantics("AND a b c", "a b c", "search", "[letters, alphabet]");
assertParameterSemantics("AND a c d", "a c d", "search", "[letters, someletters]");
assertParameterSemantics("+(AND a d e) -letter:c", "a d e", "search", "[someletters]");
@@ -54,7 +54,7 @@ public class ParameterTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testMultipleAlternativeParameterValuesInCondition() {
+ void testMultipleAlternativeParameterValuesInCondition() {
assertInputRankParameterSemantics("WEAKAND(100) one", "foo", "cat");
assertInputRankParameterSemantics("WEAKAND(100) one", "foo", "cat0");
assertInputRankParameterSemantics("WEAKAND(100) one", "bar", "cat");
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.java
index fd9003e0e05..9536c1bfb7c 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/PhraseMatchTestCase.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.prelude.semantics.test;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
/**
* Tests that the phrase produced by an automata match can subsequently be replaced by an AND of the
@@ -16,14 +16,15 @@ public class PhraseMatchTestCase extends RuleBaseAbstractTestCase {
super("phrasematch.sr", "semantics.fsa");
}
+ // TODO: Work in progress
@Test
- @Ignore // TODO: Work in progress
- public void testLiteralEquals() {
- assertSemantics("AND retailer:digital retailer:camera","keyword:digital keyword:camera");
+ @Disabled
+ void testLiteralEquals() {
+ assertSemantics("AND retailer:digital retailer:camera", "keyword:digital keyword:camera");
}
@Test
- public void testMatchingPhrase() {
+ void testMatchingPhrase() {
assertSemantics("OR (AND iphone 7) i7", "iphone 7");
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ProductionRuleTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ProductionRuleTestCase.java
index e892adc3b1c..44ebd4f1995 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ProductionRuleTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ProductionRuleTestCase.java
@@ -15,10 +15,10 @@ import com.yahoo.prelude.semantics.rule.ReferenceTermProduction;
import com.yahoo.prelude.semantics.rule.ReplacingProductionRule;
import com.yahoo.prelude.semantics.rule.TermCondition;
import com.yahoo.prelude.semantics.rule.TermProduction;
-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
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue;
public class ProductionRuleTestCase {
@Test
- public void testProductionRule() {
+ void testProductionRule() {
var linguistics = new RuleBaseLinguistics(new SimpleLinguistics());
TermCondition term = new TermCondition("sony", linguistics);
NamedCondition named = new NamedCondition("brand", term);
@@ -46,7 +46,7 @@ public class ProductionRuleTestCase {
ruleBase.addRule(rule);
ruleBase.initialize();
- assertTrue("Brand is referenced", rule.matchReferences().contains("brand"));
+ assertTrue(rule.matchReferences().contains("brand"), "Brand is referenced");
Query query = new Query("?query=sony");
RuleEvaluation e = new Evaluation(query, null).freshRuleEvaluation();
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseAbstractTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseAbstractTestCase.java
index 84e47edae29..668251c0a1f 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseAbstractTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseAbstractTestCase.java
@@ -14,7 +14,7 @@ import com.yahoo.search.test.QueryTestCase;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* DO NOT USE. Use RuleBaseTester instead
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseTester.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseTester.java
index cc9e758a0e0..dc43ffc55e7 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseTester.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/RuleBaseTester.java
@@ -14,7 +14,7 @@ import com.yahoo.search.test.QueryTestCase;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Helper for testing with a rule base.
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/SegmentSubstitutionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/SegmentSubstitutionTestCase.java
index 69faed1da90..8d7c16f5544 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/SegmentSubstitutionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/SegmentSubstitutionTestCase.java
@@ -8,8 +8,7 @@ import com.yahoo.prelude.query.parser.TestLinguistics;
import com.yahoo.search.Query;
import com.yahoo.search.query.parser.Parsable;
import com.yahoo.search.query.parser.ParserEnvironment;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SegmentSubstitutionTestCase extends RuleBaseAbstractTestCase {
@@ -18,7 +17,7 @@ public class SegmentSubstitutionTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testBasicSubstitution() {
+ void testBasicSubstitution() {
Item a = parseQuery("firstsecond");
Query q = new Query("?query=ignored&tracelevel=0&tracelevel.rules=0");
q.getModel().getQueryTree().setRoot(a);
@@ -27,7 +26,7 @@ public class SegmentSubstitutionTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testSubstitutionAndMoreTerms() {
+ void testSubstitutionAndMoreTerms() {
Item a = parseQuery("bcfirstsecondfg");
Query q = new Query("?query=ignored&tracelevel=0&tracelevel.rules=0");
q.getModel().getQueryTree().setRoot(a);
@@ -36,7 +35,7 @@ public class SegmentSubstitutionTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testSubstitutionAndNot() {
+ void testSubstitutionAndNot() {
Item a = parseQuery("-firstsecond bc");
Query q = new Query("?query=ignored&tracelevel=0&tracelevel.rules=0");
q.getModel().getQueryTree().setRoot(a);
@@ -45,7 +44,7 @@ public class SegmentSubstitutionTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testSubstitutionSomeNoise() {
+ void testSubstitutionSomeNoise() {
Item a = parseQuery("9270bcsecond2389");
Query q = new Query("?query=ignored&tracelevel=0&tracelevel.rules=0");
q.getModel().getQueryTree().setRoot(a);
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/SemanticSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/SemanticSearcherTestCase.java
index bee65db4347..489afcb3088 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/SemanticSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/SemanticSearcherTestCase.java
@@ -8,12 +8,12 @@ import com.yahoo.prelude.query.NullItem;
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.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests semantic searching
@@ -27,128 +27,128 @@ public class SemanticSearcherTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testSingleShopping() {
+ void testSingleShopping() {
assertSemantics("brand:sony",
- "sony");
+ "sony");
assertSemantics("brand:sony!150",
- "sony!150");
+ "sony!150");
}
@Test
- public void testCombinedShopping() {
+ void testCombinedShopping() {
assertSemantics("AND brand:sony category:camera",
- "sony camera");
+ "sony camera");
}
@Test
- public void testPhrasedShopping() {
+ void testPhrasedShopping() {
assertSemantics("AND brand:sony category:\"digital camera\"",
- "sony digital camera");
+ "sony digital camera");
}
@Test
- public void testSimpleLocal() {
+ void testSimpleLocal() {
assertSemantics("AND listing:restaurant place:geary",
- "restaurant in geary");
+ "restaurant in geary");
}
@Test
- public void testLocal() {
+ void testLocal() {
assertSemantics("AND listing:restaurant place:\"geary street san francisco\"",
- "restaurant in geary street san francisco");
+ "restaurant in geary street san francisco");
}
@Test
- public void testLiteralReplacing() {
+ void testLiteralReplacing() {
assertSemantics("AND lord of rings", "lotr");
}
@Test
- public void testAddingAnd() {
+ void testAddingAnd() {
assertSemantics("AND bar foobar:bar",
- "bar");
+ "bar");
}
@Test
- public void testAddingRank() {
+ void testAddingRank() {
assertSemantics("RANK word foobar:word",
- "word");
+ "word");
}
@Test
- public void testFilterIsIgnored() {
+ void testFilterIsIgnored() {
assertSemantics("RANK word |a |word |b foobar:word",
- "word&filter=a word b");
+ "word&filter=a word b");
assertSemantics("RANK a |word |b",
- "a&filter=word b");
+ "a&filter=word b");
}
@Test
- public void testAddingNegative() {
+ void testAddingNegative() {
assertSemantics("+java -coffee",
- "java");
+ "java");
}
@Test
- public void testAddingNegativePluralToSingular() {
+ void testAddingNegativePluralToSingular() {
assertSemantics("+javas -coffee",
- "javas");
+ "javas");
}
@Test
- public void testCombined() {
+ void testCombined() {
assertSemantics("AND bar listing:restaurant place:\"geary street san francisco\" foobar:bar",
- "bar restaurant in geary street san francisco");
+ "bar restaurant in geary street san francisco");
}
@Test
- public void testStopWord() {
- assertSemantics("strokes","the strokes");
+ void testStopWord() {
+ assertSemantics("strokes", "the strokes");
}
@Test
- public void testStopWords1() {
- assertSemantics("strokes","be the strokes");
+ void testStopWords1() {
+ assertSemantics("strokes", "be the strokes");
}
@Test
- public void testStopWords2() {
- assertSemantics("strokes","the strokes be");
+ void testStopWords2() {
+ assertSemantics("strokes", "the strokes be");
}
@Test
- public void testDontRemoveEverything() {
- assertSemantics("the","the the the");
+ void testDontRemoveEverything() {
+ assertSemantics("the", "the the the");
}
@Test
- public void testMoreStopWordRemoval() {
- assertSemantics("hamlet","hamlet to be or not to be");
+ void testMoreStopWordRemoval() {
+ assertSemantics("hamlet", "hamlet to be or not to be");
}
@Test
- public void testTypeChange() {
- assertSemantics("RANK default:typechange doors","typechange doors");
+ void testTypeChange() {
+ assertSemantics("RANK default:typechange doors", "typechange doors");
}
@Test
- public void testTypeChangeWithSingularToPluralButNonReplaceWillNotSingularify() {
- assertSemantics("RANK default:typechange door","typechange door");
+ void testTypeChangeWithSingularToPluralButNonReplaceWillNotSingularify() {
+ assertSemantics("RANK default:typechange door", "typechange door");
}
@Test
- public void testExplicitContext() {
- assertSemantics("AND from:paris to:texas","paris to texas");
+ void testExplicitContext() {
+ assertSemantics("AND from:paris to:texas", "paris to texas");
}
@Test
- public void testOrProduction() {
+ void testOrProduction() {
assertSemantics("OR something somethingelse", "something");
}
// This test is order dependent. Fix it!!
@Test
- public void testWeightedSetItem() {
+ void testWeightedSetItem() {
Query q = new Query();
WeightedSetItem weightedSet = new WeightedSetItem("fieldName");
weightedSet.addToken("a", 1);
@@ -158,7 +158,7 @@ public class SemanticSearcherTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testNullQuery() {
+ void testNullQuery() {
Query query = new Query(""); // Causes a query containing a NullItem
doSearch(searcher, query, 0, 10);
assertEquals(NullItem.class, query.getModel().getQueryTree().getRoot().getClass()); // Still a NullItem
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/StemmingTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/StemmingTestCase.java
index b8efbf7422b..c5277bf6ef6 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/StemmingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/StemmingTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests stemming.
@@ -11,43 +11,43 @@ import org.junit.Test;
public class StemmingTestCase {
@Test
- public void testRewritingDueToStemmingInQuery() {
+ void testRewritingDueToStemmingInQuery() {
var tester = new RuleBaseTester("stemming.sr");
tester.assertSemantics("+(AND i:vehicle TRUE) -i:s", "i:cars -i:s");
}
@Test
- public void testNoRewritingDueToStemmingInQueryWhenStemmingDisabled() {
+ void testNoRewritingDueToStemmingInQueryWhenStemmingDisabled() {
var tester = new RuleBaseTester("stemming-none.sr");
tester.assertSemantics("+i:cars -i:s", "i:cars -i:s");
}
@Test
- public void testRewritingDueToStemmingInRule() {
+ void testRewritingDueToStemmingInRule() {
var tester = new RuleBaseTester("stemming.sr");
tester.assertSemantics("+(AND i:animal TRUE) -i:s", "i:horse -i:s");
}
@Test
- public void testNoRewritingDueToStemmingInRuleWhenStemmingDisabled() {
+ void testNoRewritingDueToStemmingInRuleWhenStemmingDisabled() {
var tester = new RuleBaseTester("stemming-none.sr");
tester.assertSemantics("+i:horse -i:s", "i:horse -i:s");
}
@Test
- public void testRewritingDueToExactMatch() {
+ void testRewritingDueToExactMatch() {
var tester = new RuleBaseTester("stemming.sr");
tester.assertSemantics("+(AND i:arts i:sciences TRUE) -i:s", "i:as -i:s");
}
@Test
- public void testEnglishStemming() {
+ void testEnglishStemming() {
var tester = new RuleBaseTester("stemming.sr");
tester.assertSemantics("i:drive", "i:going");
}
@Test
- public void testFrenchStemming() {
+ void testFrenchStemming() {
var tester = new RuleBaseTester("stemming-french.sr");
tester.assertSemantics("i:going", "i:going");
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/StopwordTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/StopwordTestCase.java
index a0c2cf4545c..207ae7f8877 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/StopwordTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/StopwordTestCase.java
@@ -3,7 +3,7 @@ package com.yahoo.prelude.semantics.test;
import com.yahoo.search.Query;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests numeric terms
@@ -17,21 +17,21 @@ public class StopwordTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testStopwords() {
+ void testStopwords() {
assertSemantics("WEAKAND(100) mlr:ve mlr:heard mlr:beautiful mlr:world",
- new Query(QueryTestCase.httpEncode("?query=i don't know if you've heard, but it's a beautiful world&default-index=mlr&tracelevel.rules=0")));
+ new Query(QueryTestCase.httpEncode("?query=i don't know if you've heard, but it's a beautiful world&default-index=mlr&tracelevel.rules=0")));
}
/** If the query contains nothing but stopwords, we won't remove them */
@Test
- public void testOnlyStopwords() {
+ void testOnlyStopwords() {
assertSemantics("WEAKAND(100) mlr:the", new Query(QueryTestCase.httpEncode("?query=the the&default-index=mlr&tracelevel.rules=0")));
}
@Test
- public void testStopwordsInPhrase() {
+ void testStopwordsInPhrase() {
assertSemantics("WEAKAND(100) mlr:\"ve heard\" mlr:beautiful mlr:world",
- new Query(QueryTestCase.httpEncode("?query=\"i don't know if you've heard\", but it's a beautiful world&default-index=mlr&tracelevel.rules=0")));
+ new Query(QueryTestCase.httpEncode("?query=\"i don't know if you've heard\", but it's a beautiful world&default-index=mlr&tracelevel.rules=0")));
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/SynonymTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/SynonymTestCase.java
index 8f69be2f710..65001cfcd44 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/SynonymTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/SynonymTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -9,7 +9,7 @@ import org.junit.Test;
public class SynonymTestCase {
@Test
- public void testReplacingBySynonyms() {
+ void testReplacingBySynonyms() {
var tester = new RuleBaseTester("synonyms.sr");
tester.assertSemantics("EQUIV index1:foo index1:baz index1:bar", "index1:foo");
tester.assertSemantics("EQUIV index1:foo index1:baz index1:bar", "index1:bar");
@@ -20,7 +20,7 @@ public class SynonymTestCase {
}
@Test
- public void testAddingSynonyms() {
+ void testAddingSynonyms() {
var tester = new RuleBaseTester("synonyms.sr");
tester.assertSemantics("EQUIV index2:foo index2:baz index2:bar", "index2:foo");
tester.assertSemantics("EQUIV index2:bar index2:foo index2:baz", "index2:bar");
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/UrlTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/UrlTestCase.java
index 9bc64370030..c9eb30b3578 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/UrlTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/UrlTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests working with url indexes
@@ -15,8 +15,8 @@ public class UrlTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testFromDefaultToUrlIndex() {
- assertSemantics("fromurl:\"youtube com\"","youtube.com");
+ void testFromDefaultToUrlIndex() {
+ assertSemantics("fromurl:\"youtube com\"", "youtube.com");
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/WeightingTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/WeightingTestCase.java
index d89e6fdbfa3..e5d7408f3c0 100644
--- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/WeightingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/WeightingTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author bratseth
@@ -13,7 +13,7 @@ public class WeightingTestCase extends RuleBaseAbstractTestCase {
}
@Test
- public void testWeighting() {
+ void testWeighting() {
assertSemantics("foo!150", "foo");
assertSemantics("AND foo!150 snip", "foo snip");
assertSemantics("AND foo!150 bar", "foo bar");
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/GetRawWordTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/GetRawWordTestCase.java
index 9ed84298838..edf039723fd 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/GetRawWordTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/GetRawWordTestCase.java
@@ -4,9 +4,9 @@ package com.yahoo.prelude.test;
import com.yahoo.prelude.query.AndItem;
import com.yahoo.prelude.query.WordItem;
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;
/**
* Tests a case reported by MSBE
@@ -16,27 +16,28 @@ import static org.junit.Assert.assertEquals;
public class GetRawWordTestCase {
@Test
- public void testGetRawWord() {
+ void testGetRawWord() {
Query query = new Query("?query=%C4%B0%C5%9EBANKASI%20GAZ%C4%B0EM%C4%B0R&type=all&searchChain=vespa");
assertEquals("AND \u0130\u015EBANKASI GAZ\u0130EM\u0130R", query.getModel().getQueryTree().toString());
- AndItem root = (AndItem)query.getModel().getQueryTree().getRoot();
+ AndItem root = (AndItem) query.getModel().getQueryTree().getRoot();
{
- WordItem word = (WordItem)root.getItem(0);
+ WordItem word = (WordItem) root.getItem(0);
assertEquals("\u0130\u015EBANKASI", word.getRawWord());
assertEquals(0, word.getOrigin().start);
assertEquals(9, word.getOrigin().end);
}
{
- WordItem word = (WordItem)root.getItem(1);
+ WordItem word = (WordItem) root.getItem(1);
assertEquals("GAZ\u0130EM\u0130R", word.getRawWord());
assertEquals(10, word.getOrigin().start);
assertEquals(18, word.getOrigin().end);
}
- assertEquals("Total string is just these words",18,
- ((WordItem)root.getItem(0)).getOrigin().getSuperstring().length());
+ assertEquals(18,
+ ((WordItem) root.getItem(0)).getOrigin().getSuperstring().length(),
+ "Total string is just these words");
}
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
index 6a54492f5e5..4b24ba3671e 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
@@ -11,7 +11,8 @@ import com.yahoo.prelude.SearchDefinition;
import com.yahoo.search.Query;
import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -20,10 +21,7 @@ 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.jupiter.api.Assertions.*;
/**
* Tests using synthetic index names for IndexFacts class.
@@ -58,7 +56,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testBasicCases() {
+ void testBasicCases() {
// First check default behavior
IndexFacts indexFacts = createIndexFacts();
Query q = newQuery("?query=a:b", indexFacts);
@@ -68,7 +66,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testDefaultPosition() {
+ void testDefaultPosition() {
Index a = new Index("a");
assertFalse(a.isDefaultPosition());
a.addCommand("any");
@@ -80,21 +78,21 @@ public class IndexFactsTestCase {
sd.addCommand("b", "any");
assertNull(sd.getDefaultPosition());
sd.addCommand("c", "default-position");
- assertTrue(sd.getDefaultPosition().equals("c"));
+ assertEquals(sd.getDefaultPosition(), "c");
SearchDefinition sd2 = new SearchDefinition("sd2");
sd2.addIndex(new Index("b").addCommand("any"));
assertNull(sd2.getDefaultPosition());
sd2.addIndex(a);
- assertTrue(sd2.getDefaultPosition().equals("a"));
+ assertEquals(sd2.getDefaultPosition(), "a");
IndexFacts indexFacts = createIndexFacts(ImmutableList.of(sd, sd2));
- assertTrue(indexFacts.getDefaultPosition(null).equals("a"));
- assertTrue(indexFacts.getDefaultPosition("sd").equals("c"));
+ assertEquals(indexFacts.getDefaultPosition(null), "a");
+ assertEquals(indexFacts.getDefaultPosition("sd"), "c");
}
@Test
- public void testIndicesInAnyConfigurationAreIndicesInDefault() {
+ void testIndicesInAnyConfigurationAreIndicesInDefault() {
IndexFacts.Session indexFacts = createIndexFacts().newSession(new Query());
assertTrue(indexFacts.isIndex("a"));
assertTrue(indexFacts.isIndex("b"));
@@ -104,21 +102,21 @@ public class IndexFactsTestCase {
}
@Test
- public void testDefaultIsUnionHostIndex() {
+ void testDefaultIsUnionHostIndex() {
IndexFacts.Session session = createIndexFacts().newSession(new Query());
assertTrue(session.getIndex("c").isHostIndex());
assertFalse(session.getIndex("a").isHostIndex());
}
@Test
- public void testDefaultIsUnionUriIndex() {
+ void testDefaultIsUnionUriIndex() {
IndexFacts indexFacts = createIndexFacts();
assertTrue(indexFacts.newSession(new Query()).getIndex("d").isUriIndex());
assertFalse(indexFacts.newSession(new Query()).getIndex("a").isUriIndex());
}
@Test
- public void testDefaultIsUnionStemMode() {
+ void testDefaultIsUnionStemMode() {
IndexFacts.Session session = createIndexFacts().newSession(new Query());
assertEquals(StemMode.NONE, session.getIndex("a").getStemMode());
assertEquals(StemMode.NONE, session.getIndex("b").getStemMode());
@@ -140,7 +138,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testExactMatching() {
+ void testExactMatching() {
assertExactIsWorking("test");
assertExactIsWorking("artist_name_ft_norm1");
@@ -157,7 +155,7 @@ public class IndexFactsTestCase {
Index e = nullSession.getIndex("e");
assertTrue(e.isExact());
- assertEquals("kj(/&",e.getExactTerminator());
+ assertEquals("kj(/&", e.getExactTerminator());
Index a = nullSession.getIndex("a");
assertFalse(a.isExact());
@@ -169,7 +167,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testComplexExactMatching() {
+ void testComplexExactMatching() {
SearchDefinition sd = new SearchDefinition("foobar");
String u_name = "foo_bar";
Index u_index = new Index(u_name);
@@ -190,7 +188,7 @@ public class IndexFactsTestCase {
// This is also backed by a system test on cause of complex config
@Test
- public void testRestrictLists1() {
+ void testRestrictLists1() {
Query query = new Query();
query.getModel().getSources().add("nalle");
query.getModel().getSources().add("one");
@@ -203,7 +201,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testRestrictLists2() {
+ void testRestrictLists2() {
Query query = new Query();
query.getModel().getSources().add("clusterTwo");
query.getModel().getRestrict().add("three");
@@ -223,7 +221,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testRestrictLists3() {
+ void testRestrictLists3() {
Query query = new Query();
query.getModel().getSources().add("clusterOne");
query.getModel().getRestrict().add("two");
@@ -242,7 +240,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testPredicateBounds() {
+ void testPredicateBounds() {
Index index = new Index("a");
assertEquals(Long.MIN_VALUE, index.getPredicateLowerBound());
assertEquals(Long.MAX_VALUE, index.getPredicateUpperBound());
@@ -264,7 +262,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testUriIndexAndRestrict() {
+ void testUriIndexAndRestrict() {
IndexInfoConfig.Builder b = new IndexInfoConfig.Builder();
IndexInfoConfig.Indexinfo.Builder b1 = new IndexInfoConfig.Indexinfo.Builder();
@@ -298,7 +296,7 @@ public class IndexFactsTestCase {
}
@Test
- public void testConflictingAliases() {
+ void testConflictingAliases() {
SearchDefinition first = new SearchDefinition("first");
Index field1 = new Index("field1");
first.addIndex(field1);
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/IntegrationTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/IntegrationTestCase.java
index b34edbf208c..10573b63bdc 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/IntegrationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/IntegrationTestCase.java
@@ -5,7 +5,7 @@ import com.yahoo.search.result.Hit;
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;
/**
* Runs a query thru the configured search chain from a real http channel
@@ -32,8 +32,8 @@ public class IntegrationTestCase {
}
@Test
- public void testQuery() throws java.io.IOException {
- /*
+ void testQuery() throws java.io.IOException {
+ /*
TODO: (JSB) This blocks forever on Linux (not Windows) because
the ServerSocketChannel.accept method in Server
seems to starve the test running thread,
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/LocationTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/LocationTestCase.java
index 07750613249..96a24ac92c8 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/LocationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/LocationTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.prelude.test;
import com.yahoo.prelude.Location;
-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 the Location class. Currently does not test all "features" of Location class.
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertEquals;
public class LocationTestCase {
@Test
- public void testAspect() {
+ void testAspect() {
//0 degrees latitude, on the equator
Location loc1 = new Location("[2,-1110000,330000,-1160000,340000](2,-1100222,0,300,0,1,0,CalcLatLon)");
assertEquals(loc1.toString(), "[2,-1110000,330000,-1160000,340000](2,-1100222,0,300,0,1,0,4294967295)");
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java
index e77f0d00578..495f11e0780 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.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.prelude.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashSet;
-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.*;
/**
* Tests null members in HashSet
@@ -15,7 +13,7 @@ import static org.junit.Assert.assertTrue;
public class NullSetMemberTestCase {
@Test
- public void testNullMember() {
+ void testNullMember() {
HashSet<?> s = new HashSet<>();
assertEquals(s.size(), 0);
assertFalse(s.contains(null));
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java
index eaab7e12f33..95ecf3c2dba 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java
@@ -14,12 +14,12 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.Sorting;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.yolean.Exceptions;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests for query class
@@ -29,7 +29,7 @@ import static org.junit.Assert.*;
public class QueryTestCase {
@Test
- public void testBoolItem() {
+ void testBoolItem() {
var original = new BoolItem(false);
var cloned = original.clone();
assertNotSame(original, cloned);
@@ -37,7 +37,7 @@ public class QueryTestCase {
}
@Test
- public void testSimpleQueryParsing () {
+ void testSimpleQueryParsing() {
Query q = newQuery("/search?query=foobar&offset=10&hits=20&type=all");
assertEquals("foobar", ((WordItem) q.getModel().getQueryTree().getRoot()).getWord());
assertEquals(10, q.getOffset());
@@ -45,7 +45,7 @@ public class QueryTestCase {
}
@Test
- public void testAdvancedQueryParsing () {
+ void testAdvancedQueryParsing() {
Query q = newQuery("/search?query=fOObar and kanoo&offset=10&hits=20&filter=-foo +bar&type=adv&suggestonly=true");
assertEquals("AND (+(AND fOObar kanoo) -|foo) |bar", q.getModel().getQueryTree().getRoot().toString());
assertEquals(10, q.getOffset());
@@ -54,7 +54,7 @@ public class QueryTestCase {
}
@Test
- public void testAnyQueryParsing () {
+ void testAnyQueryParsing() {
Query q = newQuery("/search?query=foobar and kanoo&offset=10&hits=10&type=any&suggestonly=true&filter=-fast.type:offensive&encoding=latin1");
assertEquals("+(OR foobar and kanoo) -|fast.type:offensive", q.getModel().getQueryTree().getRoot().toString());
assertEquals(10, q.getOffset());
@@ -64,13 +64,13 @@ public class QueryTestCase {
}
@Test
- public void testLongQueryParsing() {
+ void testLongQueryParsing() {
Query q = newQuery("/p13n?query=news"
- +"interest:cnn!254+interest:cnnfn!171+interest:cnn+"
- +"financial!96+interest:"
- +"yahoo+com!253+interest:www+yahoo!138+"
- +"interest:www+yahoo+com!136"
- +"&hits=20&offset=0&vectorranking=queryrank");
+ + "interest:cnn!254+interest:cnnfn!171+interest:cnn+"
+ + "financial!96+interest:"
+ + "yahoo+com!253+interest:www+yahoo!138+"
+ + "interest:www+yahoo+com!136"
+ + "&hits=20&offset=0&vectorranking=queryrank");
assertEquals("/p13n", q.getHttpRequest().getUri().getPath());
assertEquals(0, q.getOffset());
assertEquals(20, q.getHits());
@@ -83,9 +83,9 @@ public class QueryTestCase {
* is not a number.
*/
@Test
- public void testGetParamInt() {
+ void testGetParamInt() {
Query q = newQuery("/search?query=foo%20bar&someint=10&notint=hello");
- assertEquals(10, (int)q.properties().getInteger("someint"));
+ assertEquals(10, (int) q.properties().getInteger("someint"));
// provoke an exception. if exception is not triggered
// we fail the test.
@@ -98,13 +98,13 @@ public class QueryTestCase {
}
@Test
- public void testUtf8Decoding() {
+ void testUtf8Decoding() {
Query q = new Query("/?query=beyonc%C3%A9&type=all");
assertEquals("beyonc\u00e9", ((WordItem) q.getModel().getQueryTree().getRoot()).getWord());
}
@Test
- public void testSortSpec() {
+ void testSortSpec() {
Query q = newQuery("?query=test&sortspec=+a -b c +[rank]");
assertNotNull(q.getRanking().getSorting());
List<Sorting.FieldOrder> sortSpec = q.getRanking().getSorting().fieldOrders();
@@ -120,13 +120,13 @@ public class QueryTestCase {
}
@Test
- public void testSortSpecLowerCase() {
+ void testSortSpecLowerCase() {
Query q = newQuery("?query=test&sortspec=-lowercase(name)");
assertNotNull(q.getRanking().getSorting());
List<Sorting.FieldOrder> sortSpec = q.getRanking().getSorting().fieldOrders();
assertEquals(sortSpec.size(), 1);
assertEquals(Sorting.Order.DESCENDING,
- sortSpec.get(0).getSortOrder());
+ sortSpec.get(0).getSortOrder());
assertEquals("name", sortSpec.get(0).getFieldName());
assertTrue(sortSpec.get(0).getSorter() instanceof Sorting.LowerCaseSorter);
}
@@ -143,7 +143,7 @@ public class QueryTestCase {
}
@Test
- public void testSortSpecUca() {
+ void testSortSpecUca() {
checkUcaUS("?query=test&sortspec=-uca(name,en_US)");
checkUcaUS("?query=test&sortspec=-UCA(name,en_US)");
checkSortSpecUcaUSOptional("?query=test&sortspec=-uca(name,en_US,tertiary)");
@@ -151,21 +151,21 @@ public class QueryTestCase {
}
@Test
- public void testInvalidSortFunction() {
+ void testInvalidSortFunction() {
assertQueryError(
"?query=test&sortspec=-ucca(name,en_US)",
"Could not set 'ranking.sorting' to '-ucca(name,en_US)': Unknown sort function 'ucca'");
}
@Test
- public void testMissingSortFunction() {
+ void testMissingSortFunction() {
assertQueryError(
"?query=test&sortspec=-(name)",
"Could not set 'ranking.sorting' to '-(name)': No sort function specified");
}
@Test
- public void testInvalidUcaStrength() {
+ void testInvalidUcaStrength() {
assertQueryError(
"?query=test&sortspec=-uca(name,en_US,tertary)",
"Could not set 'ranking.sorting' to '-uca(name,en_US,tertary)': Unknown collation strength: 'tertary'");
@@ -189,7 +189,7 @@ public class QueryTestCase {
* Extremely simple for now, will be used for pathological cases.
*/
@Test
- public void testHashCode() {
+ void testHashCode() {
Query p = newQuery("?query=foo&type=any");
Query q = newQuery("?query=foo&type=all");
assertTrue(p.hashCode() != q.hashCode());
@@ -197,17 +197,17 @@ public class QueryTestCase {
/** Test using the defauultindex feature */
@Test
- public void testDefaultIndex() {
+ void testDefaultIndex() {
Query q = newQuery("?query=hi hello keyword:kanoo " +
- "default:munkz \"phrases too\"&default-index=def");
+ "default:munkz \"phrases too\"&default-index=def");
assertEquals("WEAKAND(100) def:hi def:hello keyword:kanoo " +
- "default:munkz def:\"phrases too\"",
- q.getModel().getQueryTree().getRoot().toString());
+ "default:munkz def:\"phrases too\"",
+ q.getModel().getQueryTree().getRoot().toString());
}
- /** Test that GET parameter names are case in-sensitive */
- @Test
- public void testGETParametersCase() {
+ /** Test that GET parameter names are case in-sensitive */
+ @Test
+ void testGETParametersCase() {
Query q = newQuery("?QUERY=testing&hits=10&oFfSeT=10");
assertEquals("testing", q.getModel().getQueryString());
@@ -217,108 +217,108 @@ public class QueryTestCase {
@Test
- public void testNegativeHitValue() {
+ void testNegativeHitValue() {
assertQueryError(
"?query=test&hits=-1",
"Could not set 'hits' to '-1': Must be a positive number");
}
@Test
- public void testNaNHitValue() {
+ void testNaNHitValue() {
assertQueryError(
"?query=test&hits=NaN",
"Could not set 'hits' to 'NaN': 'NaN' is not a valid integer");
}
@Test
- public void testNoneHitValue() {
+ void testNoneHitValue() {
assertQueryError(
"?query=test&hits=(none)",
"Could not set 'hits' to '(none)': '(none)' is not a valid integer");
}
@Test
- public void testNegativeOffsetValue() {
+ void testNegativeOffsetValue() {
assertQueryError(
"?query=test&offset=-1",
"Could not set 'offset' to '-1': Must be a positive number");
}
@Test
- public void testNaNOffsetValue() {
+ void testNaNOffsetValue() {
assertQueryError(
"?query=test&offset=NaN",
"Could not set 'offset' to 'NaN': 'NaN' is not a valid integer");
}
@Test
- public void testNoneOffsetValue() {
+ void testNoneOffsetValue() {
assertQueryError(
"?query=test&offset=(none)",
"Could not set 'offset' to '(none)': '(none)' is not a valid integer");
}
@Test
- public void testNoneHitsNegativeOffsetValue() {
+ void testNoneHitsNegativeOffsetValue() {
assertQueryError(
"?query=test&hits=(none)&offset=-10",
"Could not set 'hits' to '(none)': '(none)' is not a valid integer");
}
@Test
- public void testFeedbackIsTransferredToResult() {
+ void testFeedbackIsTransferredToResult() {
assertQueryError(
"?query=test&hits=(none)&offset=-10",
"Could not set 'hits' to '(none)': '(none)' is not a valid integer");
}
@Test
- public void testUnicodeNormalization() {
+ void testUnicodeNormalization() {
Linguistics linguistics = new SimpleLinguistics();
Query query = newQueryFromEncoded("?query=content:%EF%BC%B3%EF%BC%AF%EF%BC%AE%EF%BC%B9&type=all", Language.ENGLISH,
- linguistics);
+ linguistics);
assertEquals("SONY", ((WordItem) query.getModel().getQueryTree().getRoot()).getWord());
query = newQueryFromEncoded("?query=foo&filter=+%EF%BC%B3%EF%BC%AF%EF%BC%AE%EF%BC%B9&type=all", Language.ENGLISH,
- linguistics);
+ linguistics);
assertEquals("RANK foo |SONY", query.getModel().getQueryTree().getRoot().toString());
query = newQueryFromEncoded("?query=foo+AND+%EF%BC%B3%EF%BC%AF%EF%BC%AE%EF%BC%B9)&type=adv",
- Language.ENGLISH, linguistics);
+ Language.ENGLISH, linguistics);
assertEquals("AND foo SONY", query.getModel().getQueryTree().getRoot().toString());
}
/** Test a vertical specific patch, see Tokenizer */
@Test
- @Ignore
- public void testPrivateUseCharacterParsing() {
+ @Disabled
+ void testPrivateUseCharacterParsing() {
Query query = newQuery("?query=%EF%89%AB");
assertEquals(Character.UnicodeBlock.PRIVATE_USE_AREA,
- Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(0)));
+ Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(0)));
}
/** Test a vertical specific patch, see Tokenizer */
@Test
- @Ignore
- public void testOtherCharactersParsing() {
+ @Disabled
+ void testOtherCharactersParsing() {
Query query = newQuery(com.yahoo.search.test.QueryTestCase.httpEncode("?query=\u3007\u2e80\u2eff\u2ed0"));
assertEquals(Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION,
- Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(0)));
+ Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(0)));
assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT,
- Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(1)));
+ Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(1)));
assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT,
- Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(2)));
+ Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(2)));
assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT,
- Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(3)));
+ Character.UnicodeBlock.of(query.getModel().getQueryTree().getRoot().toString().charAt(3)));
}
@Test
- public void testFreshness() {
+ void testFreshness() {
Query query = newQuery("?query=test&datetime=103");
- assertTrue(query.getRanking().getFreshness().getRefTime()==103);
+ assertEquals(query.getRanking().getFreshness().getRefTime(), 103);
query.getRanking().setFreshness("193");
- assertTrue(query.getRanking().getFreshness().getRefTime()==193);
+ assertEquals(query.getRanking().getFreshness().getRefTime(), 193);
query.getRanking().setFreshness("now");
assertTrue(query.getRanking().getFreshness().getSystemTimeInSecondsSinceEpoch() >= query.getRanking().getFreshness().getRefTime());
@@ -330,10 +330,10 @@ public class QueryTestCase {
}
@Test
- public void testCopy() {
+ void testCopy() {
Query qs = newQuery("?query=test&rankfeature.something=2");
assertEquals("WEAKAND(100) test", qs.getModel().getQueryTree().toString());
- assertEquals((int)qs.properties().getInteger("rankfeature.something"),2);
+ assertEquals((int) qs.properties().getInteger("rankfeature.something"), 2);
Query qp = new Query(qs);
assertEquals("WEAKAND(100) test", qp.getModel().getQueryTree().getRoot().toString());
assertFalse(qp.getRanking().getFeatures().isEmpty());
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/ResultTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/ResultTestCase.java
index edbfe558ffd..28afe0611d4 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/ResultTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/ResultTestCase.java
@@ -4,11 +4,11 @@ package com.yahoo.prelude.test;
import java.util.Iterator;
import com.yahoo.search.Query;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.search.result.Hit;
import com.yahoo.search.Result;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
/**
* Tests the result class
@@ -18,16 +18,16 @@ import static org.junit.Assert.assertEquals;
public class ResultTestCase {
@Test
- public void testHitOrdering() {
- Result result=new Result(new Query("dummy"));
- result.hits().add(new Hit("test:hit1",80));
- result.hits().add(new Hit("test:hit2",90));
- result.hits().add(new Hit("test:hit3",70));
+ void testHitOrdering() {
+ Result result = new Result(new Query("dummy"));
+ result.hits().add(new Hit("test:hit1", 80));
+ result.hits().add(new Hit("test:hit2", 90));
+ result.hits().add(new Hit("test:hit3", 70));
- Iterator<?> hits= result.hits().deepIterator();
- assertEquals(new Hit("test:hit2",90),hits.next());
- assertEquals(new Hit("test:hit1",80),hits.next());
- assertEquals(new Hit("test:hit3",70),hits.next());
+ Iterator<?> hits = result.hits().deepIterator();
+ assertEquals(new Hit("test:hit2", 90), hits.next());
+ assertEquals(new Hit("test:hit1", 80), hits.next());
+ assertEquals(new Hit("test:hit3", 70), hits.next());
}
private void resultInit(Result result){
@@ -43,48 +43,48 @@ public class ResultTestCase {
}
@Test
- public void testHitTrimming(){
- Result result=new Result(new Query("dummy"));
+ void testHitTrimming() {
+ Result result = new Result(new Query("dummy"));
//case 1: keep some hits in the middle
resultInit(result);
result.hits().trim(3, 3);
- assertEquals(3,result.getHitCount());
- Iterator<Hit> hits= result.hits().deepIterator();
- assertEquals(new Hit("test:hit3",70),hits.next());
- assertEquals(new Hit("test:hit8",55),hits.next());
- assertEquals(new Hit("test:hit5",50),hits.next());
- assertEquals(false,hits.hasNext());
+ assertEquals(3, result.getHitCount());
+ Iterator<Hit> hits = result.hits().deepIterator();
+ assertEquals(new Hit("test:hit3", 70), hits.next());
+ assertEquals(new Hit("test:hit8", 55), hits.next());
+ assertEquals(new Hit("test:hit5", 50), hits.next());
+ assertEquals(false, hits.hasNext());
//case 2: keep some hits at the end
- result=new Result(new Query("dummy"));
+ result = new Result(new Query("dummy"));
resultInit(result);
result.hits().trim(5, 4);
- hits= result.hits().deepIterator();
- assertEquals(new Hit("test:hit5",50),hits.next());
- assertEquals(new Hit("test:hit4",40),hits.next());
- assertEquals(new Hit("test:hit6",20),hits.next());
- assertEquals(new Hit("test:hit7",20),hits.next());
- assertEquals(false,hits.hasNext());
+ hits = result.hits().deepIterator();
+ assertEquals(new Hit("test:hit5", 50), hits.next());
+ assertEquals(new Hit("test:hit4", 40), hits.next());
+ assertEquals(new Hit("test:hit6", 20), hits.next());
+ assertEquals(new Hit("test:hit7", 20), hits.next());
+ assertEquals(false, hits.hasNext());
//case 3: keep some hits at the beginning
- result=new Result(new Query("dummy"));
+ result = new Result(new Query("dummy"));
resultInit(result);
result.hits().trim(0, 4);
- hits= result.hits().deepIterator();
- assertEquals(new Hit("test:hit2",90),hits.next());
- assertEquals(new Hit("test:hit1",80),hits.next());
- assertEquals(new Hit("test:hit9",75),hits.next());
- assertEquals(new Hit("test:hit3",70),hits.next());
- assertEquals(false,hits.hasNext());
+ hits = result.hits().deepIterator();
+ assertEquals(new Hit("test:hit2", 90), hits.next());
+ assertEquals(new Hit("test:hit1", 80), hits.next());
+ assertEquals(new Hit("test:hit9", 75), hits.next());
+ assertEquals(new Hit("test:hit3", 70), hits.next());
+ assertEquals(false, hits.hasNext());
//case 4: keep no hits
- result=new Result(new Query("dummy"));
+ result = new Result(new Query("dummy"));
resultInit(result);
result.hits().trim(10, 4);
- hits= result.hits().deepIterator();
- assertEquals(false,hits.hasNext());
+ hits = result.hits().deepIterator();
+ assertEquals(false, hits.hasNext());
}
//This test is broken
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 {
diff --git a/container-search/src/test/java/com/yahoo/select/SelectTestCase.java b/container-search/src/test/java/com/yahoo/select/SelectTestCase.java
index 6ebcc3a1aae..887a1a3a033 100644
--- a/container-search/src/test/java/com/yahoo/select/SelectTestCase.java
+++ b/container-search/src/test/java/com/yahoo/select/SelectTestCase.java
@@ -33,18 +33,12 @@ import com.yahoo.search.query.SelectParser;
import com.yahoo.search.query.parser.Parsable;
import com.yahoo.search.query.parser.ParserEnvironment;
import com.yahoo.search.yql.VespaGroupingStep;
-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.assertFalse;
-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.*;
/**
* Tests Query.Select
@@ -61,7 +55,7 @@ public class SelectTestCase {
//------------------------------------------------------------------- "where" tests
@Test
- public void test_contains() {
+ void test_contains() {
ObjectNode json = jsonMapper.createObjectNode();
ArrayNode arrayNode = jsonMapper.createArrayNode();
arrayNode.add("default").add("foo");
@@ -70,22 +64,21 @@ public class SelectTestCase {
}
@Test
- public void test() {
+ void test() {
assertParse("{'contains' : ['title', 'madonna']}",
"title:madonna");
}
@Test
- public void testDottedFieldNames() {
+ void testDottedFieldNames() {
assertParse("{ 'contains' : ['my.nested.title', 'madonna']}",
"my.nested.title:madonna");
}
-
@Test
- public void testOr() throws Exception {
+ void testOr() throws Exception {
ObjectNode json_two_or = jsonMapper.createObjectNode();
ObjectNode json_three_or = jsonMapper.createObjectNode();
ArrayNode contains1 = jsonMapper.createArrayNode().add("title").add("madonna");
@@ -107,7 +100,7 @@ public class SelectTestCase {
}
@Test
- public void testAnd() throws Exception{
+ void testAnd() throws Exception {
ObjectNode json_two_and = jsonMapper.createObjectNode();
ObjectNode json_three_and = jsonMapper.createObjectNode();
ArrayNode contains1 = jsonMapper.createArrayNode().add("title").add("madonna");
@@ -129,7 +122,7 @@ public class SelectTestCase {
}
@Test
- public void testAndNot() {
+ void testAndNot() {
ObjectNode json_and_not = jsonMapper.createObjectNode();
ArrayNode contains1 = jsonMapper.createArrayNode().add("title").add("madonna");
ArrayNode contains2 = jsonMapper.createArrayNode().add("title").add("saint");
@@ -146,7 +139,7 @@ public class SelectTestCase {
}
@Test
- public void testLessThan() {
+ void testLessThan() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put("<", 500);
@@ -160,7 +153,7 @@ public class SelectTestCase {
}
@Test
- public void testGreaterThan() {
+ void testGreaterThan() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put(">", 500);
@@ -174,7 +167,7 @@ public class SelectTestCase {
}
@Test
- public void testLessThanOrEqual() {
+ void testLessThanOrEqual() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put("<=", 500);
@@ -188,7 +181,7 @@ public class SelectTestCase {
}
@Test
- public void testGreaterThanOrEqual() {
+ void testGreaterThanOrEqual() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put(">=", 500);
@@ -202,7 +195,7 @@ public class SelectTestCase {
}
@Test
- public void testEquality() {
+ void testEquality() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put("=", 500);
@@ -216,7 +209,7 @@ public class SelectTestCase {
}
@Test
- public void testNegativeLessThan() {
+ void testNegativeLessThan() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put("<", -500);
@@ -230,7 +223,7 @@ public class SelectTestCase {
}
@Test
- public void testNegativeGreaterThan() {
+ void testNegativeGreaterThan() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put(">", -500);
@@ -244,7 +237,7 @@ public class SelectTestCase {
}
@Test
- public void testNegativeLessThanOrEqual() {
+ void testNegativeLessThanOrEqual() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put("<=", -500);
@@ -258,7 +251,7 @@ public class SelectTestCase {
}
@Test
- public void testNegativeGreaterThanOrEqual() {
+ void testNegativeGreaterThanOrEqual() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put(">=", -500);
@@ -272,7 +265,7 @@ public class SelectTestCase {
}
@Test
- public void testNegativeEquality() {
+ void testNegativeEquality() {
ObjectNode range_json = jsonMapper.createObjectNode();
ObjectNode operators = jsonMapper.createObjectNode();
operators.put("=", -500);
@@ -286,38 +279,38 @@ public class SelectTestCase {
}
@Test
- public void testAnnotatedLessThan() {
+ void testAnnotatedLessThan() {
String jsonString = "{ \"range\": { \"children\" : [\"price\", {\"<\" : -500}], \"attributes\" : {\"filter\" : true} } }";
assertParse(jsonString, "|price:<-500");
}
@Test
- public void testAnnotatedGreaterThan() {
+ void testAnnotatedGreaterThan() {
String jsonString = "{ \"range\": { \"children\" : [\"price\", {\">\" : 500}], \"attributes\" : {\"filter\" : true} } }";
assertParse(jsonString, "|price:>500");
}
@Test
- public void testAnnotatedLessThanOrEqual() {
+ void testAnnotatedLessThanOrEqual() {
String jsonString = "{ \"range\": { \"children\" : [\"price\", {\"<=\" : -500}], \"attributes\" : {\"filter\" : true} } }";
assertParse(jsonString, "|price:[;-500]");
}
@Test
- public void testAnnotatedGreaterThanOrEqual() {
+ void testAnnotatedGreaterThanOrEqual() {
String jsonString = "{ \"range\": { \"children\" : [\"price\", {\">=\" : 500}], \"attributes\" : {\"filter\" : true} } }";
assertParse(jsonString, "|price:[500;]");
}
@Test
- public void testAnnotatedEquality() {
+ void testAnnotatedEquality() {
String jsonString = "{ \"range\": { \"children\" : [\"price\", {\"=\" : -500}], \"attributes\" : {\"filter\" : true} } }";
assertParse(jsonString, "|price:-500");
}
@Test
- public void testTermAnnotations() {
+ void testTermAnnotations() {
assertEquals("merkelapp",
getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"label\" : \"merkelapp\"} } }").getLabel());
assertEquals("another",
@@ -334,7 +327,7 @@ public class SelectTestCase {
}
@Test
- public void testSameElement() {
+ void testSameElement() {
assertParse("{ \"contains\": [ \"baz\", {\"sameElement\" : [ { \"contains\" : [\"f1\", \"a\"] }, { \"contains\" : [\"f2\", \"b\"] } ]} ] }",
"baz:{f1:a f2:b}");
@@ -346,53 +339,53 @@ public class SelectTestCase {
}
@Test
- public void testPhrase() {
+ void testPhrase() {
assertParse("{ \"contains\": [ \"baz\", {\"phrase\" : [ \"a\", \"b\"] } ] }",
"baz:\"a b\"");
}
@Test
- public void testNestedPhrase() {
+ void testNestedPhrase() {
assertParse("{ \"contains\": [ \"baz\", {\"phrase\" : [ \"a\", \"b\", {\"phrase\" : [ \"c\", \"d\"] }] } ] }",
"baz:\"a b c d\"");
}
@Test
- public void testStemming() {
+ void testStemming() {
assertTrue(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"stem\" : false} } }").isStemmed());
assertFalse(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"stem\" : true} } }").isStemmed());
assertFalse(getRootWord("{ \"contains\": [\"baz\", \"colors\"] }").isStemmed());
}
@Test
- public void testRaw() {
+ void testRaw() {
Item root = parseWhere("{ \"contains\":[ \"baz\", \"yoni jo dima\" ] }").getRoot();
assertTrue(root instanceof WordItem);
assertFalse(root instanceof ExactStringItem);
- assertEquals("yoni jo dima", ((WordItem)root).getWord());
+ assertEquals("yoni jo dima", ((WordItem) root).getWord());
root = parseWhere("{ \"contains\": { \"children\" : [\"baz\", \"yoni jo dima\"], \"attributes\" : {\"grammar\" : \"raw\"} } }").getRoot();
assertTrue(root instanceof WordItem);
assertFalse(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("{ \"contains\": { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"accentDrop\" : false} } }").isNormalizable());
assertTrue(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"accentDrop\" : true} } }").isNormalizable());
assertTrue(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"] } }").isNormalizable());
}
@Test
- public void testCaseNormalization() {
+ void testCaseNormalization() {
assertTrue(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"normalizeCase\" : false} } }").isLowercased());
assertFalse(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"normalizeCase\" : true} } }").isLowercased());
assertFalse(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"] } }").isLowercased());
}
@Test
- public void testSegmentingRule() {
+ void testSegmentingRule() {
assertEquals(SegmentingRule.PHRASE,
getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"andSegmenting\" : false} } }").getSegmentingRule());
assertEquals(SegmentingRule.BOOLEAN_AND,
@@ -402,30 +395,30 @@ public class SelectTestCase {
}
@Test
- public void testNfkc() {
+ void testNfkc() {
assertEquals("a\u030a", getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"a\\u030a\"], \"attributes\" : {\"nfkc\" : false} } }").getWord());
assertEquals("\u00e5", getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"a\\u030a\"], \"attributes\" : {\"nfkc\" : true} } }").getWord());
- assertEquals("No NKFC by default", "a\u030a", getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"a\\u030a\"] } } ").getWord());
+ assertEquals("a\u030a", getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"a\\u030a\"] } } ").getWord(), "No NKFC by default");
}
@Test
- public void testImplicitTransforms() {
+ void testImplicitTransforms() {
assertFalse(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"cox\"], \"attributes\" : {\"implicitTransforms\" : false} } }").isFromQuery());
assertTrue(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"cox\"], \"attributes\" : {\"implicitTransforms\" : true} } }").isFromQuery());
assertTrue(getRootWord("{ \"contains\": { \"children\" : [\"baz\", \"cox\"] } }").isFromQuery());
}
@Test
- public void testConnectivity() {
+ void testConnectivity() {
QueryTree parsed = parseWhere("{ \"and\": [ {\"contains\" : { \"children\" : [\"title\", \"madonna\"], \"attributes\" : {\"id\": 1, \"connectivity\": {\"id\": 3, \"weight\": 7.0}} } }, " +
"{ \"contains\" : { \"children\" : [\"title\", \"saint\"], \"attributes\" : {\"id\": 2} } }, " +
"{ \"contains\" : { \"children\" : [\"title\", \"angel\"], \"attributes\" : {\"id\": 3} } } ] }");
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);
+ AndItem root = (AndItem) parsed.getRoot();
+ WordItem first = (WordItem) root.getItem(0);
+ WordItem second = (WordItem) root.getItem(1);
+ WordItem third = (WordItem) root.getItem(2);
assertEquals(third, first.getConnectedItem());
assertEquals(first.getConnectivity(), 7.0d, 1E-6);
assertNull(second.getConnectedItem());
@@ -434,37 +427,37 @@ public class SelectTestCase {
"{ \"contains\" : { \"children\" : [\"title\", \"saint\"], \"attributes\" : {\"id\": 2} } }, " +
"{ \"contains\" : { \"children\" : [\"title\", \"angel\"], \"attributes\" : {\"id\": 3} } } ] }",
new IllegalArgumentException("Item 'title:madonna' was specified to connect to item with ID 4, " +
- "which does not exist in the query."));
+ "which does not exist in the query."));
}
@Test
- public void testAnnotatedPhrase() {
+ void testAnnotatedPhrase() {
QueryTree parsed = parseWhere("{ \"contains\": [\"baz\", { \"phrase\": { \"children\": [\"a\", \"b\"], \"attributes\": { \"label\": \"hello world\" } } }] }");
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 = parseWhere("{ \"range\": [\"baz\", { \">=\": 1, \"<=\": 8 }] }");
assertEquals("baz:[1;8]", parsed.toString());
}
@Test
- public void testNegativeRange() {
+ void testNegativeRange() {
QueryTree parsed = parseWhere("{ \"range\": [\"baz\", { \">=\": -8, \"<=\": -1 }] }");
assertEquals("baz:[-8;-1]", parsed.toString());
}
@Test
- public void testRangeIllegalArguments() {
+ void testRangeIllegalArguments() {
assertParseFail("{ \"range\": [\"baz\", { \">=\": \"cox\", \"<=\": -1 }] }",
new IllegalArgumentException("Expected a numeric argument to range, but got the string 'cox'"));
}
@Test
- public void testNear() {
+ void testNear() {
assertParse("{ \"contains\": [\"description\", { \"near\": [\"a\", \"b\"] }] }",
"NEAR(2) description:a description:b");
assertParse("{ \"contains\": [\"description\", { \"near\": { \"children\": [\"a\", \"b\"], \"attributes\": { \"distance\": 100 } } } ] }",
@@ -472,7 +465,7 @@ public class SelectTestCase {
}
@Test
- public void testOrderedNear() {
+ void testOrderedNear() {
assertParse("{ \"contains\": [\"description\", { \"onear\": [\"a\", \"b\"] }] }",
"ONEAR(2) description:a description:b");
assertParse("{ \"contains\": [\"description\", { \"onear\": { \"children\": [\"a\", \"b\"], \"attributes\": { \"distance\": 100 } } } ] }",
@@ -480,7 +473,7 @@ public class SelectTestCase {
}
@Test
- public void testWand() {
+ void testWand() {
assertParse("{ \"wand\": [\"description\", { \"a\": 1, \"b\": 2 }] }",
"WAND(10,0.0,1.0) description{[1]:\"a\",[2]:\"b\"}");
assertParse("{ \"wand\": { \"children\": [\"description\", { \"a\": 1, \"b\": 2 }], \"attributes\": { \"scoreThreshold\": 13.3, \"targetHits\": 7, \"thresholdBoostFactor\": 2.3 } } }",
@@ -488,7 +481,7 @@ public class SelectTestCase {
}
@Test
- public void testNumericWand() {
+ void testNumericWand() {
String numWand = "WAND(10,0.0,1.0) description{[1]:\"11\",[2]:\"37\"}";
assertParse("{ \"wand\" : [\"description\", [[11,1], [37,2]] ]}", numWand);
assertParseFail("{ \"wand\" : [\"description\", 12] }",
@@ -496,7 +489,7 @@ public class SelectTestCase {
}
@Test
- public void testWeightedSet() {
+ void testWeightedSet() {
assertParse("{ \"weightedSet\" : [\"description\", {\"a\":1, \"b\":2} ]}",
"WEIGHTEDSET description{[1]:\"a\",[2]:\"b\"}");
assertParseFail("{ \"weightedSet\" : [\"description\", {\"a\":\"g\", \"b\":2} ]}",
@@ -506,7 +499,7 @@ public class SelectTestCase {
}
@Test
- public void testDotProduct() {
+ void testDotProduct() {
assertParse("{ \"dotProduct\" : [\"description\", {\"a\":1, \"b\":2} ]}",
"DOTPRODUCT description{[1]:\"a\",[2]:\"b\"}");
assertParse("{ \"dotProduct\" : [\"description\", {\"a\":2} ]}",
@@ -514,7 +507,7 @@ public class SelectTestCase {
}
@Test
- public void testPredicate() {
+ void testPredicate() {
assertParse("{ \"predicate\" : [\"predicate_field\", {\"gender\":\"male\", \"hobby\":[\"music\", \"hiking\"]}, {\"age\":23} ]}",
"PREDICATE_QUERY_ITEM gender=male, hobby=music, hobby=hiking, age:23");
assertParse("{ \"predicate\" : [\"predicate_field\", 0, \"void\" ]}",
@@ -522,7 +515,7 @@ public class SelectTestCase {
}
@Test
- public void testRank() {
+ void testRank() {
assertParse("{ \"rank\": [{ \"contains\": [\"a\", \"A\"] }, { \"contains\": [\"b\", \"B\"] } ] }",
"RANK a:A b:B");
assertParse("{ \"rank\": [{ \"contains\": [\"a\", \"A\"] }, { \"contains\": [\"b\", \"B\"] }, { \"contains\": [\"c\", \"C\"] } ] }",
@@ -532,19 +525,19 @@ public class SelectTestCase {
}
@Test
- public void testGeoLocation() {
+ void testGeoLocation() {
assertParse("{ \"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("{ \"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("{ \"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)");
assertParse("{ \"geoLocation\": [ \"workplace\", -12.0, -34.0, \"-77 deg\" ] }",
- "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("{ \"nearestNeighbor\": [ \"f1field\", \"q2prop\" ] }",
"NEAREST_NEIGHBOR {field=f1field,queryTensorName=q2prop,hnsw.exploreAdditionalHits=0,distanceThreshold=Infinity,approximate=true,targetHits=0}");
@@ -554,7 +547,7 @@ public class SelectTestCase {
@Test
@SuppressWarnings("deprecation")
- public void testWeakAnd() {
+ void testWeakAnd() {
assertParse("{ \"weakAnd\": [{ \"contains\": [\"a\", \"A\"] }, { \"contains\": [\"b\", \"B\"] } ] }",
"WEAKAND(100) a:A b:B");
assertParse("{ \"weakAnd\": { \"children\" : [{ \"contains\": [\"a\", \"A\"] }, { \"contains\": [\"b\", \"B\"] } ], \"attributes\" : {\"targetHits\": 37} }}",
@@ -566,7 +559,7 @@ public class SelectTestCase {
}
@Test
- public void testEquiv() {
+ void testEquiv() {
assertParse("{ \"contains\" : [\"fieldName\", {\"equiv\" : [\"A\",\"B\"]}]}",
"EQUIV fieldName:A fieldName:B");
@@ -582,42 +575,42 @@ public class SelectTestCase {
}
@Test
- public void testAffixItems() {
+ void testAffixItems() {
assertRootClass("{ \"contains\" : { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"suffix\": true} } }",
- SuffixItem.class);
+ SuffixItem.class);
assertRootClass("{ \"contains\" : { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"prefix\": true} } }",
- PrefixItem.class);
+ PrefixItem.class);
assertRootClass("{ \"contains\" : { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"substring\": true} } }",
- SubstringItem.class);
+ SubstringItem.class);
assertParseFail("{ \"contains\" : { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"suffix\": true, \"prefix\" : true} } }",
- new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
+ new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
assertParseFail("{ \"contains\" : { \"children\" : [\"baz\", \"colors\"], \"attributes\" : {\"suffix\": true, \"substring\" : true} } }",
- new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
+ new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
}
@Test
- public void testLongNumberInSimpleExpression() {
+ void testLongNumberInSimpleExpression() {
assertParse("{ \"range\" : [ \"price\", { \"=\" : 8589934592 }]}",
"price:8589934592");
}
@Test
- public void testNegativeLongNumberInSimpleExpression() {
+ void testNegativeLongNumberInSimpleExpression() {
assertParse("{ \"range\" : [ \"price\", { \"=\" : -8589934592 }]}",
"price:-8589934592");
}
@Test
- public void testNegativeHitLimit() {
+ void testNegativeHitLimit() {
assertParse(
"{ \"range\" : { \"children\":[ \"foo\", { \">=\" : 0, \"<=\" : 1 }], \"attributes\" : {\"hitLimit\": -38 } } }",
"foo:[0;1;-38]");
}
@Test
- public void testRangeSearchHitPopulationOrdering() {
+ void testRangeSearchHitPopulationOrdering() {
assertParse("{ \"range\" : { \"children\":[ \"foo\", { \">=\" : 0, \"<=\" : 1 }], \"attributes\" : {\"hitLimit\": 38 ,\"ascending\": true} } }", "foo:[0;1;38]");
assertParse("{ \"range\" : { \"children\":[ \"foo\", { \">=\" : 0, \"<=\" : 1 }], \"attributes\" : {\"hitLimit\": 38 ,\"ascending\": false} } }", "foo:[0;1;-38]");
assertParse("{ \"range\" : { \"children\":[ \"foo\", { \">=\" : 0, \"<=\" : 1 }], \"attributes\" : {\"hitLimit\": 38 ,\"descending\": true} } }", "foo:[0;1;-38]");
@@ -627,8 +620,8 @@ public class SelectTestCase {
try {
parseWhere("{ \"range\" : { \"children\":[ \"foo\", { \">=\" : 0, \"<=\" : 1 }], \"attributes\" : {\"hitLimit\": 38, \"ascending\": true, \"descending\": false} } }");
} catch (IllegalArgumentException e) {
- assertTrue("Expected information about abuse of settings.",
- e.getCause().getMessage().contains("both ascending and descending ordering set"));
+ assertTrue(e.getCause().getMessage().contains("both ascending and descending ordering set"),
+ "Expected information about abuse of settings.");
gotExceptionFromParse = true;
}
assertTrue(gotExceptionFromParse);
@@ -636,9 +629,9 @@ public class SelectTestCase {
// NB: Uses operator-keys to set bounds, not annotations
@Test
- public void testOpenIntervals() {
+ void testOpenIntervals() {
assertParse("{ \"range\" : { \"children\":[ \"title\", { \">=\" : 0.0, \"<=\" : 500.0 }] } }" +
- "select * from sources * where range(title, 0.0, 500.0)",
+ "select * from sources * where range(title, 0.0, 500.0)",
"title:[0.0;500.0]");
assertParse(
"{ \"range\" : { \"children\":[ \"title\", { \">\" : 0.0, \"<\" : 500.0 }] } }",
@@ -652,13 +645,13 @@ public class SelectTestCase {
}
@Test
- public void testEquals() {
- assertParse("{\"equals\": [\"public\",true]}","public:true");
- assertParse("{\"equals\": [\"public\",5]}","public:5");
+ void testEquals() {
+ assertParse("{\"equals\": [\"public\",true]}", "public:true");
+ assertParse("{\"equals\": [\"public\",5]}", "public:5");
}
@Test
- public void testRegexp() {
+ void testRegexp() {
QueryTree x = parseWhere("{ \"matches\" : [\"foo\", \"a b\"]}");
Item root = x.getRoot();
assertSame(RegExpItem.class, root.getClass());
@@ -666,7 +659,7 @@ public class SelectTestCase {
}
@Test
- public void testWordAlternatives() {
+ void testWordAlternatives() {
QueryTree x = parseWhere("{\"contains\" : [\"foo\", {\"alternatives\" : [{\"trees\": 1.0, \"tree\": 0.7}]}]}");
Item root = x.getRoot();
assertSame(WordAlternativesItem.class, root.getClass());
@@ -675,7 +668,7 @@ public class SelectTestCase {
}
@Test
- public void testFuzzy() {
+ void testFuzzy() {
QueryTree x = parseWhere("{ \"contains\": [\"description\", { \"fuzzy\": [\"a b\"] }] }");
Item root = x.getRoot();
assertSame(FuzzyItem.class, root.getClass());
@@ -686,14 +679,14 @@ public class SelectTestCase {
//------------------------------------------------------------------- grouping tests
@Test
- public void testGrouping(){
+ void testGrouping() {
String grouping = "[ { \"all\" : { \"group\" : \"time.year(a)\", \"each\" : { \"output\" : \"count()\" } } } ]";
String expected = "[[]all(group(time.year(a)) each(output(count())))]";
assertGrouping(expected, parseGrouping(grouping));
}
@Test
- public void testMultipleGroupings() {
+ void testMultipleGroupings() {
String grouping = "[ { \"all\" : { \"group\" : \"a\", \"each\" : { \"output\" : \"count()\"}}}, { \"all\" : { \"group\" : \"b\", \"each\" : { \"output\" : \"count()\"}}} ]";
String expected = "[[]all(group(a) each(output(count()))), []all(group(b) each(output(count())))]";
@@ -701,14 +694,14 @@ public class SelectTestCase {
}
@Test
- public void testGroupingWithPredefinedBuckets() {
+ void testGroupingWithPredefinedBuckets() {
String grouping = "[ { \"all\" : { \"group\" : { \"predefined\" : [ \"foo\", { \"bucket\": [1,2]}, { \"bucket\": [3,4]} ] } } } ]";
String expected = "[[]all(group(predefined(foo, bucket[1, 2>, bucket[3, 4>)))]";
assertGrouping(expected, parseGrouping(grouping));
}
@Test
- public void testMultipleOutputs() {
+ void testMultipleOutputs() {
String grouping = "[ { \"all\" : { \"group\" : \"b\", \"each\" : {\"output\": [ \"count()\", \"avg(foo)\" ] } } } ]";
String expected = "[[]all(group(b) each(output(count(), avg(foo))))]";
assertGrouping(expected, parseGrouping(grouping));
@@ -717,7 +710,7 @@ public class SelectTestCase {
//------------------------------------------------------------------- Other tests
@Test
- public void testOverridingOtherQueryTree() {
+ void testOverridingOtherQueryTree() {
Query query = new Query("?query=default:query");
assertEquals("WEAKAND(100) default:query", query.getModel().getQueryTree().toString());
assertEquals(Query.Type.WEAKAND, query.getModel().getType());
@@ -728,7 +721,7 @@ public class SelectTestCase {
}
@Test
- public void testOverridingWhereQueryTree() {
+ void testOverridingWhereQueryTree() {
Query query = new Query("?query=default:query");
query.getSelect().setWhereString("{\"contains\" : [\"default\", \"select\"] }");
assertEquals("default:select", query.getModel().getQueryTree().toString());
@@ -741,7 +734,7 @@ public class SelectTestCase {
}
@Test
- public void testProgrammaticAssignment() {
+ void testProgrammaticAssignment() {
Query query = new Query();
query.getSelect().setGroupingString("[ { \"all\" : { \"group\" : \"time.year(a)\", \"each\" : { \"output\" : \"count()\" } } } ]");
assertEquals(1, query.getSelect().getGrouping().size());
@@ -754,7 +747,7 @@ public class SelectTestCase {
}
@Test
- public void testConstructionAndClone() {
+ void testConstructionAndClone() {
Query query = new Query();
query.getSelect().setWhereString("{\"contains\" : [\"default\", \"select\"] }");
query.getSelect().setGroupingString("[ { \"all\" : { \"group\" : \"time.dayofmonth(a)\", \"each\" : { \"output\" : \"count()\" } } } ]");
@@ -776,7 +769,7 @@ public class SelectTestCase {
}
@Test
- public void testCloneWithGroupingExpressionString() {
+ void testCloneWithGroupingExpressionString() {
Query query = new Query();
query.getSelect().setGroupingExpressionString("all(group(foo) each(output(count())))");
@@ -785,12 +778,12 @@ public class SelectTestCase {
}
@Test
- public void testProgrammaticBuilding() {
+ void testProgrammaticBuilding() {
String expected =
"all(group(myfield) max(10000) each(" +
- "output(min(foo), max(bar)) " +
- "all(group(foo) max(10000) output(count()))" +
- "))";
+ "output(min(foo), max(bar)) " +
+ "all(group(foo) max(10000) output(count()))" +
+ "))";
Query query = new Query();
GroupingRequest grouping = GroupingRequest.newInstance(query);
AllOperation root = new AllOperation();
@@ -871,11 +864,11 @@ public class SelectTestCase {
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 {
diff --git a/container-search/src/test/java/com/yahoo/text/interpretation/test/AnnotationTestCase.java b/container-search/src/test/java/com/yahoo/text/interpretation/test/AnnotationTestCase.java
index f439db390ee..fcb77851f0f 100644
--- a/container-search/src/test/java/com/yahoo/text/interpretation/test/AnnotationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/text/interpretation/test/AnnotationTestCase.java
@@ -11,12 +11,9 @@ import com.yahoo.text.interpretation.AnnotationClass;
import com.yahoo.text.interpretation.Annotations;
import com.yahoo.text.interpretation.Interpretation;
import com.yahoo.text.interpretation.Span;
-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.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Arne Bergene Fossaa
@@ -24,12 +21,12 @@ import static org.junit.Assert.assertTrue;
public class AnnotationTestCase {
@Test
- public void testSimpleAnnotations() {
- Interpretation i= new Interpretation("new york hotel");
- i.annotate("sentence").put("isValid",true);
- i.annotate(0,3,"token");
- i.annotate(0,8,"place_name").put("^taxonomy:place_category","city");
- i.annotate(0,8,"place_name").put("woeid","12345678");
+ void testSimpleAnnotations() {
+ Interpretation i = new Interpretation("new york hotel");
+ i.annotate("sentence").put("isValid", true);
+ i.annotate(0, 3, "token");
+ i.annotate(0, 8, "place_name").put("^taxonomy:place_category", "city");
+ i.annotate(0, 8, "place_name").put("woeid", "12345678");
//i.getInterpretationAnnotation().put("domain","jaffa");
i.setProbability(0.5);
@@ -37,32 +34,32 @@ public class AnnotationTestCase {
}
@Test
- public void testAnnotationAPI() {
+ void testAnnotationAPI() {
Interpretation a = new Interpretation("new york hotel");
- a.annotate(0,3,"token");
- a.annotate(0,8,"state").put("name","New York");
- a.annotate(0,8,"state").put("country","US");
- a.annotate(0,8,"state").put("coast","east");
- a.annotate(9,14,"business");
- a.annotate(4,8,"token");
- a.annotate(9,14,"token");
+ a.annotate(0, 3, "token");
+ a.annotate(0, 8, "state").put("name", "New York");
+ a.annotate(0, 8, "state").put("country", "US");
+ a.annotate(0, 8, "state").put("coast", "east");
+ a.annotate(9, 14, "business");
+ a.annotate(4, 8, "token");
+ a.annotate(9, 14, "token");
- for(Span span : a.getTokens()) {
+ for (Span span : a.getTokens()) {
assertTrue(span.hasClass(new AnnotationClass("token")));
}
- Set<AnnotationClass> annotationClasses = a.getClasses(0,3);
+ Set<AnnotationClass> annotationClasses = a.getClasses(0, 3);
Set<AnnotationClass> testClass = new HashSet<>(Arrays.asList(
new AnnotationClass("token"), new AnnotationClass("state")));
- assertEquals(testClass,annotationClasses);
+ assertEquals(testClass, annotationClasses);
- assertNull(a.get("state","country"));
- assertEquals("US", a.get(0,8,"state","country"));
+ assertNull(a.get("state", "country"));
+ assertEquals("US", a.get(0, 8, "state", "country"));
assertEquals("new york", a.root().getSubSpans().get(0).getText());
assertEquals("hotel", a.root().getSubSpans().get(1).getText());
- assertEquals(2,a.root().getSubSpans().size());
+ assertEquals(2, a.root().getSubSpans().size());
//Test scoring
@@ -77,37 +74,37 @@ public class AnnotationTestCase {
//This is bad about the API, getTokens may not necessairily return what a user thinks a token is
//But it should still be tested
- a.annotate(0,1,"n");
- Set<String> testSet = new HashSet<>(Arrays.asList("n","york","hotel"));
- for(Span span:a.getTokens()) {
+ a.annotate(0, 1, "n");
+ Set<String> testSet = new HashSet<>(Arrays.asList("n", "york", "hotel"));
+ for (Span span :a.getTokens()) {
assertTrue(testSet.remove(span.getText()));
}
- assertEquals(0,testSet.size());
+ assertEquals(0, testSet.size());
}
//The following testcase is a test with the api on a use_case, no cornercases here
@Test
- public void testUsability() {
+ void testUsability() {
Interpretation interpretation = new Interpretation("new york crab pizza");
- interpretation.annotate(0,8,"place_name").put("^taxonomy:place_category","city");
- interpretation.annotate(0,8,"place_name").put("woe_id",2459115);
- interpretation.annotate(9,13,"food");
- interpretation.annotate(14,19,"food");
+ interpretation.annotate(0, 8, "place_name").put("^taxonomy:place_category", "city");
+ interpretation.annotate(0, 8, "place_name").put("woe_id", 2459115);
+ interpretation.annotate(9, 13, "food");
+ interpretation.annotate(14, 19, "food");
//Here we want to write code that finds out if the interpretation
//matches pizza and toppings.
List<Span> pizzaSpans = interpretation.getTermSpans("pizza");
- if(pizzaSpans.size() > 0) {
+ if (pizzaSpans.size() > 0) {
//We know that we have pizza, now we want to get some topping
//In a perfect world, pizza topping would have its own annotation class
//but for now, we'll just accept terms that have been tokenized with food
List<String> toppings = new ArrayList<>();
- for(Annotations annotations :interpretation.getAll("food")) {
- if(!annotations.getSubString().equalsIgnoreCase("pizza")) {
+ for (Annotations annotations :interpretation.getAll("food")) {
+ if (!annotations.getSubString().equalsIgnoreCase("pizza")) {
toppings.add(annotations.getSubString());
}
}
@@ -116,13 +113,13 @@ public class AnnotationTestCase {
//that all spans that has the annotation "place_name" has a "woe_id".
int woe_id = 0;
- for(Annotations annotations :interpretation.getAll("place_name")) {
+ for (Annotations annotations :interpretation.getAll("place_name")) {
//This will return either 0 or throw a bad exception
//if a number is not found
woe_id = annotations.getInteger("woe_id");
}
- assertEquals(Arrays.asList("crab"),toppings);
- assertEquals(2459115,woe_id);
+ assertEquals(Arrays.asList("crab"), toppings);
+ assertEquals(2459115, woe_id);
}
}
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/ListMergerTestCase.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/ListMergerTestCase.java
index 5523fe3c893..97dc2674256 100644
--- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/ListMergerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/ListMergerTestCase.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.streamingvisitors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.LinkedList;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Ulf Carlin
@@ -31,9 +31,9 @@ public class ListMergerTestCase {
}
@Test
- public void testMergeLists() {
+ void testMergeLists() {
int entryCount = 6;
- int padding = (int)Math.log10(entryCount) + 1;
+ int padding = (int) Math.log10(entryCount) + 1;
List<String> list1 = new LinkedList<>();
List<String> list2 = new LinkedList<>();
@@ -42,17 +42,17 @@ public class ListMergerTestCase {
List<String> newList = ListMerger.mergeIntoArrayList(list1, list2);
verifyList(newList, entryCount, padding);
- newList = ListMerger.mergeIntoArrayList(list1, list2, entryCount/2);
- verifyList(newList, entryCount/2, padding);
+ newList = ListMerger.mergeIntoArrayList(list1, list2, entryCount / 2);
+ verifyList(newList, entryCount / 2, padding);
- ListMerger.mergeLinkedLists(list1, list2, entryCount/2);
- verifyList(list1, entryCount/2, padding);
+ ListMerger.mergeLinkedLists(list1, list2, entryCount / 2);
+ verifyList(list1, entryCount / 2, padding);
}
@Test
- public void testMergeListsReversed() {
+ void testMergeListsReversed() {
int entryCount = 6;
- int padding = (int)Math.log10(entryCount) + 1;
+ int padding = (int) Math.log10(entryCount) + 1;
List<String> list1 = new LinkedList<>();
List<String> list2 = new LinkedList<>();
@@ -61,11 +61,11 @@ public class ListMergerTestCase {
List<String> newList = ListMerger.mergeIntoArrayList(list1, list2);
verifyList(newList, entryCount, padding);
- newList = ListMerger.mergeIntoArrayList(list1, list2, entryCount/2);
- verifyList(newList, entryCount/2, padding);
+ newList = ListMerger.mergeIntoArrayList(list1, list2, entryCount / 2);
+ verifyList(newList, entryCount / 2, padding);
- ListMerger.mergeLinkedLists(list1, list2, entryCount/2);
- verifyList(list1, entryCount/2, padding);
+ ListMerger.mergeLinkedLists(list1, list2, entryCount / 2);
+ verifyList(list1, entryCount / 2, padding);
}
}
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java
index c407945ee15..8e2380f72c2 100644
--- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java
@@ -9,11 +9,9 @@ import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.vdslib.VisitorStatistics;
-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.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Ulf Carlin
@@ -36,12 +34,12 @@ public class MetricsSearcherTestCase {
assertEquals("news:0", result.hits().get(0).getId().toString());
} else {
assertNotNull(result.hits().getError());
- assertTrue("Expected '" + message + "' to be contained in '"
- + result.hits().getErrorHit().errors().iterator().next().getMessage() + "'",
- result.hits().getErrorHit().errors().iterator().next().getMessage().contains(message));
- assertTrue("Expected '" + detailedMessage + "' to be contained in '"
- + result.hits().getErrorHit().errors().iterator().next().getDetailedMessage() + "'",
- result.hits().getErrorHit().errors().iterator().next().getDetailedMessage().contains(detailedMessage));
+ assertTrue(result.hits().getErrorHit().errors().iterator().next().getMessage().contains(message),
+ "Expected '" + message + "' to be contained in '"
+ + result.hits().getErrorHit().errors().iterator().next().getMessage() + "'");
+ assertTrue(result.hits().getErrorHit().errors().iterator().next().getDetailedMessage().contains(detailedMessage),
+ "Expected '" + detailedMessage + "' to be contained in '"
+ + result.hits().getErrorHit().errors().iterator().next().getDetailedMessage() + "'");
}
if (metricParam == null) {
@@ -77,21 +75,21 @@ public class MetricsSearcherTestCase {
}
@Test
- public void testBasics() {
+ void testBasics() {
// Start counting at -1 since count is reset upon the first query by MetricsSearcher.search
expStatsLt1.count--;
- String[] loadTypes = { LOADTYPE1, LOADTYPE2};
+ String[] loadTypes = {LOADTYPE1, LOADTYPE2};
for (String loadType : loadTypes) {
- verifySearch("streaming.loadtype="+loadType, null, null);
- verifySearch("metricsearcher.id="+loadType, null, null);
+ verifySearch("streaming.loadtype=" + loadType, null, null);
+ verifySearch("metricsearcher.id=" + loadType, null, null);
verifySearch(null, null, null);
- verifySearch("streaming.loadtype="+loadType, "Backend communication error", "Detailed error message");
+ verifySearch("streaming.loadtype=" + loadType, "Backend communication error", "Detailed error message");
}
}
@Test
- public void searcherDoesNotTryToDereferenceNullQueryContext() {
+ void searcherDoesNotTryToDereferenceNullQueryContext() {
backend.setImplicitlyCreateContext(false);
// This will crash with an NPE if the searcher does not cope with null
// query contexts.
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java
index 3cf2a38982a..0ecf1db01e5 100644
--- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java
@@ -23,7 +23,7 @@ import com.yahoo.vespa.streamingvisitors.tracing.MockUtils;
import com.yahoo.vespa.streamingvisitors.tracing.MonotonicNanoClock;
import com.yahoo.vespa.streamingvisitors.tracing.SamplingStrategy;
import com.yahoo.vespa.streamingvisitors.tracing.TraceExporter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashMap;
@@ -31,11 +31,7 @@ import java.util.List;
import java.util.Map;
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.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -185,12 +181,12 @@ public class VdsStreamingSearcherTestCase {
for (Query query : generateTestQueries(queryString)) {
Result result = executeQuery(searcher, query);
assertNotNull(result.hits().getError());
- assertTrue("Expected '" + message + "' to be contained in '"
- + result.hits().getErrorHit().errors().iterator().next().getMessage() + "'",
- result.hits().getErrorHit().errors().iterator().next().getMessage().contains(message));
- assertTrue("Expected '" + detailedMessage + "' to be contained in '"
- + result.hits().getErrorHit().errors().iterator().next().getDetailedMessage() + "'",
- result.hits().getErrorHit().errors().iterator().next().getDetailedMessage().contains(detailedMessage));
+ assertTrue(result.hits().getErrorHit().errors().iterator().next().getMessage().contains(message),
+ "Expected '" + message + "' to be contained in '"
+ + result.hits().getErrorHit().errors().iterator().next().getMessage() + "'");
+ assertTrue(result.hits().getErrorHit().errors().iterator().next().getDetailedMessage().contains(detailedMessage),
+ "Expected '" + detailedMessage + "' to be contained in '"
+ + result.hits().getErrorHit().errors().iterator().next().getDetailedMessage() + "'");
}
}
@@ -217,17 +213,17 @@ public class VdsStreamingSearcherTestCase {
}
@Test
- public void testBasics() {
+ void testBasics() {
MockVisitorFactory factory = new MockVisitorFactory();
VdsStreamingSearcher searcher = new VdsStreamingSearcher(factory);
var schema = new Schema.Builder("test");
schema.add(new com.yahoo.search.schema.DocumentSummary.Builder("default").build());
searcher.init("container.0",
- new SummaryParameters("default"),
- new ClusterParams("clusterName"),
- new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("test")).build(),
- new SchemaInfo(List.of(schema.build()), Map.of()));
+ new SummaryParameters("default"),
+ new ClusterParams("clusterName"),
+ new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("test")).build(),
+ new SchemaInfo(List.of(schema.build()), Map.of()));
// Magic query values are used to trigger specific behaviors from mock visitor.
checkError(searcher, "/?query=noselection",
@@ -256,7 +252,7 @@ public class VdsStreamingSearcherTestCase {
}
@Test
- public void testVerifyDocId() {
+ void testVerifyDocId() {
Query generalQuery = new Query("/?streaming.selection=true&query=test");
Query user1Query = new Query("/?streaming.userid=1&query=test");
Query group1Query = new Query("/?streaming.groupname=group1&query=test");
@@ -321,7 +317,7 @@ public class VdsStreamingSearcherTestCase {
}
@Test
- public void trace_level_set_if_sampling_strategy_returns_true() {
+ void trace_level_set_if_sampling_strategy_returns_true() {
var f = TraceFixture.withSampledTrace(true);
executeQuery(f.searcher, new Query("/?streaming.userid=1&query=timeoutexception"));
@@ -330,7 +326,7 @@ public class VdsStreamingSearcherTestCase {
}
@Test
- public void trace_level_not_set_if_sampling_strategy_returns_false() {
+ void trace_level_not_set_if_sampling_strategy_returns_false() {
var f = TraceFixture.withSampledTrace(false);
executeQuery(f.searcher, new Query("/?streaming.userid=1&query=timeoutexception"));
@@ -339,7 +335,7 @@ public class VdsStreamingSearcherTestCase {
}
@Test
- public void trace_is_exported_if_timed_out_beyond_threshold() {
+ void trace_is_exported_if_timed_out_beyond_threshold() {
// Default mock timeout threshold is 2x timeout
var f = TraceFixture.withTracingAndClockSampledAt(1000, 3001);
executeQuery(f.searcher, new Query("/?streaming.userid=1&query=timeoutexception&timeout=1.0"));
@@ -348,7 +344,7 @@ public class VdsStreamingSearcherTestCase {
}
@Test
- public void trace_is_not_exported_if_timed_out_less_than_threshold() {
+ void trace_is_not_exported_if_timed_out_less_than_threshold() {
// Default mock timeout threshold is 2x timeout
var f = TraceFixture.withTracingAndClockSampledAt(1000, 2999);
executeQuery(f.searcher, new Query("/?streaming.userid=1&query=timeoutexception&timeout=1.0"));
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsVisitorTestCase.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsVisitorTestCase.java
index 19fa8c50424..0e3ecf1c8cc 100644
--- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsVisitorTestCase.java
+++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsVisitorTestCase.java
@@ -19,13 +19,13 @@ import com.yahoo.text.Utf8String;
import com.yahoo.vdslib.DocumentSummary;
import com.yahoo.vdslib.SearchResult;
import com.yahoo.vespa.objects.BufferSerializer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author <a href="mailto:ulf@yahoo-inc.com">Ulf Carlin</a>
@@ -280,13 +280,13 @@ public class VdsVisitorTestCase {
}
@Test
- public void testGetQueryFlags() {
+ void testGetQueryFlags() {
assertEquals(0x00028000, VdsVisitor.getQueryFlags(new Query("/?query=test")));
assertEquals(0x00028080, VdsVisitor.getQueryFlags(new Query("/?query=test&hitcountestimate=true")));
assertEquals(0x00068000, VdsVisitor.getQueryFlags(new Query("/?query=test&rankfeatures=true")));
assertEquals(0x00068080, VdsVisitor.getQueryFlags(new Query("/?query=test&hitcountestimate=true&rankfeatures=true")));
- Query query= new Query("/?query=test");
+ Query query = new Query("/?query=test");
assertEquals(0x00028000, VdsVisitor.getQueryFlags(query));
query.setNoCache(true);
assertEquals(0x00038000, VdsVisitor.getQueryFlags(query));
@@ -295,7 +295,7 @@ public class VdsVisitorTestCase {
}
@Test
- public void testBasics() throws Exception {
+ void testBasics() throws Exception {
Route route = Route.parse("storageClusterRouteSpec");
String searchCluster = "searchClusterConfigId";
MockVisitorSessionFactory factory = new MockVisitorSessionFactory();
@@ -318,7 +318,7 @@ public class VdsVisitorTestCase {
}
@Test
- public void testFailures() throws Exception {
+ void testFailures() throws Exception {
Route route = Route.parse("storageClusterRouteSpec");
String searchCluster = "searchClusterConfigId";
MockVisitorSessionFactory factory = new MockVisitorSessionFactory();
@@ -346,11 +346,11 @@ public class VdsVisitorTestCase {
VdsVisitor visitor = new VdsVisitor(buildQuery(qa), searchCluster, route, "mytype", factory, 0);
try {
visitor.doSearch();
- assertTrue("Visitor did not fail", false);
+ assertTrue(false, "Visitor did not fail");
} catch (TimeoutException te) {
- assertTrue("Got TimeoutException unexpectedly", factory.timeoutQuery);
+ assertTrue(factory.timeoutQuery, "Got TimeoutException unexpectedly");
} catch (IllegalArgumentException iae) {
- assertTrue("Got IllegalArgumentException unexpectedly", factory.failQuery);
+ assertTrue(factory.failQuery, "Got IllegalArgumentException unexpectedly");
}
}
@@ -363,7 +363,7 @@ public class VdsVisitorTestCase {
visitor.onMessage(createDSM("id:ns:type::2"), ackToken);
try {
visitor.onMessage(createM(), ackToken);
- assertTrue("Unsupported message did not cause exception", false);
+ assertTrue(false, "Unsupported message did not cause exception");
} catch (UnsupportedOperationException uoe) {
assertTrue(uoe.getMessage().contains("VdsVisitor can only accept query result, search result, and documentsummary messages"));
}
@@ -389,10 +389,10 @@ public class VdsVisitorTestCase {
assertEquals("id:ns:type::0", hit.getDocId());
assertEquals(0.3, hit.getRank(), 0.01);
} else {
- assertTrue("Got too many hits", false);
+ assertTrue(false, "Got too many hits");
}
DocumentSummary.Summary summary = visitor.getSummaryMap().get(hit.getDocId());
- assertNotNull("Did not find summary for " + hit.getDocId(), summary);
+ assertNotNull(summary, "Did not find summary for " + hit.getDocId());
}
}
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/MaxSamplesPerPeriodTest.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/MaxSamplesPerPeriodTest.java
index cd951e83699..349bedafcce 100644
--- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/MaxSamplesPerPeriodTest.java
+++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/MaxSamplesPerPeriodTest.java
@@ -1,22 +1,22 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.streamingvisitors.tracing;
-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;
public class MaxSamplesPerPeriodTest {
@Test
- public void first_sample_in_period_returns_true() {
+ void first_sample_in_period_returns_true() {
var clock = MockUtils.mockedClockReturning(1000L);
var sampler = new MaxSamplesPerPeriod(clock, 1000L, 1L);
assertTrue(sampler.shouldSample());
}
@Test
- public void samples_exceeding_period_count_return_false() {
+ void samples_exceeding_period_count_return_false() {
var clock = MockUtils.mockedClockReturning(1000L, 1100L, 1200L);
var sampler = new MaxSamplesPerPeriod(clock, 1000L, 2L);
assertTrue(sampler.shouldSample());
@@ -25,7 +25,7 @@ public class MaxSamplesPerPeriodTest {
}
@Test
- public void sample_in_new_period_returns_true() {
+ void sample_in_new_period_returns_true() {
var clock = MockUtils.mockedClockReturning(1000L, 1900L, 2000L, 2900L);
var sampler = new MaxSamplesPerPeriod(clock, 1000L, 1L);
assertTrue(sampler.shouldSample());
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/ProbabilisticSampleRateTest.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/ProbabilisticSampleRateTest.java
index 1ce05df5f26..f5576d5d512 100644
--- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/ProbabilisticSampleRateTest.java
+++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/ProbabilisticSampleRateTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.streamingvisitors.tracing;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.TimeUnit;
-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;
public class ProbabilisticSampleRateTest {
@@ -15,7 +15,7 @@ public class ProbabilisticSampleRateTest {
}
@Test
- public void samples_are_rate_limited_per_second() {
+ void samples_are_rate_limited_per_second() {
var clock = MockUtils.mockedClockReturning(ms2ns(10_000), ms2ns(10_500), ms2ns(10_500), ms2ns(10_501));
var rng = MockUtils.mockedRandomReturning(0.1, 0.51, 0.49, 0.01);
var sampler = new ProbabilisticSampleRate(clock, () -> rng, 1.0);
@@ -30,7 +30,7 @@ public class ProbabilisticSampleRateTest {
}
@Test
- public void zero_desired_sample_rate_returns_false() {
+ void zero_desired_sample_rate_returns_false() {
var clock = MockUtils.mockedClockReturning(ms2ns(10_000));
var rng = MockUtils.mockedRandomReturning(0.99999999); // [0, 1)
var sampler = new ProbabilisticSampleRate(clock, () -> rng, 0.0);
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/SamplingTraceExporterTest.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/SamplingTraceExporterTest.java
index 36b6ed35213..f143efbf786 100644
--- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/SamplingTraceExporterTest.java
+++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/tracing/SamplingTraceExporterTest.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.streamingvisitors.tracing;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -12,7 +12,7 @@ import static org.mockito.Mockito.when;
public class SamplingTraceExporterTest {
@Test
- public void sampling_decision_is_deferred_to_provided_sampler() {
+ void sampling_decision_is_deferred_to_provided_sampler() {
var exporter = mock(TraceExporter.class);
var sampler = mock(SamplingStrategy.class);
when(sampler.shouldSample()).thenReturn(true, false);