aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNodeTestCase.java
blob: 225748bbc2e939b22e79f295fd7376c4cedd08d1 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchlib.rankingexpression.rule;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
 * @author Simon Thoresen Hult
 */
public class ReferenceNodeTestCase {

    @Test
    public void requireThatAccessorsWork() {
        ReferenceNode node = new ReferenceNode("foo", Arrays.asList(new NameNode("bar"), new NameNode("baz")), "cox");
        assertEquals("foo", node.getName());
        List<ExpressionNode> args = node.getArguments().expressions();
        assertEquals(2, args.size());
        assertEquals(new NameNode("bar"), args.get(0));
        assertEquals(new NameNode("baz"), args.get(1));
        assertEquals("cox", node.getOutput());

        node = node.setArguments(Arrays.<ExpressionNode>asList(new NameNode("bar'")));
        assertEquals(new NameNode("bar'"), node.getArguments().expressions().get(0));

        node = node.setArguments(Arrays.<ExpressionNode>asList(new NameNode("baz'")));
        assertEquals(new NameNode("baz'"), node.getArguments().expressions().get(0));

        node = node.setOutput("cox'");
        assertEquals("cox'", node.getOutput());
    }
}