// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; /** * @author lesters */ public class DisallowComplexMapAndWsetKeyTypesTestCase { @Test(expected = IllegalArgumentException.class) public void requireThatComplexTypesForMapKeysFail() throws ParseException { testFieldType("map"); } @Test(expected = IllegalArgumentException.class) public void requireThatComplexTypesForWsetFail() throws ParseException { testFieldType("weightedset"); } @Test(expected = IllegalArgumentException.class) public void requireThatNestedComplexTypesForMapFail() throws ParseException { testFieldType("array>"); } @Test public void requireThatNestedComplexValuesForMapSucceed() throws ParseException { testFieldType("array>"); } @Test(expected = IllegalArgumentException.class) public void requireThatNestedComplexTypesForWsetFail() throws ParseException { testFieldType("array>"); } @Test(expected = IllegalArgumentException.class) public void requireThatDeepNestedComplexTypesForMapFail() throws ParseException { testFieldType("map>"); } private void testFieldType(String fieldType) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); builder.addSchema( "search test {\n" + " document test { \n" + " struct mystruct {}\n" + " field a type " + fieldType + " {}\n" + " }\n" + "}\n"); builder.build(); } }