aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/test/GetRawWordTestCase.java
blob: 9ed8429883840c1923a80c66e5718fea2fed3dc6 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.test;

import com.yahoo.prelude.query.AndItem;
import com.yahoo.prelude.query.WordItem;
import com.yahoo.search.Query;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Tests a case reported by MSBE
 *
 * @author bratseth
 */
public class GetRawWordTestCase {

    @Test
    public void testGetRawWord() {
        Query query = new Query("?query=%C4%B0%C5%9EBANKASI%20GAZ%C4%B0EM%C4%B0R&type=all&searchChain=vespa");
        assertEquals("AND \u0130\u015EBANKASI GAZ\u0130EM\u0130R", query.getModel().getQueryTree().toString());
        AndItem root = (AndItem)query.getModel().getQueryTree().getRoot();

        {
            WordItem word = (WordItem)root.getItem(0);
            assertEquals("\u0130\u015EBANKASI", word.getRawWord());
            assertEquals(0, word.getOrigin().start);
            assertEquals(9, word.getOrigin().end);
        }

        {
            WordItem word = (WordItem)root.getItem(1);
            assertEquals("GAZ\u0130EM\u0130R", word.getRawWord());
            assertEquals(10, word.getOrigin().start);
            assertEquals(18, word.getOrigin().end);
        }

        assertEquals("Total string is just these words",18,
                     ((WordItem)root.getItem(0)).getOrigin().getSuperstring().length());
    }

}