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

import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.PhraseSegmentItem;

import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.query.WordItem;

/**
 * Functional test for the logic in items made up from a single block of text.
 *
 * @author steinar
 */
public class SegmentItemTestCase {

    @Test
    final void test() {
        PhraseSegmentItem item = new PhraseSegmentItem("a b c", false, true);
        item.addItem(new WordItem("a"));
        item.addItem(new WordItem("b"));
        item.addItem(new WordItem("c"));
        assertEquals(100, item.getItem(0).getWeight());
        item.setWeight(150);
        assertEquals(150, item.getItem(0).getWeight());
        assertEquals(item.getItem(0).getWeight(), item.getItem(1).getWeight());
        assertEquals(item.getItem(0).getWeight(), item.getItem(2).getWeight());
    }

}