aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexesTest.java
blob: c4c75c4a59f48f0e781ba069408b5c311d3fa234 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation;

import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg;
import org.junit.jupiter.api.Test;

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

/**
 * @author Harald Musum
 */
public class NoPrefixForIndexesTest {

    @Test
    void requireThatPrefixIsSupported() {
        new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/prefix/").create();
    }

    @Test
    void requireThatPrefixIsSupportedForStreaming() {
        new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/prefix_streaming/").create();
    }

    @Test
    void requireThatPrefixIsIllegalForIndexField() {
        try {
            new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/prefix_index/").create();
            fail();
        } catch (IllegalArgumentException e) {
            assertEquals("For schema 'simple', field 'artist': match/index:prefix is not supported for indexes.", e.getMessage());
        }
    }

    @Test
    void requireThatPrefixIsIllegalForMixedAttributeAndIndexField() {
        try {
            new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/prefix_index_and_attribute/").create();
            fail();
        } catch (IllegalArgumentException e) {
            assertEquals("For schema 'simple', field 'artist': match/index:prefix is not supported for indexes.", e.getMessage());
        }
    }
}