summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NoRankingSearcherTestCase.java
blob: 0c26325e96b398721ab8f55a92b67d11a55ba87f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.querytransform.test;

import junit.framework.TestCase;

import com.yahoo.search.Query;
import com.yahoo.prelude.querytransform.NoRankingSearcher;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;

public class NoRankingSearcherTestCase extends TestCase {

    Searcher s = new NoRankingSearcher();

    public void testDoSearch() {
        Query q = new Query("?query=a&sorting=%2ba%20-b&ranking=hello");
        assertEquals("hello", q.getRanking().getProfile());
        new Execution(s, Execution.Context.createContextStub()).search(q);
        assertEquals("unranked", q.getRanking().getProfile());
     }

    public void testSortOnRelevanceAscending() {
        Query q = new Query("?query=a&sorting=%2ba%20-b%20-[rank]&ranking=hello");
        new Execution(s, Execution.Context.createContextStub()).search(q);
        assertEquals("hello", q.getRanking().getProfile());
     }

    public void testSortOnRelevanceDescending() {
        Query q = new Query("?query=a&sorting=%2ba%20-b%20-[rank]&ranking=hello");
        new Execution(s, Execution.Context.createContextStub()).search(q);
        assertEquals("hello", q.getRanking().getProfile());
     }

    public void testNoSorting() {
        Query q = new Query("?query=a");
        new Execution(s, Execution.Context.createContextStub()).search(q);
        assertEquals("default", q.getRanking().getProfile());
     }
}