diff options
author | Harald Musum <musum@yahoo-inc.com> | 2016-07-11 14:46:59 +0200 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2016-07-11 14:46:59 +0200 |
commit | 87269478068a5a5131125f70505ede29d3863aa5 (patch) | |
tree | e51081a90c9af8e23112f6f5219bf3e2b201880c /config-model/src | |
parent | 821091ce24daaa653ebccffbae10a9e1dca210b2 (diff) |
Fail when search does not have document
Diffstat (limited to 'config-model/src')
2 files changed, 32 insertions, 1 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java index 74f359602bd..bb3ff0ac434 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java @@ -28,9 +28,9 @@ public class Processing { RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { search.process(); + new SearchMustHaveDocument(search, deployLogger, rankProfileRegistry, queryProfiles).process(); new UrlFieldValidator(search, deployLogger, rankProfileRegistry, queryProfiles).process(); new BuiltInFieldSets(search, deployLogger, rankProfileRegistry, queryProfiles).process(); - new SearchMustHaveDocument(search, deployLogger, rankProfileRegistry, queryProfiles).process(); new ReservedDocumentNames(search, deployLogger, rankProfileRegistry, queryProfiles).process(); new IndexFieldNames(search, deployLogger, rankProfileRegistry, queryProfiles).process(); new IntegerIndex2Attribute(search, deployLogger, rankProfileRegistry, queryProfiles).process(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java new file mode 100644 index 00000000000..dcb6347e96c --- /dev/null +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java @@ -0,0 +1,31 @@ +// Copyright 2016 Yahoo Inc. 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.SearchBuilder; +import com.yahoo.searchdefinition.parser.ParseException; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.fail; + +/** + * @author hmusum + */ +public class SearchMustHaveDocumentTest { + + @Test + public void requireErrorWhenMissingDocument() throws IOException, ParseException { + try { + SearchBuilder.buildFromFile("src/test/examples/invalid_sd_missing_document.sd"); + fail("SD without document"); + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + if (!e.getMessage() + .contains("For search 'imageconfig': A search specification must have an equally named document inside of it.")) { + throw e; + } + } + } + +} |