aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java
blob: 29bba224f46340b7e4b11f7660b464c2d53dfb9c (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
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;

import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.SearchDefinitionTestCase;
import com.yahoo.searchdefinition.UnprocessingSearchBuilder;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.model.container.search.QueryProfiles;
import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
 * @author baldersheim
 */
public class IntegerIndex2AttributeTestCase extends SearchDefinitionTestCase {

    @Test
    public void testIntegerIndex2Attribute() throws IOException, ParseException {
        Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/integerindex2attribute.sd");
        search.process();
        new IntegerIndex2Attribute(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true, false);

        SDField f;
        f = search.getConcreteField("s1");
        assertTrue(f.getAttributes().isEmpty());
        assertTrue(f.existsIndex("s1"));
        f = search.getConcreteField("s2");
        assertEquals(f.getAttributes().size(), 1);
        assertTrue(f.existsIndex("s2"));

        f = search.getConcreteField("as1");
        assertTrue(f.getAttributes().isEmpty());
        assertTrue(f.existsIndex("as1"));
        f = search.getConcreteField("as2");
        assertEquals(f.getAttributes().size(), 1);
        assertTrue(f.existsIndex("as2"));

        f = search.getConcreteField("i1");
        assertEquals(f.getAttributes().size(), 1);
        assertTrue( ! f.existsIndex("i1"));

        f = search.getConcreteField("i2");
        assertEquals(f.getAttributes().size(), 1);
        assertTrue( ! f.existsIndex("i2"));

        f = search.getConcreteField("ai1");
        assertEquals(search.getConcreteField("ai1").getAttributes().size(), 1);
        assertTrue( ! search.getConcreteField("ai1").existsIndex("ai1"));
        f = search.getConcreteField("ai2");
        assertEquals(f.getAttributes().size(), 1);
        assertTrue( ! f.existsIndex("ai2"));
    }

}