summaryrefslogtreecommitdiffstats
path: root/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/parser/DefaultFieldNameTestCase.java
blob: 2a71aeb564cce1b8c69e37578e3a874d8298aa57 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.indexinglanguage.parser;

import com.yahoo.language.process.Encoder;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.vespa.indexinglanguage.ScriptParserContext;
import com.yahoo.vespa.indexinglanguage.expressions.Expression;
import com.yahoo.vespa.indexinglanguage.expressions.InputExpression;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

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

    @Test
    public void requireThatDefaultFieldNameIsAppliedWhenArgumentIsMissing() throws ParseException {
        IndexingInput input = new IndexingInput("input");
        InputExpression exp = (InputExpression)Expression.newInstance(new ScriptParserContext(new SimpleLinguistics(),
                                                                                              Encoder.throwsOnUse)
                                                                              .setInputStream(input)
                                                                              .setDefaultFieldName("foo"));
        assertEquals("foo", exp.getFieldName());
    }

}