diff options
Diffstat (limited to 'container-search/src/test/java/com/yahoo/prelude/semantics')
41 files changed, 396 insertions, 400 deletions
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"); |