aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NoRankingSearcherTestCase.java
blob: 16d6bd40178b6ea27d705bfce7f2a34a3b3c6b70 (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
40
41
42
43
44
45
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.querytransform.test;

import com.yahoo.search.Query;
import com.yahoo.prelude.querytransform.NoRankingSearcher;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class NoRankingSearcherTestCase {

    Searcher s = new NoRankingSearcher();

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

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

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

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

}