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