aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/schema/derived/IdTestCase.java
blob: 188017e0af1513829f1026a40b268258fbf06582 (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
45
46
47
48
49
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.derived;

import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.document.DataType;
import com.yahoo.schema.RankProfileRegistry;
import com.yahoo.schema.Schema;
import com.yahoo.schema.document.SDDocumentType;
import com.yahoo.schema.document.SDField;
import com.yahoo.schema.processing.Processing;
import com.yahoo.vespa.model.container.search.QueryProfiles;
import org.junit.jupiter.api.Test;

import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
 * Tests that documents ids are treated as they should
 *
 * @author bratseth
 */
public class IdTestCase extends AbstractExportingTestCase {

    @Test
    void testExplicitUpperCaseIdField() {
        Schema schema = new Schema("test", MockApplicationPackage.createEmpty());
        SDDocumentType document = new SDDocumentType("test");
        schema.addDocument(document);
        SDField uri = new SDField(document, "URI", DataType.URI);
        uri.parseIndexingScript("{ summary | index }");
        document.addField(uri);

        new Processing().process(schema, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(),
                true, false, Set.of());

        assertNull(document.getField("uri"));
        assertNull(document.getField("Uri"));
        assertNotNull(document.getField("URI"));
    }

    @Test
    void testCompleteDeriving() throws Exception {
        assertCorrectDeriving("id");
    }

}